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

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

petites corrections cosmetiques - Reza 23/8/2000

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