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

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

Introduction de l'option graphique tit/notit (methodes ds PIStdImgApp, modifs ds baseexcut.cc et ds servnobjmgr.cc - Reza 22/08/2000

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