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