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