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

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

Pb compil sous Sophya - Reza 23/12/99

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