source: Sophya/trunk/SophyaPI/PIext/pistdimgapp.cc@ 2406

Last change on this file since 2406 was 2402, checked in by ansari, 22 years ago

Correction bug gestion des WRsId - Reza 10/06/2003

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