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