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

Last change on this file since 1251 was 1251, checked in by ercodmgr, 25 years ago

fenetre pour CxxExecutor - Reza 24/10/2000

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