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