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