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

Last change on this file since 2263 was 2263, checked in by ansari, 23 years ago
  • Ajout commande de trace d'elements graphiques (addpoly addctext ...)
  • Ajout de commandes de lecture ascii matrices/vecteurs
  • Trace de vecteur vx vs vy pour tout type de vecteurs

Reza 14/11/2002

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