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

Last change on this file since 2307 was 2265, checked in by ansari, 23 years ago

Ajout addarca et addfarca: Trace d'arc defini par un angle et dangle + sum/product/mean/sigma ds RPNEvaluator - Reza 14/11/2002

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