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

Last change on this file since 1504 was 1504, checked in by ansari, 24 years ago

ajout option graphique revcmap pour inverser l'indexage des ColorMap - Reza 21/5/2001

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