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