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