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

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

GetTmpDir SetTmpDir ds nobjmgr.h
re-ecriture commande sur piconsole en bleu/bleu_gras
suppression OBJ ds CrMakeFile

rz+cmv 31/10/00

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