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

Last change on this file since 1617 was 1593, checked in by ansari, 24 years ago

Adaptation au changement interface PIApplication::PrefCompSz() PIApplication::PrefCompSize() - Reza 23/7/2001

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