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

Last change on this file since 2001 was 1971, checked in by ansari, 23 years ago

1/ Basculement de decodage des options de display aux methodes
PIDrawer/PIWdg::DecodeOptionString()
2/ Possibilite de Show/Hide de la partie Zoom/ColorMap/Stat du MainWindow

Reza 30/4/2002

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