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

Last change on this file since 779 was 709, checked in by ercodmgr, 26 years ago

petites Corrections diverses - Reza 21/01/2000

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