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

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

Plantage sur exit sur Linux-PPC ajout de MainWin()->Hide() ds destructeur , Reza 17/7/2000

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