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