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

Last change on this file since 1539 was 1513, checked in by ansari, 24 years ago

Modifs cosmetiques ... Reza 31/5/2001

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