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