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

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

Adaptateur de TArray et lecture FITS - Reza 13/11/2000

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