| 1 | #include "sopnamsp.h"
 | 
|---|
| 2 | #include "machdefs.h"
 | 
|---|
| 3 | #include <stdlib.h>
 | 
|---|
| 4 | #include <stdio.h>
 | 
|---|
| 5 | #include <unistd.h>
 | 
|---|
| 6 | #include <string.h>
 | 
|---|
| 7 | 
 | 
|---|
| 8 | #include <typeinfo>
 | 
|---|
| 9 | 
 | 
|---|
| 10 | #include <string>
 | 
|---|
| 11 | #include <vector>
 | 
|---|
| 12 | 
 | 
|---|
| 13 | #include "strutil.h"
 | 
|---|
| 14 | #include "timing.h"
 | 
|---|
| 15 | #include "perrors.h"
 | 
|---|
| 16 | #include "ctimer.h"
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #include "psighand.h"
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include "cimage.h" // pour pouvoir faire extract 
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #include "pistdimgapp.h"
 | 
|---|
| 23 | #include "servnobjm.h"
 | 
|---|
| 24 | // #include "pihisto2d.h"
 | 
|---|
| 25 | #include "psfile.h"
 | 
|---|
| 26 | #include "piimgtools.h"
 | 
|---|
| 27 | #include "pidrwtools.h"
 | 
|---|
| 28 | #include "piaxestools.h"
 | 
|---|
| 29 | 
 | 
|---|
| 30 | #include "pistzwin.h"
 | 
|---|
| 31 | 
 | 
|---|
| 32 | #include "piinit.h"
 | 
|---|
| 33 | #include "piversion.h"
 | 
|---|
| 34 | #include "piaversion.h"
 | 
|---|
| 35 | 
 | 
|---|
| 36 | 
 | 
|---|
| 37 | static char ImgDir[256];
 | 
|---|
| 38 | static char WorkDir[256];
 | 
|---|
| 39 | // Initialiseur
 | 
|---|
| 40 | static PIAppInitiator * glst_piai = NULL; 
 | 
|---|
| 41 | 
 | 
|---|
| 42 | // Pour la creation de fenetre info (about piapp)
 | 
|---|
| 43 | static void createInfoWindow(PIStdImgApp* app);
 | 
|---|
| 44 | static void deleteInfoWindow();
 | 
|---|
| 45 | static void showInfoWindow(PIStdImgApp* app);
 | 
|---|
| 46 | static void hideInfoWindow(PIStdImgApp* app);
 | 
|---|
| 47 | 
 | 
|---|
| 48 | // Pour compter le nombre de display same a la suite
 | 
|---|
| 49 | static int nb_disp_same = 0;
 | 
|---|
| 50 | 
 | 
|---|
| 51 | /* ........................................................... */
 | 
|---|
| 52 | /*    Classe SIA_RU__Periodic : mise a jour periodique de      */
 | 
|---|
| 53 | /*    la fenetre Stat/Ressource info                           */
 | 
|---|
| 54 | /*    + execution de commande soumis de l'exterieur            */
 | 
|---|
| 55 | /* ........................................................... */
 | 
|---|
| 56 | 
 | 
|---|
| 57 | class SIA_RU__Periodic : public PIPeriodic 
 | 
|---|
| 58 | {
 | 
|---|
| 59 | public:
 | 
|---|
| 60 |   SIA_RU__Periodic(PIStdImgApp* app);
 | 
|---|
| 61 |   virtual ~SIA_RU__Periodic();
 | 
|---|
| 62 |   virtual void DoPeriodic();
 | 
|---|
| 63 | private:
 | 
|---|
| 64 |   PIStdImgApp* _app;
 | 
|---|
| 65 | };
 | 
|---|
| 66 | 
 | 
|---|
| 67 | SIA_RU__Periodic::SIA_RU__Periodic(PIStdImgApp* app)
 | 
|---|
| 68 |   : PIPeriodX(1)
 | 
|---|
| 69 | {
 | 
|---|
| 70 |   _app = app;
 | 
|---|
| 71 | }
 | 
|---|
| 72 | 
 | 
|---|
| 73 | SIA_RU__Periodic::~SIA_RU__Periodic()
 | 
|---|
| 74 | {
 | 
|---|
| 75 | }
 | 
|---|
| 76 | 
 | 
|---|
| 77 | void SIA_RU__Periodic::DoPeriodic()
 | 
|---|
| 78 | {
 | 
|---|
| 79 |   if (_app) { 
 | 
|---|
| 80 |     // RZDEL: Normalement, il ne devrait plus y avoir besoin de cette
 | 
|---|
| 81 |     // methode avec le thread separe de l'interpreteur - Reza 27/12/2003 
 | 
|---|
| 82 |     //    _app->ExecuteExtCommand();
 | 
|---|
| 83 |     _app->UpdateStatResourceInfo();
 | 
|---|
| 84 |   }
 | 
|---|
| 85 | }
 | 
|---|
| 86 | 
 | 
|---|
| 87 | /* ............................................................. */
 | 
|---|
| 88 | 
 | 
|---|
| 89 | 
 | 
|---|
| 90 | /* ........................................................... */
 | 
|---|
| 91 | /*                    Classe PIStdImgApp                         */
 | 
|---|
| 92 | /* ........................................................... */
 | 
|---|
| 93 | 
 | 
|---|
| 94 | /* --Methode-- */
 | 
|---|
| 95 | PIStdImgApp::PIStdImgApp(bool fgsmall, int narg, char* arg[])
 | 
|---|
| 96 |   : PIApplication(420, (fgsmall)?320:220, narg, arg) , resusg(ResourceUsage::RU_All)
 | 
|---|
| 97 | {
 | 
|---|
| 98 | 
 | 
|---|
| 99 | // Les menus
 | 
|---|
| 100 | m[0] = new PIMenu(Menubar(),"Fichier");
 | 
|---|
| 101 | m[0]->AppendItem("About piapp", 10150);
 | 
|---|
| 102 | m[0]->AppendItem("Open-Fits", 10120);
 | 
|---|
| 103 | m[0]->AppendItem("Open-PPF", 10130);
 | 
|---|
| 104 | #ifndef SANS_EVOLPLANCK
 | 
|---|
| 105 | m[0]->AppendItem("Open-ASCII", 10140);
 | 
|---|
| 106 | #endif
 | 
|---|
| 107 | // m[0]->AppendItem("Options", 10101);
 | 
|---|
| 108 | m[0]->AppendItem("Help", 10100);
 | 
|---|
| 109 | m[0]->AppendSeparator();
 | 
|---|
| 110 | m[0]->AppendItem("Exit", 10105);
 | 
|---|
| 111 | 
 | 
|---|
| 112 | m[1] = new PIMenu(Menubar(),"Objets");
 | 
|---|
| 113 | m[1]->AppendItem("ObjectManager", 10201);
 | 
|---|
| 114 | m[1]->AppendItem("OpenOutPPF", 10220);
 | 
|---|
| 115 | m[1]->AppendItem("CloseOutPPF", 10230);
 | 
|---|
| 116 | m[1]->AppendItem("Delete CurWdg", 10270);
 | 
|---|
| 117 | 
 | 
|---|
| 118 | m[2] = new PIMenu(Menubar(),"Tools");
 | 
|---|
| 119 | m[2]->AppendItem("Show ImageTools", 10301);
 | 
|---|
| 120 | m[2]->AppendItem("Show DrawerTools", 10302);
 | 
|---|
| 121 | m[2]->AppendItem("Show AxesTools", 10303);
 | 
|---|
| 122 | m[2]->AppendItem("CxxExecutorWindow", 10304);
 | 
|---|
| 123 | m[2]->AppendItem("Ext.Pave", 10311);
 | 
|---|
| 124 | m[2]->SetSensitivityMsg(10311, false);
 | 
|---|
| 125 | m[2]->AppendItem("Ext.Pave+Org", 10312);
 | 
|---|
| 126 | m[2]->SetSensitivityMsg(10312, false);
 | 
|---|
| 127 | m[2]->AppendItem("Cuts X,Y", 10313);
 | 
|---|
| 128 | m[2]->SetSensitivityMsg(10313, false);
 | 
|---|
| 129 | mc = new PIMenu(m[2], "StackTools");
 | 
|---|
| 130 | mc->AppendItem("DispNext", 10320);
 | 
|---|
| 131 | mc->AppendItem("Blink 0.5s", 10321);
 | 
|---|
| 132 | mc->AppendItem("Blink 1s", 10322);
 | 
|---|
| 133 | mc->AppendItem("Blink 2s", 10324);
 | 
|---|
| 134 | mc->AppendItem("Stop Blink", 10329);
 | 
|---|
| 135 | mc->AppendItem("RemoveCurrent", 10330);
 | 
|---|
| 136 | m[2]->AppendPDMenu(mc);
 | 
|---|
| 137 | m[2]->SetSensitivity("StackTools", false);
 | 
|---|
| 138 | 
 | 
|---|
| 139 | m[3] = new PIMenu(Menubar(),"Window");
 | 
|---|
| 140 | m[3]->AppendItem("StackWindow", 10400);
 | 
|---|
| 141 | m[3]->AppendItem("Window", 10411);
 | 
|---|
| 142 | m[3]->AppendItem("Window 2x1", 10421);
 | 
|---|
| 143 | // m[3]->AppendItem("Window 1x2", 10412);
 | 
|---|
| 144 | m[3]->AppendItem("Window 2x2", 10422);
 | 
|---|
| 145 | // m[3]->AppendItem("Window 3x1", 10431);
 | 
|---|
| 146 | m[3]->AppendItem("Window 3x3", 10433);
 | 
|---|
| 147 | m[3]->AppendItem("Cur->LastWdg", 10441);
 | 
|---|
| 148 | m[3]->AppendItem("Close CurWin", 10460);
 | 
|---|
| 149 | m[3]->AppendCheckItem("StatZoomWin", 10470);
 | 
|---|
| 150 | m[3]->SetStateMsg(10470, true);
 | 
|---|
| 151 | 
 | 
|---|
| 152 | m[4] = new PIMenu(Menubar(),"PostScript");
 | 
|---|
| 153 | m[4]->AppendItem("OpenPS", 10501);
 | 
|---|
| 154 | m[4]->AppendItem("ClosePS", 10505);
 | 
|---|
| 155 | m[4]->AppendItem("Window->PS", 10511);
 | 
|---|
| 156 | m[4]->AppendItem("Image->PS", 10515);
 | 
|---|
| 157 | m[4]->AppendItem("Window->EPS", 10512);
 | 
|---|
| 158 | m[4]->AppendItem("Image->EPS", 10516);
 | 
|---|
| 159 | m[4]->SetSensitivityMsg(10515, false);
 | 
|---|
| 160 | m[4]->SetSensitivityMsg(10516, false);
 | 
|---|
| 161 | 
 | 
|---|
| 162 | m[5] = new PIMenu(Menubar(),"Special");
 | 
|---|
| 163 | m[5]->AppendItem("CloseAll", 10601);
 | 
|---|
| 164 | // m[5]->AppendCheckItem("Red.Out/Err", 10602);
 | 
|---|
| 165 | m[5]->AppendCheckItem("Catch SigFPE", 10603);
 | 
|---|
| 166 | m[5]->AppendCheckItem("Catch SigSEGV", 10604);
 | 
|---|
| 167 | m[5]->AppendCheckItem("ObjMgr Verb", 10605);
 | 
|---|
| 168 | m[5]->AppendItem("CxxExecOption", 10606);
 | 
|---|
| 169 | 
 | 
|---|
| 170 | m[6] = new PIMenu(Menubar(),"Modules");
 | 
|---|
| 171 | 
 | 
|---|
| 172 | AppendMenu(m[0]);
 | 
|---|
| 173 | AppendMenu(m[1]);
 | 
|---|
| 174 | AppendMenu(m[2]);
 | 
|---|
| 175 | AppendMenu(m[3]);
 | 
|---|
| 176 | AppendMenu(m[4]);
 | 
|---|
| 177 | AppendMenu(m[5]);
 | 
|---|
| 178 | // AppendMenu(m[6]);  Menu Modules vide pour le moment 
 | 
|---|
| 179 | 
 | 
|---|
| 180 | int scsx, scsy;
 | 
|---|
| 181 | ScreenSize(scsx, scsy);
 | 
|---|
| 182 | if (scsy <= 600)  mFgScSz = 0;
 | 
|---|
| 183 | else if (scsy <= 800)  mFgScSz = 1;
 | 
|---|
| 184 | else if (scsy <= 1024)  mFgScSz = 2;
 | 
|---|
| 185 | else   mFgScSz = 3;
 | 
|---|
| 186 | int msx = 420+mFgScSz*60;
 | 
|---|
| 187 | int msy = 320+mFgScSz*40;
 | 
|---|
| 188 | int sfgsz = mFgScSz;
 | 
|---|
| 189 | if (fgsmall) {  // Flag petite taille de fenetre 
 | 
|---|
| 190 |   if (mFgScSz > 1) mFgScSz = 1;
 | 
|---|
| 191 |   msx = 420+mFgScSz*40;
 | 
|---|
| 192 |   msy = 220+mFgScSz*20;
 | 
|---|
| 193 | }
 | 
|---|
| 194 | MainWin()->SetSize(msx, msy);
 | 
|---|
| 195 | 
 | 
|---|
| 196 | //------------------------------------------------------
 | 
|---|
| 197 | // On cree un container intermediaire permettant de gerer 
 | 
|---|
| 198 | // le widget zoom, colormap, stats, ...
 | 
|---|
| 199 | 
 | 
|---|
| 200 | int bss = 105+mFgScSz*15;
 | 
|---|
| 201 | 
 | 
|---|
| 202 | int statc_szy = bss+10+14+mFgScSz*2+5; 
 | 
|---|
| 203 | statcont = new PIContainer(MainWin(), "ZGCSCont", msx, statc_szy, 0, 0);
 | 
|---|
| 204 | statcont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
 | 
|---|
| 205 | 
 | 
|---|
| 206 | gimv = new PIPixmap(statcont, "GloV", bss, bss, 5, 5);
 | 
|---|
| 207 | gimv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free); 
 | 
|---|
| 208 | zoom = new PIPixmap(statcont, "Zoom", bss, bss, bss+10, 5);
 | 
|---|
| 209 | zoom->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free); 
 | 
|---|
| 210 | cmapv = new PICMapView(statcont, "CMapView", msx-10, 14+mFgScSz*2, 5, bss+10); 
 | 
|---|
| 211 | cmapv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 
 | 
|---|
| 212 | 
 | 
|---|
| 213 | // Widget pour affichage des stats / ressources 
 | 
|---|
| 214 | lab_mem = new PILabel(statcont, "memlab", msx-2*(bss+20), 20, 2*bss+20, 5);
 | 
|---|
| 215 | lab_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 
 | 
|---|
| 216 | lab_mem->SetLabel("MemoryUsage");
 | 
|---|
| 217 | lab_mem->SetForegroundColor(PI_Red);
 | 
|---|
| 218 | lab_mem->SetBorderWidth(1);
 | 
|---|
| 219 | therm_mem = new PIThermometer(statcont, "memtherm", msx-2*(bss+20), 15, 2*bss+20, 30);
 | 
|---|
| 220 | therm_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 
 | 
|---|
| 221 | therm_mem->SetThreshold(0.5, 0.75);
 | 
|---|
| 222 | 
 | 
|---|
| 223 | lab_cpu = new PILabel(statcont, "cpulab", msx-2*(bss+20), 20, 2*bss+20, 50);
 | 
|---|
| 224 | lab_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 
 | 
|---|
| 225 | lab_cpu->SetLabel("CPUUsage");
 | 
|---|
| 226 | lab_cpu->SetForegroundColor(PI_Black);
 | 
|---|
| 227 | lab_cpu->SetBorderWidth(1);
 | 
|---|
| 228 | therm_cpu = new PIThermometer(statcont, "cputherm", msx-2*(bss+20), 15, 2*bss+20, 75);
 | 
|---|
| 229 | therm_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 
 | 
|---|
| 230 | therm_cpu->SetThreshold(0.75, 0.90);
 | 
|---|
| 231 | lab_thrcmd = new PILabel(statcont, "thrcmdlab", msx-2*(bss+20), 20, 2*bss+20, 95);
 | 
|---|
| 232 | lab_thrcmd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 
 | 
|---|
| 233 | lab_thrcmd->SetLabel("CommandThread");
 | 
|---|
| 234 | lab_thrcmd->SetForegroundColor(PI_Green);
 | 
|---|
| 235 | lab_thrcmd->SetBorderWidth(1);
 | 
|---|
| 236 | 
 | 
|---|
| 237 | fg_exc_cmd = false;
 | 
|---|
| 238 | mCmd = NULL;  // Avant d'appeler UpdateStatResource() si PIACmd non cree
 | 
|---|
| 239 | mSopex = NULL; 
 | 
|---|
| 240 | UpdateStatResourceInfo();
 | 
|---|
| 241 | resupd_periodic = new SIA_RU__Periodic(this);
 | 
|---|
| 242 | //resupd_periodic->SetIntervalms(500);
 | 
|---|
| 243 | resupd_periodic->Start();
 | 
|---|
| 244 | 
 | 
|---|
| 245 | statcont->Show();
 | 
|---|
| 246 | // StatZoomWindowSetVisible(true);
 | 
|---|
| 247 | //------------------------------------------------------
 | 
|---|
| 248 | 
 | 
|---|
| 249 | //int cpy = bss+10+14+mFgScSz*2+5;
 | 
|---|
| 250 | int cpy = statc_szy;
 | 
|---|
| 251 | 
 | 
|---|
| 252 | // Creation d'une console avec gestion des commandes  
 | 
|---|
| 253 | consolecont = new PIContainer(MainWin(), "ConsoleCont", msx, msy-cpy, 0, cpy );
 | 
|---|
| 254 | consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); 
 | 
|---|
| 255 | mCons = new PIConsole(consolecont, "Console", 30200, 512, 132, msx, msy-cpy, 0, 0 );
 | 
|---|
| 256 | mCons->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); 
 | 
|---|
| 257 | mCons->AcceptCmd(true, 50);
 | 
|---|
| 258 | consolecont->Show();
 | 
|---|
| 259 | redirecout = NORED_OE;
 | 
|---|
| 260 | RedirectStdOutErr(NORED_OE);  // pas de redirect par defaut 
 | 
|---|
| 261 | 
 | 
|---|
| 262 | mFgScSz = sfgsz;
 | 
|---|
| 263 |  
 | 
|---|
| 264 | mObjMgr = new NamedObjMgr(true);
 | 
|---|
| 265 | mCmd = new PIACmd(this);
 | 
|---|
| 266 | mSopex = new SOpExObj(this);
 | 
|---|
| 267 | 
 | 
|---|
| 268 | // Pas trop de message de la part de NamedObjMgr
 | 
|---|
| 269 | m[5]->SetStateMsg(10605, false);
 | 
|---|
| 270 | mObjMgr->SetVerbose(false);
 | 
|---|
| 271 | 
 | 
|---|
| 272 | char* varenv;
 | 
|---|
| 273 | ImgDir[0] = WorkDir[0] = '\0';
 | 
|---|
| 274 | if ( (varenv=getenv("PEIDA_IMAGES")) != NULL )   strncpy(ImgDir, varenv, 256);
 | 
|---|
| 275 | if ( (varenv=getenv("PEIDA_WORK")) != NULL )  strncpy(WorkDir, varenv, 256);
 | 
|---|
| 276 | 
 | 
|---|
| 277 | pfc_fits = new PIFileChooser(this,"FITS-FileChooser", 10125); 
 | 
|---|
| 278 | pfc_ppf = new PIFileChooser(this,"PPF-FileChooser", 10135); 
 | 
|---|
| 279 | pfc_ascii = new PIFileChooser(this,"ASCII-FileChooser", 10145); 
 | 
|---|
| 280 | pfc_ps = new PIFileChooser(this,"PS-FileChooser", 10525); 
 | 
|---|
| 281 | 
 | 
|---|
| 282 | mObjmgrw = new ObjMgrWind(this);
 | 
|---|
| 283 | mPpinmgrw = new PPInMgrWind(this);
 | 
|---|
| 284 | 
 | 
|---|
| 285 | // Attention : A faire apres creation de ObjMgrWind !!! 
 | 
|---|
| 286 | mObjMgr->SetImgApp(this);
 | 
|---|
| 287 | 
 | 
|---|
| 288 | // Gestion des feneteres widgets et drawers
 | 
|---|
| 289 | mWId = mDId = mBWId = 0;
 | 
|---|
| 290 | mCurWin = NULL;  
 | 
|---|
| 291 | mCurWdg = NULL;
 | 
|---|
| 292 | mLastWdg = NULL;
 | 
|---|
| 293 | mGrW = NULL;
 | 
|---|
| 294 | mStW = NULL;
 | 
|---|
| 295 | mGrIdx = mStIdx = -1;
 | 
|---|
| 296 | 
 | 
|---|
| 297 | mFCMsg = 0;
 | 
|---|
| 298 | mFgCWImg = false;
 | 
|---|
| 299 | 
 | 
|---|
| 300 | // Gestion fichiers PS
 | 
|---|
| 301 | num_eps = 0;
 | 
|---|
| 302 | name_ps = "";
 | 
|---|
| 303 | name_ps = "pia.ps";
 | 
|---|
| 304 | mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
 | 
|---|
| 305 | 
 | 
|---|
| 306 | // Gestion OUT-PPF
 | 
|---|
| 307 | mPpfout = NULL;
 | 
|---|
| 308 | name_outppf = "";
 | 
|---|
| 309 | 
 | 
|---|
| 310 | // Attributs graphiques courants
 | 
|---|
| 311 | mAxesFlags = kAxesDflt;
 | 
|---|
| 312 | SetInsetLimits(0.4, 0.6, 0.4, 0.6);
 | 
|---|
| 313 | mAddTitle = true;
 | 
|---|
| 314 | 
 | 
|---|
| 315 | // Initialisation 
 | 
|---|
| 316 | glst_piai = new PIAppInitiator(this);
 | 
|---|
| 317 | 
 | 
|---|
| 318 | char buff[128];
 | 
|---|
| 319 | mCons->AddStr("  ............  starting piapp .............\n", PIVA_Blue );
 | 
|---|
| 320 | #ifdef SANS_EVOLPLANCK
 | 
|---|
| 321 | sprintf(buff, "Version: piapp=%g  PI=%g  PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER, 
 | 
|---|
| 322 |               (double)PI_VERSIONNUMBER, (float)PeidaVersion());
 | 
|---|
| 323 | mCons->AddStr(buff, PIVA_Blue );
 | 
|---|
| 324 | #else
 | 
|---|
| 325 | string svers;
 | 
|---|
| 326 | SophyaInitiator::GetVersion(svers);
 | 
|---|
| 327 | mCons->AddStr(svers.c_str(), PIVA_Blue );
 | 
|---|
| 328 | #endif
 | 
|---|
| 329 | mCons->AddStr("  ..........................................\n", PIVA_Blue );
 | 
|---|
| 330 | // PrintPeidaVersion();
 | 
|---|
| 331 | 
 | 
|---|
| 332 | pfc_fits->SetPath(ImgDir);
 | 
|---|
| 333 | pfc_ppf->SetPath(WorkDir);
 | 
|---|
| 334 | pfc_ps->SetPath(WorkDir);
 | 
|---|
| 335 | 
 | 
|---|
| 336 | SetReady();
 | 
|---|
| 337 | fg_glsynlock = false;
 | 
|---|
| 338 | }
 | 
|---|
| 339 | 
 | 
|---|
| 340 | /* --Methode-- */
 | 
|---|
| 341 | PIStdImgApp::~PIStdImgApp()
 | 
|---|
| 342 | {
 | 
|---|
| 343 | int i;
 | 
|---|
| 344 | 
 | 
|---|
| 345 | // On inactive la fenetre principale
 | 
|---|
| 346 | //  Sinon, ca peut provoquer un SEGV ds delete de console ?? - Reza 07/2000
 | 
|---|
| 347 | MainWin()->Hide();  
 | 
|---|
| 348 | 
 | 
|---|
| 349 | // Destrucion de tous les objets de NameObjMgr
 | 
|---|
| 350 | string patt = "/*/*";
 | 
|---|
| 351 | mObjMgr->DelObjects(patt, true);
 | 
|---|
| 352 | 
 | 
|---|
| 353 | delete mc;
 | 
|---|
| 354 | for(i=0; i<7; i++)  
 | 
|---|
| 355 |   if (m[i]) delete m[i];
 | 
|---|
| 356 | 
 | 
|---|
| 357 | WindMList::iterator it;
 | 
|---|
| 358 | for(it = mWList.begin(); it != mWList.end(); it++)  delete (*it).second;
 | 
|---|
| 359 | 
 | 
|---|
| 360 | delete mObjMgr;
 | 
|---|
| 361 | delete mCmd;
 | 
|---|
| 362 | 
 | 
|---|
| 363 | delete zoom;
 | 
|---|
| 364 | delete gimv;
 | 
|---|
| 365 | delete cmapv;
 | 
|---|
| 366 | 
 | 
|---|
| 367 | delete lab_mem;
 | 
|---|
| 368 | delete therm_mem;
 | 
|---|
| 369 | delete lab_cpu;
 | 
|---|
| 370 | delete therm_cpu;
 | 
|---|
| 371 | delete lab_thrcmd;
 | 
|---|
| 372 | 
 | 
|---|
| 373 | delete statcont;
 | 
|---|
| 374 | 
 | 
|---|
| 375 | delete pfc_fits;
 | 
|---|
| 376 | delete pfc_ppf;
 | 
|---|
| 377 | delete pfc_ascii;
 | 
|---|
| 378 | delete pfc_ps;
 | 
|---|
| 379 | 
 | 
|---|
| 380 | delete mCons;
 | 
|---|
| 381 | delete consolecont;
 | 
|---|
| 382 | 
 | 
|---|
| 383 | delete mObjmgrw;
 | 
|---|
| 384 | delete mPpinmgrw;
 | 
|---|
| 385 | 
 | 
|---|
| 386 | deleteInfoWindow();
 | 
|---|
| 387 | 
 | 
|---|
| 388 | // Les fichiers 
 | 
|---|
| 389 | if (mpsfile) delete mpsfile;
 | 
|---|
| 390 | if (mPpfout) delete mPpfout;
 | 
|---|
| 391 | 
 | 
|---|
| 392 | if (resupd_periodic) delete resupd_periodic;
 | 
|---|
| 393 | 
 | 
|---|
| 394 | if (glst_piai) delete glst_piai;   glst_piai = NULL;
 | 
|---|
| 395 | 
 | 
|---|
| 396 | }  
 | 
|---|
| 397 | 
 | 
|---|
| 398 | /*
 | 
|---|
| 399 | class RunAlarm : public Periodic {
 | 
|---|
| 400 | public:
 | 
|---|
| 401 |   RunAlarm(PIStdImgApp* app) :
 | 
|---|
| 402 |     Periodic(1)
 | 
|---|
| 403 |   { _app = app; SetIntervalms(1); }
 | 
|---|
| 404 |   ~RunAlarm() { }
 | 
|---|
| 405 |   virtual void DoPeriodic()
 | 
|---|
| 406 |   { _app->getMutex().broadcast(); }
 | 
|---|
| 407 |   PIStdImgApp* _app;
 | 
|---|
| 408 | };
 | 
|---|
| 409 | */
 | 
|---|
| 410 | 
 | 
|---|
| 411 | class Reveil : public ZThread {
 | 
|---|
| 412 | public:
 | 
|---|
| 413 |   Reveil(PIStdImgApp* app) :
 | 
|---|
| 414 |     ZThread() 
 | 
|---|
| 415 |   { _app = app; _fgstop = false; }
 | 
|---|
| 416 |   virtual ~Reveil() { }
 | 
|---|
| 417 |   inline void Stop() { _fgstop = true; }
 | 
|---|
| 418 |   virtual void run() 
 | 
|---|
| 419 |   {
 | 
|---|
| 420 |     while (!_fgstop) {
 | 
|---|
| 421 |       usleep(2000);
 | 
|---|
| 422 |       _app->LockMutex();
 | 
|---|
| 423 |       bool fgb = false;
 | 
|---|
| 424 |       if (_app->CheckPendingEvents() != 0)  fgb = true;
 | 
|---|
| 425 |       _app->UnlockMutex(fgb);      
 | 
|---|
| 426 |     }
 | 
|---|
| 427 |   }
 | 
|---|
| 428 | 
 | 
|---|
| 429 |   PIStdImgApp* _app;
 | 
|---|
| 430 |   bool _fgstop;
 | 
|---|
| 431 | };
 | 
|---|
| 432 | 
 | 
|---|
| 433 | int PIStdImgApp::CheckPendingEvents()
 | 
|---|
| 434 | {
 | 
|---|
| 435 |   return XtAppPending(*_appctx);
 | 
|---|
| 436 | }
 | 
|---|
| 437 | 
 | 
|---|
| 438 | void PIStdImgApp::CkEvt_LockMutex()
 | 
|---|
| 439 | {
 | 
|---|
| 440 |   for(int i=0; i<5; i++) {   // On tente 5 fois de vider le buffer d'evenements
 | 
|---|
| 441 |     LockMutex();
 | 
|---|
| 442 |     int nev = CheckPendingEvents();
 | 
|---|
| 443 |     bool fgbr = (nev > 0) ? true : false;
 | 
|---|
| 444 |     UnlockMutex(fgbr);
 | 
|---|
| 445 |     if (nev < 1) break;
 | 
|---|
| 446 |   }
 | 
|---|
| 447 |   LockMutex();
 | 
|---|
| 448 | }
 | 
|---|
| 449 | 
 | 
|---|
| 450 | /* --Methode-- */
 | 
|---|
| 451 | void PIStdImgApp::Run()
 | 
|---|
| 452 | {
 | 
|---|
| 453 | XEvent evt;
 | 
|---|
| 454 | int szx, szy, szf;
 | 
|---|
| 455 | XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
 | 
|---|
| 456 | _appctx = appctx;   // Pour CheckPendingEvents()
 | 
|---|
| 457 | // Pour appeler FinishCreate() des objets dans la fenetre principale 
 | 
|---|
| 458 | if (mStop) { // C'est la premiere fois
 | 
|---|
| 459 |   topcont->SetSize(topcont->XSize(), topcont->YSize());
 | 
|---|
| 460 |   MBCont()->FinishCreate();   
 | 
|---|
| 461 |   }
 | 
|---|
| 462 | else mStop = true;   // On rerentre apres un stop 
 | 
|---|
| 463 | 
 | 
|---|
| 464 | // Creation et demarrage de l'objet de reveil periodique
 | 
|---|
| 465 | // de la boucle d'evts 
 | 
|---|
| 466 | /* RunAlarm * mru = new RunAlarm(this);
 | 
|---|
| 467 |    mru->Start(); */
 | 
|---|
| 468 | Reveil* mrv = new Reveil(this);
 | 
|---|
| 469 | mrv->start(); 
 | 
|---|
| 470 | // Demarrage du thread de l'interpreteur
 | 
|---|
| 471 | CmdInterpreter()->start();
 | 
|---|
| 472 | // Demarrage du thread de l'executeur de commandes simples 
 | 
|---|
| 473 | getSOpExObj()->start();
 | 
|---|
| 474 | 
 | 
|---|
| 475 | 
 | 
|---|
| 476 | thr_glsyn.lock(); //  <ZThread> 
 | 
|---|
| 477 | //DEL-DBG int klp = 0;
 | 
|---|
| 478 | while (mStop) {
 | 
|---|
| 479 |   fg_glsynlock = true;
 | 
|---|
| 480 |   int nevtproc = 0;
 | 
|---|
| 481 |   while (XtAppPending(*appctx) != 0) {   // Boucle XtAppPending() 
 | 
|---|
| 482 |     try {
 | 
|---|
| 483 |       XtAppNextEvent(*appctx, &evt);
 | 
|---|
| 484 |       XtDispatchEvent(&evt);
 | 
|---|
| 485 |       // Soumission de la commande exterieur a executer 
 | 
|---|
| 486 |       if (fg_exc_cmd) {
 | 
|---|
| 487 |         fg_exc_cmd = false; 
 | 
|---|
| 488 |         CmdInterpreter()->AddInputLine(exc_command);
 | 
|---|
| 489 |       }
 | 
|---|
| 490 |       nevtproc++;
 | 
|---|
| 491 |       if (nevtproc >= 300)  break;
 | 
|---|
| 492 |     }
 | 
|---|
| 493 |     catch ( PThrowable & exc ) {
 | 
|---|
| 494 |       cerr << "\nPIStdImgApp::Run()/ Exception catched in event loop: \n   " 
 | 
|---|
| 495 |            << (string)typeid(exc).name() << " Msg= " << exc.Msg() << endl;
 | 
|---|
| 496 |       cerr << "  Trying to continue event loop ... " << endl;
 | 
|---|
| 497 |     }
 | 
|---|
| 498 |     catch ( std::exception & sexc ) {
 | 
|---|
| 499 |       cerr << "\nPIStdImgApp::Run()/ Exception catched in event loop: \n   " 
 | 
|---|
| 500 |            << (string)typeid(sexc).name() << " what()= " << sexc.what() << endl;
 | 
|---|
| 501 |       cerr << "  Trying to continue event loop ... " << endl;
 | 
|---|
| 502 |     }
 | 
|---|
| 503 |     catch ( ... ) {
 | 
|---|
| 504 |       cerr << "\nPIStdImgApp::Run()/ Unknown Exception (...) catched in event loop ! " << endl;
 | 
|---|
| 505 |       cerr << "  Trying to continue event loop ... " << endl;
 | 
|---|
| 506 |     } 
 | 
|---|
| 507 |   }   // FIN Boucle XtAppPending() 
 | 
|---|
| 508 |   fg_glsynlock = false;
 | 
|---|
| 509 |   //DBG cout << " "DBG-Run:: Going to wait ... " << klp << endl;
 | 
|---|
| 510 |   thr_glsyn.wait();  //  <ZThread> 
 | 
|---|
| 511 |   //DBG cout << "DBG-Run:: Out of wait " << ++klp << endl;  
 | 
|---|
| 512 |     //  usleep(1000);
 | 
|---|
| 513 | }
 | 
|---|
| 514 | 
 | 
|---|
| 515 | thr_glsyn.unlock();  //  <ZThread> 
 | 
|---|
| 516 | mrv->Stop();
 | 
|---|
| 517 | delete mrv;
 | 
|---|
| 518 | // delete mru;
 | 
|---|
| 519 | return;
 | 
|---|
| 520 | }
 | 
|---|
| 521 | 
 | 
|---|
| 522 | /* --Methode-- */
 | 
|---|
| 523 | void PIStdImgApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
 | 
|---|
| 524 | {
 | 
|---|
| 525 | PIWdg *sndw;
 | 
|---|
| 526 | PIMessage tmsg, smm;
 | 
|---|
| 527 | 
 | 
|---|
| 528 | tmsg = msg;
 | 
|---|
| 529 | msg = UserMsg(msg);
 | 
|---|
| 530 | smm = ModMsg(tmsg);
 | 
|---|
| 531 | 
 | 
|---|
| 532 | //printf("SuperDebug: msg=%d Mod=%d  State=%d\n", (int)msg, (int)smm, (int)GetState());
 | 
|---|
| 533 | if  ((GetState()) && (msg != mFCMsg)) { PIBeep(); return; }
 | 
|---|
| 534 | 
 | 
|---|
| 535 | #ifdef SANS_EVOLPLANCK
 | 
|---|
| 536 |   TRY {
 | 
|---|
| 537 | #else
 | 
|---|
| 538 |   try {
 | 
|---|
| 539 | #endif
 | 
|---|
| 540 | 
 | 
|---|
| 541 | //   Messages active-window
 | 
|---|
| 542 | if (smm == PIMsg_Active)
 | 
|---|
| 543 |   {
 | 
|---|
| 544 |   sndw = dynamic_cast<PIWdg *>(sender);
 | 
|---|
| 545 |   switch(sndw->kind())
 | 
|---|
| 546 |     {
 | 
|---|
| 547 |     case PIWindow::ClassId :
 | 
|---|
| 548 |       mCurWin = dynamic_cast<PIWindow *>(sndw);
 | 
|---|
| 549 |       break;
 | 
|---|
| 550 | 
 | 
|---|
| 551 |     case PIScDrawWdg::ClassId :
 | 
|---|
| 552 |     case PIDraw3DWdg::ClassId :
 | 
|---|
| 553 |       mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
 | 
|---|
| 554 | //      cerr << "*DBG11* ImgTools -> NonSensitive " << sndw->kind() << endl;
 | 
|---|
| 555 |       if (mFgCWImg) {
 | 
|---|
| 556 | //        cerr << "*DBG* ImgTools -> NonSensitive " << endl;
 | 
|---|
| 557 |         m[2]->SetSensitivityMsg(10311, false);
 | 
|---|
| 558 |         m[2]->SetSensitivityMsg(10312, false);
 | 
|---|
| 559 |         m[2]->SetSensitivityMsg(10313, false);
 | 
|---|
| 560 |         m[4]->SetSensitivityMsg(10515, false);
 | 
|---|
| 561 |         m[4]->SetSensitivityMsg(10516, false);
 | 
|---|
| 562 |         mFgCWImg = false;
 | 
|---|
| 563 |         }
 | 
|---|
| 564 |       break;
 | 
|---|
| 565 |     case PIImage::ClassId :
 | 
|---|
| 566 |       mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
 | 
|---|
| 567 |       if (!mFgCWImg) {
 | 
|---|
| 568 | //        cerr << "*DBG* ImgTools -> Sensitive " << endl;
 | 
|---|
| 569 |         m[2]->SetSensitivityMsg(10311, true);
 | 
|---|
| 570 |         m[2]->SetSensitivityMsg(10312, true);
 | 
|---|
| 571 |         m[2]->SetSensitivityMsg(10313, true);
 | 
|---|
| 572 |         m[4]->SetSensitivityMsg(10515, true);
 | 
|---|
| 573 |         m[4]->SetSensitivityMsg(10516, true);
 | 
|---|
| 574 |         mFgCWImg = true;
 | 
|---|
| 575 |         }
 | 
|---|
| 576 |       break;
 | 
|---|
| 577 |       /*
 | 
|---|
| 578 |     default :
 | 
|---|
| 579 |       mCurWdg = NULL;
 | 
|---|
| 580 |       if (mFgCWImg) {
 | 
|---|
| 581 |         m[2]->SetSensitivityMsg(10311, false);
 | 
|---|
| 582 |         m[2]->SetSensitivityMsg(10312, false);
 | 
|---|
| 583 |         m[2]->SetSensitivityMsg(10313, false);
 | 
|---|
| 584 |         m[4]->SetSensitivityMsg(10515, false);
 | 
|---|
| 585 |         m[4]->SetSensitivityMsg(10516, false);
 | 
|---|
| 586 |         mFgCWImg = false;
 | 
|---|
| 587 |         }
 | 
|---|
| 588 |       break;
 | 
|---|
| 589 |       */
 | 
|---|
| 590 |     }
 | 
|---|
| 591 |   }
 | 
|---|
| 592 | //  Message window-close
 | 
|---|
| 593 | else if (smm == PIMsg_Close)
 | 
|---|
| 594 |   {
 | 
|---|
| 595 |   sndw = (PIWdg *)sender;
 | 
|---|
| 596 |   if(sndw->kind() == PIWindow::ClassId)
 | 
|---|
| 597 |     {
 | 
|---|
| 598 |     mCurWin = (PIWindow *)sender;
 | 
|---|
| 599 |     if (mCurWin == mStW) m[2]->SetSensitivity("StackTools", false); 
 | 
|---|
| 600 |     DeleteWindow(mCurWin);
 | 
|---|
| 601 |     }
 | 
|---|
| 602 |   else  
 | 
|---|
| 603 |     printf("PIStdImgApp/Bug ? CloseMsd received from NonWindow (%d %d %lx) \n",
 | 
|---|
| 604 |            (int)tmsg,  (int)sndw->kind(), (long)sender);       
 | 
|---|
| 605 |   }
 | 
|---|
| 606 | 
 | 
|---|
| 607 | // Traitement des messages des menus 
 | 
|---|
| 608 | else if ( (msg >= 10100) && (msg < 10200) )  MBProcess1(msg, sender, data);
 | 
|---|
| 609 | else if ( (msg >= 10200) && (msg < 10300) )  MBProcess2(msg, sender, data);
 | 
|---|
| 610 | else if ( (msg >= 10300) && (msg < 10400) )  MBProcess3(msg, sender, data);
 | 
|---|
| 611 | else if ( (msg >= 10400) && (msg < 10500) )  MBProcess4(msg, sender, data);
 | 
|---|
| 612 | else if ( (msg >= 10500) && (msg < 10600) )  MBProcess5(msg, sender, data);
 | 
|---|
| 613 | else if ( (msg >= 10600) && (msg < 10700) )  MBProcess6(msg, sender, data);
 | 
|---|
| 614 | else if ( (msg == 30200) && (smm == PIMsg_Cancel) )  // <Cntrl C> appuye sur Console
 | 
|---|
| 615 |   CmdInterpreter()->StopExecution();
 | 
|---|
| 616 | else if ( (msg == 30200 ) && (smm == PIMsg_OK) ){    // Objet PIConsole avec <Return>/<Enter>
 | 
|---|
| 617 |   string s = mCons->GetCmdString();
 | 
|---|
| 618 |   //  string s2 = "\nExecuting " + s + "\n";
 | 
|---|
| 619 |   mCons->AddStr("Cmd> ", PIVA_Blue, false);
 | 
|---|
| 620 |   //  s2 = s + "\n";
 | 
|---|
| 621 |   mCons->AddStr(s.c_str(), PIVA_Blue|PIVA_Bold, false);
 | 
|---|
| 622 |   mCons->AddChar('\n', PIVA_Def, true);
 | 
|---|
| 623 |   SetBusy();
 | 
|---|
| 624 | #ifdef SANS_EVOLPLANCK
 | 
|---|
| 625 |   TRY {
 | 
|---|
| 626 |     mCmd->Interpret(s);
 | 
|---|
| 627 |     }  CATCH(merr) { 
 | 
|---|
| 628 |     fflush(stdout); 
 | 
|---|
| 629 |     cout << endl; 
 | 
|---|
| 630 |     cerr << endl;
 | 
|---|
| 631 |     string es = PeidaExc(merr);
 | 
|---|
| 632 |     cerr << "PIStdImgApp::Process()/ Cmd->Do() Exception :" << es << " (" << merr << ")" << endl ;
 | 
|---|
| 633 |     }
 | 
|---|
| 634 | #else
 | 
|---|
| 635 |   try {
 | 
|---|
| 636 |     //    mCmd->Interpret(s);
 | 
|---|
| 637 |     CmdInterpreter()->AddInputLine(s);
 | 
|---|
| 638 |     }  
 | 
|---|
| 639 |   catch ( PThrowable & exc ) {
 | 
|---|
| 640 |     cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Exception :" 
 | 
|---|
| 641 |          << (string)typeid(exc).name() << " Msg= " 
 | 
|---|
| 642 |          << exc.Msg() << endl;
 | 
|---|
| 643 |     cout << endl; 
 | 
|---|
| 644 |   }
 | 
|---|
| 645 |   catch ( ... ) {
 | 
|---|
| 646 |     cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Catched Exception ..." 
 | 
|---|
| 647 |          << endl;
 | 
|---|
| 648 |     cout << endl; 
 | 
|---|
| 649 |   }
 | 
|---|
| 650 | 
 | 
|---|
| 651 | #endif
 | 
|---|
| 652 |   SetReady();
 | 
|---|
| 653 |   }
 | 
|---|
| 654 | 
 | 
|---|
| 655 | else printf("PIStdImgApp::Process() BUG?? Msg %d (%d-%d) \n", 
 | 
|---|
| 656 |             (int)tmsg,(int)msg,(int)smm);
 | 
|---|
| 657 | 
 | 
|---|
| 658 | #ifdef SANS_EVOLPLANCK
 | 
|---|
| 659 | }  CATCH(merr) { 
 | 
|---|
| 660 |   fflush(stdout); 
 | 
|---|
| 661 |   cout << endl; 
 | 
|---|
| 662 |   cerr << endl;
 | 
|---|
| 663 |   string es = PeidaExc(merr);
 | 
|---|
| 664 |   cerr << "PIStdImgApp::Process()/  Exception :" << es << " (" << merr << ")" << endl ;
 | 
|---|
| 665 |   SetReady();
 | 
|---|
| 666 |   }
 | 
|---|
| 667 | #else
 | 
|---|
| 668 |   }
 | 
|---|
| 669 |   catch ( PThrowable & exc ) {
 | 
|---|
| 670 |     cerr << "\n PIStdImgApp::Process() SOPHYA Exception :" 
 | 
|---|
| 671 |          << (string)typeid(exc).name() << "\n Msg= " 
 | 
|---|
| 672 |          << exc.Msg() << endl;
 | 
|---|
| 673 |     SetReady();
 | 
|---|
| 674 |   }
 | 
|---|
| 675 |   catch ( std::exception & sex ) {
 | 
|---|
| 676 |     cerr << "\n PIStdImgApp::Process() std::exception :" 
 | 
|---|
| 677 |          << (string)typeid(sex).name() << "\n msg= " 
 | 
|---|
| 678 |          << sex.what() << endl;
 | 
|---|
| 679 |     SetReady();
 | 
|---|
| 680 |   }
 | 
|---|
| 681 |   catch ( ... ) {
 | 
|---|
| 682 |     cerr << "\n PIStdImgApp::Process()/  Catched unknown (...) Exception " << endl;
 | 
|---|
| 683 |     SetReady();
 | 
|---|
| 684 |   }
 | 
|---|
| 685 | 
 | 
|---|
| 686 | #endif
 | 
|---|
| 687 | 
 | 
|---|
| 688 | return;
 | 
|---|
| 689 | }
 | 
|---|
| 690 | 
 | 
|---|
| 691 | /* --Methode-- */
 | 
|---|
| 692 | void PIStdImgApp::SetReady()
 | 
|---|
| 693 | {
 | 
|---|
| 694 | mCons->SetSensitive();
 | 
|---|
| 695 | gimv->SetSensitive();
 | 
|---|
| 696 | PIApplication::SetReady();
 | 
|---|
| 697 | }
 | 
|---|
| 698 | 
 | 
|---|
| 699 | /* --Methode-- */
 | 
|---|
| 700 | void PIStdImgApp::SetBusy()
 | 
|---|
| 701 | {
 | 
|---|
| 702 | mCons->SetUnSensitive();
 | 
|---|
| 703 | gimv->SetUnSensitive();
 | 
|---|
| 704 | PIApplication::SetBusy();
 | 
|---|
| 705 | // Attention : Appel XSync specifique X11 -  en attendant multi-thread
 | 
|---|
| 706 | // XSync(PIXDisplay(), False);  RZDEL
 | 
|---|
| 707 | }
 | 
|---|
| 708 | 
 | 
|---|
| 709 | /* --Methode-- */
 | 
|---|
| 710 | void PIStdImgApp::SetBlocked()
 | 
|---|
| 711 | {
 | 
|---|
| 712 | mCons->SetUnSensitive();
 | 
|---|
| 713 | gimv->SetUnSensitive();
 | 
|---|
| 714 | PIApplication::SetBlocked();
 | 
|---|
| 715 | // Attention : Appel XSync specifique X11 -  en attendant multi-thread
 | 
|---|
| 716 | // XSync(PIXDisplay(), False);  RZDEL
 | 
|---|
| 717 | }
 | 
|---|
| 718 | 
 | 
|---|
| 719 | class SyncPIS {
 | 
|---|
| 720 | public:
 | 
|---|
| 721 |   explicit SyncPIS(ZMutex & mtx, bool fglock=true, int sigbr=0) 
 | 
|---|
| 722 |   {
 | 
|---|
| 723 |   _mtx = &mtx; _sigbr = sigbr; 
 | 
|---|
| 724 |   _fglock = fglock; 
 | 
|---|
| 725 |   if (_fglock)  mtx.lock(); 
 | 
|---|
| 726 |   }
 | 
|---|
| 727 |   ~SyncPIS() 
 | 
|---|
| 728 |   { 
 | 
|---|
| 729 |     if (_fglock && (_mtx != NULL) ) { 
 | 
|---|
| 730 |       if (_sigbr == 1) _mtx->signal(); 
 | 
|---|
| 731 |       else  if (_sigbr == 2) _mtx->broadcast(); 
 | 
|---|
| 732 |       _mtx->unlock(); 
 | 
|---|
| 733 |     }
 | 
|---|
| 734 |   }
 | 
|---|
| 735 | 
 | 
|---|
| 736 | private:
 | 
|---|
| 737 |   ZMutex * _mtx;
 | 
|---|
| 738 |   int _sigbr;
 | 
|---|
| 739 |   bool _fglock;
 | 
|---|
| 740 |   inline        SyncPIS() {_mtx = NULL; _sigbr = 0; _fglock = false; }
 | 
|---|
| 741 | };
 | 
|---|
| 742 | 
 | 
|---|
| 743 | 
 | 
|---|
| 744 | /* --Methode-- */
 | 
|---|
| 745 | int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, string const& sop, 
 | 
|---|
| 746 |                            bool fgimagnav, int oid, bool fglock)
 | 
|---|
| 747 | {
 | 
|---|
| 748 | PIImage* pii=NULL;
 | 
|---|
| 749 | PIImageNavigator* piin=NULL; 
 | 
|---|
| 750 | PIWindow* win;
 | 
|---|
| 751 | int sx, sy, px, py, flag;
 | 
|---|
| 752 | 
 | 
|---|
| 753 | if (nouv == NULL)
 | 
|---|
| 754 |   {
 | 
|---|
| 755 |   printf("PIStdImgApp::DispImage_Error  Cannot Display  NULL image \n");
 | 
|---|
| 756 |   return(-1);
 | 
|---|
| 757 |   }
 | 
|---|
| 758 | 
 | 
|---|
| 759 | if ( (nouv->XSize() <= 0)  || (nouv->YSize() <= 0))
 | 
|---|
| 760 |   {
 | 
|---|
| 761 |   printf("PIStdImgApp::DispImage_Error Pb Size Sz=%d*%d  \n", 
 | 
|---|
| 762 |           nouv->XSize(), nouv->YSize());
 | 
|---|
| 763 |   return(-1);
 | 
|---|
| 764 |   }
 | 
|---|
| 765 | 
 | 
|---|
| 766 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 767 | SyncPIS zs(getMutex(), fglock, 2);
 | 
|---|
| 768 | 
 | 
|---|
| 769 | // On decode les options graphiques
 | 
|---|
| 770 | vector<string> opts;
 | 
|---|
| 771 | string wname = name; 
 | 
|---|
| 772 | DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname);
 | 
|---|
| 773 | 
 | 
|---|
| 774 | // Pas de same ou inset pour DispImage
 | 
|---|
| 775 | if ((dwopt == Disp_Same) || (dwopt == Disp_Inset) ) dwopt = Disp_Next;
 | 
|---|
| 776 | 
 | 
|---|
| 777 | // Choix de la taille de fenetre
 | 
|---|
| 778 | #define MINPIIMGSIZE 100
 | 
|---|
| 779 | sx = (nouv->XSize() > MINPIIMGSIZE) ? nouv->XSize() : MINPIIMGSIZE;
 | 
|---|
| 780 | sy = (nouv->YSize() > MINPIIMGSIZE) ? nouv->XSize() : MINPIIMGSIZE;
 | 
|---|
| 781 | if (sx > 400+mFgScSz*100) sx = 400+mFgScSz*100;
 | 
|---|
| 782 | if (sy > 400+mFgScSz*100) sy = 400+mFgScSz*100;
 | 
|---|
| 783 | px = py = 0;
 | 
|---|
| 784 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str());
 | 
|---|
| 785 | if (fgimagnav) {  // Creation de naviguateur d'image 
 | 
|---|
| 786 |   piin = new PIImageNavigator(win, (char *)wname.c_str(), sx, sy, px,py);
 | 
|---|
| 787 |   piin->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
 | 
|---|
| 788 |   piin->Show();
 | 
|---|
| 789 |   piin->ImageWdg()->ShowCursor(true);
 | 
|---|
| 790 |   pii = piin->ImageWdg();
 | 
|---|
| 791 |   piin->SetUserData(NULL, oid);
 | 
|---|
| 792 |   pii->SetUserData(NULL, oid);
 | 
|---|
| 793 | }
 | 
|---|
| 794 | else { // Creation de widget PIImage normal
 | 
|---|
| 795 |   pii = new PIImage(win, (char *)wname.c_str(), sx, sy, px,py);
 | 
|---|
| 796 |   pii->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
 | 
|---|
| 797 |   pii->SetZoomWin(zoom, false);
 | 
|---|
| 798 |   pii->SetGloVWin(gimv, false);
 | 
|---|
| 799 |   pii->SetCMapWin(cmapv, false);
 | 
|---|
| 800 |   pii->ShowCursor(true);
 | 
|---|
| 801 |   pii->SetUserData(NULL, oid);
 | 
|---|
| 802 | }
 | 
|---|
| 803 | 
 | 
|---|
| 804 | 
 | 
|---|
| 805 | pii->SetImage(nouv, true, false);
 | 
|---|
| 806 | 
 | 
|---|
| 807 | // decode des options en chaine de caracteres
 | 
|---|
| 808 | if (mAxesAtt.size() > 0) 
 | 
|---|
| 809 |   pii->DecodeOptionString(mAxesAtt, false);   // Les options d'axe
 | 
|---|
| 810 | if (mDefaultAtt.size() > 0) 
 | 
|---|
| 811 |   pii->DecodeOptionString(mDefaultAtt, false);  // d'abord les options par defaut
 | 
|---|
| 812 | if (opts.size() > 0) 
 | 
|---|
| 813 |   pii->DecodeOptionString(opts);    // ensuite, les options specifies en argument
 | 
|---|
| 814 | 
 | 
|---|
| 815 | // On recalcule la taille de la fenetre si Disp_Win
 | 
|---|
| 816 | if (dwopt == Disp_Win) {
 | 
|---|
| 817 |   int sx2 = (int)((float)nouv->XSize()*pii->GetZoomF());
 | 
|---|
| 818 |   int sy2 = (int)((float)nouv->YSize()*pii->GetZoomF());
 | 
|---|
| 819 |   
 | 
|---|
| 820 |   if (sx2 > 400+mFgScSz*100) sx2 = 400+mFgScSz*100;
 | 
|---|
| 821 |   if (sy2 > 400+mFgScSz*100) sy2 = 400+mFgScSz*100;
 | 
|---|
| 822 |   if (sx2 < MINPIIMGSIZE) sx = MINPIIMGSIZE;
 | 
|---|
| 823 |   if (sy2 < MINPIIMGSIZE) sy = MINPIIMGSIZE;
 | 
|---|
| 824 |   if ((sx2 != sx) || (sy2 != sy))  win->SetSize(sx2, sy2);
 | 
|---|
| 825 | }
 | 
|---|
| 826 | 
 | 
|---|
| 827 | // printf("!!DBG!! PIImage Pos= %d %d  Size= %d %d \n", pii->XPos(), pii->YPos(), pii->XSize(), pii->YSize()   );
 | 
|---|
| 828 | mCurWin = win;
 | 
|---|
| 829 | mCurWdg = pii;
 | 
|---|
| 830 | mLastWdg = pii;
 | 
|---|
| 831 | mBWId++;
 | 
|---|
| 832 | if (fgimagnav)  mBWList[mBWId] = piin;
 | 
|---|
| 833 | else mBWList[mBWId] = pii;
 | 
|---|
| 834 | // pii->Refresh();
 | 
|---|
| 835 |   pii->Apply(true);
 | 
|---|
| 836 |   //  cmapv->Refresh();  Pas besoin ? , Reza Fev 2005 
 | 
|---|
| 837 | return(mBWId); 
 | 
|---|
| 838 | }
 | 
|---|
| 839 | 
 | 
|---|
| 840 | 
 | 
|---|
| 841 | /* --Methode-- */
 | 
|---|
| 842 | int PIStdImgApp::DispScDrawer(PIDrawer* scd, string const & name, string const& sop, 
 | 
|---|
| 843 |                               string title, int oid, bool fglock)
 | 
|---|
| 844 | {
 | 
|---|
| 845 | if (scd == NULL)
 | 
|---|
| 846 |   {
 | 
|---|
| 847 |   printf("PIStdImgApp::DispScDrawer_Error  Cannot Add NULL ScDrawer \n");
 | 
|---|
| 848 |   return(-1);
 | 
|---|
| 849 |   }
 | 
|---|
| 850 | 
 | 
|---|
| 851 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 852 | SyncPIS zs(getMutex(), fglock, 2);
 | 
|---|
| 853 | 
 | 
|---|
| 854 | // On decode les options graphiques
 | 
|---|
| 855 | vector<string> opts;
 | 
|---|
| 856 | string wname = name;
 | 
|---|
| 857 | DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname);
 | 
|---|
| 858 | if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next;
 | 
|---|
| 859 | 
 | 
|---|
| 860 | // Trace en superpoistion
 | 
|---|
| 861 | if ( (dwopt == Disp_Same) && (mLastWdg) ) {  
 | 
|---|
| 862 |   // Les options 
 | 
|---|
| 863 |   scd->DecodeOptionString(mDefaultAtt, false);
 | 
|---|
| 864 |   if (nb_disp_same > 0) {
 | 
|---|
| 865 |     vector<string> ostatpos;
 | 
|---|
| 866 |     int spo = nb_disp_same%4;
 | 
|---|
| 867 |     if (spo == 1) ostatpos.push_back("statposoff=-0.01,-0.26");
 | 
|---|
| 868 |     else if (spo == 2)  ostatpos.push_back("statposoff=-0.36,-0.01");
 | 
|---|
| 869 |     else  ostatpos.push_back("statposoff=-0.36,-0.26");
 | 
|---|
| 870 |     scd->DecodeOptionString(ostatpos, true);
 | 
|---|
| 871 |   }
 | 
|---|
| 872 |   scd->DecodeOptionString(opts, true);
 | 
|---|
| 873 | 
 | 
|---|
| 874 |   if (mLastWdg->kind() == PIScDrawWdg::ClassId)  ((PIScDrawWdg*)mLastWdg)->AddScDrawer(scd, true);
 | 
|---|
| 875 |   else mLastWdg->AddDrawer(scd, true, true, true);
 | 
|---|
| 876 |   scd->Refresh(); 
 | 
|---|
| 877 |   mDId++;
 | 
|---|
| 878 |   mDrwList[mDId] = scd;
 | 
|---|
| 879 |   return(-mDId);   
 | 
|---|
| 880 | }
 | 
|---|
| 881 | // Trace en medaillon
 | 
|---|
| 882 | else if ( (dwopt == Disp_Inset) && (mLastWdg) ) {
 | 
|---|
| 883 |   PIGrCoord x1, x2, y1, y2;
 | 
|---|
| 884 |   x1 = mIXmin;  x2 = mIXmax;
 | 
|---|
| 885 |   y2 = 1.-mIYmin;  y1 = 1.-mIYmax;
 | 
|---|
| 886 |   // Les options 
 | 
|---|
| 887 |   scd->DecodeOptionString(mDefaultAtt, false);
 | 
|---|
| 888 |   scd->DecodeOptionString(opts, true);
 | 
|---|
| 889 | 
 | 
|---|
| 890 |   scd->SetAxesFlags(mAxesFlags);
 | 
|---|
| 891 |   scd->UpdateLimits();
 | 
|---|
| 892 |   mLastWdg->AddDrawer(scd, x1, y1, x2, y2, true, false, true);
 | 
|---|
| 893 |   scd->Refresh();
 | 
|---|
| 894 |   mDId++;
 | 
|---|
| 895 |   mDrwList[mDId] = scd;
 | 
|---|
| 896 |   return(-mDId);   
 | 
|---|
| 897 | }
 | 
|---|
| 898 | 
 | 
|---|
| 899 | // Creation d'un nouveau PIScDrawWdg
 | 
|---|
| 900 | PIWindow* win;
 | 
|---|
| 901 | PIScDrawWdg* scw;
 | 
|---|
| 902 | int sx, sy, px, py, flag;
 | 
|---|
| 903 | sx = 200+mFgScSz*100;
 | 
|---|
| 904 | sy = 200+mFgScSz*100;
 | 
|---|
| 905 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str());
 | 
|---|
| 906 | 
 | 
|---|
| 907 | scw = new PIScDrawWdg(win, (char *)wname.c_str(), sx, sy, px, py);
 | 
|---|
| 908 | scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
 | 
|---|
| 909 | scw->SetUserData(NULL, oid);
 | 
|---|
| 910 | 
 | 
|---|
| 911 | // Decodage des options :
 | 
|---|
| 912 | vector<string> scwatt;
 | 
|---|
| 913 | scw->SetAxesFlags(mAxesFlags);
 | 
|---|
| 914 | if ( mDefaultAtt.size() > 0) { 
 | 
|---|
| 915 |   scwatt = mDefaultAtt;
 | 
|---|
| 916 |   scd->DecodeOptionString(scwatt, true);
 | 
|---|
| 917 |   scw->DecodeOptionString(scwatt, true);
 | 
|---|
| 918 | }
 | 
|---|
| 919 | if ( mAxesAtt.size() > 0) { 
 | 
|---|
| 920 |   scwatt = mAxesAtt;
 | 
|---|
| 921 |   scw->DecodeOptionString(scwatt, true);
 | 
|---|
| 922 | }
 | 
|---|
| 923 | if (opts.size() > 0) 
 | 
|---|
| 924 |   scd->DecodeOptionString(opts, true);
 | 
|---|
| 925 | if (opts.size() > 0) 
 | 
|---|
| 926 |   scw->DecodeOptionString(opts, false);
 | 
|---|
| 927 | 
 | 
|---|
| 928 | //   Titre du plot
 | 
|---|
| 929 | if (mAddTitle) {
 | 
|---|
| 930 |   if (title.length() <= 0)  title = wname;  string t2="";   
 | 
|---|
| 931 |   scw->SetTitles(title, t2);    
 | 
|---|
| 932 | }
 | 
|---|
| 933 | 
 | 
|---|
| 934 | scw->AddScDrawer(scd, true);
 | 
|---|
| 935 | // scw->Refresh();   ? Pas necessaire  Reza 19/08/98, 05/05/99 $CHECK$ 
 | 
|---|
| 936 | 
 | 
|---|
| 937 | mCurWin = win;
 | 
|---|
| 938 | mCurWdg = scw;
 | 
|---|
| 939 | mLastWdg = scw;
 | 
|---|
| 940 | mBWId++;
 | 
|---|
| 941 | mBWList[mBWId] = scw;
 | 
|---|
| 942 | return(mBWId); 
 | 
|---|
| 943 | }
 | 
|---|
| 944 | 
 | 
|---|
| 945 | /* --Methode-- */
 | 
|---|
| 946 | int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, string const& sop, 
 | 
|---|
| 947 |                               string title, int oid, bool fglock)
 | 
|---|
| 948 | {
 | 
|---|
| 949 | if (dr3 == NULL)
 | 
|---|
| 950 |   {
 | 
|---|
| 951 |   printf("PIStdImgApp::Disp3DDrawer_Error  Cannot Add NULL 3DDrawer \n");
 | 
|---|
| 952 |   return(-1);
 | 
|---|
| 953 |   }
 | 
|---|
| 954 | 
 | 
|---|
| 955 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 956 | SyncPIS zs(getMutex(), fglock, 2);
 | 
|---|
| 957 | 
 | 
|---|
| 958 | // On decode les options graphiques
 | 
|---|
| 959 | vector<string> opts;
 | 
|---|
| 960 | string wname = name;
 | 
|---|
| 961 | DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname);
 | 
|---|
| 962 | 
 | 
|---|
| 963 | if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next;
 | 
|---|
| 964 | 
 | 
|---|
| 965 | // Trace en superpoistion
 | 
|---|
| 966 | if ( (dwopt == Disp_Same) && (mLastWdg) ) {
 | 
|---|
| 967 |   // Les options 
 | 
|---|
| 968 |   dr3->DecodeOptionString(mDefaultAtt, false);
 | 
|---|
| 969 |   if (nb_disp_same > 1) {
 | 
|---|
| 970 |     vector<string> ostatpos;
 | 
|---|
| 971 |     int spo = nb_disp_same%4;
 | 
|---|
| 972 |     if (spo == 1) ostatpos.push_back("statposoff=-0.01,-0.26");
 | 
|---|
| 973 |     else if (spo == 2)  ostatpos.push_back("statposoff=-0.36,-0.01");
 | 
|---|
| 974 |     else  ostatpos.push_back("statposoff=-0.36,-0.26");
 | 
|---|
| 975 |     dr3->DecodeOptionString(ostatpos, true);
 | 
|---|
| 976 |   }
 | 
|---|
| 977 | 
 | 
|---|
| 978 |   dr3->DecodeOptionString(opts, true);
 | 
|---|
| 979 | 
 | 
|---|
| 980 |   if (mLastWdg->kind() == PIDraw3DWdg::ClassId)  ((PIDraw3DWdg*)mLastWdg)->AddDrawer3D(dr3, true);
 | 
|---|
| 981 |   else mLastWdg->AddDrawer(dr3, true, true, true);
 | 
|---|
| 982 |   dr3->Refresh();
 | 
|---|
| 983 |   mDId++;
 | 
|---|
| 984 |   mDrwList[mDId] = dr3;
 | 
|---|
| 985 |   return(-mDId);   
 | 
|---|
| 986 | }
 | 
|---|
| 987 | // Trace en medaillon
 | 
|---|
| 988 | else if ( (dwopt == Disp_Inset) && (mLastWdg) ) {
 | 
|---|
| 989 |   PIGrCoord x1, x2, y1, y2;
 | 
|---|
| 990 |   x1 = mIXmin;  x2 = mIXmax;
 | 
|---|
| 991 |   y2 = 1.-mIYmin;  y1 = 1.-mIYmax;
 | 
|---|
| 992 |   // Les options 
 | 
|---|
| 993 |   dr3->DecodeOptionString(mDefaultAtt, false);
 | 
|---|
| 994 |   dr3->DecodeOptionString(opts, true);
 | 
|---|
| 995 | 
 | 
|---|
| 996 |   dr3->SetAxesFlags(mAxesFlags);
 | 
|---|
| 997 |   dr3->UpdateLimits();
 | 
|---|
| 998 |   mLastWdg->AddDrawer(dr3, x1, y1, x2, y2, true, false, true);
 | 
|---|
| 999 |   dr3->Refresh();
 | 
|---|
| 1000 |   mDId++;
 | 
|---|
| 1001 |   mDrwList[mDId] = dr3;
 | 
|---|
| 1002 |   return(-mDId);   
 | 
|---|
| 1003 | }
 | 
|---|
| 1004 | 
 | 
|---|
| 1005 | 
 | 
|---|
| 1006 | PIWindow* win;
 | 
|---|
| 1007 | int sx, sy, px, py, flag;
 | 
|---|
| 1008 | sx = 200+mFgScSz*100;
 | 
|---|
| 1009 | sy = 200+mFgScSz*100;
 | 
|---|
| 1010 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str());
 | 
|---|
| 1011 | PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)wname.c_str(), sx, sy, px, py);
 | 
|---|
| 1012 | wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
 | 
|---|
| 1013 | wd3->SetUserData(NULL, oid);
 | 
|---|
| 1014 | 
 | 
|---|
| 1015 | // Decodage des options :
 | 
|---|
| 1016 | vector<string> scwatt;
 | 
|---|
| 1017 | // wd3->SetAxesFlags(mAxesFlags);  Attributs d'axes 3D a faire 
 | 
|---|
| 1018 | if ( mDefaultAtt.size() > 0) { 
 | 
|---|
| 1019 |   scwatt = mDefaultAtt;
 | 
|---|
| 1020 |   dr3->DecodeOptionString(scwatt, true);
 | 
|---|
| 1021 |   wd3->DecodeOptionString(scwatt, true);
 | 
|---|
| 1022 | }
 | 
|---|
| 1023 | if ( mAxesAtt.size() > 0) { 
 | 
|---|
| 1024 |   scwatt = mAxesAtt;
 | 
|---|
| 1025 |   wd3->DecodeOptionString(scwatt, true);
 | 
|---|
| 1026 | }
 | 
|---|
| 1027 | if (opts.size() > 0)  
 | 
|---|
| 1028 |   dr3->DecodeOptionString(opts, true);
 | 
|---|
| 1029 | if (opts.size() > 0)  
 | 
|---|
| 1030 |   wd3->DecodeOptionString(opts, false);
 | 
|---|
| 1031 | 
 | 
|---|
| 1032 | //   Titre du plot
 | 
|---|
| 1033 | if (mAddTitle) {
 | 
|---|
| 1034 |   if (title.length() <= 0)  title = wname;  string t2="";   
 | 
|---|
| 1035 |   wd3->SetTitles(title, t2);    
 | 
|---|
| 1036 | }
 | 
|---|
| 1037 | 
 | 
|---|
| 1038 | wd3->AddDrawer3D(dr3, true);
 | 
|---|
| 1039 | // wd3->Refresh();   ?Pas necessaire   $CHECK$ 05/05/99
 | 
|---|
| 1040 | 
 | 
|---|
| 1041 | mCurWin = win;
 | 
|---|
| 1042 | mCurWdg = wd3;
 | 
|---|
| 1043 | mLastWdg = wd3;
 | 
|---|
| 1044 | mBWId++;
 | 
|---|
| 1045 | mBWList[mBWId] = wd3;
 | 
|---|
| 1046 | return(mBWId); 
 | 
|---|
| 1047 | }
 | 
|---|
| 1048 | 
 | 
|---|
| 1049 | // RZDEL: Normalement, il ne devrait plus y avoir besoin de cette
 | 
|---|
| 1050 | // methode avec le thread separe de l'interpreteur - Reza 27/12/2003 
 | 
|---|
| 1051 | /* --Methode-- */
 | 
|---|
| 1052 | int PIStdImgApp::ExecuteExtCommand() 
 | 
|---|
| 1053 | { 
 | 
|---|
| 1054 | if (!fg_exc_cmd) return(0); 
 | 
|---|
| 1055 | else {
 | 
|---|
| 1056 |   fg_exc_cmd = false; 
 | 
|---|
| 1057 |   return CmdInterpreter()->Interpret(exc_command); 
 | 
|---|
| 1058 |   }
 | 
|---|
| 1059 | }
 | 
|---|
| 1060 | 
 | 
|---|
| 1061 | /* --Methode-- */
 | 
|---|
| 1062 | void PIStdImgApp::AddText(string const & txt, double xp, double yp, string const& sop, bool fgcn)
 | 
|---|
| 1063 | {
 | 
|---|
| 1064 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1065 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1066 | 
 | 
|---|
| 1067 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1068 | if (eld == NULL) return;
 | 
|---|
| 1069 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1070 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1071 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1072 | PIElDrwMgr* elmgr;
 | 
|---|
| 1073 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1074 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1075 | if (elmgr == NULL) return;
 | 
|---|
| 1076 | 
 | 
|---|
| 1077 | vector<string> opts;
 | 
|---|
| 1078 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1079 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1080 | unsigned long tpd = 0;
 | 
|---|
| 1081 | gratt.DecodeTextPosDirAtt(opts, tpd, false);
 | 
|---|
| 1082 | elmgr->ElAddText(xp,yp,txt.c_str(), gratt, tpd, fgcn);
 | 
|---|
| 1083 | eld->Refresh();
 | 
|---|
| 1084 | }
 | 
|---|
| 1085 | 
 | 
|---|
| 1086 | /* --Methode-- */
 | 
|---|
| 1087 | void PIStdImgApp::AddCompText(string const & txt, string const & txtup, string const & txtdn, 
 | 
|---|
| 1088 |                               double xp, double yp, string const& sop, 
 | 
|---|
| 1089 |                               string const& optss, bool fgcn)
 | 
|---|
| 1090 | {
 | 
|---|
| 1091 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1092 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1093 | 
 | 
|---|
| 1094 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1095 | if (eld == NULL) return;
 | 
|---|
| 1096 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1097 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1098 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1099 | PIElDrwMgr* elmgr;
 | 
|---|
| 1100 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1101 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1102 | if (elmgr == NULL) return;
 | 
|---|
| 1103 | 
 | 
|---|
| 1104 | vector<string> opts;
 | 
|---|
| 1105 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1106 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1107 | unsigned long tpd = 0;
 | 
|---|
| 1108 | gratt.DecodeTextPosDirAtt(opts, tpd, false);
 | 
|---|
| 1109 | ParseDisplayOption(optss, opts);
 | 
|---|
| 1110 | PIGraphicAtt grattss(opts);
 | 
|---|
| 1111 | elmgr->ElAddCompText(xp,yp,txt.c_str(), gratt, txtup, txtdn, grattss, tpd, fgcn);
 | 
|---|
| 1112 | eld->Refresh();
 | 
|---|
| 1113 | }
 | 
|---|
| 1114 | 
 | 
|---|
| 1115 | /* --Methode-- */
 | 
|---|
| 1116 | void PIStdImgApp::AddLine(double xp1, double yp1, double xp2, double yp2, 
 | 
|---|
| 1117 |                           string const& sop, bool fgarrow, bool fgcn)
 | 
|---|
| 1118 | {
 | 
|---|
| 1119 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1120 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1121 | 
 | 
|---|
| 1122 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1123 | if (eld == NULL) return;
 | 
|---|
| 1124 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1125 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1126 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1127 | PIElDrwMgr* elmgr = NULL;
 | 
|---|
| 1128 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1129 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1130 | if (elmgr == NULL) return;
 | 
|---|
| 1131 | 
 | 
|---|
| 1132 | vector<string> opts;
 | 
|---|
| 1133 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1134 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1135 | if (fgarrow) 
 | 
|---|
| 1136 |   elmgr->ElAddArrow(xp1, yp1, xp2, yp2, gratt, fgcn);
 | 
|---|
| 1137 | else elmgr->ElAddLine(xp1, yp1, xp2, yp2, gratt, fgcn);
 | 
|---|
| 1138 | eld->Refresh();
 | 
|---|
| 1139 | }
 | 
|---|
| 1140 | 
 | 
|---|
| 1141 | /* --Methode-- */
 | 
|---|
| 1142 | void PIStdImgApp::AddRectangle(double xp1, double yp1, double xp2, double yp2, 
 | 
|---|
| 1143 |                                string const& sop, bool fgfill, bool fgcn)
 | 
|---|
| 1144 | {
 | 
|---|
| 1145 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1146 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1147 | 
 | 
|---|
| 1148 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1149 | if (eld == NULL) return;
 | 
|---|
| 1150 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1151 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1152 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1153 | PIElDrwMgr* elmgr = NULL;
 | 
|---|
| 1154 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1155 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1156 | 
 | 
|---|
| 1157 | double xp,yp;
 | 
|---|
| 1158 | double dx, dy;
 | 
|---|
| 1159 | if (xp1 < xp2) {
 | 
|---|
| 1160 |   xp = xp1; dx = xp2-xp1;
 | 
|---|
| 1161 | }
 | 
|---|
| 1162 | else {
 | 
|---|
| 1163 |   xp = xp2; dx = xp1-xp2;
 | 
|---|
| 1164 | }
 | 
|---|
| 1165 | if (yp1 < yp2) {
 | 
|---|
| 1166 |   yp = yp1; dy = yp2-yp1;
 | 
|---|
| 1167 | }
 | 
|---|
| 1168 | else {
 | 
|---|
| 1169 |   yp = yp2; dy = yp1-yp2;
 | 
|---|
| 1170 | }
 | 
|---|
| 1171 | 
 | 
|---|
| 1172 | vector<string> opts;
 | 
|---|
| 1173 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1174 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1175 | 
 | 
|---|
| 1176 | if (fgfill) elmgr->ElAddFRect(xp, yp, dx, dy, gratt, fgcn);
 | 
|---|
| 1177 | else elmgr->ElAddRect(xp, yp, dx, dy, gratt, fgcn);
 | 
|---|
| 1178 | eld->Refresh();
 | 
|---|
| 1179 | }
 | 
|---|
| 1180 | 
 | 
|---|
| 1181 | /* --Methode-- */
 | 
|---|
| 1182 | void PIStdImgApp::AddCircle(double xc, double yc, double r, string const& sop, 
 | 
|---|
| 1183 |                             bool fgfill, bool fgcn)
 | 
|---|
| 1184 | {
 | 
|---|
| 1185 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1186 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1187 | 
 | 
|---|
| 1188 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1189 | if (eld == NULL) return;
 | 
|---|
| 1190 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1191 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1192 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1193 | PIElDrwMgr* elmgr = NULL;
 | 
|---|
| 1194 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1195 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1196 | 
 | 
|---|
| 1197 | vector<string> opts;
 | 
|---|
| 1198 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1199 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1200 | if (r < -0.5)
 | 
|---|
| 1201 |   elmgr->ElAddMarker(xc, yc, gratt);
 | 
|---|
| 1202 | else {
 | 
|---|
| 1203 |   if (fgfill) elmgr->ElAddFCirc(xc, yc, r, gratt, fgcn);
 | 
|---|
| 1204 |   else elmgr->ElAddCirc(xc, yc, r, gratt, fgcn);
 | 
|---|
| 1205 | }
 | 
|---|
| 1206 | eld->Refresh();
 | 
|---|
| 1207 | }
 | 
|---|
| 1208 | /* --Methode-- */
 | 
|---|
| 1209 | void PIStdImgApp::AddOval(double xp, double yp, double dx, double dy, 
 | 
|---|
| 1210 |                           string const& sop, bool fgfill, bool fgcn)
 | 
|---|
| 1211 | {
 | 
|---|
| 1212 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1213 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1214 | 
 | 
|---|
| 1215 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1216 | if (eld == NULL) return;
 | 
|---|
| 1217 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1218 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1219 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1220 | PIElDrwMgr* elmgr = NULL;
 | 
|---|
| 1221 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1222 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1223 | 
 | 
|---|
| 1224 | 
 | 
|---|
| 1225 | vector<string> opts;
 | 
|---|
| 1226 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1227 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1228 | 
 | 
|---|
| 1229 | if (fgfill) elmgr->ElAddFOval(xp, yp, dx, dy, gratt, fgcn);
 | 
|---|
| 1230 | else elmgr->ElAddOval(xp, yp, dx, dy, gratt, fgcn);
 | 
|---|
| 1231 | eld->Refresh();
 | 
|---|
| 1232 | }
 | 
|---|
| 1233 | 
 | 
|---|
| 1234 | /* --Methode-- */
 | 
|---|
| 1235 | void PIStdImgApp::AddArc(double xc, double yc, double r, double a, double da, 
 | 
|---|
| 1236 |                          string const& sop, bool fgfill, bool fgcn)
 | 
|---|
| 1237 | {
 | 
|---|
| 1238 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1239 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1240 | 
 | 
|---|
| 1241 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1242 | if (eld == NULL) return;
 | 
|---|
| 1243 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1244 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1245 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1246 | PIElDrwMgr* elmgr = NULL;
 | 
|---|
| 1247 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1248 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1249 | 
 | 
|---|
| 1250 | vector<string> opts;
 | 
|---|
| 1251 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1252 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1253 | if (fgfill) elmgr->ElAddFArc(xc, yc, r, a, da, gratt, fgcn);
 | 
|---|
| 1254 | else elmgr->ElAddArc(xc, yc, r, a, da, gratt, fgcn);
 | 
|---|
| 1255 | eld->Refresh();
 | 
|---|
| 1256 | }
 | 
|---|
| 1257 | 
 | 
|---|
| 1258 | /* --Methode-- */
 | 
|---|
| 1259 | void PIStdImgApp::AddArc(double x1, double y1, double x2, double y2,
 | 
|---|
| 1260 |                          double x3, double y3, string const& sop, bool fgfill, bool fgcn)
 | 
|---|
| 1261 | {
 | 
|---|
| 1262 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1263 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1264 | 
 | 
|---|
| 1265 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1266 | if (eld == NULL) return;
 | 
|---|
| 1267 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1268 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1269 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1270 | PIElDrwMgr* elmgr = NULL;
 | 
|---|
| 1271 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1272 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1273 | if (elmgr == NULL) return;
 | 
|---|
| 1274 | 
 | 
|---|
| 1275 | vector<string> opts;
 | 
|---|
| 1276 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1277 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1278 | if (fgfill) 
 | 
|---|
| 1279 |   elmgr->ElAddFArc(x1, y1, x2, y2, x3, y3, gratt, fgcn);
 | 
|---|
| 1280 | else  elmgr->ElAddArc(x1, y1, x2, y2, x3, y3, gratt, fgcn);
 | 
|---|
| 1281 | eld->Refresh();
 | 
|---|
| 1282 | }
 | 
|---|
| 1283 | 
 | 
|---|
| 1284 | /* --Methode-- */
 | 
|---|
| 1285 | void PIStdImgApp::AddPoly(vector<double>& xpol, vector<double>& ypol, 
 | 
|---|
| 1286 |                           string const& sop, bool fgfill, bool fgcn)
 | 
|---|
| 1287 | {
 | 
|---|
| 1288 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1289 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1290 | 
 | 
|---|
| 1291 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1292 | if (eld == NULL) return;
 | 
|---|
| 1293 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1294 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1295 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1296 | PIElDrwMgr* elmgr = NULL;
 | 
|---|
| 1297 | if (eld2) elmgr = &(eld2->ElDrwMgr());
 | 
|---|
| 1298 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
 | 
|---|
| 1299 | if (elmgr == NULL) return;
 | 
|---|
| 1300 | 
 | 
|---|
| 1301 | vector<string> opts;
 | 
|---|
| 1302 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1303 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1304 | if (fgfill) 
 | 
|---|
| 1305 |   elmgr->ElAddFPoly(xpol, ypol, gratt, fgcn);
 | 
|---|
| 1306 | else  elmgr->ElAddPoly(xpol, ypol, gratt, fgcn);
 | 
|---|
| 1307 | eld->Refresh();
 | 
|---|
| 1308 | 
 | 
|---|
| 1309 | }
 | 
|---|
| 1310 | 
 | 
|---|
| 1311 | 
 | 
|---|
| 1312 | /* --Methode-- */
 | 
|---|
| 1313 | void PIStdImgApp::SetTitle(string const & titletop, string const & titlebottom, string const& sop)
 | 
|---|
| 1314 | {
 | 
|---|
| 1315 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1316 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1317 | 
 | 
|---|
| 1318 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1319 | if (eld == NULL) return;
 | 
|---|
| 1320 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1321 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
 | 
|---|
| 1322 | if ((eld2 == NULL) && (eld3 == NULL)) return;
 | 
|---|
| 1323 | 
 | 
|---|
| 1324 | vector<string> opts;
 | 
|---|
| 1325 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1326 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1327 | 
 | 
|---|
| 1328 | if (eld2) { 
 | 
|---|
| 1329 |   eld2->SetTitles(titletop, titlebottom, gratt);
 | 
|---|
| 1330 |   eld2->ShowTitles(true);
 | 
|---|
| 1331 | }
 | 
|---|
| 1332 | else if (eld3) { 
 | 
|---|
| 1333 |   eld3->SetTitles(titletop, titlebottom, gratt);
 | 
|---|
| 1334 |   eld3->ShowTitles(true);
 | 
|---|
| 1335 | }
 | 
|---|
| 1336 | eld->Refresh();
 | 
|---|
| 1337 | }
 | 
|---|
| 1338 | /* --Methode-- */
 | 
|---|
| 1339 | void PIStdImgApp::SetAxeLabels(string const & xLabel, string const & yLabel, string const& sop)
 | 
|---|
| 1340 | {
 | 
|---|
| 1341 | // <ZThread> global PIApplication event loop synchronisation
 | 
|---|
| 1342 | ZSync zs(thr_glsyn, 2);  zs.NOp(); 
 | 
|---|
| 1343 | 
 | 
|---|
| 1344 | PIDrawer *eld=CurrentElDrawer();
 | 
|---|
| 1345 | if (eld == NULL) return;
 | 
|---|
| 1346 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
 | 
|---|
| 1347 | if (eld2 == NULL) return;
 | 
|---|
| 1348 | 
 | 
|---|
| 1349 | vector<string> opts;
 | 
|---|
| 1350 | ParseDisplayOption(sop, opts);
 | 
|---|
| 1351 | PIGraphicAtt gratt(opts);
 | 
|---|
| 1352 | 
 | 
|---|
| 1353 | eld2->SetAxesLabels(xLabel, yLabel, gratt);
 | 
|---|
| 1354 | eld2->ShowAxesLabels(true);
 | 
|---|
| 1355 | 
 | 
|---|
| 1356 | eld->Refresh();
 | 
|---|
| 1357 | }
 | 
|---|
| 1358 | 
 | 
|---|
| 1359 | /* --Methode-- */
 | 
|---|
| 1360 | PIDrawer* PIStdImgApp::CurrentElDrawer()
 | 
|---|
| 1361 | {
 | 
|---|
| 1362 | PIDrawer *eld=NULL;
 | 
|---|
| 1363 | if (!mLastWdg)  return(eld);
 | 
|---|
| 1364 | PIScDrawWdg* sdw=NULL;
 | 
|---|
| 1365 | PIDraw3DWdg* w3d=NULL;
 | 
|---|
| 1366 | PIImage* imgw;
 | 
|---|
| 1367 | switch(mLastWdg->kind()) {
 | 
|---|
| 1368 |   case PIScDrawWdg::ClassId :
 | 
|---|
| 1369 |     sdw = dynamic_cast<PIScDrawWdg *>(mLastWdg);
 | 
|---|
| 1370 |     if (sdw) eld = sdw->BaseDrawer();
 | 
|---|
| 1371 |     break;
 | 
|---|
| 1372 |   case PIDraw3DWdg::ClassId :
 | 
|---|
| 1373 |     w3d = dynamic_cast<PIDraw3DWdg *>(mLastWdg);
 | 
|---|
| 1374 |     if (w3d) eld = w3d->BaseDrawer();
 | 
|---|
| 1375 |     break;
 | 
|---|
| 1376 |   case PIImage::ClassId :
 | 
|---|
| 1377 |     imgw = dynamic_cast<PIImage *>(mLastWdg);
 | 
|---|
| 1378 |     if (imgw) eld = imgw->BaseDrawer();
 | 
|---|
| 1379 |     break;
 | 
|---|
| 1380 |   default :
 | 
|---|
| 1381 |     break;
 | 
|---|
| 1382 |   }
 | 
|---|
| 1383 | return(eld);
 | 
|---|
| 1384 | }
 | 
|---|
| 1385 | 
 | 
|---|
| 1386 | /* --Methode-- */
 | 
|---|
| 1387 | void PIStdImgApp::CreateGraphWin(int nx, int ny, int sx, int sy)
 | 
|---|
| 1388 | {
 | 
|---|
| 1389 | if (nx < 1)  nx = 1;
 | 
|---|
| 1390 | if (ny < 1)  ny = 1;
 | 
|---|
| 1391 | if (nx > 8)  nx = 8;    
 | 
|---|
| 1392 | if (ny > 8)  ny = 8;
 | 
|---|
| 1393 | if ( (sx < 50) && (sy < 50) )   sx = sy = 400+mFgScSz*100; 
 | 
|---|
| 1394 | char buff[64];
 | 
|---|
| 1395 | mWId++;
 | 
|---|
| 1396 | int px, py; 
 | 
|---|
| 1397 | MainWin()->GetScreenPos(px, py);
 | 
|---|
| 1398 | sprintf(buff, "PI-GraphicWin (%d)",mWId);
 | 
|---|
| 1399 | PIZoneWindow* win = new PIZoneWindow(this,  buff, PIWK_normal, nx, ny, sx, sy, px+MainWin()->XSize()+30, 0);
 | 
|---|
| 1400 | win->SetUserData(NULL, ny*10+nx);  // UserFlag= nY*10 + nX  
 | 
|---|
| 1401 | mWList[mWId*10+1] = (PIWindow*)win;
 | 
|---|
| 1402 | win->SetAutoDelChilds(true);
 | 
|---|
| 1403 | // win->Show();
 | 
|---|
| 1404 | mGrW = win; 
 | 
|---|
| 1405 | mGrIdx = 0;
 | 
|---|
| 1406 | }
 | 
|---|
| 1407 | 
 | 
|---|
| 1408 | /* --Methode-- */
 | 
|---|
| 1409 | void PIStdImgApp::CreateStackWin(int sx, int sy)
 | 
|---|
| 1410 | {
 | 
|---|
| 1411 | if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; 
 | 
|---|
| 1412 | char buff[64];
 | 
|---|
| 1413 | mWId++;
 | 
|---|
| 1414 | int px, py; 
 | 
|---|
| 1415 | MainWin()->GetScreenPos(px, py);
 | 
|---|
| 1416 | sprintf(buff, "PI-StackWin (%d)",mWId); 
 | 
|---|
| 1417 | PIStackWindow* win = new PIStackWindow(this,  buff, PIWK_normal, sx, sy, px+MainWin()->XSize()+30, 100);
 | 
|---|
| 1418 | win->SetUserData(NULL, 9999);  // UserFlag= 9999 
 | 
|---|
| 1419 | mWList[mWId*10+2] = (PIWindow*)win;
 | 
|---|
| 1420 | win->SetAutoDelChilds(true);
 | 
|---|
| 1421 | // win->Show();
 | 
|---|
| 1422 | mStW = win;
 | 
|---|
| 1423 | m[2]->SetSensitivity("StackTools", true); 
 | 
|---|
| 1424 | mStIdx = 0;
 | 
|---|
| 1425 | }
 | 
|---|
| 1426 | 
 | 
|---|
| 1427 | /* --Methode-- */
 | 
|---|
| 1428 | PIWindow* PIStdImgApp::GetWindow(DispWinEnum typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom)
 | 
|---|
| 1429 | {
 | 
|---|
| 1430 | PIWindow* rw;
 | 
|---|
| 1431 | 
 | 
|---|
| 1432 | switch (typ) {
 | 
|---|
| 1433 |   case Disp_Next :  // Fenetre graphique courante
 | 
|---|
| 1434 |   case Disp_Default :
 | 
|---|
| 1435 |     {
 | 
|---|
| 1436 |     if (mGrW == NULL) CreateGraphWin();
 | 
|---|
| 1437 |     int nx, ny;
 | 
|---|
| 1438 |     mGrW->NbZone(nx, ny);
 | 
|---|
| 1439 |     PIWdg* nw = mGrW->NextChildPosSize(px, py, sx, sy);
 | 
|---|
| 1440 | //    cerr << "**DBG** PIStdImgApp::GetWindow() DispNext : nw = " << (long)nw << endl;
 | 
|---|
| 1441 |     if (nw) DeleteWidget(nw, false, false);
 | 
|---|
| 1442 |     flag = mGrIdx;
 | 
|---|
| 1443 |     mGrIdx = (mGrIdx+1)%(nx*ny);
 | 
|---|
| 1444 |     rw = mGrW;
 | 
|---|
| 1445 |     break;
 | 
|---|
| 1446 |     }
 | 
|---|
| 1447 | 
 | 
|---|
| 1448 |   case Disp_Stack :  // Fenetre de type stack (empilement)
 | 
|---|
| 1449 |     {
 | 
|---|
| 1450 |     if (mStW == NULL) CreateStackWin(sx, sy);
 | 
|---|
| 1451 |     px = py = 0;
 | 
|---|
| 1452 |     sx = mStW->XSize();
 | 
|---|
| 1453 |     sy = mStW->YSize();
 | 
|---|
| 1454 |     flag = mStIdx;
 | 
|---|
| 1455 |     mStIdx++;
 | 
|---|
| 1456 |     rw = mStW;
 | 
|---|
| 1457 |     }
 | 
|---|
| 1458 |     break;
 | 
|---|
| 1459 | 
 | 
|---|
| 1460 |   default :      // Fenetre ordinaire
 | 
|---|
| 1461 |     {
 | 
|---|
| 1462 |     int pwx, pwy; 
 | 
|---|
| 1463 |     MainWin()->GetScreenPos(pwx, pwy);
 | 
|---|
| 1464 |     if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; 
 | 
|---|
| 1465 |     rw = new PIWindow(this,  nom, PIWK_normal, sx, sy, pwx+MainWin()->XSize()+30, 300);
 | 
|---|
| 1466 |     rw->SetUserData(NULL, 0);  // UserFlag= 0 
 | 
|---|
| 1467 |     mWId++;
 | 
|---|
| 1468 |     mWList[mWId*10] = rw;
 | 
|---|
| 1469 |     rw->SetAutoDelChilds(true);
 | 
|---|
| 1470 |     //    rw->Show();
 | 
|---|
| 1471 |     px = py = 0;
 | 
|---|
| 1472 |     flag = 0;
 | 
|---|
| 1473 |     break;
 | 
|---|
| 1474 |     }
 | 
|---|
| 1475 |   }
 | 
|---|
| 1476 | 
 | 
|---|
| 1477 | rw->Show();
 | 
|---|
| 1478 | mCurWin = rw;
 | 
|---|
| 1479 | return(rw);
 | 
|---|
| 1480 | }
 | 
|---|
| 1481 | 
 | 
|---|
| 1482 | /* --Methode-- */
 | 
|---|
| 1483 | void PIStdImgApp::SetZone(int nzx, int nzy)
 | 
|---|
| 1484 | {
 | 
|---|
| 1485 | if (!mGrW) CreateGraphWin(nzx, nzy);
 | 
|---|
| 1486 | else { 
 | 
|---|
| 1487 |   int k;
 | 
|---|
| 1488 |   PIWdg* cwd;
 | 
|---|
| 1489 |   for(k=0; k<mGrW->NbChilds(); k++) {
 | 
|---|
| 1490 |     if ((cwd = mGrW->GetChild(k)) == NULL)  continue; 
 | 
|---|
| 1491 |     DeleteWidget(cwd, false, false);
 | 
|---|
| 1492 |     }
 | 
|---|
| 1493 |   mGrW->SetZone(nzx, nzy);
 | 
|---|
| 1494 |   }
 | 
|---|
| 1495 | }
 | 
|---|
| 1496 | 
 | 
|---|
| 1497 | /* --Methode-- */
 | 
|---|
| 1498 | void PIStdImgApp::StackWinNext()
 | 
|---|
| 1499 | {
 | 
|---|
| 1500 | if (mStW)  mStW->DispNext();
 | 
|---|
| 1501 | }
 | 
|---|
| 1502 | 
 | 
|---|
| 1503 | /* --Methode-- */
 | 
|---|
| 1504 | void PIStdImgApp::SelectLastWidget(string & nom)
 | 
|---|
| 1505 | {
 | 
|---|
| 1506 | 
 | 
|---|
| 1507 |   if ( (mLastWdg != NULL) && (mLastWdg->Nom() == nom) ) return;
 | 
|---|
| 1508 |   if ( (mCurWdg != NULL) && (mCurWdg->Nom() == nom) ) {
 | 
|---|
| 1509 |     mLastWdg = mCurWdg;
 | 
|---|
| 1510 |     return;
 | 
|---|
| 1511 |   }
 | 
|---|
| 1512 | 
 | 
|---|
| 1513 |   PIWdg* bw = NULL;
 | 
|---|
| 1514 |   long wsid = -1;
 | 
|---|
| 1515 |   BWMList::iterator it;
 | 
|---|
| 1516 |   for(it = mBWList.begin(); it != mBWList.end(); it++) {
 | 
|---|
| 1517 |     if ( ((*it).second->Nom() == nom) && ((*it).first > wsid)) { 
 | 
|---|
| 1518 |       bw = (*it).second; wsid = (*it).first; 
 | 
|---|
| 1519 |     } 
 | 
|---|
| 1520 |   }
 | 
|---|
| 1521 |   if (bw != NULL) {
 | 
|---|
| 1522 |     if (bw->kind() == PIImageNavigator::ClassId) 
 | 
|---|
| 1523 |       mLastWdg = dynamic_cast<PIImageNavigator *>(bw)->ImageWdg();
 | 
|---|
| 1524 |     else mLastWdg = dynamic_cast<PIBaseWdg *>(bw);
 | 
|---|
| 1525 |   }
 | 
|---|
| 1526 |   return;
 | 
|---|
| 1527 | }
 | 
|---|
| 1528 | 
 | 
|---|
| 1529 | /* --Methode-- */
 | 
|---|
| 1530 | void PIStdImgApp::SelectLastWidgetByObjName(string & nom)
 | 
|---|
| 1531 | {
 | 
|---|
| 1532 |   int oid = ObjMgr()->NameToOId(nom);
 | 
|---|
| 1533 |   if (oid < 0) return;
 | 
|---|
| 1534 | 
 | 
|---|
| 1535 |   if ( (mLastWdg != NULL) && (mLastWdg->UserFlag() == oid) ) return;
 | 
|---|
| 1536 |   if ( (mCurWdg != NULL) && (mCurWdg->UserFlag() == oid) ) {
 | 
|---|
| 1537 |     mLastWdg = mCurWdg;
 | 
|---|
| 1538 |     return;
 | 
|---|
| 1539 |   }
 | 
|---|
| 1540 | 
 | 
|---|
| 1541 |   PIWdg* bw = NULL;
 | 
|---|
| 1542 |   long wsid = -1;
 | 
|---|
| 1543 |   BWMList::iterator it;
 | 
|---|
| 1544 |   for(it = mBWList.begin(); it != mBWList.end(); it++) {
 | 
|---|
| 1545 |     if ( ((*it).second->UserFlag() == oid) && ((*it).first > wsid)) { 
 | 
|---|
| 1546 |       bw = (*it).second; wsid = (*it).first; 
 | 
|---|
| 1547 |     } 
 | 
|---|
| 1548 |   }
 | 
|---|
| 1549 |   if (bw != NULL) {
 | 
|---|
| 1550 |     if (bw->kind() == PIImageNavigator::ClassId) 
 | 
|---|
| 1551 |       mLastWdg = dynamic_cast<PIImageNavigator *>(bw)->ImageWdg();
 | 
|---|
| 1552 |     else mLastWdg = dynamic_cast<PIBaseWdg *>(bw);
 | 
|---|
| 1553 |   }
 | 
|---|
| 1554 |   return;
 | 
|---|
| 1555 | }
 | 
|---|
| 1556 | 
 | 
|---|
| 1557 | /* --Methode-- */
 | 
|---|
| 1558 | void PIStdImgApp::DeleteWindow(PIWindow* w)
 | 
|---|
| 1559 | {
 | 
|---|
| 1560 | if (w == NULL)  return;
 | 
|---|
| 1561 | w->Hide();
 | 
|---|
| 1562 | bool ownwindow=false;  // To Check if this is one of our windows
 | 
|---|
| 1563 | WindMList::iterator it;
 | 
|---|
| 1564 | for(it = mWList.begin(); it != mWList.end(); it++) 
 | 
|---|
| 1565 |   if ((*it).second == w)  { mWList.erase(it);  ownwindow = true; break; }
 | 
|---|
| 1566 | if (w == mGrW) { mGrW = NULL;  mGrIdx = -1; }
 | 
|---|
| 1567 | if (w == mStW) { mStW = NULL;  mStIdx = -1; m[2]->SetSensitivity("StackTools", false); }
 | 
|---|
| 1568 | if (w == mCurWin) mCurWin = NULL;
 | 
|---|
| 1569 | 
 | 
|---|
| 1570 | if (!ownwindow) return; // We do nothing if this is not a window we have created ...
 | 
|---|
| 1571 | 
 | 
|---|
| 1572 | int k;
 | 
|---|
| 1573 | PIWdg* cwd;
 | 
|---|
| 1574 | for(k=0; k<w->NbChilds(); k++) {
 | 
|---|
| 1575 |   if ((cwd = w->GetChild(k)) == NULL)  continue; 
 | 
|---|
| 1576 |   DeleteWidget(cwd,false,false);
 | 
|---|
| 1577 |   }
 | 
|---|
| 1578 | delete w;
 | 
|---|
| 1579 | return;
 | 
|---|
| 1580 | }
 | 
|---|
| 1581 | 
 | 
|---|
| 1582 | /* --Methode-- */
 | 
|---|
| 1583 | void PIStdImgApp::DeleteWidget(PIWdg* w, bool dw, bool dwin)
 | 
|---|
| 1584 | {
 | 
|---|
| 1585 | if (w == NULL)  return;
 | 
|---|
| 1586 | BWMList::iterator it;
 | 
|---|
| 1587 | for(it = mBWList.begin(); it != mBWList.end(); it++) 
 | 
|---|
| 1588 |   if ((*it).second == w)  { mBWList.erase(it);  break; }
 | 
|---|
| 1589 | PIBaseWdg* bw = NULL;
 | 
|---|
| 1590 | if (w->kind() == PIImageNavigator::ClassId) {
 | 
|---|
| 1591 |   PIImageNavigator* piin = dynamic_cast<PIImageNavigator *>(w);
 | 
|---|
| 1592 |   if (piin) bw = piin->ImageWdg();
 | 
|---|
| 1593 | }                                
 | 
|---|
| 1594 | else bw = dynamic_cast<PIBaseWdg *>(w);
 | 
|---|
| 1595 | if (bw != NULL) {
 | 
|---|
| 1596 |   PIDrawer* drw;
 | 
|---|
| 1597 |   int k;
 | 
|---|
| 1598 |   for(k=0; k<bw->NbDrawers(); k++) {
 | 
|---|
| 1599 |     if ((drw = bw->GetDrawer(k)) == NULL)  continue; 
 | 
|---|
| 1600 |     DrwMList::iterator itt;
 | 
|---|
| 1601 |     for(itt = mDrwList.begin(); itt != mDrwList.end(); itt++) 
 | 
|---|
| 1602 |       if ((*itt).second == drw)  { mDrwList.erase(itt);  break; }
 | 
|---|
| 1603 |   }
 | 
|---|
| 1604 | }
 | 
|---|
| 1605 | 
 | 
|---|
| 1606 | if ( (w == mCurWdg) || (bw == mCurWdg) ) {  
 | 
|---|
| 1607 |   mCurWdg = NULL;
 | 
|---|
| 1608 |   if (mFgCWImg) {
 | 
|---|
| 1609 |     m[4]->SetSensitivityMsg(10515, false);
 | 
|---|
| 1610 |     m[4]->SetSensitivityMsg(10516, false);
 | 
|---|
| 1611 |     mFgCWImg = false;
 | 
|---|
| 1612 |     }
 | 
|---|
| 1613 |   }
 | 
|---|
| 1614 | 
 | 
|---|
| 1615 | if ( (w == mLastWdg) || (bw == mLastWdg) ) mLastWdg = NULL;
 | 
|---|
| 1616 | 
 | 
|---|
| 1617 | PIWdg* pw=NULL;
 | 
|---|
| 1618 | pw = (PIWdg*)(w->Parent());
 | 
|---|
| 1619 | //DBG printf("DeleteWidget(%lx)-DBG kind = %d - %d %d \n", (long)w, w->kind(), (int)dw, (int)dwin); 
 | 
|---|
| 1620 | if (dw)  delete w;
 | 
|---|
| 1621 | 
 | 
|---|
| 1622 | if (dwin && pw) { 
 | 
|---|
| 1623 |   PIWindow* pww = dynamic_cast<PIWindow *>(pw);
 | 
|---|
| 1624 |   if (pww && (pww != (PIWindow*)mGrW) && (pww != (PIWindow*)mStW) && (pww->NbChilds()==0)) 
 | 
|---|
| 1625 |     DeleteWindow((PIWindow*)pw);
 | 
|---|
| 1626 |   } 
 | 
|---|
| 1627 | return;
 | 
|---|
| 1628 | }
 | 
|---|
| 1629 | 
 | 
|---|
| 1630 | 
 | 
|---|
| 1631 | 
 | 
|---|
| 1632 | /* --Methode-- */
 | 
|---|
| 1633 | void PIStdImgApp::DelWRsId(int k)
 | 
|---|
| 1634 | {
 | 
|---|
| 1635 | //DBG cerr << "-DBG- PIStdImgApp::DelWRsId(" << k << ")" << endl; 
 | 
|---|
| 1636 | if (k > 0) { // C'est un BaseWidget
 | 
|---|
| 1637 |   BWMList::iterator it;
 | 
|---|
| 1638 |   it  = mBWList.find(k);
 | 
|---|
| 1639 |   if (it == mBWList.end())  return;
 | 
|---|
| 1640 |   PIWdg* wd = (*it).second;
 | 
|---|
| 1641 | //DBG cerr << "-DBG- PIStdImgApp::DelWRsId Deleting BaseWidget " << (long)(wd) << endl ; 
 | 
|---|
| 1642 |   DeleteWidget(wd, true, true);
 | 
|---|
| 1643 |   }
 | 
|---|
| 1644 | else {  // C'est un drawer
 | 
|---|
| 1645 |   DrwMList::iterator it;
 | 
|---|
| 1646 |   it  = mDrwList.find(-k);
 | 
|---|
| 1647 |   if (it == mDrwList.end())  return;
 | 
|---|
| 1648 |   (*it).second->SetAutoRefreshOnDelete(true);
 | 
|---|
| 1649 |   delete (*it).second;  
 | 
|---|
| 1650 |   mDrwList.erase(it);
 | 
|---|
| 1651 |   //DBG cerr << "+DBG+ PIStdImgApp::DelWRsId Deleting Drawer " << (long)((*it).second) << endl ; 
 | 
|---|
| 1652 |   }
 | 
|---|
| 1653 | }
 | 
|---|
| 1654 | /* --Methode-- */
 | 
|---|
| 1655 | bool PIStdImgApp::CheckWRsId(int k)
 | 
|---|
| 1656 | {
 | 
|---|
| 1657 | if (k > 0) { // C'est un BaseWidget
 | 
|---|
| 1658 |   BWMList::iterator it;
 | 
|---|
| 1659 |   it  = mBWList.find(k);
 | 
|---|
| 1660 |   if (it == mBWList.end())  return(false);
 | 
|---|
| 1661 |   else return(true);
 | 
|---|
| 1662 |   }
 | 
|---|
| 1663 | else {  // C'est un drawer
 | 
|---|
| 1664 |   DrwMList::iterator it;
 | 
|---|
| 1665 |   it  = mDrwList.find(-k);
 | 
|---|
| 1666 |   if (it == mDrwList.end())  return(false);
 | 
|---|
| 1667 |   else return(true);
 | 
|---|
| 1668 |   }
 | 
|---|
| 1669 | }
 | 
|---|
| 1670 | 
 | 
|---|
| 1671 | /* --Methode-- */
 | 
|---|
| 1672 | void PIStdImgApp::StatZoomWindowSetVisible(bool fg)
 | 
|---|
| 1673 | {
 | 
|---|
| 1674 | 
 | 
|---|
| 1675 |   if (fg) {
 | 
|---|
| 1676 |     consolecont->Hide();
 | 
|---|
| 1677 |     consolecont->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free); 
 | 
|---|
| 1678 |     int szy = MainWin()->YSize();
 | 
|---|
| 1679 |     MainWin()->SetSize(MainWin()->XSize(), szy+statcont->YSize());
 | 
|---|
| 1680 |     consolecont->SetPos(0, statcont->YSize());
 | 
|---|
| 1681 |     consolecont->SetSize(MainWin()->XSize(), szy);
 | 
|---|
| 1682 |     consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); 
 | 
|---|
| 1683 |     consolecont->Show();
 | 
|---|
| 1684 |     statcont->Show();
 | 
|---|
| 1685 |     m[3]->SetStateMsg(10470, true);
 | 
|---|
| 1686 |   }
 | 
|---|
| 1687 |   else {
 | 
|---|
| 1688 |     statcont->Hide();
 | 
|---|
| 1689 |     consolecont->Hide();
 | 
|---|
| 1690 |     consolecont->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free); 
 | 
|---|
| 1691 |     MainWin()->SetSize(MainWin()->XSize(), MainWin()->YSize()-statcont->YSize());
 | 
|---|
| 1692 |     consolecont->SetPos(0, 0);
 | 
|---|
| 1693 |     consolecont->SetSize(MainWin()->XSize(), MainWin()->YSize());
 | 
|---|
| 1694 |     consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); 
 | 
|---|
| 1695 |     consolecont->Show();    
 | 
|---|
| 1696 |     m[3]->SetStateMsg(10470, false);    
 | 
|---|
| 1697 |   }
 | 
|---|
| 1698 |   
 | 
|---|
| 1699 | }
 | 
|---|
| 1700 | 
 | 
|---|
| 1701 | /* --Methode-- */
 | 
|---|
| 1702 | void PIStdImgApp::UpdateStatResourceInfo()
 | 
|---|
| 1703 | {
 | 
|---|
| 1704 |   resusg.Update();
 | 
|---|
| 1705 |   char buff[256];
 | 
|---|
| 1706 |   string lab;
 | 
|---|
| 1707 |   double frac;
 | 
|---|
| 1708 |   sprintf(buff, "Mem: %ld/Max= %ld kb" , (long)resusg.getMemorySize(), 
 | 
|---|
| 1709 |           (long)resusg.getMaxMemorySize());
 | 
|---|
| 1710 |   lab = buff;
 | 
|---|
| 1711 |   lab_mem->SetLabel(lab);
 | 
|---|
| 1712 |   frac = (double)resusg.getMemorySize()/(double)resusg.getMaxMemorySize();
 | 
|---|
| 1713 |   therm_mem->SetValue(frac);
 | 
|---|
| 1714 | 
 | 
|---|
| 1715 |   sprintf(buff, "CPU: %ld/elap= %ld ms" , (long)resusg.getCPUTime(), 
 | 
|---|
| 1716 |           (long)resusg.getElapsedTime());
 | 
|---|
| 1717 |   lab = buff;
 | 
|---|
| 1718 |   lab_cpu->SetLabel(lab);
 | 
|---|
| 1719 |   if (resusg.getCPULoad() > resusg.getAverageCPULoad()) 
 | 
|---|
| 1720 |     therm_cpu->SetValue(resusg.getCPULoad());
 | 
|---|
| 1721 |   else 
 | 
|---|
| 1722 |     therm_cpu->SetValue(resusg.getAverageCPULoad());
 | 
|---|
| 1723 |   int nlx = 0;
 | 
|---|
| 1724 |   bool fgx = false;
 | 
|---|
| 1725 |   if ( CmdInterpreter() ) fgx = CmdInterpreter()->isRunning(nlx);
 | 
|---|
| 1726 |   if (!fgx) {
 | 
|---|
| 1727 |     lab = "PIACmdThread Idle";
 | 
|---|
| 1728 |     lab_thrcmd->SetLabel(lab);
 | 
|---|
| 1729 |     lab_thrcmd->SetForegroundColor(PI_Green);
 | 
|---|
| 1730 |   }
 | 
|---|
| 1731 |   else {
 | 
|---|
| 1732 |     sprintf(buff, "PIACmdThread Running - NL=%d" , nlx);
 | 
|---|
| 1733 |     lab = buff;
 | 
|---|
| 1734 |     lab_thrcmd->SetLabel(lab);
 | 
|---|
| 1735 |     if (nlx < 3)     lab_thrcmd->SetForegroundColor(PI_Yellow);
 | 
|---|
| 1736 |     else     lab_thrcmd->SetForegroundColor(PI_Red);   
 | 
|---|
| 1737 |   }
 | 
|---|
| 1738 | }
 | 
|---|
| 1739 | 
 | 
|---|
| 1740 | /* --Methode-- */
 | 
|---|
| 1741 | void PIStdImgApp::RedirectStdOutErr(RED_OUTERR_FLG redflg)
 | 
|---|
| 1742 | {
 | 
|---|
| 1743 | if (redflg == redirecout) return;
 | 
|---|
| 1744 | string fnout = ObjMgr()->GetTmpDir() + "/sout.log";
 | 
|---|
| 1745 | string fnerr = ObjMgr()->GetTmpDir() + "/serr.log";
 | 
|---|
| 1746 | bool drfg = false;
 | 
|---|
| 1747 | PIConsole* pcons = NULL;
 | 
|---|
| 1748 | switch (redflg) {
 | 
|---|
| 1749 |   case NORED_OE :
 | 
|---|
| 1750 |     pcons = NULL;
 | 
|---|
| 1751 |     break;
 | 
|---|
| 1752 |   case CONSRED_OE :
 | 
|---|
| 1753 |     pcons = mCons;
 | 
|---|
| 1754 |     drfg = false;
 | 
|---|
| 1755 |     break;
 | 
|---|
| 1756 |   case DOUBLERED_OE:
 | 
|---|
| 1757 |     pcons = mCons;
 | 
|---|
| 1758 |     drfg = true;
 | 
|---|
| 1759 |     break;
 | 
|---|
| 1760 | }
 | 
|---|
| 1761 | 
 | 
|---|
| 1762 | char piva =  PIVA_Def;
 | 
|---|
| 1763 | RedirectOutStream(pcons, fnout, drfg, piva);
 | 
|---|
| 1764 | // ancienne maniere redirect, avec pipe : RedirectOutStream(pcons, piva);
 | 
|---|
| 1765 | piva = PIVA_Red;
 | 
|---|
| 1766 | RedirectErrStream(pcons, fnerr, drfg, piva);
 | 
|---|
| 1767 | // ancienne maniere redirect, avec pipe : RedirectErrStream(pcons, piva);
 | 
|---|
| 1768 |  
 | 
|---|
| 1769 | //  m[5]->SetStateMsg(10602, false);
 | 
|---|
| 1770 | redirecout = redflg;
 | 
|---|
| 1771 | return;
 | 
|---|
| 1772 | }
 | 
|---|
| 1773 | 
 | 
|---|
| 1774 | /* --Methode-- */
 | 
|---|
| 1775 | void PIStdImgApp::CatchSignals(bool fgfpe, bool fgsegv)
 | 
|---|
| 1776 | {    
 | 
|---|
| 1777 | #ifdef SANS_EVOLPLANCK
 | 
|---|
| 1778 | PeidaConfigureSignalhandling(fgfpe, fgsegv, true, true);  
 | 
|---|
| 1779 | #else
 | 
|---|
| 1780 | // On active aussi SIGUSR1 pour stopthr
 | 
|---|
| 1781 | SophyaConfigureSignalhandling(fgfpe, fgsegv, true, true);  
 | 
|---|
| 1782 | #endif
 | 
|---|
| 1783 | m[5]->SetStateMsg(10603, fgfpe);
 | 
|---|
| 1784 | m[5]->SetStateMsg(10604, fgsegv);
 | 
|---|
| 1785 | }
 | 
|---|
| 1786 | 
 | 
|---|
| 1787 | /* --Methode-- */
 | 
|---|
| 1788 | void PIStdImgApp::CloseAllWindows()
 | 
|---|
| 1789 | {
 | 
|---|
| 1790 | WindMList::iterator it;
 | 
|---|
| 1791 | for(it = mWList.begin(); it != mWList.end(); it++)   delete (*it).second;
 | 
|---|
| 1792 | mWList.clear();
 | 
|---|
| 1793 | mBWList.clear();
 | 
|---|
| 1794 | mDrwList.clear(); 
 | 
|---|
| 1795 | mGrW = NULL;
 | 
|---|
| 1796 | mStW = NULL;
 | 
|---|
| 1797 | mCurWin = NULL;
 | 
|---|
| 1798 | mCurWdg = NULL;
 | 
|---|
| 1799 | mLastWdg = NULL;
 | 
|---|
| 1800 | m[4]->SetSensitivityMsg(10515, false);
 | 
|---|
| 1801 | m[4]->SetSensitivityMsg(10516, false);
 | 
|---|
| 1802 | }
 | 
|---|
| 1803 | 
 | 
|---|
| 1804 | //---------------------------------------------------------------------------
 | 
|---|
| 1805 | //--------- Gestion des attributs graphiques et autres options de trace -----
 | 
|---|
| 1806 | 
 | 
|---|
| 1807 | /* --Methode-- */
 | 
|---|
| 1808 | void PIStdImgApp::SetInsetLimits(double xmin, double xmax, double ymin, double ymax)
 | 
|---|
| 1809 | {
 | 
|---|
| 1810 |   mIXmin = xmin;  mIXmax= xmax;
 | 
|---|
| 1811 |   mIYmin = ymin;  mIYmax= ymax;
 | 
|---|
| 1812 | }
 | 
|---|
| 1813 | 
 | 
|---|
| 1814 | /* --Methode-- */
 | 
|---|
| 1815 | void PIStdImgApp::SetDefaultGraphicAttributes(string const & opt)
 | 
|---|
| 1816 | {
 | 
|---|
| 1817 |   ParseDisplayOption(opt, mDefaultAtt);
 | 
|---|
| 1818 | }
 | 
|---|
| 1819 | 
 | 
|---|
| 1820 | /* --Methode-- */
 | 
|---|
| 1821 | void PIStdImgApp::SetDefaultAxesAttributes(string const & opt)
 | 
|---|
| 1822 | {
 | 
|---|
| 1823 |   ParseDisplayOption(opt, mAxesAtt);
 | 
|---|
| 1824 | }
 | 
|---|
| 1825 | 
 | 
|---|
| 1826 | /* --Methode-- */
 | 
|---|
| 1827 | DispWinEnum PIStdImgApp::ParseDisplayOption(string const & sop, vector<string>& opts, string& wname)
 | 
|---|
| 1828 | {
 | 
|---|
| 1829 |   DispWinEnum rc = Disp_Next;
 | 
|---|
| 1830 |   //DBG  cerr << " DBG-Parse-A sop=" << sop << " sop.length()= " << sop.length() << endl;
 | 
|---|
| 1831 |   if (opts.size() > 0)  opts.erase(opts.begin(), opts.end());
 | 
|---|
| 1832 |   if (sop.length() < 1) return(rc);
 | 
|---|
| 1833 |   string gratt = sop;
 | 
|---|
| 1834 |   for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
 | 
|---|
| 1835 |   if ( (gratt == "def") || (gratt == "default") ) return(rc);
 | 
|---|
| 1836 | // On separe en mots espaces par des blancs ou tabulation 
 | 
|---|
| 1837 |   size_t p = 0;
 | 
|---|
| 1838 |   size_t q = 0;
 | 
|---|
| 1839 |   size_t l = gratt.length();
 | 
|---|
| 1840 |   string token;
 | 
|---|
| 1841 |   while (q < l)  {
 | 
|---|
| 1842 |     p = gratt.find_first_not_of(" \t",q);   // au debut d'un token
 | 
|---|
| 1843 |     if (p >= l) break;
 | 
|---|
| 1844 |     q = gratt.find_first_of(" \t",p);       // Premier blanc ou tab suivant
 | 
|---|
| 1845 |     if (q<l) token = gratt.substr(p,q-p);
 | 
|---|
| 1846 |     else token = gratt.substr(p);
 | 
|---|
| 1847 |     if (token == "") continue;
 | 
|---|
| 1848 |     // Decodage option fenetre d'affichage (win, next, ...)
 | 
|---|
| 1849 |     if (token == "win")   rc =  Disp_Win;
 | 
|---|
| 1850 |     else if (token == "same")  rc = Disp_Same;
 | 
|---|
| 1851 |     else if (token == "inset")   rc = Disp_Inset;
 | 
|---|
| 1852 |     else if (token == "stack")   rc = Disp_Stack;
 | 
|---|
| 1853 |     else if (token == "next")   rc = Disp_Next;
 | 
|---|
| 1854 |     else if (token.substr(0,6)=="samew=") {
 | 
|---|
| 1855 |       string snom=token.substr(6);
 | 
|---|
| 1856 |       SelectLastWidget(snom);
 | 
|---|
| 1857 |       rc = Disp_Same;
 | 
|---|
| 1858 |     }
 | 
|---|
| 1859 |     else if (token.substr(0,6)=="inset=") {
 | 
|---|
| 1860 |       double fx1,fx2,fy1,fy2;
 | 
|---|
| 1861 |       fx1=fy1=0.4; fx2=fy2=0.6;
 | 
|---|
| 1862 |       sscanf(token.substr(6).c_str(),"%lg,%lg,%lg,%lg",&fx1,&fx2,&fy1,&fy2);
 | 
|---|
| 1863 |       SetInsetLimits(fx1, fx2, fy1, fy2);
 | 
|---|
| 1864 |       rc = Disp_Inset;
 | 
|---|
| 1865 |     }
 | 
|---|
| 1866 |     else if (token.substr(0,6)=="wname=") {   // specification de nom de widget
 | 
|---|
| 1867 |       wname=token.substr(6);
 | 
|---|
| 1868 |     }
 | 
|---|
| 1869 |     // Option a etre decode par les drawers, etc ...
 | 
|---|
| 1870 |     else  opts.push_back(token); 
 | 
|---|
| 1871 |   }
 | 
|---|
| 1872 | 
 | 
|---|
| 1873 |   //DBG  cerr << " DBG-Parse-B opts.size()=" << opts.size() << endl;
 | 
|---|
| 1874 |   if (rc == Disp_Same) nb_disp_same++;
 | 
|---|
| 1875 |   else nb_disp_same = 0;
 | 
|---|
| 1876 |   return (rc);
 | 
|---|
| 1877 | }
 | 
|---|
| 1878 | 
 | 
|---|
| 1879 | //---------------------------------------------------------------------------
 | 
|---|
| 1880 | //------------       Methodes privees (MBProcessx, ...)    ----------
 | 
|---|
| 1881 | 
 | 
|---|
| 1882 | /* --Methode-- */
 | 
|---|
| 1883 | void PIStdImgApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
 | 
|---|
| 1884 | {
 | 
|---|
| 1885 | 
 | 
|---|
| 1886 |   switch(msg)
 | 
|---|
| 1887 |     {
 | 
|---|
| 1888 |     case 10150 :
 | 
|---|
| 1889 |       showInfoWindow(this);
 | 
|---|
| 1890 |       break;
 | 
|---|
| 1891 | 
 | 
|---|
| 1892 |     case 10155 :
 | 
|---|
| 1893 |       hideInfoWindow(this);
 | 
|---|
| 1894 |       break;
 | 
|---|
| 1895 | 
 | 
|---|
| 1896 |     case 10100 :
 | 
|---|
| 1897 |       CmdInterpreter()->ShowHelpWindow();
 | 
|---|
| 1898 |       break;
 | 
|---|
| 1899 | 
 | 
|---|
| 1900 |     case 10120 :
 | 
|---|
| 1901 |       pfc_fits->AcceptNewFile(false);
 | 
|---|
| 1902 |       mFCMsg = 10125; 
 | 
|---|
| 1903 |       pfc_fits->SetMsg(mFCMsg);
 | 
|---|
| 1904 |       SetBlocked();
 | 
|---|
| 1905 |       pfc_fits->Show();
 | 
|---|
| 1906 |       break;
 | 
|---|
| 1907 | 
 | 
|---|
| 1908 |     case 10125 :
 | 
|---|
| 1909 |       SetBusy();
 | 
|---|
| 1910 |       if (data)  { 
 | 
|---|
| 1911 |         string cmd = "readfits ";
 | 
|---|
| 1912 |         cmd += pfc_fits->GetFileName();
 | 
|---|
| 1913 |         try {
 | 
|---|
| 1914 |           CmdInterpreter()->AddInputLine(cmd);
 | 
|---|
| 1915 |           // CmdInterpreter()->ExecuteCommand(kw, args, toks);
 | 
|---|
| 1916 |         }  
 | 
|---|
| 1917 |         catch ( PThrowable & exc ) {
 | 
|---|
| 1918 |           cerr << "\n PIStdImgApp::Process()/ Cmd->ExecuteCommand(readfits) Exception :" 
 | 
|---|
| 1919 |                << (string)typeid(exc).name() << " Msg= " 
 | 
|---|
| 1920 |                << exc.Msg() << endl;
 | 
|---|
| 1921 |           cout << endl; 
 | 
|---|
| 1922 |         }
 | 
|---|
| 1923 |         catch ( ... ) {
 | 
|---|
| 1924 |           cerr << "\n PIStdImgApp::Process()/ Cmd->ExecuteCommand(readfits) Catched Exception ... " << endl;
 | 
|---|
| 1925 |           cout << endl; 
 | 
|---|
| 1926 |         }
 | 
|---|
| 1927 |       }
 | 
|---|
| 1928 |       mFCMsg = 0;
 | 
|---|
| 1929 |       SetReady();
 | 
|---|
| 1930 |       break;
 | 
|---|
| 1931 | 
 | 
|---|
| 1932 |     case 10130 :
 | 
|---|
| 1933 |       pfc_ppf->AcceptNewFile(false); 
 | 
|---|
| 1934 |       mFCMsg = 10135; 
 | 
|---|
| 1935 |       pfc_ppf->SetMsg(mFCMsg);
 | 
|---|
| 1936 |       SetBlocked();
 | 
|---|
| 1937 |       pfc_ppf->Show();
 | 
|---|
| 1938 |       break;
 | 
|---|
| 1939 | 
 | 
|---|
| 1940 |     case 10135 :
 | 
|---|
| 1941 |       mFCMsg = 0;
 | 
|---|
| 1942 |       if (data)  { 
 | 
|---|
| 1943 |         PPInMgrW()->SetFile(pfc_ppf->GetFileName());
 | 
|---|
| 1944 |         PPInMgrW()->Show();
 | 
|---|
| 1945 |       }
 | 
|---|
| 1946 |       SetReady();
 | 
|---|
| 1947 |       break;
 | 
|---|
| 1948 |         
 | 
|---|
| 1949 | #ifndef SANS_EVOLPLANCK
 | 
|---|
| 1950 |     case 10140 :
 | 
|---|
| 1951 |       pfc_ascii->AcceptNewFile(false);
 | 
|---|
| 1952 |       mFCMsg = 10145; 
 | 
|---|
| 1953 |       pfc_ascii->SetMsg(mFCMsg);
 | 
|---|
| 1954 |       SetBlocked();
 | 
|---|
| 1955 |       pfc_ascii->Show();
 | 
|---|
| 1956 |       break;
 | 
|---|
| 1957 | 
 | 
|---|
| 1958 |     case 10145 :
 | 
|---|
| 1959 |       SetBusy();
 | 
|---|
| 1960 |       if (data)  { 
 | 
|---|
| 1961 |         string afname = pfc_ascii->GetFileName();
 | 
|---|
| 1962 |         string nomobj = ObjMgr()->GetServiceObj()->FileName2Name(afname);
 | 
|---|
| 1963 |         string cmd = "mtxfrascii ";
 | 
|---|
| 1964 |         cmd += nomobj;  cmd += " ";  cmd += afname;
 | 
|---|
| 1965 |         try {
 | 
|---|
| 1966 |           CmdInterpreter()->AddInputLine(cmd);
 | 
|---|
| 1967 |           //      mCmd->Interpret(cmd);
 | 
|---|
| 1968 |         }  
 | 
|---|
| 1969 |         catch ( PThrowable & exc ) {
 | 
|---|
| 1970 |           cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Exception :" 
 | 
|---|
| 1971 |                << (string)typeid(exc).name() << " Msg= " 
 | 
|---|
| 1972 |                << exc.Msg() << endl;
 | 
|---|
| 1973 |           cout << endl; 
 | 
|---|
| 1974 |         }
 | 
|---|
| 1975 |         catch ( ... ) {
 | 
|---|
| 1976 |           cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Catched Exception ... " << endl;
 | 
|---|
| 1977 |           cout << endl; 
 | 
|---|
| 1978 |         }
 | 
|---|
| 1979 |         
 | 
|---|
| 1980 |       }
 | 
|---|
| 1981 |       mFCMsg = 0;
 | 
|---|
| 1982 |       SetReady();
 | 
|---|
| 1983 |       break;
 | 
|---|
| 1984 | #endif
 | 
|---|
| 1985 | 
 | 
|---|
| 1986 |     case 10105:
 | 
|---|
| 1987 |       Stop();
 | 
|---|
| 1988 |       break;
 | 
|---|
| 1989 | 
 | 
|---|
| 1990 |   }
 | 
|---|
| 1991 | return;
 | 
|---|
| 1992 | }
 | 
|---|
| 1993 | 
 | 
|---|
| 1994 | 
 | 
|---|
| 1995 | 
 | 
|---|
| 1996 | /* --Methode-- */
 | 
|---|
| 1997 | void PIStdImgApp::MBProcess2(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
 | 
|---|
| 1998 | {
 | 
|---|
| 1999 | 
 | 
|---|
| 2000 | switch (msg)  { 
 | 
|---|
| 2001 |   case 10201 :
 | 
|---|
| 2002 |      ObjMgrW()->Show();
 | 
|---|
| 2003 |      break;
 | 
|---|
| 2004 | 
 | 
|---|
| 2005 |   case 10220 :
 | 
|---|
| 2006 |      pfc_ppf->AcceptNewFile(true);
 | 
|---|
| 2007 |      mFCMsg = 10225;
 | 
|---|
| 2008 |      pfc_ppf->SetMsg(mFCMsg);
 | 
|---|
| 2009 |      SetBlocked();
 | 
|---|
| 2010 |      pfc_ppf->Show();
 | 
|---|
| 2011 |      break;
 | 
|---|
| 2012 | 
 | 
|---|
| 2013 |    case 10225 :
 | 
|---|
| 2014 |      SetBusy();
 | 
|---|
| 2015 |      if (data) {
 | 
|---|
| 2016 |        if (mPpfout) {  
 | 
|---|
| 2017 |          printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
 | 
|---|
| 2018 |          delete mPpfout;  
 | 
|---|
| 2019 |        }
 | 
|---|
| 2020 |        name_outppf = pfc_ppf->GetFileName();
 | 
|---|
| 2021 |        mPpfout = NULL;
 | 
|---|
| 2022 |        printf("PIStdImg/Info: Opening POutPersist-File %s \n", name_outppf.c_str());
 | 
|---|
| 2023 |        mPpfout = new POutPersist(name_outppf);
 | 
|---|
| 2024 |     }
 | 
|---|
| 2025 |     mFCMsg = 0;
 | 
|---|
| 2026 |     SetReady();
 | 
|---|
| 2027 |     break;
 | 
|---|
| 2028 | 
 | 
|---|
| 2029 |   case 10230 :
 | 
|---|
| 2030 |     if (!mPpfout)  break;
 | 
|---|
| 2031 |     printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
 | 
|---|
| 2032 |     delete mPpfout;  
 | 
|---|
| 2033 |     name_outppf = "";
 | 
|---|
| 2034 |     mPpfout = NULL;
 | 
|---|
| 2035 |     break;
 | 
|---|
| 2036 | 
 | 
|---|
| 2037 |   case 10270 :
 | 
|---|
| 2038 |     if (mCurWdg) {
 | 
|---|
| 2039 |       string ssob = "DEL ";
 | 
|---|
| 2040 |       ssob += mCurWdg->Nom();
 | 
|---|
| 2041 |       getSOpExObj()->AddOpe(ssob);    
 | 
|---|
| 2042 |       }
 | 
|---|
| 2043 |     break;
 | 
|---|
| 2044 | 
 | 
|---|
| 2045 |   default:
 | 
|---|
| 2046 |     cerr << "PIStdImgApp::MBProcess2() BUG?? Msg= " <<  msg << endl;    
 | 
|---|
| 2047 |     break;
 | 
|---|
| 2048 | }
 | 
|---|
| 2049 | 
 | 
|---|
| 2050 | return;
 | 
|---|
| 2051 | }
 | 
|---|
| 2052 | 
 | 
|---|
| 2053 | /* --Methode-- */
 | 
|---|
| 2054 | void PIStdImgApp::MBProcess3(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 | 
|---|
| 2055 | {
 | 
|---|
| 2056 | 
 | 
|---|
| 2057 | switch (msg)  { 
 | 
|---|
| 2058 |   case 10301 :
 | 
|---|
| 2059 |     PIImgTools::ShowPIImgTools();
 | 
|---|
| 2060 |     break; 
 | 
|---|
| 2061 |   case 10302 :
 | 
|---|
| 2062 |     PIDrwTools::ShowPIDrwTools();
 | 
|---|
| 2063 |     break;
 | 
|---|
| 2064 |   case 10303 :
 | 
|---|
| 2065 |     PIAxesTools::ShowPIAxesTools();
 | 
|---|
| 2066 |     break;
 | 
|---|
| 2067 | 
 | 
|---|
| 2068 |   case 10304 :
 | 
|---|
| 2069 |     CmdInterpreter()->ShowCxxExecWindow();
 | 
|---|
| 2070 |     break;
 | 
|---|
| 2071 | 
 | 
|---|
| 2072 |   case 10311 :
 | 
|---|
| 2073 |   case 10312 :
 | 
|---|
| 2074 |     {
 | 
|---|
| 2075 |     PIImage* curpimg = NULL;
 | 
|---|
| 2076 |     if (!mCurWdg)  return;
 | 
|---|
| 2077 |     if (mCurWdg->kind() != PIImage::ClassId)  return;
 | 
|---|
| 2078 |     curpimg = (PIImage*)mCurWdg;
 | 
|---|
| 2079 |     if (curpimg == NULL)   return;
 | 
|---|
| 2080 |     P2DArrayAdapter* img = curpimg->Image();
 | 
|---|
| 2081 |     if (img == NULL) return;
 | 
|---|
| 2082 |     int dx = curpimg->XSzPave();
 | 
|---|
| 2083 |     int dy = curpimg->YSzPave();  
 | 
|---|
| 2084 |     int x0 = curpimg->XPave()-dx/2;
 | 
|---|
| 2085 |     int y0 = curpimg->YPave()-dy/2;
 | 
|---|
| 2086 |     if (x0 < 0)  x0 = 0;
 | 
|---|
| 2087 |     if (y0 < 0)  y0 = 0;
 | 
|---|
| 2088 |     int x1 = x0+dx;
 | 
|---|
| 2089 |     int y1 = y0+dy;
 | 
|---|
| 2090 |     if (x1 > img->XSize()) x1 = img->XSize();
 | 
|---|
| 2091 |     if (y1 > img->YSize()) y1 = img->YSize();
 | 
|---|
| 2092 |     dx = x1-x0;  dy = y1-y0;
 | 
|---|
| 2093 |     ImageR4* pim = new ImageR4(dx, dy); 
 | 
|---|
| 2094 |     int ii, jj;
 | 
|---|
| 2095 |     for(jj=0; jj<dy; jj++) 
 | 
|---|
| 2096 |       for(ii=0; ii<dx; ii++) (*pim)(ii,jj) = (*img)(ii+x0, jj+y0);
 | 
|---|
| 2097 |     if (msg == 10305) {  // Calcul des coordonnees du sous-pave
 | 
|---|
| 2098 |       double xc1, yc1;
 | 
|---|
| 2099 |       img->Coord(x0, y0, xc1, yc1);
 | 
|---|
| 2100 |       pim->SetOrg((int)xc1, (int)yc1);
 | 
|---|
| 2101 |     }
 | 
|---|
| 2102 |     string nom = mCurWdg->Nom() + "_pave";
 | 
|---|
| 2103 |     ObjMgr()->AddObj(pim, nom);
 | 
|---|
| 2104 |     ObjMgr()->DisplayObj(nom, "w");
 | 
|---|
| 2105 |     break;
 | 
|---|
| 2106 |     }
 | 
|---|
| 2107 | 
 | 
|---|
| 2108 |   case 10313 :
 | 
|---|
| 2109 |     {
 | 
|---|
| 2110 |     PIImage* curpimg = NULL;
 | 
|---|
| 2111 |     if (!mCurWdg)  return;
 | 
|---|
| 2112 |     if (mCurWdg->kind() != PIImage::ClassId)  return;
 | 
|---|
| 2113 |     curpimg = (PIImage*)mCurWdg;
 | 
|---|
| 2114 |     if (curpimg == NULL)   return;
 | 
|---|
| 2115 |     curpimg->ShowCuts(true);
 | 
|---|
| 2116 |     break;
 | 
|---|
| 2117 |     }
 | 
|---|
| 2118 | 
 | 
|---|
| 2119 |   case 10320 :
 | 
|---|
| 2120 |     if (mStW)  mStW->DispNext();
 | 
|---|
| 2121 |     break;
 | 
|---|
| 2122 | 
 | 
|---|
| 2123 |   case 10321 :
 | 
|---|
| 2124 |   case 10322 :
 | 
|---|
| 2125 |   case 10324 :
 | 
|---|
| 2126 | //  case 10328 :
 | 
|---|
| 2127 |     if (mStW) mStW->StartAutoDisp((msg-10320)*500);
 | 
|---|
| 2128 |     break;
 | 
|---|
| 2129 | 
 | 
|---|
| 2130 |   case 10329 :
 | 
|---|
| 2131 |     if (mStW) mStW->StopAutoDisp();
 | 
|---|
| 2132 |     break;
 | 
|---|
| 2133 | 
 | 
|---|
| 2134 |   case 103330 :
 | 
|---|
| 2135 |     if (mStW) {
 | 
|---|
| 2136 |       PIWdg* cw =  mStW->CurrentWdg();
 | 
|---|
| 2137 |       if (cw) DeleteWidget(cw);
 | 
|---|
| 2138 |       }
 | 
|---|
| 2139 |     break;
 | 
|---|
| 2140 | 
 | 
|---|
| 2141 |   default:
 | 
|---|
| 2142 |     cerr << "PIStdImgApp::MBProcess3() BUG?? Msg= " <<  msg << endl;    
 | 
|---|
| 2143 |     break;
 | 
|---|
| 2144 |   }
 | 
|---|
| 2145 | return;
 | 
|---|
| 2146 | }
 | 
|---|
| 2147 | 
 | 
|---|
| 2148 | /* --Methode-- */
 | 
|---|
| 2149 | void PIStdImgApp::MBProcess4(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 | 
|---|
| 2150 | {
 | 
|---|
| 2151 | 
 | 
|---|
| 2152 | switch (msg)  { 
 | 
|---|
| 2153 | 
 | 
|---|
| 2154 |   case 10400 :
 | 
|---|
| 2155 |     CreateStackWin();
 | 
|---|
| 2156 |     break;
 | 
|---|
| 2157 | 
 | 
|---|
| 2158 |   case 10411 :
 | 
|---|
| 2159 |     CreateGraphWin(1,1);
 | 
|---|
| 2160 |     break;
 | 
|---|
| 2161 |   case 10421 :
 | 
|---|
| 2162 |     CreateGraphWin(1,2);
 | 
|---|
| 2163 |     break;
 | 
|---|
| 2164 |   case 10412 :
 | 
|---|
| 2165 |     CreateGraphWin(2,1);
 | 
|---|
| 2166 |     break;
 | 
|---|
| 2167 |   case 10422 :
 | 
|---|
| 2168 |     CreateGraphWin(2,2);
 | 
|---|
| 2169 |     break;
 | 
|---|
| 2170 |   case 10431 :
 | 
|---|
| 2171 |     CreateGraphWin(1,3);
 | 
|---|
| 2172 |     break;
 | 
|---|
| 2173 |   case 10433 :
 | 
|---|
| 2174 |     CreateGraphWin(3,3);
 | 
|---|
| 2175 |     break;
 | 
|---|
| 2176 |   case 10441 :
 | 
|---|
| 2177 |     if (mCurWdg)  { 
 | 
|---|
| 2178 |       mLastWdg = mCurWdg;
 | 
|---|
| 2179 |       cout << " Using current widget as last-widget (display same) " << endl;
 | 
|---|
| 2180 |       }
 | 
|---|
| 2181 |     else  cout << " No current widget - select widget with mouse " << endl;
 | 
|---|
| 2182 |     break;
 | 
|---|
| 2183 |     case 10460 :
 | 
|---|
| 2184 |       DeleteWindow(mCurWin);
 | 
|---|
| 2185 |       break;
 | 
|---|
| 2186 |     case 10470 :
 | 
|---|
| 2187 |       StatZoomWindowSetVisible(m[3]->GetStateMsg(10470));
 | 
|---|
| 2188 |       break;
 | 
|---|
| 2189 |   default:
 | 
|---|
| 2190 |     cerr << "PIStdImgApp::MBProcess4() BUG?? Msg= " <<  msg << endl;    
 | 
|---|
| 2191 |     break;
 | 
|---|
| 2192 |   }
 | 
|---|
| 2193 | return;
 | 
|---|
| 2194 | }
 | 
|---|
| 2195 | 
 | 
|---|
| 2196 | 
 | 
|---|
| 2197 | /* --Methode-- */
 | 
|---|
| 2198 | void PIStdImgApp::MBProcess5(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
 | 
|---|
| 2199 | {
 | 
|---|
| 2200 | char nomps[64],strg[512];
 | 
|---|
| 2201 | PSFile *mps;
 | 
|---|
| 2202 | int sxt, syt, syo, syo1, sx[4], sy[4];
 | 
|---|
| 2203 | 
 | 
|---|
| 2204 | switch (msg)
 | 
|---|
| 2205 |   { 
 | 
|---|
| 2206 |   case 10501 :
 | 
|---|
| 2207 |      pfc_ps->AcceptNewFile(true); 
 | 
|---|
| 2208 |      mFCMsg = 10525; 
 | 
|---|
| 2209 |      pfc_ps->SetMsg(mFCMsg);
 | 
|---|
| 2210 |      SetBlocked();
 | 
|---|
| 2211 |      pfc_ps->Show();
 | 
|---|
| 2212 |      break;
 | 
|---|
| 2213 | 
 | 
|---|
| 2214 |    case 10525 :
 | 
|---|
| 2215 |      SetBusy();
 | 
|---|
| 2216 |      if (data) {
 | 
|---|
| 2217 |        if (mpsfile) {  
 | 
|---|
| 2218 |          printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
 | 
|---|
| 2219 |          delete mpsfile;  
 | 
|---|
| 2220 |          }
 | 
|---|
| 2221 |         name_ps = pfc_ps->GetFileName();
 | 
|---|
| 2222 |         printf("PIStdImg/Info: Opening PS-File %s \n", name_ps.c_str());
 | 
|---|
| 2223 |         mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 2., 2.);
 | 
|---|
| 2224 |         }
 | 
|---|
| 2225 |       mFCMsg = 0;
 | 
|---|
| 2226 |       SetReady();
 | 
|---|
| 2227 |       break;
 | 
|---|
| 2228 | 
 | 
|---|
| 2229 |   case 10505 :
 | 
|---|
| 2230 |     if (!mpsfile)  break;
 | 
|---|
| 2231 |     printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
 | 
|---|
| 2232 |     delete mpsfile;
 | 
|---|
| 2233 |     mpsfile = NULL;
 | 
|---|
| 2234 |     name_ps = "";
 | 
|---|
| 2235 |     break;
 | 
|---|
| 2236 | 
 | 
|---|
| 2237 |   case 10511 :     // Window -> PS
 | 
|---|
| 2238 |   case 10512 :     // Window -> EPS 
 | 
|---|
| 2239 |     if (CurrentWindow() == NULL)  break;
 | 
|---|
| 2240 |     if (msg == 10512) 
 | 
|---|
| 2241 |       { 
 | 
|---|
| 2242 |       num_eps++;
 | 
|---|
| 2243 |       sprintf(nomps,"pia%d.eps", num_eps);
 | 
|---|
| 2244 |       printf("PIStdImg/Info: Creating EPSFile %s (CurWin-> EPS) \n", nomps);
 | 
|---|
| 2245 |       mps = new PSFile(nomps);
 | 
|---|
| 2246 |       }
 | 
|---|
| 2247 |     else {
 | 
|---|
| 2248 |       if (mpsfile == NULL) {
 | 
|---|
| 2249 |         name_ps = "pia.ps";
 | 
|---|
| 2250 |         mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 0., 0.);
 | 
|---|
| 2251 |         printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
 | 
|---|
| 2252 |       }
 | 
|---|
| 2253 |       printf("PIStdImg/Info: CurWin-> PSFile %s\n", name_ps.c_str());      
 | 
|---|
| 2254 |       mps = mpsfile; 
 | 
|---|
| 2255 |       }
 | 
|---|
| 2256 |     CurrentWindow()->PSPrint(mps,0,0);
 | 
|---|
| 2257 | 
 | 
|---|
| 2258 |     if (msg == 10512)   delete mps;   // fichier eps
 | 
|---|
| 2259 |     break;
 | 
|---|
| 2260 | 
 | 
|---|
| 2261 |   case 10515 :    // Image -> PS
 | 
|---|
| 2262 |   case 10516 :    // Image -> EPS 
 | 
|---|
| 2263 |      {
 | 
|---|
| 2264 |      PIImage* curpimg = NULL;
 | 
|---|
| 2265 |      if (!mCurWdg)  return;
 | 
|---|
| 2266 |      if (mCurWdg->kind() != PIImage::ClassId)  return;
 | 
|---|
| 2267 |      curpimg = (PIImage*)mCurWdg;
 | 
|---|
| 2268 |      if (curpimg == NULL)   return;
 | 
|---|
| 2269 |      if (msg == 10516) 
 | 
|---|
| 2270 |       { 
 | 
|---|
| 2271 |       num_eps++;
 | 
|---|
| 2272 |       sprintf(nomps,"pia%d.eps", num_eps);
 | 
|---|
| 2273 |       printf("PIStdImg/Info: Creating EPSFile %s (CurImage-> EPS)\n", nomps);
 | 
|---|
| 2274 |       mps = new PSFile(nomps);
 | 
|---|
| 2275 |       }
 | 
|---|
| 2276 |     else {
 | 
|---|
| 2277 |       if (mpsfile == NULL) {
 | 
|---|
| 2278 |         name_ps = "pia.ps";
 | 
|---|
| 2279 |         mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
 | 
|---|
| 2280 |         printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
 | 
|---|
| 2281 |       }
 | 
|---|
| 2282 |       printf("PIStdImg/Info: CurImage-> PSFile %s\n", name_ps.c_str());       
 | 
|---|
| 2283 |       mps = mpsfile; 
 | 
|---|
| 2284 |       }
 | 
|---|
| 2285 | 
 | 
|---|
| 2286 |     sx[0] = gimv->XSize(); 
 | 
|---|
| 2287 |     sy[0] = gimv->YSize();
 | 
|---|
| 2288 |     sx[1] = zoom->XSize(); 
 | 
|---|
| 2289 |     sy[1] = zoom->YSize();
 | 
|---|
| 2290 |     sx[2] = cmapv->XSize(); 
 | 
|---|
| 2291 |     sy[2] = cmapv->YSize();
 | 
|---|
| 2292 |     sx[3] = curpimg->XSize(); 
 | 
|---|
| 2293 |     sy[3] = curpimg->YSize();
 | 
|---|
| 2294 |     if (sy[1] > sy[0])  { syo1 = sy[1]+50;  syo = sy[1]+sy[2]+60; }
 | 
|---|
| 2295 |     else  { syo1 = sy[0]+50;  syo = sy[0]+sy[2]+60; }
 | 
|---|
| 2296 |     syt = sy[3]+syo;
 | 
|---|
| 2297 |     sxt = sx[3];
 | 
|---|
| 2298 |     if (sxt < (sx[0]+sx[1]+20))  sxt = sx[0]+sx[1]+20;
 | 
|---|
| 2299 |     if (sxt < sx[2])  sxt = sx[2];
 | 
|---|
| 2300 | 
 | 
|---|
| 2301 |     // Pour ecrire le titre 
 | 
|---|
| 2302 |     mps->NewPage((float)sxt, (float)syt, PI_Portrait);
 | 
|---|
| 2303 |     mps->NewBloc(0,0, (float)sxt, 30., (float)sxt, 30.);
 | 
|---|
| 2304 |     sprintf(strg,"Image: %s -  Pave %d %d \n",  curpimg->Nom().c_str(), 
 | 
|---|
| 2305 |             curpimg->XPave(),  curpimg->YPave());     
 | 
|---|
| 2306 |     mps->DrawString(10., 25., strg, PI_Black, PI_DefaultFont, PI_BoldFont, 20);
 | 
|---|
| 2307 |     mps->EndBloc();
 | 
|---|
| 2308 | 
 | 
|---|
| 2309 |     // Les quatre fenetres glovimage, zoom, cmap, image 
 | 
|---|
| 2310 |     gimv->PSPrint(mps, -gimv->XPos(), -gimv->YPos()+40);
 | 
|---|
| 2311 |     zoom->PSPrint(mps, -zoom->XPos()+sx[0]+20, -zoom->YPos()+40);
 | 
|---|
| 2312 |     cmapv->PSPrint(mps, -cmapv->XPos(), -cmapv->YPos()+syo1);
 | 
|---|
| 2313 |     curpimg->PSPrint(mps, -curpimg->XPos(), -curpimg->YPos()+syo);
 | 
|---|
| 2314 |      
 | 
|---|
| 2315 |     if (msg == 10516)   delete mps;    // fichier eps
 | 
|---|
| 2316 |     break;
 | 
|---|
| 2317 |     }
 | 
|---|
| 2318 | 
 | 
|---|
| 2319 |   default:
 | 
|---|
| 2320 |     cerr << "PIStdImgApp::MBProcess5() BUG?? Msg= " <<  msg << endl;    
 | 
|---|
| 2321 |     break;
 | 
|---|
| 2322 |   }
 | 
|---|
| 2323 | 
 | 
|---|
| 2324 | }
 | 
|---|
| 2325 | 
 | 
|---|
| 2326 | 
 | 
|---|
| 2327 | /* --Methode-- */
 | 
|---|
| 2328 | void PIStdImgApp::MBProcess6(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
 | 
|---|
| 2329 | {
 | 
|---|
| 2330 | switch (msg)  { 
 | 
|---|
| 2331 |   case 10601:
 | 
|---|
| 2332 |     CloseAllWindows();
 | 
|---|
| 2333 |     break;
 | 
|---|
| 2334 |     /*
 | 
|---|
| 2335 |  case 10602:
 | 
|---|
| 2336 |     RedirectStdOutErr(*((bool*)data));
 | 
|---|
| 2337 |     break;
 | 
|---|
| 2338 |     */
 | 
|---|
| 2339 |   case 10603:
 | 
|---|
| 2340 |   case 10604:
 | 
|---|
| 2341 |     CatchSignals(m[5]->GetStateMsg(10603), m[5]->GetStateMsg(10604));
 | 
|---|
| 2342 |     break;
 | 
|---|
| 2343 |   case 10605:
 | 
|---|
| 2344 |     mObjMgr->SetVerbose(m[5]->GetStateMsg(10605));
 | 
|---|
| 2345 |     break;
 | 
|---|
| 2346 |   case 10606:
 | 
|---|
| 2347 |     CmdInterpreter()->ShowCxxOptionWindow();
 | 
|---|
| 2348 |     break;
 | 
|---|
| 2349 |   default:
 | 
|---|
| 2350 |     cerr << "PIStdImgApp::MBProcess6() BUG?? Msg= " <<  msg << endl;    
 | 
|---|
| 2351 |     break;
 | 
|---|
| 2352 |   }
 | 
|---|
| 2353 | return;
 | 
|---|
| 2354 | }
 | 
|---|
| 2355 | 
 | 
|---|
| 2356 | 
 | 
|---|
| 2357 | 
 | 
|---|
| 2358 | //  -------------------------------------------------
 | 
|---|
| 2359 | //        Fenetre info piapp (About piapp) 
 | 
|---|
| 2360 | //  -------------------------------------------------
 | 
|---|
| 2361 | static PIWindow* infow_win = NULL;
 | 
|---|
| 2362 | static PIText* infow_txt = NULL;
 | 
|---|
| 2363 | static PICMapView* infow_cmap = NULL;
 | 
|---|
| 2364 | static PIButton* infow_but = NULL;
 | 
|---|
| 2365 | 
 | 
|---|
| 2366 | /* Nouvelle-Fonction */
 | 
|---|
| 2367 | static void createInfoWindow(PIStdImgApp* app)
 | 
|---|
| 2368 | {
 | 
|---|
| 2369 | if (infow_win) return;
 | 
|---|
| 2370 | 
 | 
|---|
| 2371 | int bsx, bsy;
 | 
|---|
| 2372 | PIApplicationPrefCompSize(bsx, bsy);
 | 
|---|
| 2373 | int spx, spy;
 | 
|---|
| 2374 | spx = bsx/6;   spy = bsy/6;
 | 
|---|
| 2375 | 
 | 
|---|
| 2376 | infow_win = new PIWindow((PIMsgHandler *)app, "About piapp", 
 | 
|---|
| 2377 |                          PIWK_dialog, bsx*5+3*spx, bsy*4+spy*3, 200, 200);
 | 
|---|
| 2378 | infow_win->SetAutoDelChilds(true);
 | 
|---|
| 2379 | infow_txt = new PIText(infow_win,"about_piapp_text", true, false, bsx*5+spx, bsy*3, spx, spy);
 | 
|---|
| 2380 | infow_txt->SetMutiLineMode(true);
 | 
|---|
| 2381 | infow_txt->SetTextEditable(false);
 | 
|---|
| 2382 | infow_txt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
| 2383 | infow_cmap = new PICMapView(infow_win, "about_piapp_cmap", bsx*4, bsy*0.7, spx, 2*spy+bsy*3.15); 
 | 
|---|
| 2384 | infow_cmap->SetColMapId(CMAP_COLBR32, 1., -1., false); 
 | 
|---|
| 2385 | infow_cmap->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
| 2386 | infow_but = new PIButton(infow_win,"OK", 10155, bsx, bsy, bsx*4+2*spx, 2*spy+bsy*3);
 | 
|---|
| 2387 | infow_but->SetMsgParent((PIMsgHandler *)app);
 | 
|---|
| 2388 | infow_but->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
| 2389 | 
 | 
|---|
| 2390 | string info = "piapp : Interactive analysis program\n";
 | 
|---|
| 2391 | char buff[128];
 | 
|---|
| 2392 | #ifdef SANS_EVOLPLANCK
 | 
|---|
| 2393 | sprintf(buff, "Version: piapp=%g  PI=%g  PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER, 
 | 
|---|
| 2394 |               (double)PI_VERSIONNUMBER, (float)PeidaVersion());
 | 
|---|
| 2395 | info += buff;
 | 
|---|
| 2396 | #else
 | 
|---|
| 2397 | string svers;
 | 
|---|
| 2398 | SophyaInitiator::GetVersion(svers);
 | 
|---|
| 2399 | info += svers;
 | 
|---|
| 2400 | sprintf(buff, "\n Version: PI=%g  --  PIext/piapp= %g \n", (double)PI_VERSIONNUMBER, 
 | 
|---|
| 2401 |         (double)PIAPP_VERSIONNUMBER);
 | 
|---|
| 2402 | info += buff; 
 | 
|---|
| 2403 | #endif
 | 
|---|
| 2404 | info += "(C) LAL-IN2P3/CNRS  1996-2006\n";
 | 
|---|
| 2405 | info += "(C) SPP-DAPNIA/CEA 1996-2006\n";
 | 
|---|
| 2406 | #ifndef SANS_EVOLPLANCK
 | 
|---|
| 2407 |  info += "Check http://www.sophya.org for more information";
 | 
|---|
| 2408 | #endif
 | 
|---|
| 2409 | infow_txt->SetText(info);
 | 
|---|
| 2410 | }
 | 
|---|
| 2411 | 
 | 
|---|
| 2412 | /* Nouvelle-Fonction */
 | 
|---|
| 2413 | static void showInfoWindow(PIStdImgApp* app)
 | 
|---|
| 2414 | {
 | 
|---|
| 2415 | if (!infow_win) createInfoWindow(app);
 | 
|---|
| 2416 | if (infow_win) infow_win->Show();
 | 
|---|
| 2417 | }
 | 
|---|
| 2418 | /* Nouvelle-Fonction */
 | 
|---|
| 2419 | static void hideInfoWindow(PIStdImgApp* app)
 | 
|---|
| 2420 | {
 | 
|---|
| 2421 | if (infow_win) infow_win->Hide();
 | 
|---|
| 2422 | }
 | 
|---|
| 2423 | 
 | 
|---|
| 2424 | /* Nouvelle-Fonction */
 | 
|---|
| 2425 | static void deleteInfoWindow()
 | 
|---|
| 2426 | {
 | 
|---|
| 2427 | if (!infow_win) return;
 | 
|---|
| 2428 | delete infow_win;
 | 
|---|
| 2429 | infow_win = NULL;
 | 
|---|
| 2430 | infow_txt = NULL;
 | 
|---|
| 2431 | infow_cmap = NULL;
 | 
|---|
| 2432 | infow_but = NULL;
 | 
|---|
| 2433 | }
 | 
|---|
| 2434 | 
 | 
|---|
| 2435 | 
 | 
|---|