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

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

Center Image et Cur-LastWdg - Reza 9/9/99

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