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

Last change on this file since 1925 was 1905, checked in by ansari, 24 years ago

Adaptation a l'introduction de la classe PIGraphicAtt - Reza 18/02/2002

  • Property svn:executable set to *
File size: 42.2 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->GetGraphicAtt().SetColAtt(mFCol, mBCol);
526if (mLAtt != PI_NotDefLineAtt) scd->GetGraphicAtt().SetLineAtt(mLAtt);
527if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
528 scd->GetGraphicAtt().SetFontAtt(mFSz, mFAtt);
529if ( mFName != PI_DefaultFont )
530 scd->GetGraphicAtt().SetFontAtt(mFName, scd->GetGraphicAtt().GetFontSz(),
531 scd->GetGraphicAtt().GetFontAtt());
532if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) )
533 scd->GetGraphicAtt().SetMarkerAtt(mMSz, mMrk);
534if ( mCmapid != CMAP_OTHER ) scd->GetGraphicAtt().SetColMapId(mCmapid);
535
536
537if ( (!mLastWdg) && ( (opt == Disp_Same) || (opt == Disp_Inset) ) ) opt = Disp_Next;
538// Trace en superpoistion
539if ( (opt == Disp_Same) && (mLastWdg) ) {
540 if (mLastWdg->kind() == PIScDrawWdg::ClassId) ((PIScDrawWdg*)mLastWdg)->AddScDrawer(scd, true);
541 else mLastWdg->AddDrawer(scd, true, true, true);
542 scd->Refresh();
543 mDId++;
544 mDrwList[mDId] = scd;
545 return(-mDId);
546}
547// Trace en medaillon
548else if ( (opt == Disp_Inset) && (mLastWdg) ) {
549 PIGrCoord x1, x2, y1, y2;
550 x1 = mIXmin; x2 = mIXmax;
551 y2 = 1.-mIYmin; y1 = 1.-mIYmax;
552 scd->SetAxesFlags(mAxesFlags);
553 if (maXlog || maYlog) scd->SetLogScale(maXlog, maYlog); // Echelle log
554 if (mFXYlim) // Forcage limites XY
555 scd->SetLimits(mXmin, mXmax, mYmin, mYmax);
556 else scd->UpdateLimits();
557 mLastWdg->AddDrawer(scd, x1, y1, x2, y2, true, false, true);
558 scd->Refresh();
559 mDId++;
560 mDrwList[mDId] = scd;
561 return(-mDId);
562}
563
564PIWindow* win;
565PIScDrawWdg* scw;
566int sx, sy, px, py, flag;
567sx = 200+mFgScSz*100;
568sy = 200+mFgScSz*100;
569win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
570/*
571if (typeid(*scd) != typeid(PIHisto2D))
572else scw = new PIH2DWdg(win, (char *)name.c_str(), sx, sy, px, py);
573*/
574scw = new PIScDrawWdg(win, (char *)name.c_str(), sx, sy, px, py);
575scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
576scw->SetUserData(NULL, oid);
577if (maXlog || maYlog) scw->SetLogScale(maXlog, maYlog); // Echelle log
578if (mFXYlim) // Forcage limites XY
579 scw->SetLimits(mXmin, mXmax, mYmin, mYmax);
580scw->SetAxesFlags(mAxesFlags);
581// Fonte de trace d'axe
582scw->BaseDrawer()->GetGraphicAtt().SetFontAtt(mFName, mFSz, mFAtt);
583/*
584if (typeid(*scd) != typeid(PIHisto2D))
585else ((PIH2DWdg*)scw)->SetPIHisto((PIHisto2D*)scd);
586*/
587scw->AddScDrawer(scd, true);
588// Titre du plot
589if (mAddTitle) {
590 if (title.length() <= 0) title = name; string t2="";
591 scw->SetTitles(title, t2);
592}
593
594// scw->Refresh(); ? Pas necessaire Reza 19/08/98, 05/05/99 $CHECK$
595mCurWin = win;
596mCurWdg = scw;
597mLastWdg = scw;
598mBWId++;
599mBWList[mBWId] = scw;
600return(mBWId);
601}
602
603/* --Methode-- */
604int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, int opt, string title, int oid)
605{
606if (dr3 == NULL)
607 {
608 printf("PIStdImgApp::Disp3DDrawer_Error Cannot Add NULL 3DDrawer \n");
609 return(-1);
610 }
611
612// Changement d'attributs graphiques courants du drawer
613if (mFCol != PI_NotDefColor) dr3->GetGraphicAtt().SetColAtt(mFCol, mBCol);
614if (mLAtt != PI_NotDefLineAtt) dr3->GetGraphicAtt().SetLineAtt(mLAtt);
615if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
616 dr3->GetGraphicAtt().SetFontAtt(mFSz, mFAtt);
617if ( mFName != PI_DefaultFont )
618 dr3->GetGraphicAtt().SetFontAtt(mFName, dr3->GetGraphicAtt().GetFontSz(),
619 dr3->GetGraphicAtt().GetFontAtt());
620if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) )
621 dr3->GetGraphicAtt().SetMarkerAtt(mMSz, mMrk);
622if ( mCmapid != CMAP_OTHER ) dr3->GetGraphicAtt().SetColMapId(mCmapid);
623
624if ( (!mLastWdg) && ( (opt == Disp_Same) || (opt == Disp_Inset) ) ) opt = Disp_Next;
625// Trace en superpoistion
626if ( (opt == Disp_Same) && (mLastWdg) ) {
627 if (mLastWdg->kind() == PIDraw3DWdg::ClassId) ((PIDraw3DWdg*)mLastWdg)->AddDrawer3D(dr3, true);
628 else mLastWdg->AddDrawer(dr3, true, true, true);
629 dr3->Refresh();
630 mDId++;
631 mDrwList[mDId] = dr3;
632 return(-mDId);
633}
634// Trace en medaillon
635else if ( (opt == Disp_Inset) && (mLastWdg) ) {
636 PIGrCoord x1, x2, y1, y2;
637 x1 = mIXmin; x2 = mIXmax;
638 y2 = 1.-mIYmin; y1 = 1.-mIYmax;
639 dr3->SetAxesFlags(mAxesFlags);
640 dr3->UpdateLimits();
641 mLastWdg->AddDrawer(dr3, x1, y1, x2, y2, true, false, true);
642 dr3->Refresh();
643 mDId++;
644 mDrwList[mDId] = dr3;
645 return(-mDId);
646}
647
648
649PIWindow* win;
650int sx, sy, px, py, flag;
651sx = 200+mFgScSz*100;
652sy = 200+mFgScSz*100;
653win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
654PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)name.c_str(), sx, sy, px, py);
655wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
656wd3->SetUserData(NULL, oid);
657wd3->AddDrawer3D(dr3, true);
658// Titre du plot
659if (mAddTitle) {
660 if (title.length() <= 0) title = name; string t2="";
661 wd3->SetTitles(title, t2);
662}
663// wd3->Refresh(); ?Pas necessaire $CHECK$ 05/05/99
664mCurWin = win;
665mCurWdg = wd3;
666mLastWdg = wd3;
667mBWId++;
668mBWList[mBWId] = wd3;
669return(mBWId);
670}
671
672/* --Methode-- */
673void PIStdImgApp::AddText(string const & txt, double xp, double yp)
674{
675PIElDrawer *eld=CurrentElDrawer();
676if (eld == NULL) return;
677
678if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
679 eld->GetGraphicAtt().SetFontAtt(mFSz, mFAtt);
680if ( mFName != PI_DefaultFont )
681 eld->GetGraphicAtt().SetFontAtt(mFName, eld->GetGraphicAtt().GetFontSz(),
682 eld->GetGraphicAtt().GetFontAtt());
683eld->ElAddText(xp,yp,txt.c_str(),mFCol);
684eld->Refresh();
685}
686
687/* --Methode-- */
688void PIStdImgApp::AddLine(double xp1, double yp1, double xp2, double yp2)
689{
690PIElDrawer *eld=CurrentElDrawer();
691if (eld == NULL) return;
692
693eld->ElAddLine(xp1, yp1, xp2, yp2, mFCol);
694eld->Refresh();
695}
696
697/* --Methode-- */
698void PIStdImgApp::AddRectangle(double xp1, double yp1, double xp2, double yp2, bool fgfill)
699{
700PIElDrawer *eld=CurrentElDrawer();
701if (eld == NULL) return;
702
703double xp,yp;
704double dx, dy;
705if (xp1 < xp2) {
706 xp = xp1; dx = xp2-xp1;
707}
708else {
709 xp = xp2; dx = xp1-xp2;
710}
711if (yp1 < yp2) {
712 yp = yp1; dy = yp2-yp1;
713}
714else {
715 yp = yp2; dy = yp1-yp2;
716}
717if (fgfill) eld->ElAddFRect(xp, yp, dx, dy, mFCol);
718else eld->ElAddRect(xp, yp, dx, dy, mFCol);
719eld->Refresh();
720}
721
722/* --Methode-- */
723void PIStdImgApp::AddCircle(double xc, double yc, double r, bool fgfill)
724{
725PIElDrawer *eld=CurrentElDrawer();
726if (eld == NULL) return;
727
728if (fgfill) eld->ElAddFCirc(xc, yc, r, mFCol);
729else eld->ElAddCirc(xc, yc, r, mFCol);
730eld->Refresh();
731}
732
733/* --Methode-- */
734void PIStdImgApp::SetTitle(string const & titletop, string const & titlebottom)
735{
736PIElDrawer *eld=CurrentElDrawer();
737if (eld == NULL) return;
738
739if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
740 eld->GetGraphicAtt().SetFontAtt(mFSz, mFAtt);
741if ( mFName != PI_DefaultFont )
742 eld->GetGraphicAtt().SetFontAtt(mFName, eld->GetGraphicAtt().GetFontSz(),
743 eld->GetGraphicAtt().GetFontAtt());
744eld->SetTitles(titletop, titlebottom);
745eld->Refresh();
746}
747
748/* --Methode-- */
749PIElDrawer* PIStdImgApp::CurrentElDrawer()
750{
751PIElDrawer *eld=NULL;
752if (!mLastWdg) return(eld);
753PIScDrawWdg* sdw=NULL;
754PIDraw3DWdg* w3d=NULL;
755PIImage* imgw;
756switch(mLastWdg->kind()) {
757 case PIScDrawWdg::ClassId :
758 sdw = dynamic_cast<PIScDrawWdg *>(mLastWdg);
759 if (sdw) eld = sdw->BaseDrawer();
760 break;
761 case PIDraw3DWdg::ClassId :
762 w3d = dynamic_cast<PIDraw3DWdg *>(mLastWdg);
763 if (w3d) eld = w3d->BaseDrawer();
764 break;
765 case PIImage::ClassId :
766 imgw = dynamic_cast<PIImage *>(mLastWdg);
767 if (imgw) eld = imgw->BaseDrawer();
768 break;
769 default :
770 break;
771 }
772return(eld);
773}
774
775/* --Methode-- */
776void PIStdImgApp::CreateGraphWin(int nx, int ny, int sx, int sy)
777{
778if (nx < 1) nx = 1;
779if (ny < 1) ny = 1;
780if (nx > 8) nx = 8;
781if (ny > 8) ny = 8;
782if ( (sx < 50) && (sy < 50) ) sx = sy = 400+mFgScSz*100;
783char buff[64];
784mWId++;
785int px, py;
786MainWin()->GetScreenPos(px, py);
787sprintf(buff, "PI-GraphicWin (%d)",mWId);
788PIZoneWindow* win = new PIZoneWindow(this, buff, PIWK_normal, nx, ny, sx, sy, px+MainWin()->XSize()+30, 0);
789win->SetUserData(NULL, ny*10+nx); // UserFlag= nY*10 + nX
790mWList[mWId*10+1] = (PIWindow*)win;
791win->SetAutoDelChilds(true);
792// win->Show();
793mGrW = win;
794mGrIdx = 0;
795}
796
797/* --Methode-- */
798void PIStdImgApp::CreateStackWin(int sx, int sy)
799{
800if ( (sx < 50) && (sy < 50) ) sx = sy = 300+mFgScSz*100;
801char buff[64];
802mWId++;
803int px, py;
804MainWin()->GetScreenPos(px, py);
805sprintf(buff, "PI-StackWin (%d)",mWId);
806PIStackWindow* win = new PIStackWindow(this, buff, PIWK_normal, sx, sy, px+MainWin()->XSize()+30, 100);
807win->SetUserData(NULL, 9999); // UserFlag= 9999
808mWList[mWId*10+2] = (PIWindow*)win;
809win->SetAutoDelChilds(true);
810// win->Show();
811mStW = win;
812m[2]->SetSensitivity("StackTools", true);
813mStIdx = 0;
814}
815
816/* --Methode-- */
817PIWindow* PIStdImgApp::GetWindow(int typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom)
818{
819PIWindow* rw;
820
821switch (typ) {
822 case Disp_Next : // Fenetre graphique courante
823 {
824 if (mGrW == NULL) CreateGraphWin();
825 int nx, ny;
826 mGrW->NbZone(nx, ny);
827 PIWdg* nw = mGrW->NextChildPosSize(px, py, sx, sy);
828// cerr << "**DBG** PIStdImgApp::GetWindow() DispNext : nw = " << (long)nw << endl;
829 if (nw) DeleteBaseWidget((PIBaseWdg*)nw, false, false);
830 flag = mGrIdx;
831 mGrIdx = (mGrIdx+1)%(nx*ny);
832 rw = mGrW;
833 break;
834 }
835
836 case Disp_Stack : // Fenetre de type stack (empilement)
837 {
838 if (mStW == NULL) CreateStackWin(sx, sy);
839 px = py = 0;
840 sx = mStW->XSize();
841 sy = mStW->YSize();
842 flag = mStIdx;
843 mStIdx++;
844 rw = mStW;
845 }
846 break;
847
848 default : // Fenetre ordinaire
849 {
850 int pwx, pwy;
851 MainWin()->GetScreenPos(pwx, pwy);
852 if ( (sx < 50) && (sy < 50) ) sx = sy = 300+mFgScSz*100;
853 rw = new PIWindow(this, nom, PIWK_normal, sx, sy, pwx+MainWin()->XSize()+30, 300);
854 rw->SetUserData(NULL, 0); // UserFlag= 0
855 mWId++;
856 mWList[mWId*10] = rw;
857 rw->SetAutoDelChilds(true);
858 // rw->Show();
859 px = py = 0;
860 flag = 0;
861 break;
862 }
863 }
864
865rw->Show();
866mCurWin = rw;
867return(rw);
868}
869
870/* --Methode-- */
871void PIStdImgApp::SetZone(int nzx, int nzy)
872{
873if (!mGrW) CreateGraphWin(nzx, nzy);
874else {
875 int k;
876 PIWdg* cwd;
877 for(k=0; k<mGrW->NbChilds(); k++) {
878 if ((cwd = mGrW->GetChild(k)) == NULL) continue;
879 DeleteBaseWidget((PIBaseWdg*)cwd, false, false);
880 }
881 mGrW->SetZone(nzx, nzy);
882 }
883}
884
885/* --Methode-- */
886void PIStdImgApp::StackWinNext()
887{
888if (mStW) mStW->DispNext();
889}
890
891/* --Methode-- */
892void PIStdImgApp::DeleteWindow(PIWindow* w)
893{
894if (w == NULL) return;
895w->Hide();
896bool ownwindow=false; // To Check if this is one of our windows
897WindMList::iterator it;
898for(it = mWList.begin(); it != mWList.end(); it++)
899 if ((*it).second == w) { mWList.erase(it); ownwindow = true; break; }
900if (w == mGrW) { mGrW = NULL; mGrIdx = -1; }
901if (w == mStW) { mStW = NULL; mStIdx = -1; m[2]->SetSensitivity("StackTools", false); }
902if (w == mCurWin) mCurWin = NULL;
903
904if (!ownwindow) return; // We do nothing if this is not a window we have created ...
905
906int k;
907PIWdg* cwd;
908for(k=0; k<w->NbChilds(); k++) {
909 if ((cwd = w->GetChild(k)) == NULL) continue;
910 DeleteBaseWidget((PIBaseWdg*)cwd,false,false);
911 }
912delete w;
913return;
914}
915
916/* --Methode-- */
917void PIStdImgApp::DeleteBaseWidget(PIBaseWdg* w, bool dw, bool dwin)
918{
919if (w == NULL) return;
920BWMList::iterator it;
921for(it = mBWList.begin(); it != mBWList.end(); it++)
922 if ((*it).second == w) { mBWList.erase(it); break; }
923int k;
924PIDrawer* drw;
925for(k=0; k<w->NbDrawers(); k++) {
926 if ((drw = w->GetDrawer(k)) == NULL) continue;
927 DrwMList::iterator itt;
928 for(itt = mDrwList.begin(); itt != mDrwList.end(); itt++)
929 if ((*itt).second == drw) { mDrwList.erase(itt); break; }
930 }
931
932if (w == mCurWdg) {
933 mCurWdg = NULL;
934 if (mFgCWImg) {
935 m[4]->SetSensitivityMsg(10515, false);
936 m[4]->SetSensitivityMsg(10516, false);
937 mFgCWImg = false;
938 }
939 }
940
941if (w == mLastWdg) mLastWdg = NULL;
942
943PIWdg* pw=NULL;
944if (dwin) pw = (PIWdg*)(w->Parent());
945//DBG printf("DeleteBaseWidget(%lx)-DBG kind = %d - %d %d \n", (long)w, w->kind(), (int)dw, (int)dwin);
946if (dw) delete w;
947if (pw && (pw->kind() == PIWindow::ClassId )) {
948 PIWindow* pww = (PIWindow*) pw;
949 if ((pww != (PIWindow*)mGrW) && (pww != (PIWindow*)mStW) && (pww->NbChilds()==0))
950 DeleteWindow((PIWindow*)pw);
951 }
952return;
953}
954
955
956
957/* --Methode-- */
958void PIStdImgApp::DelWRsId(int k)
959{
960//DBG cerr << "-DBG- PIStdImgApp::DelWRsId(" << k << ")" << endl;
961if (k > 0) { // C'est un BaseWidget
962 BWMList::iterator it;
963 it = mBWList.find(k);
964 if (it == mBWList.end()) return;
965 PIBaseWdg* wd = (*it).second;
966//DBG cerr << "-DBG- PIStdImgApp::DelWRsId Deleting BaseWidget " << (long)(wd) << endl ;
967 DeleteBaseWidget(wd, true, true);
968 }
969else { // C'est un drawer
970 DrwMList::iterator it;
971 it = mDrwList.find(-k);
972 if (it == mDrwList.end()) return;
973 delete (*it).second;
974 mDrwList.erase(it);
975// cerr << "+DBG+ PIStdImgApp::DelWRsId Deleting Drawer " << (long)((*it).second) << endl ;
976 }
977}
978/* --Methode-- */
979bool PIStdImgApp::CheckWRsId(int k)
980{
981if (k > 0) { // C'est un BaseWidget
982 BWMList::iterator it;
983 it = mBWList.find(k);
984 if (it == mBWList.end()) return(false);
985 else return(true);
986 }
987else { // C'est un drawer
988 DrwMList::iterator it;
989 it = mDrwList.find(-k);
990 if (it == mDrwList.end()) return(false);
991 else return(true);
992 }
993}
994
995
996/* --Methode-- */
997void PIStdImgApp::RedirectStdOutErr(bool fg)
998{
999if (fg) {
1000 RedirectOutStream(mCons);
1001 RedirectErrStream(mCons);
1002 m[5]->SetStateMsg(10602, true);
1003 redirecout = true;
1004 }
1005else {
1006 RedirectOutStream(NULL);
1007 RedirectErrStream(NULL);
1008 m[5]->SetStateMsg(10602, false);
1009 redirecout = false;
1010 }
1011return;
1012}
1013
1014/* --Methode-- */
1015void PIStdImgApp::CatchSignals(bool fgfpe, bool fgsegv)
1016{
1017#ifdef SANS_EVOLPLANCK
1018PeidaConfigureSignalhandling(fgfpe, fgsegv, true, true);
1019#else
1020SophyaConfigureSignalhandling(fgfpe, fgsegv, true, true);
1021#endif
1022m[5]->SetStateMsg(10603, fgfpe);
1023m[5]->SetStateMsg(10604, fgsegv);
1024}
1025
1026/* --Methode-- */
1027void PIStdImgApp::CloseAllWindows()
1028{
1029WindMList::iterator it;
1030for(it = mWList.begin(); it != mWList.end(); it++) delete (*it).second;
1031mWList.clear();
1032mBWList.clear();
1033mDrwList.clear();
1034mGrW = NULL;
1035mStW = NULL;
1036mCurWin = NULL;
1037mCurWdg = NULL;
1038mLastWdg = NULL;
1039m[4]->SetSensitivityMsg(10515, false);
1040m[4]->SetSensitivityMsg(10516, false);
1041}
1042
1043/* --Methode-- */
1044void PIStdImgApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
1045{
1046
1047 switch(msg)
1048 {
1049 case 10150 :
1050 showInfoWindow(this);
1051 break;
1052
1053 case 10155 :
1054 hideInfoWindow(this);
1055 break;
1056
1057 case 10100 :
1058 mCmd->ShowHelpWindow();
1059 break;
1060
1061 case 10120 :
1062 pfc_fits->AcceptNewFile(false);
1063 mFCMsg = 10125;
1064 pfc_fits->SetMsg(mFCMsg);
1065 SetBlocked();
1066 pfc_fits->Show();
1067 break;
1068
1069 case 10125 :
1070 SetBusy();
1071 if (data) {
1072 string nomobj="";
1073 ObjMgr()->ReadFits(pfc_fits->GetFileName(), nomobj);
1074 ObjMgr()->DisplayObj(nomobj, "win");
1075 }
1076 mFCMsg = 0;
1077 SetReady();
1078 break;
1079
1080 case 10130 :
1081 pfc_ppf->AcceptNewFile(false);
1082 mFCMsg = 10135;
1083 pfc_ppf->SetMsg(mFCMsg);
1084 SetBlocked();
1085 pfc_ppf->Show();
1086 break;
1087
1088 case 10135 :
1089 mFCMsg = 0;
1090 if (data) {
1091 PPInMgrW()->SetFile(pfc_ppf->GetFileName());
1092 PPInMgrW()->Show();
1093 }
1094 SetReady();
1095 break;
1096
1097 case 10105:
1098 Stop();
1099 break;
1100
1101 }
1102return;
1103}
1104
1105
1106
1107/* --Methode-- */
1108void PIStdImgApp::MBProcess2(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
1109{
1110
1111switch (msg) {
1112 case 10201 :
1113 ObjMgrW()->Show();
1114 break;
1115
1116 case 10220 :
1117 pfc_ppf->AcceptNewFile(true);
1118 mFCMsg = 10225;
1119 pfc_ppf->SetMsg(mFCMsg);
1120 SetBlocked();
1121 pfc_ppf->Show();
1122 break;
1123
1124 case 10225 :
1125 SetBusy();
1126 if (data) {
1127 if (mPpfout) {
1128 printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
1129 delete mPpfout;
1130 }
1131 name_outppf = pfc_ppf->GetFileName();
1132 mPpfout = NULL;
1133 printf("PIStdImg/Info: Opening POutPersist-File %s \n", name_outppf.c_str());
1134 mPpfout = new POutPersist(name_outppf);
1135 }
1136 mFCMsg = 0;
1137 SetReady();
1138 break;
1139
1140 case 10230 :
1141 if (!mPpfout) break;
1142 printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
1143 delete mPpfout;
1144 name_outppf = "";
1145 mPpfout = NULL;
1146 break;
1147
1148 case 10270 :
1149 if (mCurWdg) {
1150 int oid = mCurWdg->UserFlag();
1151 DeleteBaseWidget(mCurWdg);
1152 mObjMgr->DelObj_Id(oid);
1153 }
1154 break;
1155
1156 default:
1157 cerr << "PIStdImgApp::MBProcess2() BUG?? Msg= " << msg << endl;
1158 break;
1159}
1160
1161return;
1162}
1163
1164/* --Methode-- */
1165void PIStdImgApp::MBProcess3(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
1166{
1167
1168switch (msg) {
1169 case 10301 :
1170 PIImgTools::ShowPIImgTools();
1171 break;
1172 case 10302 :
1173 PIDrwTools::ShowPIDrwTools();
1174 break;
1175 case 10303 :
1176 PIAxesTools::ShowPIAxesTools();
1177 break;
1178
1179 case 10304 :
1180 mCmd->ShowCxxExecWindow();
1181 break;
1182
1183 case 10311 :
1184 case 10312 :
1185 {
1186 PIImage* curpimg = NULL;
1187 if (!mCurWdg) return;
1188 if (mCurWdg->kind() != PIImage::ClassId) return;
1189 curpimg = (PIImage*)mCurWdg;
1190 if (curpimg == NULL) return;
1191 P2DArrayAdapter* img = curpimg->Image();
1192 if (img == NULL) return;
1193 int dx = curpimg->XSzPave();
1194 int dy = curpimg->YSzPave();
1195 int x0 = curpimg->XPave()-dx/2;
1196 int y0 = curpimg->YPave()-dy/2;
1197 if (x0 < 0) x0 = 0;
1198 if (y0 < 0) y0 = 0;
1199 int x1 = x0+dx;
1200 int y1 = y0+dy;
1201 if (x1 > img->XSize()) x1 = img->XSize();
1202 if (y1 > img->YSize()) y1 = img->YSize();
1203 dx = x1-x0; dy = y1-y0;
1204 ImageR4* pim = new ImageR4(dx, dy);
1205 int ii, jj;
1206 for(jj=0; jj<dy; jj++)
1207 for(ii=0; ii<dx; ii++) (*pim)(ii,jj) = (*img)(ii+x0, jj+y0);
1208 if (msg == 10305) { // Calcul des coordonnees du sous-pave
1209 double xc1, yc1;
1210 img->Coord(x0, y0, xc1, yc1);
1211 pim->SetOrg((int)xc1, (int)yc1);
1212 }
1213 string nom = mCurWdg->Nom() + "_pave";
1214 ObjMgr()->AddObj(pim, nom);
1215 ObjMgr()->DisplayObj(nom, "w");
1216 break;
1217 }
1218
1219 case 10313 :
1220 {
1221 PIImage* curpimg = NULL;
1222 if (!mCurWdg) return;
1223 if (mCurWdg->kind() != PIImage::ClassId) return;
1224 curpimg = (PIImage*)mCurWdg;
1225 if (curpimg == NULL) return;
1226 curpimg->ShowCuts(true);
1227 break;
1228 }
1229
1230 case 10320 :
1231 if (mStW) mStW->DispNext();
1232 break;
1233
1234 case 10321 :
1235 case 10322 :
1236 case 10324 :
1237// case 10328 :
1238 if (mStW) mStW->StartAutoDisp((msg-10320)*500);
1239 break;
1240
1241 case 10329 :
1242 if (mStW) mStW->StopAutoDisp();
1243 break;
1244
1245 case 103330 :
1246 if (mStW) {
1247 PIWdg* cw = mStW->CurrentWdg();
1248 if (cw) DeleteBaseWidget((PIBaseWdg*)cw);
1249 }
1250 break;
1251
1252 default:
1253 cerr << "PIStdImgApp::MBProcess3() BUG?? Msg= " << msg << endl;
1254 break;
1255 }
1256return;
1257}
1258
1259/* --Methode-- */
1260void PIStdImgApp::MBProcess4(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
1261{
1262
1263switch (msg) {
1264
1265 case 10400 :
1266 CreateStackWin();
1267 break;
1268
1269 case 10411 :
1270 CreateGraphWin(1,1);
1271 break;
1272 case 10421 :
1273 CreateGraphWin(1,2);
1274 break;
1275 case 10412 :
1276 CreateGraphWin(2,1);
1277 break;
1278 case 10422 :
1279 CreateGraphWin(2,2);
1280 break;
1281 case 10431 :
1282 CreateGraphWin(1,3);
1283 break;
1284 case 10433 :
1285 CreateGraphWin(3,3);
1286 break;
1287 case 10441 :
1288 if (mCurWdg) {
1289 mLastWdg = mCurWdg;
1290 cout << " Using current widget as last-widget (display same) " << endl;
1291 }
1292 else cout << " No current widget - select widget with mouse " << endl;
1293 break;
1294 case 10460 :
1295 DeleteWindow(mCurWin);
1296 break;
1297 default:
1298 cerr << "PIStdImgApp::MBProcess4() BUG?? Msg= " << msg << endl;
1299 break;
1300 }
1301return;
1302}
1303
1304
1305/* --Methode-- */
1306void PIStdImgApp::MBProcess5(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
1307{
1308char nomps[64],strg[512];
1309PSFile *mps;
1310int sxt, syt, syo, syo1, sx[4], sy[4];
1311
1312switch (msg)
1313 {
1314 case 10501 :
1315 pfc_ps->AcceptNewFile(true);
1316 mFCMsg = 10525;
1317 pfc_ps->SetMsg(mFCMsg);
1318 SetBlocked();
1319 pfc_ps->Show();
1320 break;
1321
1322 case 10525 :
1323 SetBusy();
1324 if (data) {
1325 if (mpsfile) {
1326 printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
1327 delete mpsfile;
1328 }
1329 name_ps = pfc_ps->GetFileName();
1330 printf("PIStdImg/Info: Opening PS-File %s \n", name_ps.c_str());
1331 mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 2., 2.);
1332 }
1333 mFCMsg = 0;
1334 SetReady();
1335 break;
1336
1337 case 10505 :
1338 if (!mpsfile) break;
1339 printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
1340 delete mpsfile;
1341 mpsfile = NULL;
1342 name_ps = "";
1343 break;
1344
1345 case 10511 : // Window -> PS
1346 case 10512 : // Window -> EPS
1347 if (CurrentWindow() == NULL) break;
1348 if (msg == 10512)
1349 {
1350 num_eps++;
1351 sprintf(nomps,"pia%d.eps", num_eps);
1352 printf("PIStdImg/Info: Creating EPSFile %s (CurWin-> EPS) \n", nomps);
1353 mps = new PSFile(nomps);
1354 }
1355 else {
1356 if (mpsfile == NULL) {
1357 name_ps = "pia.ps";
1358 mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 0., 0.);
1359 printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
1360 }
1361 printf("PIStdImg/Info: CurWin-> PSFile %s\n", name_ps.c_str());
1362 mps = mpsfile;
1363 }
1364 CurrentWindow()->PSPrint(mps,0,0);
1365
1366 if (msg == 10512) delete mps; // fichier eps
1367 break;
1368
1369 case 10515 : // Image -> PS
1370 case 10516 : // Image -> EPS
1371 {
1372 PIImage* curpimg = NULL;
1373 if (!mCurWdg) return;
1374 if (mCurWdg->kind() != PIImage::ClassId) return;
1375 curpimg = (PIImage*)mCurWdg;
1376 if (curpimg == NULL) return;
1377 if (msg == 10516)
1378 {
1379 num_eps++;
1380 sprintf(nomps,"pia%d.eps", num_eps);
1381 printf("PIStdImg/Info: Creating EPSFile %s (CurImage-> EPS)\n", nomps);
1382 mps = new PSFile(nomps);
1383 }
1384 else {
1385 if (mpsfile == NULL) {
1386 name_ps = "pia.ps";
1387 mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
1388 printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
1389 }
1390 printf("PIStdImg/Info: CurImage-> PSFile %s\n", name_ps.c_str());
1391 mps = mpsfile;
1392 }
1393
1394 sx[0] = gimv->XSize();
1395 sy[0] = gimv->YSize();
1396 sx[1] = zoom->XSize();
1397 sy[1] = zoom->YSize();
1398 sx[2] = cmapv->XSize();
1399 sy[2] = cmapv->YSize();
1400 sx[3] = curpimg->XSize();
1401 sy[3] = curpimg->YSize();
1402 if (sy[1] > sy[0]) { syo1 = sy[1]+50; syo = sy[1]+sy[2]+60; }
1403 else { syo1 = sy[0]+50; syo = sy[0]+sy[2]+60; }
1404 syt = sy[3]+syo;
1405 sxt = sx[3];
1406 if (sxt < (sx[0]+sx[1]+20)) sxt = sx[0]+sx[1]+20;
1407 if (sxt < sx[2]) sxt = sx[2];
1408
1409 // Pour ecrire le titre
1410 mps->NewPage((float)sxt, (float)syt, PI_Portrait);
1411 mps->NewBloc(0,0, (float)sxt, 30., (float)sxt, 30.);
1412 sprintf(strg,"Image: %s - Pave %d %d \n", curpimg->Nom().c_str(),
1413 curpimg->XPave(), curpimg->YPave());
1414 mps->DrawString(10., 25., strg, PI_Black, PI_DefaultFont, PI_BoldFont, 20);
1415 mps->EndBloc();
1416
1417 // Les quatre fenetres glovimage, zoom, cmap, image
1418 gimv->PSPrint(mps, -gimv->XPos(), -gimv->YPos()+40);
1419 zoom->PSPrint(mps, -zoom->XPos()+sx[0]+20, -zoom->YPos()+40);
1420 cmapv->PSPrint(mps, -cmapv->XPos(), -cmapv->YPos()+syo1);
1421 curpimg->PSPrint(mps, -curpimg->XPos(), -curpimg->YPos()+syo);
1422
1423 if (msg == 10516) delete mps; // fichier eps
1424 break;
1425 }
1426
1427 default:
1428 cerr << "PIStdImgApp::MBProcess5() BUG?? Msg= " << msg << endl;
1429 break;
1430 }
1431
1432}
1433
1434
1435/* --Methode-- */
1436void PIStdImgApp::MBProcess6(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
1437{
1438switch (msg) {
1439 case 10601:
1440 CloseAllWindows();
1441 break;
1442 case 10602:
1443 RedirectStdOutErr(*((bool*)data));
1444 break;
1445 case 10603:
1446 case 10604:
1447 CatchSignals(m[5]->GetStateMsg(10603), m[5]->GetStateMsg(10604));
1448 break;
1449 case 10605:
1450 mObjMgr->SetVerbose(m[5]->GetStateMsg(10605));
1451 break;
1452 case 10606:
1453 mCmd->ShowCxxOptionWindow();
1454 break;
1455 default:
1456 cerr << "PIStdImgApp::MBProcess6() BUG?? Msg= " << msg << endl;
1457 break;
1458 }
1459return;
1460}
1461
1462
1463/* --Methode-- */
1464void PIStdImgApp::SetColAtt(PIColors fg, PIColors bg)
1465{
1466 mFCol = fg;
1467 mBCol = bg;
1468}
1469/* --Methode-- */
1470void PIStdImgApp::SetLineAtt(PILineAtt lat)
1471{
1472 mLAtt = lat;
1473}
1474
1475/* --Methode-- */
1476void PIStdImgApp::SetFontName(PIFontName fn)
1477{
1478 mFName = fn;
1479}
1480
1481/* --Methode-- */
1482void PIStdImgApp::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
1483{
1484 mFSz = fsz;
1485 mFAtt = fat;
1486}
1487/* --Methode-- */
1488void PIStdImgApp::SetMarkerAtt(int sz, PIMarker mrk)
1489{
1490 mMSz = sz;
1491 mMrk = mrk;
1492}
1493
1494/* --Methode-- */
1495void PIStdImgApp::SetZoomAtt(int zoom)
1496{
1497 if ( (zoom > 10) || (zoom < -10) ) zoom = 0;
1498 mZoom = zoom;
1499}
1500/* --Methode-- */
1501void PIStdImgApp::SetAxesAtt(unsigned int axfl)
1502{
1503 mAxesFlags = axfl;
1504}
1505/* --Methode-- */
1506void PIStdImgApp::SetXYLimits(double xmin, double xmax, double ymin, double ymax)
1507{
1508 mXmin = xmin; mXmax= xmax;
1509 mYmin = ymin; mYmax= ymax;
1510}
1511/* --Methode-- */
1512void PIStdImgApp::SetInsetLimits(double xmin, double xmax, double ymin, double ymax)
1513{
1514 mIXmin = xmin; mIXmax= xmax;
1515 mIYmin = ymin; mIYmax= ymax;
1516}
1517/* --Methode-- */
1518void PIStdImgApp::SetImageCenterPosition(int x, int y)
1519{
1520 mXImgCenter = x; mYImgCenter = y;
1521}
1522
1523/* --Methode-- */
1524void PIStdImgApp::SaveGraphicAtt()
1525{
1526 mSFCol = mFCol;
1527 mSBCol = mBCol;
1528 mSLAtt = mLAtt;
1529 mSFName = mFName;
1530 mSFSz = mFSz;
1531 mSFAtt = mFAtt;
1532 mSMSz = mMSz;
1533 mSMrk = mMrk;
1534 mSCmapid = mCmapid;
1535 mSRevCmap = mRevCmap;
1536 mSZoom = mZoom;
1537 mSAxesFlags = mAxesFlags;
1538 mSXmin = mXmin; mSXmax = mXmax;
1539 mSYmin = mYmin; mSYmax = mYmax;
1540 mSIXmin = mIXmin; mSIXmax = mIXmax;
1541 mSIYmin = mIYmin; mSIYmax = mIYmax;
1542 mSFXYlim = mFXYlim;
1543 mSXImgCenter = mXImgCenter;
1544 mSYImgCenter = mYImgCenter;
1545 mSFImgCenter = mFImgCenter;
1546 mSaXlog = maXlog;
1547 mSaYlog = maYlog;
1548 mSAddTitle = mAddTitle;
1549}
1550
1551/* --Methode-- */
1552void PIStdImgApp::RestoreGraphicAtt()
1553{
1554 mFCol = mSFCol;
1555 mBCol = mSBCol;
1556 mLAtt = mSLAtt;
1557 mFName = mSFName;
1558 mFSz = mSFSz;
1559 mFAtt = mSFAtt;
1560 mMSz = mSMSz;
1561 mMrk = mSMrk;
1562 mCmapid = mSCmapid;
1563 mRevCmap = mSRevCmap;
1564 mZoom = mSZoom;
1565 mAxesFlags = mSAxesFlags;
1566 mXmin = mSXmin; mXmax = mSXmax;
1567 mYmin = mSYmin; mYmax = mSYmax;
1568 mIXmin = mSIXmin; mIXmax = mSIXmax;
1569 mIYmin = mSIYmin; mIYmax = mSIYmax;
1570 mFXYlim = mSFXYlim;
1571 mXImgCenter = mSXImgCenter;
1572 mYImgCenter = mSYImgCenter;
1573 mFImgCenter = mSFImgCenter;
1574 maXlog = mSaXlog;
1575 maYlog = mSaYlog;
1576 mAddTitle = mSAddTitle;
1577}
1578
1579// -------------------------------------------------
1580// Fenetre info piapp (About piapp)
1581// -------------------------------------------------
1582static PIWindow* infow_win = NULL;
1583static PIText* infow_txt = NULL;
1584static PICMapView* infow_cmap = NULL;
1585static PIButton* infow_but = NULL;
1586
1587/* Nouvelle-Fonction */
1588static void createInfoWindow(PIStdImgApp* app)
1589{
1590if (infow_win) return;
1591
1592int bsx, bsy;
1593PIApplicationPrefCompSize(bsx, bsy);
1594int spx, spy;
1595spx = bsx/6; spy = bsy/6;
1596
1597infow_win = new PIWindow((PIMsgHandler *)app, "About piapp",
1598 PIWK_dialog, bsx*5+3*spx, bsy*4+spy*3, 200, 200);
1599infow_win->SetAutoDelChilds(true);
1600infow_txt = new PIText(infow_win,"about_piapp_text", bsx*5+spx, bsy*3, spx, spy);
1601infow_txt->SetMutiLineMode(true);
1602infow_txt->SetTextEditable(false);
1603infow_txt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
1604infow_cmap = new PICMapView(infow_win, "about_piapp_cmap", bsx*4, bsy*0.7, spx, 2*spy+bsy*3.15);
1605infow_cmap->SetColMapId(CMAP_COLBR32, 1., -1., false);
1606infow_cmap->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
1607infow_but = new PIButton(infow_win,"OK", 10155, bsx, bsy, bsx*4+2*spx, 2*spy+bsy*3);
1608infow_but->SetMsgParent((PIMsgHandler *)app);
1609infow_but->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
1610char buff[128];
1611#ifdef SANS_EVOLPLANCK
1612sprintf(buff, "Version: piapp=%g PI=%g PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER,
1613 (double)PI_VERSIONNUMBER, (float)PeidaVersion());
1614#else
1615{
1616sprintf(buff, "Version: piapp=%g PI=%g SOPHYA=%g \n", (double)PIAPP_VERSIONNUMBER,
1617 (double)PI_VERSIONNUMBER, glst_piai->Version());
1618}
1619#endif
1620string info = "piapp : Interactive analysis program\n";
1621info += buff;
1622info += "(C) LAL-IN2P3/CNRS 1996-2000\n";
1623info += "(C) SPP-DAPNIA/CEA 1996-2000\n";
1624infow_txt->SetText(info);
1625}
1626
1627/* Nouvelle-Fonction */
1628static void showInfoWindow(PIStdImgApp* app)
1629{
1630if (!infow_win) createInfoWindow(app);
1631if (infow_win) infow_win->Show();
1632}
1633/* Nouvelle-Fonction */
1634static void hideInfoWindow(PIStdImgApp* app)
1635{
1636if (infow_win) infow_win->Hide();
1637}
1638
1639/* Nouvelle-Fonction */
1640static void deleteInfoWindow()
1641{
1642if (!infow_win) return;
1643delete infow_win;
1644infow_win = NULL;
1645infow_txt = NULL;
1646infow_cmap = NULL;
1647infow_but = NULL;
1648}
1649
Note: See TracBrowser for help on using the repository browser.