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

Last change on this file since 3748 was 3572, checked in by cmv, 17 years ago

char* -> const char* pour regler les problemes de deprecated string const... + comparaison unsigned signed + suppression EVOL_PLANCK rz+cmv 07/02/2009

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