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