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

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

Amelioration cxxexecutor - Reza , 10/11/2000

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