[293] | 1 | #include "machdefs.h"
|
---|
[165] | 2 | #include <stdlib.h>
|
---|
| 3 | #include <stdio.h>
|
---|
| 4 | #include <string.h>
|
---|
| 5 |
|
---|
[295] | 6 | #include <typeinfo>
|
---|
| 7 |
|
---|
[165] | 8 | #include <string>
|
---|
| 9 | #include <vector>
|
---|
| 10 |
|
---|
| 11 | #include "strutil.h"
|
---|
| 12 | #include "timing.h"
|
---|
| 13 | #include "perrors.h"
|
---|
| 14 | #include "ctimer.h"
|
---|
| 15 |
|
---|
| 16 | #include "psighand.h"
|
---|
| 17 |
|
---|
| 18 | #include "cimage.h" // pour pouvoir faire extract
|
---|
| 19 |
|
---|
| 20 | #include "pistdimgapp.h"
|
---|
[1856] | 21 | // #include "pihisto2d.h"
|
---|
[165] | 22 | #include "psfile.h"
|
---|
| 23 | #include "piimgtools.h"
|
---|
| 24 | #include "pidrwtools.h"
|
---|
[1590] | 25 | #include "piaxestools.h"
|
---|
[165] | 26 |
|
---|
| 27 | #include "pistzwin.h"
|
---|
| 28 |
|
---|
[295] | 29 | #include "piinit.h"
|
---|
[374] | 30 | #include "piversion.h"
|
---|
| 31 | #include "piaversion.h"
|
---|
[165] | 32 |
|
---|
[295] | 33 |
|
---|
[165] | 34 | static char ImgDir[256];
|
---|
| 35 | static char WorkDir[256];
|
---|
[692] | 36 | // Initialiseur
|
---|
| 37 | static PIAppInitiator * glst_piai = NULL;
|
---|
[165] | 38 |
|
---|
[686] | 39 | // Pour la creation de fenetre info (about piapp)
|
---|
| 40 | static void createInfoWindow(PIStdImgApp* app);
|
---|
| 41 | static void deleteInfoWindow();
|
---|
| 42 | static void showInfoWindow(PIStdImgApp* app);
|
---|
| 43 | static void hideInfoWindow(PIStdImgApp* app);
|
---|
[165] | 44 |
|
---|
[2106] | 45 |
|
---|
[165] | 46 | /* ........................................................... */
|
---|
[2106] | 47 | /* Classe SIA_RU__Periodic : mise a jour periodique de */
|
---|
| 48 | /* la fenetre Stat/Ressource info */
|
---|
[2188] | 49 | /* + execution de commande soumis de l'exterieur */
|
---|
[2106] | 50 | /* ........................................................... */
|
---|
| 51 |
|
---|
| 52 | class SIA_RU__Periodic : public PIPeriodic
|
---|
| 53 | {
|
---|
| 54 | public:
|
---|
| 55 | SIA_RU__Periodic(PIStdImgApp* app);
|
---|
| 56 | virtual ~SIA_RU__Periodic();
|
---|
| 57 | virtual void DoPeriodic();
|
---|
| 58 | private:
|
---|
| 59 | PIStdImgApp* _app;
|
---|
| 60 | };
|
---|
| 61 |
|
---|
| 62 | SIA_RU__Periodic::SIA_RU__Periodic(PIStdImgApp* app)
|
---|
| 63 | : PIPeriodX(1)
|
---|
| 64 | {
|
---|
| 65 | _app = app;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | SIA_RU__Periodic::~SIA_RU__Periodic()
|
---|
| 69 | {
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | void SIA_RU__Periodic::DoPeriodic()
|
---|
| 73 | {
|
---|
[2188] | 74 | if (_app) {
|
---|
| 75 | _app->ExecuteExtCommand();
|
---|
| 76 | _app->UpdateStatResourceInfo();
|
---|
| 77 | }
|
---|
[2106] | 78 | }
|
---|
| 79 |
|
---|
| 80 | /* ............................................................. */
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | /* ........................................................... */
|
---|
[165] | 84 | /* Classe PIStdImgApp */
|
---|
| 85 | /* ........................................................... */
|
---|
| 86 |
|
---|
| 87 | /* --Methode-- */
|
---|
| 88 | PIStdImgApp::PIStdImgApp(int narg, char* arg[])
|
---|
| 89 | : PIApplication(420, 320, narg, arg)
|
---|
| 90 | {
|
---|
| 91 |
|
---|
| 92 | // Les menus
|
---|
| 93 | m[0] = new PIMenu(Menubar(),"Fichier");
|
---|
[686] | 94 | m[0]->AppendItem("About piapp", 10150);
|
---|
[165] | 95 | m[0]->AppendItem("Open-Fits", 10120);
|
---|
| 96 | m[0]->AppendItem("Open-PPF", 10130);
|
---|
| 97 | // m[0]->AppendItem("Options", 10101);
|
---|
[686] | 98 | m[0]->AppendItem("Help", 10100);
|
---|
[1513] | 99 | m[0]->AppendSeparator();
|
---|
[165] | 100 | m[0]->AppendItem("Exit", 10105);
|
---|
| 101 |
|
---|
| 102 | m[1] = new PIMenu(Menubar(),"Objets");
|
---|
| 103 | m[1]->AppendItem("ObjectManager", 10201);
|
---|
| 104 | m[1]->AppendItem("OpenOutPPF", 10220);
|
---|
| 105 | m[1]->AppendItem("CloseOutPPF", 10230);
|
---|
[686] | 106 | m[1]->AppendItem("Delete CurWdg", 10270);
|
---|
[165] | 107 |
|
---|
| 108 | m[2] = new PIMenu(Menubar(),"Tools");
|
---|
| 109 | m[2]->AppendItem("Show ImageTools", 10301);
|
---|
| 110 | m[2]->AppendItem("Show DrawerTools", 10302);
|
---|
[1590] | 111 | m[2]->AppendItem("Show AxesTools", 10303);
|
---|
| 112 | m[2]->AppendItem("CxxExecutorWindow", 10304);
|
---|
| 113 | m[2]->AppendItem("Ext.Pave", 10311);
|
---|
| 114 | m[2]->SetSensitivityMsg(10311, false);
|
---|
| 115 | m[2]->AppendItem("Ext.Pave+Org", 10312);
|
---|
| 116 | m[2]->SetSensitivityMsg(10312, false);
|
---|
| 117 | m[2]->AppendItem("Cuts X,Y", 10313);
|
---|
| 118 | m[2]->SetSensitivityMsg(10313, false);
|
---|
[165] | 119 | mc = new PIMenu(m[2], "StackTools");
|
---|
| 120 | mc->AppendItem("DispNext", 10320);
|
---|
[191] | 121 | mc->AppendItem("Blink 0.5s", 10321);
|
---|
| 122 | mc->AppendItem("Blink 1s", 10322);
|
---|
| 123 | mc->AppendItem("Blink 2s", 10324);
|
---|
[165] | 124 | mc->AppendItem("Stop Blink", 10329);
|
---|
| 125 | mc->AppendItem("RemoveCurrent", 10330);
|
---|
| 126 | m[2]->AppendPDMenu(mc);
|
---|
| 127 | m[2]->SetSensitivity("StackTools", false);
|
---|
| 128 |
|
---|
| 129 | m[3] = new PIMenu(Menubar(),"Window");
|
---|
| 130 | m[3]->AppendItem("StackWindow", 10400);
|
---|
| 131 | m[3]->AppendItem("Window", 10411);
|
---|
| 132 | m[3]->AppendItem("Window 2x1", 10421);
|
---|
[1971] | 133 | // m[3]->AppendItem("Window 1x2", 10412);
|
---|
[165] | 134 | m[3]->AppendItem("Window 2x2", 10422);
|
---|
[1971] | 135 | // m[3]->AppendItem("Window 3x1", 10431);
|
---|
[165] | 136 | m[3]->AppendItem("Window 3x3", 10433);
|
---|
[558] | 137 | m[3]->AppendItem("Cur->LastWdg", 10441);
|
---|
[686] | 138 | m[3]->AppendItem("Close CurWin", 10460);
|
---|
[1971] | 139 | m[3]->AppendCheckItem("StatZoomWin", 10470);
|
---|
| 140 | m[3]->SetStateMsg(10470, true);
|
---|
[165] | 141 |
|
---|
| 142 | m[4] = new PIMenu(Menubar(),"PostScript");
|
---|
| 143 | m[4]->AppendItem("OpenPS", 10501);
|
---|
| 144 | m[4]->AppendItem("ClosePS", 10505);
|
---|
| 145 | m[4]->AppendItem("Window->PS", 10511);
|
---|
| 146 | m[4]->AppendItem("Image->PS", 10515);
|
---|
| 147 | m[4]->AppendItem("Window->EPS", 10512);
|
---|
| 148 | m[4]->AppendItem("Image->EPS", 10516);
|
---|
| 149 | m[4]->SetSensitivityMsg(10515, false);
|
---|
| 150 | m[4]->SetSensitivityMsg(10516, false);
|
---|
| 151 |
|
---|
| 152 | m[5] = new PIMenu(Menubar(),"Special");
|
---|
| 153 | m[5]->AppendItem("CloseAll", 10601);
|
---|
| 154 | m[5]->AppendCheckItem("Red.Out/Err", 10602);
|
---|
[374] | 155 | m[5]->AppendCheckItem("Catch SigFPE", 10603);
|
---|
| 156 | m[5]->AppendCheckItem("Catch SigSEGV", 10604);
|
---|
[449] | 157 | m[5]->AppendCheckItem("ObjMgr Verb", 10605);
|
---|
[1319] | 158 | m[5]->AppendItem("CxxExecOption", 10606);
|
---|
[165] | 159 |
|
---|
[293] | 160 | m[6] = new PIMenu(Menubar(),"Modules");
|
---|
| 161 |
|
---|
[165] | 162 | AppendMenu(m[0]);
|
---|
| 163 | AppendMenu(m[1]);
|
---|
| 164 | AppendMenu(m[2]);
|
---|
| 165 | AppendMenu(m[3]);
|
---|
| 166 | AppendMenu(m[4]);
|
---|
| 167 | AppendMenu(m[5]);
|
---|
[374] | 168 | // AppendMenu(m[6]); Menu Modules vide pour le moment
|
---|
[165] | 169 |
|
---|
| 170 | int scsx, scsy;
|
---|
[1593] | 171 | ScreenSize(scsx, scsy);
|
---|
[165] | 172 | if (scsy <= 600) mFgScSz = 0;
|
---|
| 173 | else if (scsy <= 800) mFgScSz = 1;
|
---|
| 174 | else if (scsy <= 1024) mFgScSz = 2;
|
---|
| 175 | else mFgScSz = 3;
|
---|
| 176 | int msx = 420+mFgScSz*60;
|
---|
| 177 | int msy = 320+mFgScSz*40;
|
---|
| 178 | MainWin()->SetSize(msx, msy);
|
---|
| 179 |
|
---|
[1971] | 180 | //------------------------------------------------------
|
---|
| 181 | // On cree un container intermediaire permettant de gerer
|
---|
| 182 | // le widget zoom, colormap, stats, ...
|
---|
| 183 |
|
---|
[165] | 184 | int bss = 100+mFgScSz*15;
|
---|
[1971] | 185 |
|
---|
| 186 | int statc_szy = bss+10+14+mFgScSz*2+5;
|
---|
| 187 | statcont = new PIContainer(MainWin(), "ZGCSCont", msx, statc_szy, 0, 0);
|
---|
| 188 | statcont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
|
---|
| 189 |
|
---|
| 190 | gimv = new PIPixmap(statcont, "GloV", bss, bss, 5, 5);
|
---|
[165] | 191 | gimv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free);
|
---|
[1971] | 192 | zoom = new PIPixmap(statcont, "Zoom", bss, bss, bss+10, 5);
|
---|
[165] | 193 | zoom->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free);
|
---|
[1971] | 194 | cmapv = new PICMapView(statcont, "CMapView", msx-10, 14+mFgScSz*2, 5, bss+10);
|
---|
[165] | 195 | cmapv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
|
---|
[2106] | 196 |
|
---|
| 197 | // Widget pour affichage des stats / ressources
|
---|
| 198 | lab_mem = new PILabel(statcont, "memlab", msx-2*(bss+20), 20, 2*bss+20, 10);
|
---|
| 199 | lab_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
|
---|
| 200 | lab_mem->SetLabel("MemoryUsage");
|
---|
| 201 | lab_mem->SetForegroundColor(PI_Red);
|
---|
| 202 | lab_mem->SetBorderWidth(1);
|
---|
| 203 | therm_mem = new PIThermometer(statcont, "memtherm", msx-2*(bss+20), 20, 2*bss+20, 35);
|
---|
| 204 | therm_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
|
---|
| 205 | therm_mem->SetThreshold(0.5, 0.75);
|
---|
| 206 |
|
---|
| 207 | lab_cpu = new PILabel(statcont, "cpulab", msx-2*(bss+20), 20, 2*bss+20, 60);
|
---|
| 208 | lab_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
|
---|
| 209 | lab_cpu->SetLabel("CPUUsage");
|
---|
| 210 | lab_cpu->SetForegroundColor(PI_Black);
|
---|
| 211 | lab_cpu->SetBorderWidth(1);
|
---|
| 212 | therm_cpu = new PIThermometer(statcont, "cputherm", msx-2*(bss+20), 20, 2*bss+20, 85);
|
---|
| 213 | therm_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
|
---|
| 214 | therm_cpu->SetThreshold(0.75, 0.90);
|
---|
| 215 |
|
---|
[2188] | 216 | fg_exc_cmd = false;
|
---|
[2106] | 217 | UpdateStatResourceInfo();
|
---|
| 218 | resupd_periodic = new SIA_RU__Periodic(this);
|
---|
| 219 | //resupd_periodic->SetIntervalms(500);
|
---|
| 220 | resupd_periodic->Start();
|
---|
| 221 |
|
---|
[1971] | 222 | statcont->Show();
|
---|
| 223 | // StatZoomWindowSetVisible(true);
|
---|
| 224 | //------------------------------------------------------
|
---|
[165] | 225 |
|
---|
[1971] | 226 | //int cpy = bss+10+14+mFgScSz*2+5;
|
---|
| 227 | int cpy = statc_szy;
|
---|
[165] | 228 |
|
---|
| 229 | // Creation d'une console avec gestion des commandes
|
---|
[1971] | 230 | consolecont = new PIContainer(MainWin(), "ConsoleCont", msx, msy-cpy, 0, cpy );
|
---|
| 231 | consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
|
---|
| 232 | mCons = new PIConsole(consolecont, "Console", 30200, 512, 132, msx, msy-cpy, 0, 0 );
|
---|
[165] | 233 | mCons->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
|
---|
| 234 | mCons->AcceptCmd(true, 50);
|
---|
[1971] | 235 | consolecont->Show();
|
---|
[293] | 236 | redirecout = false;
|
---|
[165] | 237 | // RedirectStdOutErr(true); pas par defaut
|
---|
| 238 |
|
---|
| 239 | mObjMgr = new NamedObjMgr;
|
---|
| 240 | mCmd = new PIACmd(mObjMgr, this);
|
---|
| 241 |
|
---|
[449] | 242 | // Pas trop de message de la part de NamedObjMgr
|
---|
| 243 | m[5]->SetStateMsg(10605, false);
|
---|
| 244 | mObjMgr->SetVerbose(false);
|
---|
| 245 |
|
---|
[165] | 246 | char* varenv;
|
---|
| 247 | ImgDir[0] = WorkDir[0] = '\0';
|
---|
| 248 | if ( (varenv=getenv("PEIDA_IMAGES")) != NULL ) strncpy(ImgDir, varenv, 256);
|
---|
| 249 | if ( (varenv=getenv("PEIDA_WORK")) != NULL ) strncpy(WorkDir, varenv, 256);
|
---|
| 250 |
|
---|
[685] | 251 | pfc_fits = new PIFileChooser(this,"FITS-FileChooser", 10125);
|
---|
| 252 | pfc_ppf = new PIFileChooser(this,"PPF-FileChooser", 10135);
|
---|
| 253 | pfc_ps = new PIFileChooser(this,"PS-FileChooser", 10525);
|
---|
[165] | 254 |
|
---|
| 255 | mObjmgrw = new ObjMgrWind(this);
|
---|
| 256 | mPpinmgrw = new PPInMgrWind(this);
|
---|
| 257 |
|
---|
[333] | 258 | // Attention : A faire apres creation de ObjMgrWind !!!
|
---|
| 259 | mObjMgr->SetImgApp(this);
|
---|
| 260 |
|
---|
[165] | 261 | // Gestion des feneteres widgets et drawers
|
---|
| 262 | mWId = mDId = mBWId = 0;
|
---|
| 263 | mCurWin = NULL;
|
---|
| 264 | mCurWdg = NULL;
|
---|
| 265 | mLastWdg = NULL;
|
---|
| 266 | mGrW = NULL;
|
---|
| 267 | mStW = NULL;
|
---|
| 268 | mGrIdx = mStIdx = -1;
|
---|
| 269 |
|
---|
| 270 | mFCMsg = 0;
|
---|
| 271 | mFgCWImg = false;
|
---|
| 272 |
|
---|
| 273 | // Gestion fichiers PS
|
---|
| 274 | num_eps = 0;
|
---|
| 275 | name_ps = "";
|
---|
| 276 | name_ps = "pia.ps";
|
---|
| 277 | mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
|
---|
| 278 |
|
---|
| 279 | // Gestion OUT-PPF
|
---|
| 280 | mPpfout = NULL;
|
---|
| 281 | name_outppf = "";
|
---|
| 282 |
|
---|
| 283 | // Attributs graphiques courants
|
---|
[203] | 284 | mAxesFlags = kBoxAxes | kExtTicks | kLabels;
|
---|
[548] | 285 | SetInsetLimits(0.4, 0.6, 0.4, 0.6);
|
---|
[1131] | 286 | mAddTitle = true;
|
---|
[165] | 287 |
|
---|
[295] | 288 | // Initialisation
|
---|
[692] | 289 | glst_piai = new PIAppInitiator(this);
|
---|
[600] | 290 |
|
---|
| 291 | char buff[128];
|
---|
| 292 | mCons->AddStr(" ............ starting piapp .............\n", PIVA_Blue );
|
---|
| 293 | #ifdef SANS_EVOLPLANCK
|
---|
| 294 | sprintf(buff, "Version: piapp=%g PI=%g PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER,
|
---|
| 295 | (double)PI_VERSIONNUMBER, (float)PeidaVersion());
|
---|
| 296 | #else
|
---|
| 297 | sprintf(buff, "Version: piapp=%g PI=%g SOPHYA=%g \n", (double)PIAPP_VERSIONNUMBER,
|
---|
[692] | 298 | (double)PI_VERSIONNUMBER, glst_piai->Version());
|
---|
[600] | 299 | #endif
|
---|
| 300 | mCons->AddStr(buff, PIVA_Blue );
|
---|
| 301 | mCons->AddStr(" ..........................................\n", PIVA_Blue );
|
---|
| 302 | // PrintPeidaVersion();
|
---|
| 303 |
|
---|
[685] | 304 | pfc_fits->SetPath(ImgDir);
|
---|
| 305 | pfc_ppf->SetPath(WorkDir);
|
---|
| 306 | pfc_ps->SetPath(WorkDir);
|
---|
| 307 |
|
---|
[165] | 308 | SetReady();
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | /* --Methode-- */
|
---|
| 312 | PIStdImgApp::~PIStdImgApp()
|
---|
| 313 | {
|
---|
| 314 | int i;
|
---|
| 315 |
|
---|
[1075] | 316 | // On inactive la fenetre principale
|
---|
| 317 | // Sinon, ca peut provoquer un SEGV ds delete de console ?? - Reza 07/2000
|
---|
| 318 | MainWin()->Hide();
|
---|
| 319 |
|
---|
[558] | 320 | // Destrucion de tous les objets de NameObjMgr
|
---|
| 321 | string patt = "/*/*";
|
---|
| 322 | mObjMgr->DelObjects(patt, true);
|
---|
| 323 |
|
---|
[205] | 324 | delete mc;
|
---|
[293] | 325 | for(i=0; i<7; i++)
|
---|
[165] | 326 | if (m[i]) delete m[i];
|
---|
| 327 |
|
---|
| 328 | WindMList::iterator it;
|
---|
| 329 | for(it = mWList.begin(); it != mWList.end(); it++) delete (*it).second;
|
---|
| 330 |
|
---|
| 331 | delete mObjMgr;
|
---|
| 332 | delete mCmd;
|
---|
| 333 |
|
---|
| 334 | delete zoom;
|
---|
| 335 | delete gimv;
|
---|
| 336 | delete cmapv;
|
---|
| 337 |
|
---|
[2106] | 338 | delete lab_mem;
|
---|
| 339 | delete therm_mem;
|
---|
| 340 | delete lab_cpu;
|
---|
| 341 | delete therm_cpu;
|
---|
| 342 |
|
---|
[1971] | 343 | delete statcont;
|
---|
| 344 |
|
---|
[685] | 345 | delete pfc_fits;
|
---|
| 346 | delete pfc_ppf;
|
---|
| 347 | delete pfc_ps;
|
---|
[165] | 348 |
|
---|
| 349 | delete mCons;
|
---|
[2106] | 350 | delete consolecont;
|
---|
[165] | 351 |
|
---|
| 352 | delete mObjmgrw;
|
---|
| 353 | delete mPpinmgrw;
|
---|
| 354 |
|
---|
[686] | 355 | deleteInfoWindow();
|
---|
| 356 |
|
---|
[165] | 357 | // Les fichiers
|
---|
| 358 | if (mpsfile) delete mpsfile;
|
---|
| 359 | if (mPpfout) delete mPpfout;
|
---|
| 360 |
|
---|
[2106] | 361 | if (resupd_periodic) delete resupd_periodic;
|
---|
| 362 |
|
---|
[692] | 363 | if (glst_piai) delete glst_piai; glst_piai = NULL;
|
---|
[2106] | 364 |
|
---|
[165] | 365 | }
|
---|
| 366 |
|
---|
| 367 | /* --Methode-- */
|
---|
| 368 | void PIStdImgApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
|
---|
| 369 | {
|
---|
| 370 | PIWdg *sndw;
|
---|
| 371 | PIMessage tmsg, smm;
|
---|
| 372 |
|
---|
| 373 | tmsg = msg;
|
---|
| 374 | msg = UserMsg(msg);
|
---|
| 375 | smm = ModMsg(tmsg);
|
---|
| 376 |
|
---|
| 377 | //printf("SuperDebug: msg=%d Mod=%d State=%d\n", (int)msg, (int)smm, (int)GetState());
|
---|
| 378 | if ((GetState()) && (msg != mFCMsg)) { PIBeep(); return; }
|
---|
| 379 |
|
---|
| 380 | // Messages active-window
|
---|
| 381 | if (smm == PIMsg_Active)
|
---|
| 382 | {
|
---|
[293] | 383 | sndw = dynamic_cast<PIWdg *>(sender);
|
---|
[165] | 384 | switch(sndw->kind())
|
---|
| 385 | {
|
---|
| 386 | case PIWindow::ClassId :
|
---|
[293] | 387 | mCurWin = dynamic_cast<PIWindow *>(sndw);
|
---|
[165] | 388 | break;
|
---|
| 389 |
|
---|
| 390 | case PIScDrawWdg::ClassId :
|
---|
| 391 | case PIDraw3DWdg::ClassId :
|
---|
[293] | 392 | mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
|
---|
[165] | 393 | // cerr << "*DBG11* ImgTools -> NonSensitive " << sndw->kind() << endl;
|
---|
| 394 | if (mFgCWImg) {
|
---|
| 395 | // cerr << "*DBG* ImgTools -> NonSensitive " << endl;
|
---|
[1590] | 396 | m[2]->SetSensitivityMsg(10311, false);
|
---|
| 397 | m[2]->SetSensitivityMsg(10312, false);
|
---|
| 398 | m[2]->SetSensitivityMsg(10313, false);
|
---|
[165] | 399 | m[4]->SetSensitivityMsg(10515, false);
|
---|
| 400 | m[4]->SetSensitivityMsg(10516, false);
|
---|
| 401 | mFgCWImg = false;
|
---|
| 402 | }
|
---|
| 403 | break;
|
---|
| 404 | case PIImage::ClassId :
|
---|
[293] | 405 | mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
|
---|
[165] | 406 | if (!mFgCWImg) {
|
---|
| 407 | // cerr << "*DBG* ImgTools -> Sensitive " << endl;
|
---|
[1590] | 408 | m[2]->SetSensitivityMsg(10311, true);
|
---|
| 409 | m[2]->SetSensitivityMsg(10312, true);
|
---|
| 410 | m[2]->SetSensitivityMsg(10313, true);
|
---|
[165] | 411 | m[4]->SetSensitivityMsg(10515, true);
|
---|
| 412 | m[4]->SetSensitivityMsg(10516, true);
|
---|
| 413 | mFgCWImg = true;
|
---|
| 414 | }
|
---|
| 415 | break;
|
---|
[293] | 416 | /*
|
---|
| 417 | default :
|
---|
| 418 | mCurWdg = NULL;
|
---|
| 419 | if (mFgCWImg) {
|
---|
[1590] | 420 | m[2]->SetSensitivityMsg(10311, false);
|
---|
| 421 | m[2]->SetSensitivityMsg(10312, false);
|
---|
| 422 | m[2]->SetSensitivityMsg(10313, false);
|
---|
[293] | 423 | m[4]->SetSensitivityMsg(10515, false);
|
---|
| 424 | m[4]->SetSensitivityMsg(10516, false);
|
---|
| 425 | mFgCWImg = false;
|
---|
| 426 | }
|
---|
| 427 | break;
|
---|
| 428 | */
|
---|
[165] | 429 | }
|
---|
| 430 | }
|
---|
| 431 | // Message window-close
|
---|
| 432 | else if (smm == PIMsg_Close)
|
---|
| 433 | {
|
---|
| 434 | sndw = (PIWdg *)sender;
|
---|
| 435 | if(sndw->kind() == PIWindow::ClassId)
|
---|
| 436 | {
|
---|
| 437 | mCurWin = (PIWindow *)sender;
|
---|
| 438 | if (mCurWin == mStW) m[2]->SetSensitivity("StackTools", false);
|
---|
| 439 | DeleteWindow(mCurWin);
|
---|
| 440 | }
|
---|
| 441 | else
|
---|
| 442 | printf("PIStdImgApp/Bug ? CloseMsd received from NonWindow (%d %d %lx) \n",
|
---|
| 443 | (int)tmsg, (int)sndw->kind(), (long)sender);
|
---|
| 444 | }
|
---|
| 445 |
|
---|
| 446 | // Traitement des messages des menus
|
---|
| 447 | else if ( (msg >= 10100) && (msg < 10200) ) MBProcess1(msg, sender, data);
|
---|
| 448 | else if ( (msg >= 10200) && (msg < 10300) ) MBProcess2(msg, sender, data);
|
---|
| 449 | else if ( (msg >= 10300) && (msg < 10400) ) MBProcess3(msg, sender, data);
|
---|
| 450 | else if ( (msg >= 10400) && (msg < 10500) ) MBProcess4(msg, sender, data);
|
---|
| 451 | else if ( (msg >= 10500) && (msg < 10600) ) MBProcess5(msg, sender, data);
|
---|
| 452 | else if ( (msg >= 10600) && (msg < 10700) ) MBProcess6(msg, sender, data);
|
---|
| 453 | else if ( msg == 30200 ) { // Objet PIConsole
|
---|
| 454 | string s = mCons->GetCmdString();
|
---|
[1265] | 455 | // string s2 = "\nExecuting " + s + "\n";
|
---|
| 456 | mCons->AddStr("Cmd> ", PIVA_Blue, false);
|
---|
| 457 | // s2 = s + "\n";
|
---|
| 458 | mCons->AddStr(s.c_str(), PIVA_Blue|PIVA_Bold, false);
|
---|
| 459 | mCons->AddChar('\n', PIVA_Def, true);
|
---|
[165] | 460 | SetBusy();
|
---|
[495] | 461 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 462 | TRY {
|
---|
[293] | 463 | mCmd->Interpret(s);
|
---|
[165] | 464 | } CATCH(merr) {
|
---|
| 465 | fflush(stdout);
|
---|
| 466 | cout << endl;
|
---|
| 467 | cerr << endl;
|
---|
| 468 | string es = PeidaExc(merr);
|
---|
[495] | 469 | cerr << "PIStdImgApp::Process()/ Cmd->Do() Exception :" << es << " (" << merr << ")" << endl ;
|
---|
| 470 | }
|
---|
| 471 | #else
|
---|
| 472 | try {
|
---|
| 473 | mCmd->Interpret(s);
|
---|
| 474 | }
|
---|
[1276] | 475 | catch ( PThrowable & exc ) {
|
---|
| 476 | cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Exception :"
|
---|
| 477 | << (string)typeid(exc).name() << " Msg= "
|
---|
| 478 | << exc.Msg() << endl;
|
---|
[495] | 479 | cout << endl;
|
---|
[165] | 480 | }
|
---|
[1276] | 481 | catch ( ... ) {
|
---|
| 482 | cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Catched Exception ..."
|
---|
| 483 | << endl;
|
---|
| 484 | cout << endl;
|
---|
| 485 | }
|
---|
| 486 |
|
---|
[495] | 487 | #endif
|
---|
[165] | 488 | SetReady();
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | else printf("PIStdImgApp::Process() BUG?? Msg %d (%d-%d) \n",
|
---|
| 492 | (int)tmsg,(int)msg,(int)smm);
|
---|
| 493 |
|
---|
| 494 |
|
---|
| 495 | return;
|
---|
| 496 | }
|
---|
| 497 |
|
---|
[194] | 498 | /* --Methode-- */
|
---|
| 499 | void PIStdImgApp::SetReady()
|
---|
| 500 | {
|
---|
| 501 | mCons->SetSensitive();
|
---|
| 502 | gimv->SetSensitive();
|
---|
| 503 | PIApplication::SetReady();
|
---|
| 504 | }
|
---|
[165] | 505 |
|
---|
[194] | 506 | /* --Methode-- */
|
---|
| 507 | void PIStdImgApp::SetBusy()
|
---|
| 508 | {
|
---|
| 509 | mCons->SetUnSensitive();
|
---|
| 510 | gimv->SetUnSensitive();
|
---|
| 511 | PIApplication::SetBusy();
|
---|
[1321] | 512 | // Attention : Appel XSync specifique X11 - en attendant multi-thread
|
---|
| 513 | XSync(PIXDisplay(), False);
|
---|
[194] | 514 | }
|
---|
[165] | 515 |
|
---|
[194] | 516 | /* --Methode-- */
|
---|
| 517 | void PIStdImgApp::SetBlocked()
|
---|
| 518 | {
|
---|
| 519 | mCons->SetUnSensitive();
|
---|
| 520 | gimv->SetUnSensitive();
|
---|
| 521 | PIApplication::SetBlocked();
|
---|
[1321] | 522 | // Attention : Appel XSync specifique X11 - en attendant multi-thread
|
---|
| 523 | XSync(PIXDisplay(), False);
|
---|
[194] | 524 | }
|
---|
[165] | 525 |
|
---|
[194] | 526 |
|
---|
[165] | 527 | /* --Methode-- */
|
---|
[1971] | 528 | int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, string const& sop, int oid)
|
---|
[165] | 529 | {
|
---|
| 530 | PIImage* pii;
|
---|
| 531 | PIWindow* win;
|
---|
| 532 | int sx, sy, px, py, flag;
|
---|
| 533 |
|
---|
| 534 | if (nouv == NULL)
|
---|
| 535 | {
|
---|
| 536 | printf("PIStdImgApp::DispImage_Error Cannot Display NULL image \n");
|
---|
| 537 | return(-1);
|
---|
| 538 | }
|
---|
| 539 |
|
---|
| 540 | if ( (nouv->XSize() <= 0) || (nouv->YSize() <= 0))
|
---|
| 541 | {
|
---|
| 542 | printf("PIStdImgApp::DispImage_Error Pb Size Sz=%d*%d \n",
|
---|
| 543 | nouv->XSize(), nouv->YSize());
|
---|
| 544 | return(-1);
|
---|
| 545 | }
|
---|
| 546 |
|
---|
[1971] | 547 | // On decode les options graphiques
|
---|
| 548 | vector<string> opts;
|
---|
| 549 | DispWinEnum dwopt = ParseDisplayOption(sop, opts);
|
---|
[165] | 550 |
|
---|
[1971] | 551 | // Pas de same ou inset pour DispImage
|
---|
| 552 | if ((dwopt == Disp_Same) || (dwopt == Disp_Inset) ) dwopt = Disp_Next;
|
---|
[165] | 553 |
|
---|
[1971] | 554 | // Choix de la taille de fenetre
|
---|
| 555 | #define MINPIIMGSIZE 100
|
---|
| 556 | sx = (nouv->XSize() > MINPIIMGSIZE) ? nouv->XSize() : MINPIIMGSIZE;
|
---|
| 557 | sy = (nouv->YSize() > MINPIIMGSIZE) ? nouv->XSize() : MINPIIMGSIZE;
|
---|
[165] | 558 | if (sx > 400+mFgScSz*100) sx = 400+mFgScSz*100;
|
---|
| 559 | if (sy > 400+mFgScSz*100) sy = 400+mFgScSz*100;
|
---|
| 560 | px = py = 0;
|
---|
[1971] | 561 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
|
---|
[165] | 562 | pii = new PIImage(win, (char *)name.c_str(), sx, sy, px,py);
|
---|
| 563 | pii->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
|
---|
| 564 | pii->SetZoomWin(zoom, false);
|
---|
| 565 | pii->SetGloVWin(gimv, false);
|
---|
| 566 | pii->SetCMapWin(cmapv, false);
|
---|
| 567 | pii->ShowCursor(true);
|
---|
[331] | 568 | pii->SetUserData(NULL, oid);
|
---|
[1971] | 569 |
|
---|
| 570 |
|
---|
| 571 | // On recalcule la taille de la fenetre si Disp_Win
|
---|
| 572 | if (dwopt == Disp_Win) {
|
---|
| 573 | int sx2 = (int)((float)nouv->XSize()*pii->GetZoomF());
|
---|
| 574 | int sy2 = (int)((float)nouv->YSize()*pii->GetZoomF());
|
---|
| 575 |
|
---|
| 576 | if (sx2 > 400+mFgScSz*100) sx2 = 400+mFgScSz*100;
|
---|
| 577 | if (sy2 > 400+mFgScSz*100) sy2 = 400+mFgScSz*100;
|
---|
| 578 | if (sx2 < MINPIIMGSIZE) sx = MINPIIMGSIZE;
|
---|
| 579 | if (sy2 < MINPIIMGSIZE) sy = MINPIIMGSIZE;
|
---|
| 580 | if ((sx2 != sx) || (sy2 != sy)) win->SetSize(sx2, sy2);
|
---|
| 581 | }
|
---|
| 582 |
|
---|
[2118] | 583 | pii->SetImage(nouv, true, false);
|
---|
[1971] | 584 |
|
---|
[2118] | 585 | // decode des options en chaine de caracteres
|
---|
[2217] | 586 | if (mAxesAtt.size() > 0)
|
---|
| 587 | pii->DecodeOptionString(mAxesAtt, false); // Les options d'axe
|
---|
| 588 | if (mDefaultAtt.size() > 0)
|
---|
| 589 | pii->DecodeOptionString(mDefaultAtt, false); // d'abord les options par defaut
|
---|
| 590 | if (opts.size() > 0)
|
---|
| 591 | pii->DecodeOptionString(opts); // ensuite, les options specifies en argument
|
---|
[2118] | 592 |
|
---|
[165] | 593 | // printf("!!DBG!! PIImage Pos= %d %d Size= %d %d \n", pii->XPos(), pii->YPos(), pii->XSize(), pii->YSize() );
|
---|
| 594 | mCurWin = win;
|
---|
| 595 | mCurWdg = pii;
|
---|
| 596 | mLastWdg = pii;
|
---|
| 597 | mBWId++;
|
---|
| 598 | mBWList[mBWId] = pii;
|
---|
[2118] | 599 | // pii->Refresh();
|
---|
| 600 | pii->Apply();
|
---|
| 601 | cmapv->Refresh();
|
---|
[165] | 602 | return(mBWId);
|
---|
| 603 | }
|
---|
| 604 |
|
---|
| 605 |
|
---|
| 606 | /* --Methode-- */
|
---|
[1971] | 607 | int PIStdImgApp::DispScDrawer(PIDrawer* scd, string const & name, string const& sop,
|
---|
| 608 | string title, int oid)
|
---|
[165] | 609 | {
|
---|
| 610 | if (scd == NULL)
|
---|
| 611 | {
|
---|
| 612 | printf("PIStdImgApp::DispScDrawer_Error Cannot Add NULL ScDrawer \n");
|
---|
| 613 | return(-1);
|
---|
| 614 | }
|
---|
| 615 |
|
---|
[1971] | 616 | // On decode les options graphiques
|
---|
| 617 | vector<string> opts;
|
---|
| 618 | DispWinEnum dwopt = ParseDisplayOption(sop, opts);
|
---|
| 619 | if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) ) dwopt = Disp_Next;
|
---|
| 620 | // Trace en superpoistion
|
---|
| 621 | if ( (dwopt == Disp_Same) && (mLastWdg) ) {
|
---|
| 622 | // Les options
|
---|
| 623 | scd->DecodeOptionString(mDefaultAtt, false);
|
---|
| 624 | scd->DecodeOptionString(opts, true);
|
---|
[165] | 625 |
|
---|
| 626 | if (mLastWdg->kind() == PIScDrawWdg::ClassId) ((PIScDrawWdg*)mLastWdg)->AddScDrawer(scd, true);
|
---|
| 627 | else mLastWdg->AddDrawer(scd, true, true, true);
|
---|
[548] | 628 | scd->Refresh();
|
---|
| 629 | mDId++;
|
---|
| 630 | mDrwList[mDId] = scd;
|
---|
| 631 | return(-mDId);
|
---|
| 632 | }
|
---|
| 633 | // Trace en medaillon
|
---|
[1971] | 634 | else if ( (dwopt == Disp_Inset) && (mLastWdg) ) {
|
---|
[548] | 635 | PIGrCoord x1, x2, y1, y2;
|
---|
| 636 | x1 = mIXmin; x2 = mIXmax;
|
---|
| 637 | y2 = 1.-mIYmin; y1 = 1.-mIYmax;
|
---|
[1971] | 638 | // Les options
|
---|
| 639 | scd->DecodeOptionString(mDefaultAtt, false);
|
---|
| 640 | scd->DecodeOptionString(opts, true);
|
---|
| 641 |
|
---|
[548] | 642 | scd->SetAxesFlags(mAxesFlags);
|
---|
[1971] | 643 | scd->UpdateLimits();
|
---|
[548] | 644 | mLastWdg->AddDrawer(scd, x1, y1, x2, y2, true, false, true);
|
---|
[165] | 645 | scd->Refresh();
|
---|
| 646 | mDId++;
|
---|
| 647 | mDrwList[mDId] = scd;
|
---|
| 648 | return(-mDId);
|
---|
| 649 | }
|
---|
| 650 |
|
---|
[1971] | 651 | // Creation d'un nouveau PIScDrawWdg
|
---|
[165] | 652 | PIWindow* win;
|
---|
| 653 | PIScDrawWdg* scw;
|
---|
| 654 | int sx, sy, px, py, flag;
|
---|
| 655 | sx = 200+mFgScSz*100;
|
---|
| 656 | sy = 200+mFgScSz*100;
|
---|
[1971] | 657 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
|
---|
| 658 |
|
---|
[1856] | 659 | scw = new PIScDrawWdg(win, (char *)name.c_str(), sx, sy, px, py);
|
---|
[165] | 660 | scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
|
---|
[331] | 661 | scw->SetUserData(NULL, oid);
|
---|
[1971] | 662 |
|
---|
| 663 | // Decodage des options :
|
---|
| 664 | vector<string> scwatt;
|
---|
[203] | 665 | scw->SetAxesFlags(mAxesFlags);
|
---|
[1971] | 666 | if ( mDefaultAtt.size() > 0) {
|
---|
| 667 | scwatt = mDefaultAtt;
|
---|
[2217] | 668 | scd->DecodeOptionString(scwatt, true);
|
---|
[1971] | 669 | scw->DecodeOptionString(scwatt, true);
|
---|
| 670 | }
|
---|
| 671 | if ( mAxesAtt.size() > 0) {
|
---|
| 672 | scwatt = mAxesAtt;
|
---|
| 673 | scw->DecodeOptionString(scwatt, true);
|
---|
| 674 | }
|
---|
| 675 | if (opts.size() > 0)
|
---|
| 676 | scd->DecodeOptionString(opts, true);
|
---|
| 677 | if (opts.size() > 0)
|
---|
| 678 | scw->DecodeOptionString(opts, false);
|
---|
| 679 |
|
---|
[165] | 680 | // Titre du plot
|
---|
[1131] | 681 | if (mAddTitle) {
|
---|
| 682 | if (title.length() <= 0) title = name; string t2="";
|
---|
| 683 | scw->SetTitles(title, t2);
|
---|
| 684 | }
|
---|
[1569] | 685 |
|
---|
[1971] | 686 | scw->AddScDrawer(scd, true);
|
---|
[293] | 687 | // scw->Refresh(); ? Pas necessaire Reza 19/08/98, 05/05/99 $CHECK$
|
---|
[1971] | 688 |
|
---|
[165] | 689 | mCurWin = win;
|
---|
| 690 | mCurWdg = scw;
|
---|
| 691 | mLastWdg = scw;
|
---|
| 692 | mBWId++;
|
---|
| 693 | mBWList[mBWId] = scw;
|
---|
| 694 | return(mBWId);
|
---|
| 695 | }
|
---|
| 696 |
|
---|
| 697 | /* --Methode-- */
|
---|
[1971] | 698 | int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, string const& sop,
|
---|
| 699 | string title, int oid)
|
---|
[165] | 700 | {
|
---|
| 701 | if (dr3 == NULL)
|
---|
| 702 | {
|
---|
| 703 | printf("PIStdImgApp::Disp3DDrawer_Error Cannot Add NULL 3DDrawer \n");
|
---|
| 704 | return(-1);
|
---|
| 705 | }
|
---|
| 706 |
|
---|
[1971] | 707 | // On decode les options graphiques
|
---|
| 708 | vector<string> opts;
|
---|
| 709 | DispWinEnum dwopt = ParseDisplayOption(sop, opts);
|
---|
[165] | 710 |
|
---|
[1971] | 711 | if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) ) dwopt = Disp_Next;
|
---|
[548] | 712 | // Trace en superpoistion
|
---|
[1971] | 713 | if ( (dwopt == Disp_Same) && (mLastWdg) ) {
|
---|
| 714 | // Les options
|
---|
| 715 | dr3->DecodeOptionString(mDefaultAtt, false);
|
---|
| 716 | dr3->DecodeOptionString(opts, true);
|
---|
| 717 |
|
---|
[165] | 718 | if (mLastWdg->kind() == PIDraw3DWdg::ClassId) ((PIDraw3DWdg*)mLastWdg)->AddDrawer3D(dr3, true);
|
---|
| 719 | else mLastWdg->AddDrawer(dr3, true, true, true);
|
---|
| 720 | dr3->Refresh();
|
---|
| 721 | mDId++;
|
---|
| 722 | mDrwList[mDId] = dr3;
|
---|
| 723 | return(-mDId);
|
---|
| 724 | }
|
---|
[548] | 725 | // Trace en medaillon
|
---|
[1971] | 726 | else if ( (dwopt == Disp_Inset) && (mLastWdg) ) {
|
---|
[548] | 727 | PIGrCoord x1, x2, y1, y2;
|
---|
| 728 | x1 = mIXmin; x2 = mIXmax;
|
---|
| 729 | y2 = 1.-mIYmin; y1 = 1.-mIYmax;
|
---|
[1971] | 730 | // Les options
|
---|
| 731 | dr3->DecodeOptionString(mDefaultAtt, false);
|
---|
| 732 | dr3->DecodeOptionString(opts, true);
|
---|
| 733 |
|
---|
[548] | 734 | dr3->SetAxesFlags(mAxesFlags);
|
---|
| 735 | dr3->UpdateLimits();
|
---|
| 736 | mLastWdg->AddDrawer(dr3, x1, y1, x2, y2, true, false, true);
|
---|
| 737 | dr3->Refresh();
|
---|
| 738 | mDId++;
|
---|
| 739 | mDrwList[mDId] = dr3;
|
---|
| 740 | return(-mDId);
|
---|
| 741 | }
|
---|
[165] | 742 |
|
---|
[548] | 743 |
|
---|
[165] | 744 | PIWindow* win;
|
---|
| 745 | int sx, sy, px, py, flag;
|
---|
| 746 | sx = 200+mFgScSz*100;
|
---|
| 747 | sy = 200+mFgScSz*100;
|
---|
[1971] | 748 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
|
---|
[165] | 749 | PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)name.c_str(), sx, sy, px, py);
|
---|
| 750 | wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
|
---|
[331] | 751 | wd3->SetUserData(NULL, oid);
|
---|
[1971] | 752 |
|
---|
| 753 | // Decodage des options :
|
---|
| 754 | vector<string> scwatt;
|
---|
| 755 | // wd3->SetAxesFlags(mAxesFlags); Attributs d'axes 3D a faire
|
---|
| 756 | if ( mDefaultAtt.size() > 0) {
|
---|
| 757 | scwatt = mDefaultAtt;
|
---|
[2217] | 758 | dr3->DecodeOptionString(scwatt, true);
|
---|
[1971] | 759 | wd3->DecodeOptionString(scwatt, true);
|
---|
| 760 | }
|
---|
| 761 | if ( mAxesAtt.size() > 0) {
|
---|
| 762 | scwatt = mAxesAtt;
|
---|
| 763 | wd3->DecodeOptionString(scwatt, true);
|
---|
| 764 | }
|
---|
| 765 | if (opts.size() > 0)
|
---|
| 766 | dr3->DecodeOptionString(opts, true);
|
---|
| 767 | if (opts.size() > 0)
|
---|
| 768 | wd3->DecodeOptionString(opts, false);
|
---|
| 769 |
|
---|
[165] | 770 | // Titre du plot
|
---|
[1131] | 771 | if (mAddTitle) {
|
---|
| 772 | if (title.length() <= 0) title = name; string t2="";
|
---|
| 773 | wd3->SetTitles(title, t2);
|
---|
| 774 | }
|
---|
[1971] | 775 |
|
---|
| 776 | wd3->AddDrawer3D(dr3, true);
|
---|
[293] | 777 | // wd3->Refresh(); ?Pas necessaire $CHECK$ 05/05/99
|
---|
[1971] | 778 |
|
---|
[165] | 779 | mCurWin = win;
|
---|
| 780 | mCurWdg = wd3;
|
---|
| 781 | mLastWdg = wd3;
|
---|
| 782 | mBWId++;
|
---|
| 783 | mBWList[mBWId] = wd3;
|
---|
| 784 | return(mBWId);
|
---|
| 785 | }
|
---|
| 786 |
|
---|
[349] | 787 | /* --Methode-- */
|
---|
[2188] | 788 | int PIStdImgApp::ExecuteExtCommand()
|
---|
| 789 | {
|
---|
| 790 | if (!fg_exc_cmd) return(0);
|
---|
| 791 | else {
|
---|
| 792 | fg_exc_cmd = false;
|
---|
| 793 | return CmdInterpreter()->Interpret(exc_command);
|
---|
| 794 | }
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | /* --Methode-- */
|
---|
[1971] | 798 | void PIStdImgApp::AddText(string const & txt, double xp, double yp, string const& sop)
|
---|
[349] | 799 | {
|
---|
[2165] | 800 | PIDrawer *eld=CurrentElDrawer();
|
---|
[1642] | 801 | if (eld == NULL) return;
|
---|
[2165] | 802 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
|
---|
| 803 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
|
---|
| 804 | if ((eld2 == NULL) && (eld3 == NULL)) return;
|
---|
| 805 | PIElDrwMgr* elmgr;
|
---|
| 806 | if (eld2) elmgr = &(eld2->ElDrwMgr());
|
---|
| 807 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
|
---|
| 808 | if (elmgr == NULL) return;
|
---|
[1642] | 809 |
|
---|
[1971] | 810 | vector<string> opts;
|
---|
| 811 | ParseDisplayOption(sop, opts);
|
---|
| 812 | PIGraphicAtt gratt(opts);
|
---|
[2243] | 813 | unsigned long tpd = 0;
|
---|
| 814 | gratt.DecodeTextPosDirAtt(opts, tpd, false);
|
---|
| 815 | elmgr->ElAddText(xp,yp,txt.c_str(), gratt, tpd);
|
---|
[1642] | 816 | eld->Refresh();
|
---|
[349] | 817 | }
|
---|
[1642] | 818 |
|
---|
[1131] | 819 | /* --Methode-- */
|
---|
[2243] | 820 | void PIStdImgApp::AddLine(double xp1, double yp1, double xp2, double yp2,
|
---|
| 821 | string const& sop, bool fgarrow)
|
---|
[1642] | 822 | {
|
---|
[2165] | 823 | PIDrawer *eld=CurrentElDrawer();
|
---|
[1642] | 824 | if (eld == NULL) return;
|
---|
[2165] | 825 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
|
---|
| 826 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
|
---|
| 827 | if ((eld2 == NULL) && (eld3 == NULL)) return;
|
---|
| 828 | PIElDrwMgr* elmgr = NULL;
|
---|
| 829 | if (eld2) elmgr = &(eld2->ElDrwMgr());
|
---|
| 830 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
|
---|
| 831 | if (elmgr == NULL) return;
|
---|
[1642] | 832 |
|
---|
[1971] | 833 | vector<string> opts;
|
---|
| 834 | ParseDisplayOption(sop, opts);
|
---|
| 835 | PIGraphicAtt gratt(opts);
|
---|
[2243] | 836 | if (fgarrow)
|
---|
| 837 | elmgr->ElAddArrow(xp1, yp1, xp2, yp2, gratt);
|
---|
| 838 | else elmgr->ElAddLine(xp1, yp1, xp2, yp2, gratt);
|
---|
[1642] | 839 | eld->Refresh();
|
---|
| 840 | }
|
---|
| 841 |
|
---|
| 842 | /* --Methode-- */
|
---|
[1971] | 843 | void PIStdImgApp::AddRectangle(double xp1, double yp1, double xp2, double yp2,
|
---|
| 844 | string const& sop, bool fgfill)
|
---|
[1642] | 845 | {
|
---|
[2165] | 846 | PIDrawer *eld=CurrentElDrawer();
|
---|
[1642] | 847 | if (eld == NULL) return;
|
---|
[2165] | 848 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
|
---|
| 849 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
|
---|
| 850 | if ((eld2 == NULL) && (eld3 == NULL)) return;
|
---|
| 851 | PIElDrwMgr* elmgr = NULL;
|
---|
| 852 | if (eld2) elmgr = &(eld2->ElDrwMgr());
|
---|
| 853 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
|
---|
[1642] | 854 |
|
---|
| 855 | double xp,yp;
|
---|
| 856 | double dx, dy;
|
---|
| 857 | if (xp1 < xp2) {
|
---|
| 858 | xp = xp1; dx = xp2-xp1;
|
---|
| 859 | }
|
---|
| 860 | else {
|
---|
| 861 | xp = xp2; dx = xp1-xp2;
|
---|
| 862 | }
|
---|
| 863 | if (yp1 < yp2) {
|
---|
| 864 | yp = yp1; dy = yp2-yp1;
|
---|
| 865 | }
|
---|
| 866 | else {
|
---|
| 867 | yp = yp2; dy = yp1-yp2;
|
---|
| 868 | }
|
---|
[1971] | 869 |
|
---|
| 870 | vector<string> opts;
|
---|
| 871 | ParseDisplayOption(sop, opts);
|
---|
| 872 | PIGraphicAtt gratt(opts);
|
---|
| 873 |
|
---|
[2165] | 874 | if (fgfill) elmgr->ElAddFRect(xp, yp, dx, dy, gratt);
|
---|
| 875 | else elmgr->ElAddRect(xp, yp, dx, dy, gratt);
|
---|
[1642] | 876 | eld->Refresh();
|
---|
| 877 | }
|
---|
| 878 |
|
---|
| 879 | /* --Methode-- */
|
---|
[1971] | 880 | void PIStdImgApp::AddCircle(double xc, double yc, double r, string const& sop, bool fgfill)
|
---|
[1642] | 881 | {
|
---|
[2165] | 882 | PIDrawer *eld=CurrentElDrawer();
|
---|
[1642] | 883 | if (eld == NULL) return;
|
---|
[2165] | 884 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
|
---|
| 885 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
|
---|
| 886 | if ((eld2 == NULL) && (eld3 == NULL)) return;
|
---|
| 887 | PIElDrwMgr* elmgr = NULL;
|
---|
| 888 | if (eld2) elmgr = &(eld2->ElDrwMgr());
|
---|
| 889 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
|
---|
[1642] | 890 |
|
---|
[1971] | 891 | vector<string> opts;
|
---|
| 892 | ParseDisplayOption(sop, opts);
|
---|
| 893 | PIGraphicAtt gratt(opts);
|
---|
[2243] | 894 | if (r < -0.5)
|
---|
| 895 | elmgr->ElAddMarker(xc, yc, gratt);
|
---|
| 896 | else {
|
---|
| 897 | if (fgfill) elmgr->ElAddFCirc(xc, yc, r, gratt);
|
---|
| 898 | else elmgr->ElAddCirc(xc, yc, r, gratt);
|
---|
| 899 | }
|
---|
| 900 | eld->Refresh();
|
---|
| 901 | }
|
---|
[1971] | 902 |
|
---|
[2243] | 903 | /* --Methode-- */
|
---|
| 904 | void PIStdImgApp::AddArc(double x1, double y1, double x2, double y2,
|
---|
| 905 | double x3, double y3, string const& sop, bool fgfill)
|
---|
| 906 | {
|
---|
| 907 | PIDrawer *eld=CurrentElDrawer();
|
---|
| 908 | if (eld == NULL) return;
|
---|
| 909 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
|
---|
| 910 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
|
---|
| 911 | if ((eld2 == NULL) && (eld3 == NULL)) return;
|
---|
| 912 | PIElDrwMgr* elmgr = NULL;
|
---|
| 913 | if (eld2) elmgr = &(eld2->ElDrwMgr());
|
---|
| 914 | else if (eld3) elmgr = &(eld3->ElDrwMgr());
|
---|
| 915 | if (elmgr == NULL) return;
|
---|
| 916 |
|
---|
| 917 | vector<string> opts;
|
---|
| 918 | ParseDisplayOption(sop, opts);
|
---|
| 919 | PIGraphicAtt gratt(opts);
|
---|
| 920 | if (fgfill)
|
---|
| 921 | elmgr->ElAddFArc(x1, y1, x2, y2, x3, y3, gratt);
|
---|
| 922 | else elmgr->ElAddArc(x1, y1, x2, y2, x3, y3, gratt);
|
---|
[1642] | 923 | eld->Refresh();
|
---|
| 924 | }
|
---|
| 925 |
|
---|
| 926 | /* --Methode-- */
|
---|
[2165] | 927 | void PIStdImgApp::SetTitle(string const & titletop, string const & titlebottom, string const& sop)
|
---|
[1131] | 928 | {
|
---|
[2165] | 929 | PIDrawer *eld=CurrentElDrawer();
|
---|
[1642] | 930 | if (eld == NULL) return;
|
---|
[2165] | 931 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
|
---|
| 932 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
|
---|
| 933 | if ((eld2 == NULL) && (eld3 == NULL)) return;
|
---|
[1642] | 934 |
|
---|
[2165] | 935 | vector<string> opts;
|
---|
| 936 | ParseDisplayOption(sop, opts);
|
---|
| 937 | PIGraphicAtt gratt(opts);
|
---|
| 938 |
|
---|
| 939 | if (eld2) {
|
---|
| 940 | eld2->SetTitles(titletop, titlebottom, gratt);
|
---|
| 941 | eld2->ShowTitles(true);
|
---|
| 942 | }
|
---|
| 943 | else if (eld3) {
|
---|
| 944 | eld3->SetTitles(titletop, titlebottom, gratt);
|
---|
| 945 | eld3->ShowTitles(true);
|
---|
| 946 | }
|
---|
[1642] | 947 | eld->Refresh();
|
---|
| 948 | }
|
---|
[2165] | 949 | /* --Methode-- */
|
---|
| 950 | void PIStdImgApp::SetAxeLabels(string const & xLabel, string const & yLabel, string const& sop)
|
---|
| 951 | {
|
---|
| 952 | PIDrawer *eld=CurrentElDrawer();
|
---|
| 953 | if (eld == NULL) return;
|
---|
| 954 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
|
---|
| 955 | if (eld2 == NULL) return;
|
---|
[1642] | 956 |
|
---|
[2165] | 957 | vector<string> opts;
|
---|
| 958 | ParseDisplayOption(sop, opts);
|
---|
| 959 | PIGraphicAtt gratt(opts);
|
---|
| 960 |
|
---|
| 961 | eld2->SetAxesLabels(xLabel, yLabel, gratt);
|
---|
| 962 | eld2->ShowAxesLabels(true);
|
---|
| 963 |
|
---|
| 964 | eld->Refresh();
|
---|
| 965 | }
|
---|
| 966 |
|
---|
[1642] | 967 | /* --Methode-- */
|
---|
[2165] | 968 | PIDrawer* PIStdImgApp::CurrentElDrawer()
|
---|
[1642] | 969 | {
|
---|
[2165] | 970 | PIDrawer *eld=NULL;
|
---|
[1642] | 971 | if (!mLastWdg) return(eld);
|
---|
[1131] | 972 | PIScDrawWdg* sdw=NULL;
|
---|
| 973 | PIDraw3DWdg* w3d=NULL;
|
---|
| 974 | PIImage* imgw;
|
---|
| 975 | switch(mLastWdg->kind()) {
|
---|
| 976 | case PIScDrawWdg::ClassId :
|
---|
| 977 | sdw = dynamic_cast<PIScDrawWdg *>(mLastWdg);
|
---|
| 978 | if (sdw) eld = sdw->BaseDrawer();
|
---|
| 979 | break;
|
---|
| 980 | case PIDraw3DWdg::ClassId :
|
---|
| 981 | w3d = dynamic_cast<PIDraw3DWdg *>(mLastWdg);
|
---|
| 982 | if (w3d) eld = w3d->BaseDrawer();
|
---|
| 983 | break;
|
---|
| 984 | case PIImage::ClassId :
|
---|
| 985 | imgw = dynamic_cast<PIImage *>(mLastWdg);
|
---|
[1642] | 986 | if (imgw) eld = imgw->BaseDrawer();
|
---|
[1131] | 987 | break;
|
---|
| 988 | default :
|
---|
| 989 | break;
|
---|
| 990 | }
|
---|
[1642] | 991 | return(eld);
|
---|
[1131] | 992 | }
|
---|
[165] | 993 |
|
---|
| 994 | /* --Methode-- */
|
---|
| 995 | void PIStdImgApp::CreateGraphWin(int nx, int ny, int sx, int sy)
|
---|
| 996 | {
|
---|
| 997 | if (nx < 1) nx = 1;
|
---|
| 998 | if (ny < 1) ny = 1;
|
---|
| 999 | if (nx > 8) nx = 8;
|
---|
| 1000 | if (ny > 8) ny = 8;
|
---|
| 1001 | if ( (sx < 50) && (sy < 50) ) sx = sy = 400+mFgScSz*100;
|
---|
| 1002 | char buff[64];
|
---|
| 1003 | mWId++;
|
---|
[210] | 1004 | int px, py;
|
---|
| 1005 | MainWin()->GetScreenPos(px, py);
|
---|
| 1006 | sprintf(buff, "PI-GraphicWin (%d)",mWId);
|
---|
| 1007 | PIZoneWindow* win = new PIZoneWindow(this, buff, PIWK_normal, nx, ny, sx, sy, px+MainWin()->XSize()+30, 0);
|
---|
[165] | 1008 | win->SetUserData(NULL, ny*10+nx); // UserFlag= nY*10 + nX
|
---|
| 1009 | mWList[mWId*10+1] = (PIWindow*)win;
|
---|
| 1010 | win->SetAutoDelChilds(true);
|
---|
[293] | 1011 | // win->Show();
|
---|
[165] | 1012 | mGrW = win;
|
---|
| 1013 | mGrIdx = 0;
|
---|
| 1014 | }
|
---|
| 1015 |
|
---|
| 1016 | /* --Methode-- */
|
---|
| 1017 | void PIStdImgApp::CreateStackWin(int sx, int sy)
|
---|
| 1018 | {
|
---|
| 1019 | if ( (sx < 50) && (sy < 50) ) sx = sy = 300+mFgScSz*100;
|
---|
| 1020 | char buff[64];
|
---|
| 1021 | mWId++;
|
---|
[210] | 1022 | int px, py;
|
---|
| 1023 | MainWin()->GetScreenPos(px, py);
|
---|
[165] | 1024 | sprintf(buff, "PI-StackWin (%d)",mWId);
|
---|
[210] | 1025 | PIStackWindow* win = new PIStackWindow(this, buff, PIWK_normal, sx, sy, px+MainWin()->XSize()+30, 100);
|
---|
[165] | 1026 | win->SetUserData(NULL, 9999); // UserFlag= 9999
|
---|
| 1027 | mWList[mWId*10+2] = (PIWindow*)win;
|
---|
| 1028 | win->SetAutoDelChilds(true);
|
---|
[293] | 1029 | // win->Show();
|
---|
[165] | 1030 | mStW = win;
|
---|
| 1031 | m[2]->SetSensitivity("StackTools", true);
|
---|
| 1032 | mStIdx = 0;
|
---|
| 1033 | }
|
---|
| 1034 |
|
---|
| 1035 | /* --Methode-- */
|
---|
[1971] | 1036 | PIWindow* PIStdImgApp::GetWindow(DispWinEnum typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom)
|
---|
[165] | 1037 | {
|
---|
| 1038 | PIWindow* rw;
|
---|
| 1039 |
|
---|
| 1040 | switch (typ) {
|
---|
| 1041 | case Disp_Next : // Fenetre graphique courante
|
---|
[1971] | 1042 | case Disp_Default :
|
---|
[165] | 1043 | {
|
---|
| 1044 | if (mGrW == NULL) CreateGraphWin();
|
---|
| 1045 | int nx, ny;
|
---|
| 1046 | mGrW->NbZone(nx, ny);
|
---|
| 1047 | PIWdg* nw = mGrW->NextChildPosSize(px, py, sx, sy);
|
---|
| 1048 | // cerr << "**DBG** PIStdImgApp::GetWindow() DispNext : nw = " << (long)nw << endl;
|
---|
| 1049 | if (nw) DeleteBaseWidget((PIBaseWdg*)nw, false, false);
|
---|
| 1050 | flag = mGrIdx;
|
---|
| 1051 | mGrIdx = (mGrIdx+1)%(nx*ny);
|
---|
| 1052 | rw = mGrW;
|
---|
| 1053 | break;
|
---|
| 1054 | }
|
---|
| 1055 |
|
---|
| 1056 | case Disp_Stack : // Fenetre de type stack (empilement)
|
---|
| 1057 | {
|
---|
| 1058 | if (mStW == NULL) CreateStackWin(sx, sy);
|
---|
| 1059 | px = py = 0;
|
---|
| 1060 | sx = mStW->XSize();
|
---|
| 1061 | sy = mStW->YSize();
|
---|
| 1062 | flag = mStIdx;
|
---|
| 1063 | mStIdx++;
|
---|
| 1064 | rw = mStW;
|
---|
| 1065 | }
|
---|
| 1066 | break;
|
---|
| 1067 |
|
---|
| 1068 | default : // Fenetre ordinaire
|
---|
| 1069 | {
|
---|
[210] | 1070 | int pwx, pwy;
|
---|
| 1071 | MainWin()->GetScreenPos(pwx, pwy);
|
---|
[165] | 1072 | if ( (sx < 50) && (sy < 50) ) sx = sy = 300+mFgScSz*100;
|
---|
[210] | 1073 | rw = new PIWindow(this, nom, PIWK_normal, sx, sy, pwx+MainWin()->XSize()+30, 300);
|
---|
[165] | 1074 | rw->SetUserData(NULL, 0); // UserFlag= 0
|
---|
| 1075 | mWId++;
|
---|
| 1076 | mWList[mWId*10] = rw;
|
---|
| 1077 | rw->SetAutoDelChilds(true);
|
---|
[293] | 1078 | // rw->Show();
|
---|
[165] | 1079 | px = py = 0;
|
---|
| 1080 | flag = 0;
|
---|
| 1081 | break;
|
---|
| 1082 | }
|
---|
| 1083 | }
|
---|
| 1084 |
|
---|
[293] | 1085 | rw->Show();
|
---|
[165] | 1086 | mCurWin = rw;
|
---|
| 1087 | return(rw);
|
---|
| 1088 | }
|
---|
| 1089 |
|
---|
| 1090 | /* --Methode-- */
|
---|
| 1091 | void PIStdImgApp::SetZone(int nzx, int nzy)
|
---|
| 1092 | {
|
---|
| 1093 | if (!mGrW) CreateGraphWin(nzx, nzy);
|
---|
| 1094 | else {
|
---|
| 1095 | int k;
|
---|
| 1096 | PIWdg* cwd;
|
---|
| 1097 | for(k=0; k<mGrW->NbChilds(); k++) {
|
---|
| 1098 | if ((cwd = mGrW->GetChild(k)) == NULL) continue;
|
---|
| 1099 | DeleteBaseWidget((PIBaseWdg*)cwd, false, false);
|
---|
| 1100 | }
|
---|
| 1101 | mGrW->SetZone(nzx, nzy);
|
---|
| 1102 | }
|
---|
| 1103 | }
|
---|
| 1104 |
|
---|
| 1105 | /* --Methode-- */
|
---|
| 1106 | void PIStdImgApp::StackWinNext()
|
---|
| 1107 | {
|
---|
| 1108 | if (mStW) mStW->DispNext();
|
---|
| 1109 | }
|
---|
| 1110 |
|
---|
| 1111 | /* --Methode-- */
|
---|
| 1112 | void PIStdImgApp::DeleteWindow(PIWindow* w)
|
---|
| 1113 | {
|
---|
| 1114 | if (w == NULL) return;
|
---|
| 1115 | w->Hide();
|
---|
[344] | 1116 | bool ownwindow=false; // To Check if this is one of our windows
|
---|
[165] | 1117 | WindMList::iterator it;
|
---|
| 1118 | for(it = mWList.begin(); it != mWList.end(); it++)
|
---|
[344] | 1119 | if ((*it).second == w) { mWList.erase(it); ownwindow = true; break; }
|
---|
[165] | 1120 | if (w == mGrW) { mGrW = NULL; mGrIdx = -1; }
|
---|
| 1121 | if (w == mStW) { mStW = NULL; mStIdx = -1; m[2]->SetSensitivity("StackTools", false); }
|
---|
| 1122 | if (w == mCurWin) mCurWin = NULL;
|
---|
[344] | 1123 |
|
---|
| 1124 | if (!ownwindow) return; // We do nothing if this is not a window we have created ...
|
---|
| 1125 |
|
---|
[165] | 1126 | int k;
|
---|
| 1127 | PIWdg* cwd;
|
---|
| 1128 | for(k=0; k<w->NbChilds(); k++) {
|
---|
| 1129 | if ((cwd = w->GetChild(k)) == NULL) continue;
|
---|
| 1130 | DeleteBaseWidget((PIBaseWdg*)cwd,false,false);
|
---|
| 1131 | }
|
---|
| 1132 | delete w;
|
---|
| 1133 | return;
|
---|
| 1134 | }
|
---|
| 1135 |
|
---|
| 1136 | /* --Methode-- */
|
---|
| 1137 | void PIStdImgApp::DeleteBaseWidget(PIBaseWdg* w, bool dw, bool dwin)
|
---|
| 1138 | {
|
---|
| 1139 | if (w == NULL) return;
|
---|
| 1140 | BWMList::iterator it;
|
---|
| 1141 | for(it = mBWList.begin(); it != mBWList.end(); it++)
|
---|
| 1142 | if ((*it).second == w) { mBWList.erase(it); break; }
|
---|
| 1143 | int k;
|
---|
| 1144 | PIDrawer* drw;
|
---|
| 1145 | for(k=0; k<w->NbDrawers(); k++) {
|
---|
| 1146 | if ((drw = w->GetDrawer(k)) == NULL) continue;
|
---|
| 1147 | DrwMList::iterator itt;
|
---|
| 1148 | for(itt = mDrwList.begin(); itt != mDrwList.end(); itt++)
|
---|
| 1149 | if ((*itt).second == drw) { mDrwList.erase(itt); break; }
|
---|
| 1150 | }
|
---|
| 1151 |
|
---|
| 1152 | if (w == mCurWdg) {
|
---|
| 1153 | mCurWdg = NULL;
|
---|
| 1154 | if (mFgCWImg) {
|
---|
| 1155 | m[4]->SetSensitivityMsg(10515, false);
|
---|
| 1156 | m[4]->SetSensitivityMsg(10516, false);
|
---|
| 1157 | mFgCWImg = false;
|
---|
| 1158 | }
|
---|
| 1159 | }
|
---|
| 1160 |
|
---|
| 1161 | if (w == mLastWdg) mLastWdg = NULL;
|
---|
| 1162 |
|
---|
| 1163 | PIWdg* pw=NULL;
|
---|
| 1164 | if (dwin) pw = (PIWdg*)(w->Parent());
|
---|
| 1165 | //DBG printf("DeleteBaseWidget(%lx)-DBG kind = %d - %d %d \n", (long)w, w->kind(), (int)dw, (int)dwin);
|
---|
| 1166 | if (dw) delete w;
|
---|
| 1167 | if (pw && (pw->kind() == PIWindow::ClassId )) {
|
---|
| 1168 | PIWindow* pww = (PIWindow*) pw;
|
---|
| 1169 | if ((pww != (PIWindow*)mGrW) && (pww != (PIWindow*)mStW) && (pww->NbChilds()==0))
|
---|
| 1170 | DeleteWindow((PIWindow*)pw);
|
---|
| 1171 | }
|
---|
| 1172 | return;
|
---|
| 1173 | }
|
---|
| 1174 |
|
---|
| 1175 |
|
---|
| 1176 |
|
---|
| 1177 | /* --Methode-- */
|
---|
| 1178 | void PIStdImgApp::DelWRsId(int k)
|
---|
| 1179 | {
|
---|
| 1180 | //DBG cerr << "-DBG- PIStdImgApp::DelWRsId(" << k << ")" << endl;
|
---|
| 1181 | if (k > 0) { // C'est un BaseWidget
|
---|
| 1182 | BWMList::iterator it;
|
---|
| 1183 | it = mBWList.find(k);
|
---|
| 1184 | if (it == mBWList.end()) return;
|
---|
| 1185 | PIBaseWdg* wd = (*it).second;
|
---|
| 1186 | //DBG cerr << "-DBG- PIStdImgApp::DelWRsId Deleting BaseWidget " << (long)(wd) << endl ;
|
---|
| 1187 | DeleteBaseWidget(wd, true, true);
|
---|
| 1188 | }
|
---|
| 1189 | else { // C'est un drawer
|
---|
| 1190 | DrwMList::iterator it;
|
---|
| 1191 | it = mDrwList.find(-k);
|
---|
| 1192 | if (it == mDrwList.end()) return;
|
---|
[2231] | 1193 | (*it).second->SetAutoRefreshOnDelete(true);
|
---|
[165] | 1194 | delete (*it).second;
|
---|
| 1195 | mDrwList.erase(it);
|
---|
| 1196 | // cerr << "+DBG+ PIStdImgApp::DelWRsId Deleting Drawer " << (long)((*it).second) << endl ;
|
---|
| 1197 | }
|
---|
| 1198 | }
|
---|
[368] | 1199 | /* --Methode-- */
|
---|
| 1200 | bool PIStdImgApp::CheckWRsId(int k)
|
---|
| 1201 | {
|
---|
| 1202 | if (k > 0) { // C'est un BaseWidget
|
---|
| 1203 | BWMList::iterator it;
|
---|
| 1204 | it = mBWList.find(k);
|
---|
| 1205 | if (it == mBWList.end()) return(false);
|
---|
| 1206 | else return(true);
|
---|
| 1207 | }
|
---|
| 1208 | else { // C'est un drawer
|
---|
| 1209 | DrwMList::iterator it;
|
---|
| 1210 | it = mDrwList.find(-k);
|
---|
| 1211 | if (it == mDrwList.end()) return(false);
|
---|
| 1212 | else return(true);
|
---|
| 1213 | }
|
---|
| 1214 | }
|
---|
[165] | 1215 |
|
---|
[1971] | 1216 | /* --Methode-- */
|
---|
| 1217 | void PIStdImgApp::StatZoomWindowSetVisible(bool fg)
|
---|
| 1218 | {
|
---|
[165] | 1219 |
|
---|
[1971] | 1220 | if (fg) {
|
---|
| 1221 | consolecont->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free);
|
---|
| 1222 | int szy = MainWin()->YSize();
|
---|
| 1223 | MainWin()->SetSize(MainWin()->XSize(), szy+statcont->YSize());
|
---|
| 1224 | consolecont->SetPos(0, statcont->YSize());
|
---|
| 1225 | consolecont->SetSize(MainWin()->XSize(), szy);
|
---|
| 1226 | consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
|
---|
| 1227 | statcont->Show();
|
---|
| 1228 | m[3]->SetStateMsg(10470, true);
|
---|
| 1229 | }
|
---|
| 1230 | else {
|
---|
| 1231 | statcont->Hide();
|
---|
| 1232 | consolecont->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free);
|
---|
| 1233 | MainWin()->SetSize(MainWin()->XSize(), MainWin()->YSize()-statcont->YSize());
|
---|
| 1234 | consolecont->SetPos(0, 0);
|
---|
| 1235 | consolecont->SetSize(MainWin()->XSize(), MainWin()->YSize());
|
---|
| 1236 | consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
|
---|
| 1237 | m[3]->SetStateMsg(10470, false);
|
---|
| 1238 | }
|
---|
| 1239 |
|
---|
| 1240 | }
|
---|
| 1241 |
|
---|
[165] | 1242 | /* --Methode-- */
|
---|
[2106] | 1243 | void PIStdImgApp::UpdateStatResourceInfo()
|
---|
| 1244 | {
|
---|
| 1245 | resusg.Update();
|
---|
| 1246 | char buff[256];
|
---|
| 1247 | string lab;
|
---|
| 1248 | double frac;
|
---|
[2158] | 1249 | sprintf(buff, "Mem: %ld/Max= %ld kb" , (long)resusg.getMemorySize(),
|
---|
| 1250 | (long)resusg.getMaxMemorySize());
|
---|
[2106] | 1251 | lab = buff;
|
---|
| 1252 | lab_mem->SetLabel(lab);
|
---|
| 1253 | frac = (double)resusg.getMemorySize()/(double)resusg.getMaxMemorySize();
|
---|
| 1254 | therm_mem->SetValue(frac);
|
---|
| 1255 |
|
---|
[2158] | 1256 | sprintf(buff, "CPU: %ld/elap= %ld ms" , (long)resusg.getCPUTime(),
|
---|
| 1257 | (long)resusg.getElapsedTime());
|
---|
[2106] | 1258 | lab = buff;
|
---|
| 1259 | lab_cpu->SetLabel(lab);
|
---|
[2158] | 1260 | therm_cpu->SetValue(resusg.getCPULoad());
|
---|
[2106] | 1261 |
|
---|
| 1262 | }
|
---|
| 1263 |
|
---|
| 1264 | /* --Methode-- */
|
---|
[165] | 1265 | void PIStdImgApp::RedirectStdOutErr(bool fg)
|
---|
| 1266 | {
|
---|
| 1267 | if (fg) {
|
---|
| 1268 | RedirectOutStream(mCons);
|
---|
| 1269 | RedirectErrStream(mCons);
|
---|
| 1270 | m[5]->SetStateMsg(10602, true);
|
---|
[293] | 1271 | redirecout = true;
|
---|
[165] | 1272 | }
|
---|
| 1273 | else {
|
---|
| 1274 | RedirectOutStream(NULL);
|
---|
| 1275 | RedirectErrStream(NULL);
|
---|
| 1276 | m[5]->SetStateMsg(10602, false);
|
---|
[293] | 1277 | redirecout = false;
|
---|
[165] | 1278 | }
|
---|
| 1279 | return;
|
---|
| 1280 | }
|
---|
| 1281 |
|
---|
| 1282 | /* --Methode-- */
|
---|
[374] | 1283 | void PIStdImgApp::CatchSignals(bool fgfpe, bool fgsegv)
|
---|
[165] | 1284 | {
|
---|
[912] | 1285 | #ifdef SANS_EVOLPLANCK
|
---|
[374] | 1286 | PeidaConfigureSignalhandling(fgfpe, fgsegv, true, true);
|
---|
[912] | 1287 | #else
|
---|
| 1288 | SophyaConfigureSignalhandling(fgfpe, fgsegv, true, true);
|
---|
| 1289 | #endif
|
---|
[374] | 1290 | m[5]->SetStateMsg(10603, fgfpe);
|
---|
| 1291 | m[5]->SetStateMsg(10604, fgsegv);
|
---|
[165] | 1292 | }
|
---|
| 1293 |
|
---|
| 1294 | /* --Methode-- */
|
---|
| 1295 | void PIStdImgApp::CloseAllWindows()
|
---|
| 1296 | {
|
---|
| 1297 | WindMList::iterator it;
|
---|
| 1298 | for(it = mWList.begin(); it != mWList.end(); it++) delete (*it).second;
|
---|
| 1299 | mWList.clear();
|
---|
| 1300 | mBWList.clear();
|
---|
| 1301 | mDrwList.clear();
|
---|
[454] | 1302 | mGrW = NULL;
|
---|
| 1303 | mStW = NULL;
|
---|
| 1304 | mCurWin = NULL;
|
---|
| 1305 | mCurWdg = NULL;
|
---|
| 1306 | mLastWdg = NULL;
|
---|
| 1307 | m[4]->SetSensitivityMsg(10515, false);
|
---|
| 1308 | m[4]->SetSensitivityMsg(10516, false);
|
---|
[165] | 1309 | }
|
---|
| 1310 |
|
---|
[1971] | 1311 | //---------------------------------------------------------------------------
|
---|
| 1312 | //--------- Gestion des attributs graphiques et autres options de trace -----
|
---|
| 1313 |
|
---|
[165] | 1314 | /* --Methode-- */
|
---|
[1971] | 1315 | void PIStdImgApp::SetInsetLimits(double xmin, double xmax, double ymin, double ymax)
|
---|
| 1316 | {
|
---|
| 1317 | mIXmin = xmin; mIXmax= xmax;
|
---|
| 1318 | mIYmin = ymin; mIYmax= ymax;
|
---|
| 1319 | }
|
---|
| 1320 |
|
---|
| 1321 | /* --Methode-- */
|
---|
| 1322 | void PIStdImgApp::SetDefaultGraphicAttributes(string const & opt)
|
---|
| 1323 | {
|
---|
| 1324 | ParseDisplayOption(opt, mDefaultAtt);
|
---|
| 1325 | }
|
---|
| 1326 |
|
---|
| 1327 | /* --Methode-- */
|
---|
| 1328 | void PIStdImgApp::SetDefaultAxesAttributes(string const & opt)
|
---|
| 1329 | {
|
---|
| 1330 | ParseDisplayOption(opt, mAxesAtt);
|
---|
| 1331 | }
|
---|
| 1332 |
|
---|
| 1333 | /* --Methode-- */
|
---|
| 1334 | DispWinEnum PIStdImgApp::ParseDisplayOption(string const & sop, vector<string>& opts)
|
---|
| 1335 | {
|
---|
| 1336 | DispWinEnum rc = Disp_Next;
|
---|
| 1337 | //DBG cerr << " DBG-Parse-A sop=" << sop << " sop.length()= " << sop.length() << endl;
|
---|
| 1338 | if (opts.size() > 0) opts.erase(opts.begin(), opts.end());
|
---|
| 1339 | if (sop.length() < 1) return(rc);
|
---|
| 1340 | string gratt = sop;
|
---|
| 1341 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
|
---|
| 1342 | if ( (gratt == "def") || (gratt == "default") ) return(rc);
|
---|
| 1343 | // On separe en mots espaces par des blancs ou tabulation
|
---|
| 1344 | size_t p = 0;
|
---|
| 1345 | size_t q = 0;
|
---|
| 1346 | size_t l = gratt.length();
|
---|
| 1347 | string token;
|
---|
| 1348 | while (q < l) {
|
---|
| 1349 | p = gratt.find_first_not_of(" \t",q); // au debut d'un token
|
---|
| 1350 | if (p >= l) break;
|
---|
| 1351 | q = gratt.find_first_of(" \t",p); // Premier blanc ou tab suivant
|
---|
| 1352 | if (q<l) token = gratt.substr(p,q-p);
|
---|
| 1353 | else token = gratt.substr(p);
|
---|
| 1354 | if (token == "") continue;
|
---|
| 1355 | // Decodage option fenetre d'affichage (win, next, ...)
|
---|
| 1356 | if (token == "win") rc = Disp_Win;
|
---|
| 1357 | else if (token == "same") rc = Disp_Same;
|
---|
| 1358 | else if (token == "inset") rc = Disp_Inset;
|
---|
| 1359 | else if (token == "stack") rc = Disp_Stack;
|
---|
[2118] | 1360 | else if (token == "next") rc = Disp_Next;
|
---|
[1971] | 1361 | // Option a etre decode par les drawers, etc ...
|
---|
| 1362 | else opts.push_back(token);
|
---|
| 1363 | }
|
---|
| 1364 |
|
---|
| 1365 | //DBG cerr << " DBG-Parse-B opts.size()=" << opts.size() << endl;
|
---|
| 1366 | return (rc);
|
---|
| 1367 | }
|
---|
| 1368 |
|
---|
| 1369 | //---------------------------------------------------------------------------
|
---|
| 1370 | //------------ Methodes privees (MBProcessx, ...) ----------
|
---|
| 1371 |
|
---|
| 1372 | /* --Methode-- */
|
---|
[165] | 1373 | void PIStdImgApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
| 1374 | {
|
---|
| 1375 |
|
---|
| 1376 | switch(msg)
|
---|
| 1377 | {
|
---|
[686] | 1378 | case 10150 :
|
---|
| 1379 | showInfoWindow(this);
|
---|
| 1380 | break;
|
---|
| 1381 |
|
---|
| 1382 | case 10155 :
|
---|
| 1383 | hideInfoWindow(this);
|
---|
| 1384 | break;
|
---|
| 1385 |
|
---|
[293] | 1386 | case 10100 :
|
---|
| 1387 | mCmd->ShowHelpWindow();
|
---|
| 1388 | break;
|
---|
| 1389 |
|
---|
[165] | 1390 | case 10120 :
|
---|
[685] | 1391 | pfc_fits->AcceptNewFile(false);
|
---|
[165] | 1392 | mFCMsg = 10125;
|
---|
[685] | 1393 | pfc_fits->SetMsg(mFCMsg);
|
---|
[165] | 1394 | SetBlocked();
|
---|
[685] | 1395 | pfc_fits->Show();
|
---|
[165] | 1396 | break;
|
---|
| 1397 |
|
---|
| 1398 | case 10125 :
|
---|
| 1399 | SetBusy();
|
---|
| 1400 | if (data) {
|
---|
[331] | 1401 | string nomobj="";
|
---|
[685] | 1402 | ObjMgr()->ReadFits(pfc_fits->GetFileName(), nomobj);
|
---|
[331] | 1403 | ObjMgr()->DisplayObj(nomobj, "win");
|
---|
[165] | 1404 | }
|
---|
| 1405 | mFCMsg = 0;
|
---|
| 1406 | SetReady();
|
---|
| 1407 | break;
|
---|
| 1408 |
|
---|
| 1409 | case 10130 :
|
---|
[685] | 1410 | pfc_ppf->AcceptNewFile(false);
|
---|
[165] | 1411 | mFCMsg = 10135;
|
---|
[685] | 1412 | pfc_ppf->SetMsg(mFCMsg);
|
---|
[165] | 1413 | SetBlocked();
|
---|
[685] | 1414 | pfc_ppf->Show();
|
---|
[165] | 1415 | break;
|
---|
| 1416 |
|
---|
| 1417 | case 10135 :
|
---|
| 1418 | mFCMsg = 0;
|
---|
| 1419 | if (data) {
|
---|
[685] | 1420 | PPInMgrW()->SetFile(pfc_ppf->GetFileName());
|
---|
[165] | 1421 | PPInMgrW()->Show();
|
---|
| 1422 | }
|
---|
| 1423 | SetReady();
|
---|
| 1424 | break;
|
---|
| 1425 |
|
---|
| 1426 | case 10105:
|
---|
| 1427 | Stop();
|
---|
| 1428 | break;
|
---|
| 1429 |
|
---|
| 1430 | }
|
---|
| 1431 | return;
|
---|
| 1432 | }
|
---|
| 1433 |
|
---|
| 1434 |
|
---|
| 1435 |
|
---|
| 1436 | /* --Methode-- */
|
---|
| 1437 | void PIStdImgApp::MBProcess2(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
| 1438 | {
|
---|
| 1439 |
|
---|
| 1440 | switch (msg) {
|
---|
| 1441 | case 10201 :
|
---|
| 1442 | ObjMgrW()->Show();
|
---|
| 1443 | break;
|
---|
| 1444 |
|
---|
| 1445 | case 10220 :
|
---|
[685] | 1446 | pfc_ppf->AcceptNewFile(true);
|
---|
[165] | 1447 | mFCMsg = 10225;
|
---|
[685] | 1448 | pfc_ppf->SetMsg(mFCMsg);
|
---|
[165] | 1449 | SetBlocked();
|
---|
[685] | 1450 | pfc_ppf->Show();
|
---|
[165] | 1451 | break;
|
---|
| 1452 |
|
---|
| 1453 | case 10225 :
|
---|
| 1454 | SetBusy();
|
---|
| 1455 | if (data) {
|
---|
| 1456 | if (mPpfout) {
|
---|
| 1457 | printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
|
---|
| 1458 | delete mPpfout;
|
---|
| 1459 | }
|
---|
[685] | 1460 | name_outppf = pfc_ppf->GetFileName();
|
---|
[165] | 1461 | mPpfout = NULL;
|
---|
| 1462 | printf("PIStdImg/Info: Opening POutPersist-File %s \n", name_outppf.c_str());
|
---|
| 1463 | mPpfout = new POutPersist(name_outppf);
|
---|
| 1464 | }
|
---|
| 1465 | mFCMsg = 0;
|
---|
| 1466 | SetReady();
|
---|
| 1467 | break;
|
---|
| 1468 |
|
---|
| 1469 | case 10230 :
|
---|
| 1470 | if (!mPpfout) break;
|
---|
| 1471 | printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
|
---|
| 1472 | delete mPpfout;
|
---|
| 1473 | name_outppf = "";
|
---|
| 1474 | mPpfout = NULL;
|
---|
| 1475 | break;
|
---|
| 1476 |
|
---|
[686] | 1477 | case 10270 :
|
---|
| 1478 | if (mCurWdg) {
|
---|
| 1479 | int oid = mCurWdg->UserFlag();
|
---|
| 1480 | DeleteBaseWidget(mCurWdg);
|
---|
| 1481 | mObjMgr->DelObj_Id(oid);
|
---|
| 1482 | }
|
---|
| 1483 | break;
|
---|
[165] | 1484 |
|
---|
| 1485 | default:
|
---|
| 1486 | cerr << "PIStdImgApp::MBProcess2() BUG?? Msg= " << msg << endl;
|
---|
| 1487 | break;
|
---|
| 1488 | }
|
---|
| 1489 |
|
---|
| 1490 | return;
|
---|
| 1491 | }
|
---|
| 1492 |
|
---|
| 1493 | /* --Methode-- */
|
---|
| 1494 | void PIStdImgApp::MBProcess3(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
|
---|
| 1495 | {
|
---|
| 1496 |
|
---|
| 1497 | switch (msg) {
|
---|
| 1498 | case 10301 :
|
---|
| 1499 | PIImgTools::ShowPIImgTools();
|
---|
| 1500 | break;
|
---|
| 1501 | case 10302 :
|
---|
| 1502 | PIDrwTools::ShowPIDrwTools();
|
---|
| 1503 | break;
|
---|
[1590] | 1504 | case 10303 :
|
---|
| 1505 | PIAxesTools::ShowPIAxesTools();
|
---|
| 1506 | break;
|
---|
[165] | 1507 |
|
---|
[1590] | 1508 | case 10304 :
|
---|
[1251] | 1509 | mCmd->ShowCxxExecWindow();
|
---|
| 1510 | break;
|
---|
| 1511 |
|
---|
[1590] | 1512 | case 10311 :
|
---|
| 1513 | case 10312 :
|
---|
[165] | 1514 | {
|
---|
| 1515 | PIImage* curpimg = NULL;
|
---|
| 1516 | if (!mCurWdg) return;
|
---|
| 1517 | if (mCurWdg->kind() != PIImage::ClassId) return;
|
---|
| 1518 | curpimg = (PIImage*)mCurWdg;
|
---|
| 1519 | if (curpimg == NULL) return;
|
---|
| 1520 | P2DArrayAdapter* img = curpimg->Image();
|
---|
| 1521 | if (img == NULL) return;
|
---|
| 1522 | int dx = curpimg->XSzPave();
|
---|
| 1523 | int dy = curpimg->YSzPave();
|
---|
| 1524 | int x0 = curpimg->XPave()-dx/2;
|
---|
| 1525 | int y0 = curpimg->YPave()-dy/2;
|
---|
| 1526 | if (x0 < 0) x0 = 0;
|
---|
| 1527 | if (y0 < 0) y0 = 0;
|
---|
| 1528 | int x1 = x0+dx;
|
---|
| 1529 | int y1 = y0+dy;
|
---|
| 1530 | if (x1 > img->XSize()) x1 = img->XSize();
|
---|
| 1531 | if (y1 > img->YSize()) y1 = img->YSize();
|
---|
| 1532 | dx = x1-x0; dy = y1-y0;
|
---|
| 1533 | ImageR4* pim = new ImageR4(dx, dy);
|
---|
| 1534 | int ii, jj;
|
---|
| 1535 | for(jj=0; jj<dy; jj++)
|
---|
| 1536 | for(ii=0; ii<dx; ii++) (*pim)(ii,jj) = (*img)(ii+x0, jj+y0);
|
---|
[338] | 1537 | if (msg == 10305) { // Calcul des coordonnees du sous-pave
|
---|
| 1538 | double xc1, yc1;
|
---|
| 1539 | img->Coord(x0, y0, xc1, yc1);
|
---|
| 1540 | pim->SetOrg((int)xc1, (int)yc1);
|
---|
| 1541 | }
|
---|
[165] | 1542 | string nom = mCurWdg->Nom() + "_pave";
|
---|
| 1543 | ObjMgr()->AddObj(pim, nom);
|
---|
| 1544 | ObjMgr()->DisplayObj(nom, "w");
|
---|
[293] | 1545 | break;
|
---|
[165] | 1546 | }
|
---|
| 1547 |
|
---|
[1590] | 1548 | case 10313 :
|
---|
[293] | 1549 | {
|
---|
| 1550 | PIImage* curpimg = NULL;
|
---|
| 1551 | if (!mCurWdg) return;
|
---|
| 1552 | if (mCurWdg->kind() != PIImage::ClassId) return;
|
---|
| 1553 | curpimg = (PIImage*)mCurWdg;
|
---|
| 1554 | if (curpimg == NULL) return;
|
---|
| 1555 | curpimg->ShowCuts(true);
|
---|
| 1556 | break;
|
---|
| 1557 | }
|
---|
| 1558 |
|
---|
[165] | 1559 | case 10320 :
|
---|
| 1560 | if (mStW) mStW->DispNext();
|
---|
| 1561 | break;
|
---|
| 1562 |
|
---|
| 1563 | case 10321 :
|
---|
| 1564 | case 10322 :
|
---|
| 1565 | case 10324 :
|
---|
| 1566 | // case 10328 :
|
---|
[191] | 1567 | if (mStW) mStW->StartAutoDisp((msg-10320)*500);
|
---|
[165] | 1568 | break;
|
---|
| 1569 |
|
---|
| 1570 | case 10329 :
|
---|
| 1571 | if (mStW) mStW->StopAutoDisp();
|
---|
| 1572 | break;
|
---|
| 1573 |
|
---|
| 1574 | case 103330 :
|
---|
| 1575 | if (mStW) {
|
---|
| 1576 | PIWdg* cw = mStW->CurrentWdg();
|
---|
| 1577 | if (cw) DeleteBaseWidget((PIBaseWdg*)cw);
|
---|
| 1578 | }
|
---|
| 1579 | break;
|
---|
| 1580 |
|
---|
| 1581 | default:
|
---|
| 1582 | cerr << "PIStdImgApp::MBProcess3() BUG?? Msg= " << msg << endl;
|
---|
| 1583 | break;
|
---|
| 1584 | }
|
---|
| 1585 | return;
|
---|
| 1586 | }
|
---|
| 1587 |
|
---|
| 1588 | /* --Methode-- */
|
---|
| 1589 | void PIStdImgApp::MBProcess4(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
|
---|
| 1590 | {
|
---|
| 1591 |
|
---|
| 1592 | switch (msg) {
|
---|
| 1593 |
|
---|
| 1594 | case 10400 :
|
---|
| 1595 | CreateStackWin();
|
---|
| 1596 | break;
|
---|
| 1597 |
|
---|
| 1598 | case 10411 :
|
---|
| 1599 | CreateGraphWin(1,1);
|
---|
| 1600 | break;
|
---|
| 1601 | case 10421 :
|
---|
| 1602 | CreateGraphWin(1,2);
|
---|
| 1603 | break;
|
---|
| 1604 | case 10412 :
|
---|
| 1605 | CreateGraphWin(2,1);
|
---|
| 1606 | break;
|
---|
| 1607 | case 10422 :
|
---|
| 1608 | CreateGraphWin(2,2);
|
---|
| 1609 | break;
|
---|
| 1610 | case 10431 :
|
---|
| 1611 | CreateGraphWin(1,3);
|
---|
| 1612 | break;
|
---|
| 1613 | case 10433 :
|
---|
| 1614 | CreateGraphWin(3,3);
|
---|
| 1615 | break;
|
---|
[558] | 1616 | case 10441 :
|
---|
| 1617 | if (mCurWdg) {
|
---|
| 1618 | mLastWdg = mCurWdg;
|
---|
| 1619 | cout << " Using current widget as last-widget (display same) " << endl;
|
---|
| 1620 | }
|
---|
| 1621 | else cout << " No current widget - select widget with mouse " << endl;
|
---|
| 1622 | break;
|
---|
[686] | 1623 | case 10460 :
|
---|
| 1624 | DeleteWindow(mCurWin);
|
---|
| 1625 | break;
|
---|
[1971] | 1626 | case 10470 :
|
---|
| 1627 | StatZoomWindowSetVisible(m[3]->GetStateMsg(10470));
|
---|
| 1628 | break;
|
---|
[165] | 1629 | default:
|
---|
| 1630 | cerr << "PIStdImgApp::MBProcess4() BUG?? Msg= " << msg << endl;
|
---|
| 1631 | break;
|
---|
| 1632 | }
|
---|
| 1633 | return;
|
---|
| 1634 | }
|
---|
| 1635 |
|
---|
| 1636 |
|
---|
| 1637 | /* --Methode-- */
|
---|
| 1638 | void PIStdImgApp::MBProcess5(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
| 1639 | {
|
---|
| 1640 | char nomps[64],strg[512];
|
---|
| 1641 | PSFile *mps;
|
---|
| 1642 | int sxt, syt, syo, syo1, sx[4], sy[4];
|
---|
| 1643 |
|
---|
| 1644 | switch (msg)
|
---|
| 1645 | {
|
---|
| 1646 | case 10501 :
|
---|
[685] | 1647 | pfc_ps->AcceptNewFile(true);
|
---|
[165] | 1648 | mFCMsg = 10525;
|
---|
[685] | 1649 | pfc_ps->SetMsg(mFCMsg);
|
---|
[165] | 1650 | SetBlocked();
|
---|
[685] | 1651 | pfc_ps->Show();
|
---|
[165] | 1652 | break;
|
---|
| 1653 |
|
---|
| 1654 | case 10525 :
|
---|
| 1655 | SetBusy();
|
---|
| 1656 | if (data) {
|
---|
| 1657 | if (mpsfile) {
|
---|
| 1658 | printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
|
---|
| 1659 | delete mpsfile;
|
---|
| 1660 | }
|
---|
[685] | 1661 | name_ps = pfc_ps->GetFileName();
|
---|
[165] | 1662 | printf("PIStdImg/Info: Opening PS-File %s \n", name_ps.c_str());
|
---|
| 1663 | mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 2., 2.);
|
---|
| 1664 | }
|
---|
| 1665 | mFCMsg = 0;
|
---|
| 1666 | SetReady();
|
---|
| 1667 | break;
|
---|
| 1668 |
|
---|
| 1669 | case 10505 :
|
---|
| 1670 | if (!mpsfile) break;
|
---|
| 1671 | printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
|
---|
| 1672 | delete mpsfile;
|
---|
| 1673 | mpsfile = NULL;
|
---|
| 1674 | name_ps = "";
|
---|
| 1675 | break;
|
---|
| 1676 |
|
---|
| 1677 | case 10511 : // Window -> PS
|
---|
| 1678 | case 10512 : // Window -> EPS
|
---|
| 1679 | if (CurrentWindow() == NULL) break;
|
---|
| 1680 | if (msg == 10512)
|
---|
| 1681 | {
|
---|
| 1682 | num_eps++;
|
---|
| 1683 | sprintf(nomps,"pia%d.eps", num_eps);
|
---|
| 1684 | printf("PIStdImg/Info: Creating EPSFile %s (CurWin-> EPS) \n", nomps);
|
---|
| 1685 | mps = new PSFile(nomps);
|
---|
| 1686 | }
|
---|
| 1687 | else {
|
---|
| 1688 | if (mpsfile == NULL) {
|
---|
| 1689 | name_ps = "pia.ps";
|
---|
| 1690 | mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 0., 0.);
|
---|
| 1691 | printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
|
---|
| 1692 | }
|
---|
| 1693 | printf("PIStdImg/Info: CurWin-> PSFile %s\n", name_ps.c_str());
|
---|
| 1694 | mps = mpsfile;
|
---|
| 1695 | }
|
---|
| 1696 | CurrentWindow()->PSPrint(mps,0,0);
|
---|
| 1697 |
|
---|
| 1698 | if (msg == 10512) delete mps; // fichier eps
|
---|
| 1699 | break;
|
---|
| 1700 |
|
---|
| 1701 | case 10515 : // Image -> PS
|
---|
| 1702 | case 10516 : // Image -> EPS
|
---|
| 1703 | {
|
---|
| 1704 | PIImage* curpimg = NULL;
|
---|
| 1705 | if (!mCurWdg) return;
|
---|
| 1706 | if (mCurWdg->kind() != PIImage::ClassId) return;
|
---|
| 1707 | curpimg = (PIImage*)mCurWdg;
|
---|
| 1708 | if (curpimg == NULL) return;
|
---|
| 1709 | if (msg == 10516)
|
---|
| 1710 | {
|
---|
| 1711 | num_eps++;
|
---|
| 1712 | sprintf(nomps,"pia%d.eps", num_eps);
|
---|
| 1713 | printf("PIStdImg/Info: Creating EPSFile %s (CurImage-> EPS)\n", nomps);
|
---|
| 1714 | mps = new PSFile(nomps);
|
---|
| 1715 | }
|
---|
| 1716 | else {
|
---|
| 1717 | if (mpsfile == NULL) {
|
---|
| 1718 | name_ps = "pia.ps";
|
---|
| 1719 | mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
|
---|
| 1720 | printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
|
---|
| 1721 | }
|
---|
| 1722 | printf("PIStdImg/Info: CurImage-> PSFile %s\n", name_ps.c_str());
|
---|
| 1723 | mps = mpsfile;
|
---|
| 1724 | }
|
---|
| 1725 |
|
---|
| 1726 | sx[0] = gimv->XSize();
|
---|
| 1727 | sy[0] = gimv->YSize();
|
---|
| 1728 | sx[1] = zoom->XSize();
|
---|
| 1729 | sy[1] = zoom->YSize();
|
---|
| 1730 | sx[2] = cmapv->XSize();
|
---|
| 1731 | sy[2] = cmapv->YSize();
|
---|
| 1732 | sx[3] = curpimg->XSize();
|
---|
| 1733 | sy[3] = curpimg->YSize();
|
---|
| 1734 | if (sy[1] > sy[0]) { syo1 = sy[1]+50; syo = sy[1]+sy[2]+60; }
|
---|
| 1735 | else { syo1 = sy[0]+50; syo = sy[0]+sy[2]+60; }
|
---|
| 1736 | syt = sy[3]+syo;
|
---|
| 1737 | sxt = sx[3];
|
---|
| 1738 | if (sxt < (sx[0]+sx[1]+20)) sxt = sx[0]+sx[1]+20;
|
---|
| 1739 | if (sxt < sx[2]) sxt = sx[2];
|
---|
| 1740 |
|
---|
| 1741 | // Pour ecrire le titre
|
---|
| 1742 | mps->NewPage((float)sxt, (float)syt, PI_Portrait);
|
---|
| 1743 | mps->NewBloc(0,0, (float)sxt, 30., (float)sxt, 30.);
|
---|
| 1744 | sprintf(strg,"Image: %s - Pave %d %d \n", curpimg->Nom().c_str(),
|
---|
| 1745 | curpimg->XPave(), curpimg->YPave());
|
---|
[384] | 1746 | mps->DrawString(10., 25., strg, PI_Black, PI_DefaultFont, PI_BoldFont, 20);
|
---|
[165] | 1747 | mps->EndBloc();
|
---|
| 1748 |
|
---|
| 1749 | // Les quatre fenetres glovimage, zoom, cmap, image
|
---|
| 1750 | gimv->PSPrint(mps, -gimv->XPos(), -gimv->YPos()+40);
|
---|
| 1751 | zoom->PSPrint(mps, -zoom->XPos()+sx[0]+20, -zoom->YPos()+40);
|
---|
| 1752 | cmapv->PSPrint(mps, -cmapv->XPos(), -cmapv->YPos()+syo1);
|
---|
| 1753 | curpimg->PSPrint(mps, -curpimg->XPos(), -curpimg->YPos()+syo);
|
---|
| 1754 |
|
---|
| 1755 | if (msg == 10516) delete mps; // fichier eps
|
---|
| 1756 | break;
|
---|
| 1757 | }
|
---|
| 1758 |
|
---|
| 1759 | default:
|
---|
| 1760 | cerr << "PIStdImgApp::MBProcess5() BUG?? Msg= " << msg << endl;
|
---|
| 1761 | break;
|
---|
| 1762 | }
|
---|
| 1763 |
|
---|
| 1764 | }
|
---|
| 1765 |
|
---|
| 1766 |
|
---|
| 1767 | /* --Methode-- */
|
---|
| 1768 | void PIStdImgApp::MBProcess6(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
| 1769 | {
|
---|
| 1770 | switch (msg) {
|
---|
| 1771 | case 10601:
|
---|
| 1772 | CloseAllWindows();
|
---|
| 1773 | break;
|
---|
| 1774 | case 10602:
|
---|
| 1775 | RedirectStdOutErr(*((bool*)data));
|
---|
| 1776 | break;
|
---|
| 1777 | case 10603:
|
---|
[374] | 1778 | case 10604:
|
---|
| 1779 | CatchSignals(m[5]->GetStateMsg(10603), m[5]->GetStateMsg(10604));
|
---|
[165] | 1780 | break;
|
---|
[449] | 1781 | case 10605:
|
---|
| 1782 | mObjMgr->SetVerbose(m[5]->GetStateMsg(10605));
|
---|
| 1783 | break;
|
---|
[1251] | 1784 | case 10606:
|
---|
| 1785 | mCmd->ShowCxxOptionWindow();
|
---|
| 1786 | break;
|
---|
[165] | 1787 | default:
|
---|
| 1788 | cerr << "PIStdImgApp::MBProcess6() BUG?? Msg= " << msg << endl;
|
---|
| 1789 | break;
|
---|
| 1790 | }
|
---|
| 1791 | return;
|
---|
| 1792 | }
|
---|
| 1793 |
|
---|
| 1794 |
|
---|
[1569] | 1795 |
|
---|
[686] | 1796 | // -------------------------------------------------
|
---|
| 1797 | // Fenetre info piapp (About piapp)
|
---|
| 1798 | // -------------------------------------------------
|
---|
| 1799 | static PIWindow* infow_win = NULL;
|
---|
| 1800 | static PIText* infow_txt = NULL;
|
---|
| 1801 | static PICMapView* infow_cmap = NULL;
|
---|
| 1802 | static PIButton* infow_but = NULL;
|
---|
| 1803 |
|
---|
| 1804 | /* Nouvelle-Fonction */
|
---|
| 1805 | static void createInfoWindow(PIStdImgApp* app)
|
---|
| 1806 | {
|
---|
| 1807 | if (infow_win) return;
|
---|
| 1808 |
|
---|
| 1809 | int bsx, bsy;
|
---|
| 1810 | PIApplicationPrefCompSize(bsx, bsy);
|
---|
| 1811 | int spx, spy;
|
---|
| 1812 | spx = bsx/6; spy = bsy/6;
|
---|
| 1813 |
|
---|
| 1814 | infow_win = new PIWindow((PIMsgHandler *)app, "About piapp",
|
---|
| 1815 | PIWK_dialog, bsx*5+3*spx, bsy*4+spy*3, 200, 200);
|
---|
| 1816 | infow_win->SetAutoDelChilds(true);
|
---|
| 1817 | infow_txt = new PIText(infow_win,"about_piapp_text", bsx*5+spx, bsy*3, spx, spy);
|
---|
| 1818 | infow_txt->SetMutiLineMode(true);
|
---|
| 1819 | infow_txt->SetTextEditable(false);
|
---|
| 1820 | infow_txt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 1821 | infow_cmap = new PICMapView(infow_win, "about_piapp_cmap", bsx*4, bsy*0.7, spx, 2*spy+bsy*3.15);
|
---|
| 1822 | infow_cmap->SetColMapId(CMAP_COLBR32, 1., -1., false);
|
---|
| 1823 | infow_cmap->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 1824 | infow_but = new PIButton(infow_win,"OK", 10155, bsx, bsy, bsx*4+2*spx, 2*spy+bsy*3);
|
---|
| 1825 | infow_but->SetMsgParent((PIMsgHandler *)app);
|
---|
| 1826 | infow_but->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 1827 | char buff[128];
|
---|
| 1828 | #ifdef SANS_EVOLPLANCK
|
---|
| 1829 | sprintf(buff, "Version: piapp=%g PI=%g PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER,
|
---|
| 1830 | (double)PI_VERSIONNUMBER, (float)PeidaVersion());
|
---|
| 1831 | #else
|
---|
[692] | 1832 | {
|
---|
[686] | 1833 | sprintf(buff, "Version: piapp=%g PI=%g SOPHYA=%g \n", (double)PIAPP_VERSIONNUMBER,
|
---|
[692] | 1834 | (double)PI_VERSIONNUMBER, glst_piai->Version());
|
---|
| 1835 | }
|
---|
[686] | 1836 | #endif
|
---|
| 1837 | string info = "piapp : Interactive analysis program\n";
|
---|
| 1838 | info += buff;
|
---|
[1971] | 1839 | info += "(C) LAL-IN2P3/CNRS 1996-2002\n";
|
---|
| 1840 | info += "(C) SPP-DAPNIA/CEA 1996-2002\n";
|
---|
[686] | 1841 | infow_txt->SetText(info);
|
---|
| 1842 | }
|
---|
| 1843 |
|
---|
| 1844 | /* Nouvelle-Fonction */
|
---|
| 1845 | static void showInfoWindow(PIStdImgApp* app)
|
---|
| 1846 | {
|
---|
[692] | 1847 | if (!infow_win) createInfoWindow(app);
|
---|
| 1848 | if (infow_win) infow_win->Show();
|
---|
[686] | 1849 | }
|
---|
| 1850 | /* Nouvelle-Fonction */
|
---|
| 1851 | static void hideInfoWindow(PIStdImgApp* app)
|
---|
| 1852 | {
|
---|
[692] | 1853 | if (infow_win) infow_win->Hide();
|
---|
[686] | 1854 | }
|
---|
| 1855 |
|
---|
| 1856 | /* Nouvelle-Fonction */
|
---|
| 1857 | static void deleteInfoWindow()
|
---|
| 1858 | {
|
---|
| 1859 | if (!infow_win) return;
|
---|
| 1860 | delete infow_win;
|
---|
| 1861 | infow_win = NULL;
|
---|
| 1862 | infow_txt = NULL;
|
---|
| 1863 | infow_cmap = NULL;
|
---|
| 1864 | infow_but = NULL;
|
---|
| 1865 | }
|
---|
| 1866 |
|
---|
[2106] | 1867 |
|
---|