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