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