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