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 | mXmin = mYmin = -1.;
|
---|
204 | mXmax = mYmax = 1;
|
---|
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 | if ( (opt == Disp_Same) && (mLastWdg) ) {
|
---|
466 | if (mLastWdg->kind() == PIScDrawWdg::ClassId) ((PIScDrawWdg*)mLastWdg)->AddScDrawer(scd, true);
|
---|
467 | else mLastWdg->AddDrawer(scd, true, true, true);
|
---|
468 | scd->Refresh();
|
---|
469 | mDId++;
|
---|
470 | mDrwList[mDId] = scd;
|
---|
471 | return(-mDId);
|
---|
472 | }
|
---|
473 | else if (opt == Disp_Same) opt = Disp_Next;
|
---|
474 |
|
---|
475 | PIWindow* win;
|
---|
476 | PIScDrawWdg* scw;
|
---|
477 | int sx, sy, px, py, flag;
|
---|
478 | sx = 200+mFgScSz*100;
|
---|
479 | sy = 200+mFgScSz*100;
|
---|
480 | win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
|
---|
481 | if (typeid(*scd) != typeid(PIHisto2D))
|
---|
482 | scw = new PIScDrawWdg(win, (char *)name.c_str(), sx, sy, px, py);
|
---|
483 | else scw = new PIH2DWdg(win, (char *)name.c_str(), sx, sy, px, py);
|
---|
484 | scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
|
---|
485 | scw->SetUserData(NULL, oid);
|
---|
486 | if (maXlog || maYlog) scw->SetLogScale(maXlog, maYlog); // Echelle log
|
---|
487 | if (mFXYlim) // Forcage limites XY
|
---|
488 | scw->SetLimits(mXmin, mXmax, mYmin, mYmax);
|
---|
489 | scw->SetAxesFlags(mAxesFlags);
|
---|
490 |
|
---|
491 | if (typeid(*scd) != typeid(PIHisto2D)) scw->AddScDrawer(scd, true);
|
---|
492 | else ((PIH2DWdg*)scw)->SetPIHisto((PIHisto2D*)scd);
|
---|
493 | // Titre du plot
|
---|
494 | if (title.length() <= 0) title = name; string t2="";
|
---|
495 | scw->SetTitles(title, t2);
|
---|
496 | // scw->Refresh(); ? Pas necessaire Reza 19/08/98, 05/05/99 $CHECK$
|
---|
497 | mCurWin = win;
|
---|
498 | mCurWdg = scw;
|
---|
499 | mLastWdg = scw;
|
---|
500 | mBWId++;
|
---|
501 | mBWList[mBWId] = scw;
|
---|
502 | return(mBWId);
|
---|
503 | }
|
---|
504 |
|
---|
505 | /* --Methode-- */
|
---|
506 | int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, int opt, string title, int oid)
|
---|
507 | {
|
---|
508 | if (dr3 == NULL)
|
---|
509 | {
|
---|
510 | printf("PIStdImgApp::Disp3DDrawer_Error Cannot Add NULL 3DDrawer \n");
|
---|
511 | return(-1);
|
---|
512 | }
|
---|
513 |
|
---|
514 | // Changement d'attributs graphiques courants du drawer
|
---|
515 | if (mFCol != PI_NotDefColor) dr3->SetColAtt(mFCol, mBCol);
|
---|
516 | if (mLAtt != PI_NotDefLineAtt) dr3->SetLineAtt(mLAtt);
|
---|
517 | if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) ) dr3->SetFontAtt(mFSz, mFAtt);
|
---|
518 | if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) ) dr3->SetMarkerAtt(mMSz, mMrk);
|
---|
519 | if ( mCmapid != CMAP_OTHER ) dr3->SetColMapId(mCmapid);
|
---|
520 |
|
---|
521 | if ( (opt == Disp_Same) && (mLastWdg) ) {
|
---|
522 | if (mLastWdg->kind() == PIDraw3DWdg::ClassId) ((PIDraw3DWdg*)mLastWdg)->AddDrawer3D(dr3, true);
|
---|
523 | else mLastWdg->AddDrawer(dr3, true, true, true);
|
---|
524 | dr3->Refresh();
|
---|
525 | mDId++;
|
---|
526 | mDrwList[mDId] = dr3;
|
---|
527 | return(-mDId);
|
---|
528 | }
|
---|
529 | else if (opt == Disp_Same) opt = Disp_Next;
|
---|
530 |
|
---|
531 | PIWindow* win;
|
---|
532 | int sx, sy, px, py, flag;
|
---|
533 | sx = 200+mFgScSz*100;
|
---|
534 | sy = 200+mFgScSz*100;
|
---|
535 | win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
|
---|
536 | PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)name.c_str(), sx, sy, px, py);
|
---|
537 | wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
|
---|
538 | wd3->SetUserData(NULL, oid);
|
---|
539 | wd3->AddDrawer3D(dr3, true);
|
---|
540 | // Titre du plot
|
---|
541 | if (title.length() <= 0) title = name; string t2="";
|
---|
542 | wd3->SetTitles(title, t2);
|
---|
543 | // wd3->Refresh(); ?Pas necessaire $CHECK$ 05/05/99
|
---|
544 | mCurWin = win;
|
---|
545 | mCurWdg = wd3;
|
---|
546 | mLastWdg = wd3;
|
---|
547 | mBWId++;
|
---|
548 | mBWList[mBWId] = wd3;
|
---|
549 | return(mBWId);
|
---|
550 | }
|
---|
551 |
|
---|
552 | /* --Methode-- */
|
---|
553 | void PIStdImgApp::AddText(string const & txt, double xp, double yp)
|
---|
554 | {
|
---|
555 | if (!mLastWdg) return;
|
---|
556 | PIElDrawer *eld=NULL;
|
---|
557 | PIScDrawWdg* sdw=NULL;
|
---|
558 | PIDraw3DWdg* w3d=NULL;
|
---|
559 | PIImage* imgw;
|
---|
560 | switch(mLastWdg->kind()) {
|
---|
561 | case PIScDrawWdg::ClassId :
|
---|
562 | sdw = dynamic_cast<PIScDrawWdg *>(mLastWdg);
|
---|
563 | if (sdw) eld = sdw->BaseDrawer();
|
---|
564 | break;
|
---|
565 | case PIDraw3DWdg::ClassId :
|
---|
566 | w3d = dynamic_cast<PIDraw3DWdg *>(mLastWdg);
|
---|
567 | if (w3d) eld = w3d->BaseDrawer();
|
---|
568 | break;
|
---|
569 | case PIImage::ClassId :
|
---|
570 | imgw = dynamic_cast<PIImage *>(mLastWdg);
|
---|
571 | if (imgw) eld = imgw->MyElDrawer();
|
---|
572 | break;
|
---|
573 | default :
|
---|
574 | break;
|
---|
575 | }
|
---|
576 | if (eld) {
|
---|
577 | if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) ) eld->SetFontAtt(mFSz, mFAtt);
|
---|
578 | eld->ElAddText(xp,yp,txt.c_str(),mFCol);
|
---|
579 | eld->Refresh();
|
---|
580 | }
|
---|
581 | }
|
---|
582 |
|
---|
583 | /* --Methode-- */
|
---|
584 | void PIStdImgApp::CreateGraphWin(int nx, int ny, int sx, int sy)
|
---|
585 | {
|
---|
586 | if (nx < 1) nx = 1;
|
---|
587 | if (ny < 1) ny = 1;
|
---|
588 | if (nx > 8) nx = 8;
|
---|
589 | if (ny > 8) ny = 8;
|
---|
590 | if ( (sx < 50) && (sy < 50) ) sx = sy = 400+mFgScSz*100;
|
---|
591 | char buff[64];
|
---|
592 | mWId++;
|
---|
593 | int px, py;
|
---|
594 | MainWin()->GetScreenPos(px, py);
|
---|
595 | sprintf(buff, "PI-GraphicWin (%d)",mWId);
|
---|
596 | PIZoneWindow* win = new PIZoneWindow(this, buff, PIWK_normal, nx, ny, sx, sy, px+MainWin()->XSize()+30, 0);
|
---|
597 | win->SetUserData(NULL, ny*10+nx); // UserFlag= nY*10 + nX
|
---|
598 | mWList[mWId*10+1] = (PIWindow*)win;
|
---|
599 | win->SetAutoDelChilds(true);
|
---|
600 | // win->Show();
|
---|
601 | mGrW = win;
|
---|
602 | mGrIdx = 0;
|
---|
603 | }
|
---|
604 |
|
---|
605 | /* --Methode-- */
|
---|
606 | void PIStdImgApp::CreateStackWin(int sx, int sy)
|
---|
607 | {
|
---|
608 | if ( (sx < 50) && (sy < 50) ) sx = sy = 300+mFgScSz*100;
|
---|
609 | char buff[64];
|
---|
610 | mWId++;
|
---|
611 | int px, py;
|
---|
612 | MainWin()->GetScreenPos(px, py);
|
---|
613 | sprintf(buff, "PI-StackWin (%d)",mWId);
|
---|
614 | PIStackWindow* win = new PIStackWindow(this, buff, PIWK_normal, sx, sy, px+MainWin()->XSize()+30, 100);
|
---|
615 | win->SetUserData(NULL, 9999); // UserFlag= 9999
|
---|
616 | mWList[mWId*10+2] = (PIWindow*)win;
|
---|
617 | win->SetAutoDelChilds(true);
|
---|
618 | // win->Show();
|
---|
619 | mStW = win;
|
---|
620 | m[2]->SetSensitivity("StackTools", true);
|
---|
621 | mStIdx = 0;
|
---|
622 | }
|
---|
623 |
|
---|
624 | /* --Methode-- */
|
---|
625 | PIWindow* PIStdImgApp::GetWindow(int typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom)
|
---|
626 | {
|
---|
627 | PIWindow* rw;
|
---|
628 |
|
---|
629 | switch (typ) {
|
---|
630 | case Disp_Next : // Fenetre graphique courante
|
---|
631 | {
|
---|
632 | if (mGrW == NULL) CreateGraphWin();
|
---|
633 | int nx, ny;
|
---|
634 | mGrW->NbZone(nx, ny);
|
---|
635 | PIWdg* nw = mGrW->NextChildPosSize(px, py, sx, sy);
|
---|
636 | // cerr << "**DBG** PIStdImgApp::GetWindow() DispNext : nw = " << (long)nw << endl;
|
---|
637 | if (nw) DeleteBaseWidget((PIBaseWdg*)nw, false, false);
|
---|
638 | flag = mGrIdx;
|
---|
639 | mGrIdx = (mGrIdx+1)%(nx*ny);
|
---|
640 | rw = mGrW;
|
---|
641 | break;
|
---|
642 | }
|
---|
643 |
|
---|
644 | case Disp_Stack : // Fenetre de type stack (empilement)
|
---|
645 | {
|
---|
646 | if (mStW == NULL) CreateStackWin(sx, sy);
|
---|
647 | px = py = 0;
|
---|
648 | sx = mStW->XSize();
|
---|
649 | sy = mStW->YSize();
|
---|
650 | flag = mStIdx;
|
---|
651 | mStIdx++;
|
---|
652 | rw = mStW;
|
---|
653 | }
|
---|
654 | break;
|
---|
655 |
|
---|
656 | default : // Fenetre ordinaire
|
---|
657 | {
|
---|
658 | int pwx, pwy;
|
---|
659 | MainWin()->GetScreenPos(pwx, pwy);
|
---|
660 | if ( (sx < 50) && (sy < 50) ) sx = sy = 300+mFgScSz*100;
|
---|
661 | rw = new PIWindow(this, nom, PIWK_normal, sx, sy, pwx+MainWin()->XSize()+30, 300);
|
---|
662 | rw->SetUserData(NULL, 0); // UserFlag= 0
|
---|
663 | mWId++;
|
---|
664 | mWList[mWId*10] = rw;
|
---|
665 | rw->SetAutoDelChilds(true);
|
---|
666 | // rw->Show();
|
---|
667 | px = py = 0;
|
---|
668 | flag = 0;
|
---|
669 | break;
|
---|
670 | }
|
---|
671 | }
|
---|
672 |
|
---|
673 | rw->Show();
|
---|
674 | mCurWin = rw;
|
---|
675 | return(rw);
|
---|
676 | }
|
---|
677 |
|
---|
678 | /* --Methode-- */
|
---|
679 | void PIStdImgApp::SetZone(int nzx, int nzy)
|
---|
680 | {
|
---|
681 | if (!mGrW) CreateGraphWin(nzx, nzy);
|
---|
682 | else {
|
---|
683 | int k;
|
---|
684 | PIWdg* cwd;
|
---|
685 | for(k=0; k<mGrW->NbChilds(); k++) {
|
---|
686 | if ((cwd = mGrW->GetChild(k)) == NULL) continue;
|
---|
687 | DeleteBaseWidget((PIBaseWdg*)cwd, false, false);
|
---|
688 | }
|
---|
689 | mGrW->SetZone(nzx, nzy);
|
---|
690 | }
|
---|
691 | }
|
---|
692 |
|
---|
693 | /* --Methode-- */
|
---|
694 | void PIStdImgApp::StackWinNext()
|
---|
695 | {
|
---|
696 | if (mStW) mStW->DispNext();
|
---|
697 | }
|
---|
698 |
|
---|
699 | /* --Methode-- */
|
---|
700 | void PIStdImgApp::DeleteWindow(PIWindow* w)
|
---|
701 | {
|
---|
702 | if (w == NULL) return;
|
---|
703 | w->Hide();
|
---|
704 | bool ownwindow=false; // To Check if this is one of our windows
|
---|
705 | WindMList::iterator it;
|
---|
706 | for(it = mWList.begin(); it != mWList.end(); it++)
|
---|
707 | if ((*it).second == w) { mWList.erase(it); ownwindow = true; break; }
|
---|
708 | if (w == mGrW) { mGrW = NULL; mGrIdx = -1; }
|
---|
709 | if (w == mStW) { mStW = NULL; mStIdx = -1; m[2]->SetSensitivity("StackTools", false); }
|
---|
710 | if (w == mCurWin) mCurWin = NULL;
|
---|
711 |
|
---|
712 | if (!ownwindow) return; // We do nothing if this is not a window we have created ...
|
---|
713 |
|
---|
714 | int k;
|
---|
715 | PIWdg* cwd;
|
---|
716 | for(k=0; k<w->NbChilds(); k++) {
|
---|
717 | if ((cwd = w->GetChild(k)) == NULL) continue;
|
---|
718 | DeleteBaseWidget((PIBaseWdg*)cwd,false,false);
|
---|
719 | }
|
---|
720 | delete w;
|
---|
721 | return;
|
---|
722 | }
|
---|
723 |
|
---|
724 | /* --Methode-- */
|
---|
725 | void PIStdImgApp::DeleteBaseWidget(PIBaseWdg* w, bool dw, bool dwin)
|
---|
726 | {
|
---|
727 | if (w == NULL) return;
|
---|
728 | BWMList::iterator it;
|
---|
729 | for(it = mBWList.begin(); it != mBWList.end(); it++)
|
---|
730 | if ((*it).second == w) { mBWList.erase(it); break; }
|
---|
731 | int k;
|
---|
732 | PIDrawer* drw;
|
---|
733 | for(k=0; k<w->NbDrawers(); k++) {
|
---|
734 | if ((drw = w->GetDrawer(k)) == NULL) continue;
|
---|
735 | DrwMList::iterator itt;
|
---|
736 | for(itt = mDrwList.begin(); itt != mDrwList.end(); itt++)
|
---|
737 | if ((*itt).second == drw) { mDrwList.erase(itt); break; }
|
---|
738 | }
|
---|
739 |
|
---|
740 | if (w == mCurWdg) {
|
---|
741 | mCurWdg = NULL;
|
---|
742 | if (mFgCWImg) {
|
---|
743 | m[4]->SetSensitivityMsg(10515, false);
|
---|
744 | m[4]->SetSensitivityMsg(10516, false);
|
---|
745 | mFgCWImg = false;
|
---|
746 | }
|
---|
747 | }
|
---|
748 |
|
---|
749 | if (w == mLastWdg) mLastWdg = NULL;
|
---|
750 |
|
---|
751 | PIWdg* pw=NULL;
|
---|
752 | if (dwin) pw = (PIWdg*)(w->Parent());
|
---|
753 | //DBG printf("DeleteBaseWidget(%lx)-DBG kind = %d - %d %d \n", (long)w, w->kind(), (int)dw, (int)dwin);
|
---|
754 | if (dw) delete w;
|
---|
755 | if (pw && (pw->kind() == PIWindow::ClassId )) {
|
---|
756 | PIWindow* pww = (PIWindow*) pw;
|
---|
757 | if ((pww != (PIWindow*)mGrW) && (pww != (PIWindow*)mStW) && (pww->NbChilds()==0))
|
---|
758 | DeleteWindow((PIWindow*)pw);
|
---|
759 | }
|
---|
760 | return;
|
---|
761 | }
|
---|
762 |
|
---|
763 |
|
---|
764 |
|
---|
765 | /* --Methode-- */
|
---|
766 | void PIStdImgApp::DelWRsId(int k)
|
---|
767 | {
|
---|
768 | //DBG cerr << "-DBG- PIStdImgApp::DelWRsId(" << k << ")" << endl;
|
---|
769 | if (k > 0) { // C'est un BaseWidget
|
---|
770 | BWMList::iterator it;
|
---|
771 | it = mBWList.find(k);
|
---|
772 | if (it == mBWList.end()) return;
|
---|
773 | PIBaseWdg* wd = (*it).second;
|
---|
774 | //DBG cerr << "-DBG- PIStdImgApp::DelWRsId Deleting BaseWidget " << (long)(wd) << endl ;
|
---|
775 | DeleteBaseWidget(wd, true, true);
|
---|
776 | }
|
---|
777 | else { // C'est un drawer
|
---|
778 | DrwMList::iterator it;
|
---|
779 | it = mDrwList.find(-k);
|
---|
780 | if (it == mDrwList.end()) return;
|
---|
781 | delete (*it).second;
|
---|
782 | mDrwList.erase(it);
|
---|
783 | // cerr << "+DBG+ PIStdImgApp::DelWRsId Deleting Drawer " << (long)((*it).second) << endl ;
|
---|
784 | }
|
---|
785 | }
|
---|
786 | /* --Methode-- */
|
---|
787 | bool PIStdImgApp::CheckWRsId(int k)
|
---|
788 | {
|
---|
789 | if (k > 0) { // C'est un BaseWidget
|
---|
790 | BWMList::iterator it;
|
---|
791 | it = mBWList.find(k);
|
---|
792 | if (it == mBWList.end()) return(false);
|
---|
793 | else return(true);
|
---|
794 | }
|
---|
795 | else { // C'est un drawer
|
---|
796 | DrwMList::iterator it;
|
---|
797 | it = mDrwList.find(-k);
|
---|
798 | if (it == mDrwList.end()) return(false);
|
---|
799 | else return(true);
|
---|
800 | }
|
---|
801 | }
|
---|
802 |
|
---|
803 |
|
---|
804 | /* --Methode-- */
|
---|
805 | void PIStdImgApp::RedirectStdOutErr(bool fg)
|
---|
806 | {
|
---|
807 | if (fg) {
|
---|
808 | RedirectOutStream(mCons);
|
---|
809 | RedirectErrStream(mCons);
|
---|
810 | m[5]->SetStateMsg(10602, true);
|
---|
811 | redirecout = true;
|
---|
812 | }
|
---|
813 | else {
|
---|
814 | RedirectOutStream(NULL);
|
---|
815 | RedirectErrStream(NULL);
|
---|
816 | m[5]->SetStateMsg(10602, false);
|
---|
817 | redirecout = false;
|
---|
818 | }
|
---|
819 | return;
|
---|
820 | }
|
---|
821 |
|
---|
822 | /* --Methode-- */
|
---|
823 | void PIStdImgApp::CatchSignals(bool fgfpe, bool fgsegv)
|
---|
824 | {
|
---|
825 | PeidaConfigureSignalhandling(fgfpe, fgsegv, true, true);
|
---|
826 | m[5]->SetStateMsg(10603, fgfpe);
|
---|
827 | m[5]->SetStateMsg(10604, fgsegv);
|
---|
828 | }
|
---|
829 |
|
---|
830 | /* --Methode-- */
|
---|
831 | void PIStdImgApp::CloseAllWindows()
|
---|
832 | {
|
---|
833 | WindMList::iterator it;
|
---|
834 | for(it = mWList.begin(); it != mWList.end(); it++) delete (*it).second;
|
---|
835 | mWList.clear();
|
---|
836 | mBWList.clear();
|
---|
837 | mDrwList.clear();
|
---|
838 | mGrW = NULL;
|
---|
839 | mStW = NULL;
|
---|
840 | mCurWin = NULL;
|
---|
841 | mCurWdg = NULL;
|
---|
842 | mLastWdg = NULL;
|
---|
843 | m[4]->SetSensitivityMsg(10515, false);
|
---|
844 | m[4]->SetSensitivityMsg(10516, false);
|
---|
845 | }
|
---|
846 |
|
---|
847 | /* --Methode-- */
|
---|
848 | void PIStdImgApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
849 | {
|
---|
850 |
|
---|
851 | switch(msg)
|
---|
852 | {
|
---|
853 | case 10100 :
|
---|
854 | mCmd->ShowHelpWindow();
|
---|
855 | break;
|
---|
856 |
|
---|
857 | case 10120 :
|
---|
858 | pfc->SetPath(ImgDir);
|
---|
859 | pfc->AcceptNewFile(false);
|
---|
860 | mFCMsg = 10125;
|
---|
861 | pfc->SetMsg(mFCMsg);
|
---|
862 | SetBlocked();
|
---|
863 | pfc->Show();
|
---|
864 | break;
|
---|
865 |
|
---|
866 | case 10125 :
|
---|
867 | SetBusy();
|
---|
868 | if (data) {
|
---|
869 | string nomobj="";
|
---|
870 | ObjMgr()->ReadFits(pfc->GetFileName(), nomobj);
|
---|
871 | ObjMgr()->DisplayObj(nomobj, "win");
|
---|
872 | }
|
---|
873 | mFCMsg = 0;
|
---|
874 | SetReady();
|
---|
875 | break;
|
---|
876 |
|
---|
877 | case 10130 :
|
---|
878 | pfc->SetPath(WorkDir);
|
---|
879 | pfc->AcceptNewFile(false);
|
---|
880 | mFCMsg = 10135;
|
---|
881 | pfc->SetMsg(mFCMsg);
|
---|
882 | SetBlocked();
|
---|
883 | pfc->Show();
|
---|
884 | break;
|
---|
885 |
|
---|
886 | case 10135 :
|
---|
887 | mFCMsg = 0;
|
---|
888 | if (data) {
|
---|
889 | PPInMgrW()->SetFile(pfc->GetFileName());
|
---|
890 | PPInMgrW()->Show();
|
---|
891 | }
|
---|
892 | SetReady();
|
---|
893 | break;
|
---|
894 |
|
---|
895 | case 10110 :
|
---|
896 | DeleteWindow(mCurWin);
|
---|
897 | break;
|
---|
898 |
|
---|
899 | case 10111 :
|
---|
900 | if (mCurWdg) {
|
---|
901 | int oid = mCurWdg->UserFlag();
|
---|
902 | DeleteBaseWidget(mCurWdg);
|
---|
903 | mObjMgr->DelObj_Id(oid);
|
---|
904 | }
|
---|
905 | break;
|
---|
906 |
|
---|
907 | case 10105:
|
---|
908 | Stop();
|
---|
909 | break;
|
---|
910 |
|
---|
911 | }
|
---|
912 | return;
|
---|
913 | }
|
---|
914 |
|
---|
915 |
|
---|
916 |
|
---|
917 | /* --Methode-- */
|
---|
918 | void PIStdImgApp::MBProcess2(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
919 | {
|
---|
920 |
|
---|
921 | switch (msg) {
|
---|
922 | case 10201 :
|
---|
923 | ObjMgrW()->Show();
|
---|
924 | break;
|
---|
925 |
|
---|
926 | case 10220 :
|
---|
927 | pfc->SetPath(WorkDir);
|
---|
928 | pfc->AcceptNewFile(true);
|
---|
929 | mFCMsg = 10225;
|
---|
930 | pfc->SetMsg(mFCMsg);
|
---|
931 | SetBlocked();
|
---|
932 | pfc->Show();
|
---|
933 | break;
|
---|
934 |
|
---|
935 | case 10225 :
|
---|
936 | SetBusy();
|
---|
937 | if (data) {
|
---|
938 | if (mPpfout) {
|
---|
939 | printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
|
---|
940 | delete mPpfout;
|
---|
941 | }
|
---|
942 | name_outppf = pfc->GetFileName();
|
---|
943 | mPpfout = NULL;
|
---|
944 | printf("PIStdImg/Info: Opening POutPersist-File %s \n", name_outppf.c_str());
|
---|
945 | mPpfout = new POutPersist(name_outppf);
|
---|
946 | }
|
---|
947 | mFCMsg = 0;
|
---|
948 | SetReady();
|
---|
949 | break;
|
---|
950 |
|
---|
951 | case 10230 :
|
---|
952 | if (!mPpfout) break;
|
---|
953 | printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
|
---|
954 | delete mPpfout;
|
---|
955 | name_outppf = "";
|
---|
956 | mPpfout = NULL;
|
---|
957 | break;
|
---|
958 |
|
---|
959 |
|
---|
960 | default:
|
---|
961 | cerr << "PIStdImgApp::MBProcess2() BUG?? Msg= " << msg << endl;
|
---|
962 | break;
|
---|
963 | }
|
---|
964 |
|
---|
965 | return;
|
---|
966 | }
|
---|
967 |
|
---|
968 | /* --Methode-- */
|
---|
969 | void PIStdImgApp::MBProcess3(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
|
---|
970 | {
|
---|
971 |
|
---|
972 | switch (msg) {
|
---|
973 | case 10301 :
|
---|
974 | PIImgTools::ShowPIImgTools();
|
---|
975 | break;
|
---|
976 | case 10302 :
|
---|
977 | PIDrwTools::ShowPIDrwTools();
|
---|
978 | break;
|
---|
979 |
|
---|
980 | case 10304 :
|
---|
981 | case 10305 :
|
---|
982 | {
|
---|
983 | PIImage* curpimg = NULL;
|
---|
984 | if (!mCurWdg) return;
|
---|
985 | if (mCurWdg->kind() != PIImage::ClassId) return;
|
---|
986 | curpimg = (PIImage*)mCurWdg;
|
---|
987 | if (curpimg == NULL) return;
|
---|
988 | P2DArrayAdapter* img = curpimg->Image();
|
---|
989 | if (img == NULL) return;
|
---|
990 | int dx = curpimg->XSzPave();
|
---|
991 | int dy = curpimg->YSzPave();
|
---|
992 | int x0 = curpimg->XPave()-dx/2;
|
---|
993 | int y0 = curpimg->YPave()-dy/2;
|
---|
994 | if (x0 < 0) x0 = 0;
|
---|
995 | if (y0 < 0) y0 = 0;
|
---|
996 | int x1 = x0+dx;
|
---|
997 | int y1 = y0+dy;
|
---|
998 | if (x1 > img->XSize()) x1 = img->XSize();
|
---|
999 | if (y1 > img->YSize()) y1 = img->YSize();
|
---|
1000 | dx = x1-x0; dy = y1-y0;
|
---|
1001 | ImageR4* pim = new ImageR4(dx, dy);
|
---|
1002 | int ii, jj;
|
---|
1003 | for(jj=0; jj<dy; jj++)
|
---|
1004 | for(ii=0; ii<dx; ii++) (*pim)(ii,jj) = (*img)(ii+x0, jj+y0);
|
---|
1005 | if (msg == 10305) { // Calcul des coordonnees du sous-pave
|
---|
1006 | double xc1, yc1;
|
---|
1007 | img->Coord(x0, y0, xc1, yc1);
|
---|
1008 | pim->SetOrg((int)xc1, (int)yc1);
|
---|
1009 | }
|
---|
1010 | string nom = mCurWdg->Nom() + "_pave";
|
---|
1011 | ObjMgr()->AddObj(pim, nom);
|
---|
1012 | ObjMgr()->DisplayObj(nom, "w");
|
---|
1013 | break;
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | case 10306 :
|
---|
1017 | {
|
---|
1018 | PIImage* curpimg = NULL;
|
---|
1019 | if (!mCurWdg) return;
|
---|
1020 | if (mCurWdg->kind() != PIImage::ClassId) return;
|
---|
1021 | curpimg = (PIImage*)mCurWdg;
|
---|
1022 | if (curpimg == NULL) return;
|
---|
1023 | curpimg->ShowCuts(true);
|
---|
1024 | break;
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | case 10320 :
|
---|
1028 | if (mStW) mStW->DispNext();
|
---|
1029 | break;
|
---|
1030 |
|
---|
1031 | case 10321 :
|
---|
1032 | case 10322 :
|
---|
1033 | case 10324 :
|
---|
1034 | // case 10328 :
|
---|
1035 | if (mStW) mStW->StartAutoDisp((msg-10320)*500);
|
---|
1036 | break;
|
---|
1037 |
|
---|
1038 | case 10329 :
|
---|
1039 | if (mStW) mStW->StopAutoDisp();
|
---|
1040 | break;
|
---|
1041 |
|
---|
1042 | case 103330 :
|
---|
1043 | if (mStW) {
|
---|
1044 | PIWdg* cw = mStW->CurrentWdg();
|
---|
1045 | if (cw) DeleteBaseWidget((PIBaseWdg*)cw);
|
---|
1046 | }
|
---|
1047 | break;
|
---|
1048 |
|
---|
1049 | default:
|
---|
1050 | cerr << "PIStdImgApp::MBProcess3() BUG?? Msg= " << msg << endl;
|
---|
1051 | break;
|
---|
1052 | }
|
---|
1053 | return;
|
---|
1054 | }
|
---|
1055 |
|
---|
1056 | /* --Methode-- */
|
---|
1057 | void PIStdImgApp::MBProcess4(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
|
---|
1058 | {
|
---|
1059 |
|
---|
1060 | switch (msg) {
|
---|
1061 |
|
---|
1062 | case 10400 :
|
---|
1063 | CreateStackWin();
|
---|
1064 | break;
|
---|
1065 |
|
---|
1066 | case 10411 :
|
---|
1067 | CreateGraphWin(1,1);
|
---|
1068 | break;
|
---|
1069 | case 10421 :
|
---|
1070 | CreateGraphWin(1,2);
|
---|
1071 | break;
|
---|
1072 | case 10412 :
|
---|
1073 | CreateGraphWin(2,1);
|
---|
1074 | break;
|
---|
1075 | case 10422 :
|
---|
1076 | CreateGraphWin(2,2);
|
---|
1077 | break;
|
---|
1078 | case 10431 :
|
---|
1079 | CreateGraphWin(1,3);
|
---|
1080 | break;
|
---|
1081 | case 10433 :
|
---|
1082 | CreateGraphWin(3,3);
|
---|
1083 | break;
|
---|
1084 |
|
---|
1085 | default:
|
---|
1086 | cerr << "PIStdImgApp::MBProcess4() BUG?? Msg= " << msg << endl;
|
---|
1087 | break;
|
---|
1088 | }
|
---|
1089 | return;
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 |
|
---|
1093 | /* --Methode-- */
|
---|
1094 | void PIStdImgApp::MBProcess5(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
1095 | {
|
---|
1096 | char nomps[64],strg[512];
|
---|
1097 | PSFile *mps;
|
---|
1098 | int sxt, syt, syo, syo1, sx[4], sy[4];
|
---|
1099 |
|
---|
1100 | switch (msg)
|
---|
1101 | {
|
---|
1102 | case 10501 :
|
---|
1103 | pfc->SetPath(WorkDir);
|
---|
1104 | pfc->AcceptNewFile(true);
|
---|
1105 | mFCMsg = 10525;
|
---|
1106 | pfc->SetMsg(mFCMsg);
|
---|
1107 | SetBlocked();
|
---|
1108 | pfc->Show();
|
---|
1109 | break;
|
---|
1110 |
|
---|
1111 | case 10525 :
|
---|
1112 | SetBusy();
|
---|
1113 | if (data) {
|
---|
1114 | if (mpsfile) {
|
---|
1115 | printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
|
---|
1116 | delete mpsfile;
|
---|
1117 | }
|
---|
1118 | name_ps = pfc->GetFileName();
|
---|
1119 | printf("PIStdImg/Info: Opening PS-File %s \n", name_ps.c_str());
|
---|
1120 | mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 2., 2.);
|
---|
1121 | }
|
---|
1122 | mFCMsg = 0;
|
---|
1123 | SetReady();
|
---|
1124 | break;
|
---|
1125 |
|
---|
1126 | case 10505 :
|
---|
1127 | if (!mpsfile) break;
|
---|
1128 | printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
|
---|
1129 | delete mpsfile;
|
---|
1130 | mpsfile = NULL;
|
---|
1131 | name_ps = "";
|
---|
1132 | break;
|
---|
1133 |
|
---|
1134 | case 10511 : // Window -> PS
|
---|
1135 | case 10512 : // Window -> EPS
|
---|
1136 | if (CurrentWindow() == NULL) break;
|
---|
1137 | if (msg == 10512)
|
---|
1138 | {
|
---|
1139 | num_eps++;
|
---|
1140 | sprintf(nomps,"pia%d.eps", num_eps);
|
---|
1141 | printf("PIStdImg/Info: Creating EPSFile %s (CurWin-> EPS) \n", nomps);
|
---|
1142 | mps = new PSFile(nomps);
|
---|
1143 | }
|
---|
1144 | else {
|
---|
1145 | if (mpsfile == NULL) {
|
---|
1146 | name_ps = "pia.ps";
|
---|
1147 | mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 0., 0.);
|
---|
1148 | printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
|
---|
1149 | }
|
---|
1150 | printf("PIStdImg/Info: CurWin-> PSFile %s\n", name_ps.c_str());
|
---|
1151 | mps = mpsfile;
|
---|
1152 | }
|
---|
1153 | CurrentWindow()->PSPrint(mps,0,0);
|
---|
1154 |
|
---|
1155 | if (msg == 10512) delete mps; // fichier eps
|
---|
1156 | break;
|
---|
1157 |
|
---|
1158 | case 10515 : // Image -> PS
|
---|
1159 | case 10516 : // Image -> EPS
|
---|
1160 | {
|
---|
1161 | PIImage* curpimg = NULL;
|
---|
1162 | if (!mCurWdg) return;
|
---|
1163 | if (mCurWdg->kind() != PIImage::ClassId) return;
|
---|
1164 | curpimg = (PIImage*)mCurWdg;
|
---|
1165 | if (curpimg == NULL) return;
|
---|
1166 | if (msg == 10516)
|
---|
1167 | {
|
---|
1168 | num_eps++;
|
---|
1169 | sprintf(nomps,"pia%d.eps", num_eps);
|
---|
1170 | printf("PIStdImg/Info: Creating EPSFile %s (CurImage-> EPS)\n", nomps);
|
---|
1171 | mps = new PSFile(nomps);
|
---|
1172 | }
|
---|
1173 | else {
|
---|
1174 | if (mpsfile == NULL) {
|
---|
1175 | name_ps = "pia.ps";
|
---|
1176 | mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
|
---|
1177 | printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
|
---|
1178 | }
|
---|
1179 | printf("PIStdImg/Info: CurImage-> PSFile %s\n", name_ps.c_str());
|
---|
1180 | mps = mpsfile;
|
---|
1181 | }
|
---|
1182 |
|
---|
1183 | sx[0] = gimv->XSize();
|
---|
1184 | sy[0] = gimv->YSize();
|
---|
1185 | sx[1] = zoom->XSize();
|
---|
1186 | sy[1] = zoom->YSize();
|
---|
1187 | sx[2] = cmapv->XSize();
|
---|
1188 | sy[2] = cmapv->YSize();
|
---|
1189 | sx[3] = curpimg->XSize();
|
---|
1190 | sy[3] = curpimg->YSize();
|
---|
1191 | if (sy[1] > sy[0]) { syo1 = sy[1]+50; syo = sy[1]+sy[2]+60; }
|
---|
1192 | else { syo1 = sy[0]+50; syo = sy[0]+sy[2]+60; }
|
---|
1193 | syt = sy[3]+syo;
|
---|
1194 | sxt = sx[3];
|
---|
1195 | if (sxt < (sx[0]+sx[1]+20)) sxt = sx[0]+sx[1]+20;
|
---|
1196 | if (sxt < sx[2]) sxt = sx[2];
|
---|
1197 |
|
---|
1198 | // Pour ecrire le titre
|
---|
1199 | mps->NewPage((float)sxt, (float)syt, PI_Portrait);
|
---|
1200 | mps->NewBloc(0,0, (float)sxt, 30., (float)sxt, 30.);
|
---|
1201 | sprintf(strg,"Image: %s - Pave %d %d \n", curpimg->Nom().c_str(),
|
---|
1202 | curpimg->XPave(), curpimg->YPave());
|
---|
1203 | mps->DrawString(10., 25., strg, PI_Black, PI_DefaultFont, PI_BoldFont, 20);
|
---|
1204 | mps->EndBloc();
|
---|
1205 |
|
---|
1206 | // Les quatre fenetres glovimage, zoom, cmap, image
|
---|
1207 | gimv->PSPrint(mps, -gimv->XPos(), -gimv->YPos()+40);
|
---|
1208 | zoom->PSPrint(mps, -zoom->XPos()+sx[0]+20, -zoom->YPos()+40);
|
---|
1209 | cmapv->PSPrint(mps, -cmapv->XPos(), -cmapv->YPos()+syo1);
|
---|
1210 | curpimg->PSPrint(mps, -curpimg->XPos(), -curpimg->YPos()+syo);
|
---|
1211 |
|
---|
1212 | if (msg == 10516) delete mps; // fichier eps
|
---|
1213 | break;
|
---|
1214 | }
|
---|
1215 |
|
---|
1216 | default:
|
---|
1217 | cerr << "PIStdImgApp::MBProcess5() BUG?? Msg= " << msg << endl;
|
---|
1218 | break;
|
---|
1219 | }
|
---|
1220 |
|
---|
1221 | }
|
---|
1222 |
|
---|
1223 |
|
---|
1224 | /* --Methode-- */
|
---|
1225 | void PIStdImgApp::MBProcess6(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
1226 | {
|
---|
1227 | switch (msg) {
|
---|
1228 | case 10601:
|
---|
1229 | CloseAllWindows();
|
---|
1230 | break;
|
---|
1231 | case 10602:
|
---|
1232 | RedirectStdOutErr(*((bool*)data));
|
---|
1233 | break;
|
---|
1234 | case 10603:
|
---|
1235 | case 10604:
|
---|
1236 | CatchSignals(m[5]->GetStateMsg(10603), m[5]->GetStateMsg(10604));
|
---|
1237 | break;
|
---|
1238 | case 10605:
|
---|
1239 | mObjMgr->SetVerbose(m[5]->GetStateMsg(10605));
|
---|
1240 | break;
|
---|
1241 | default:
|
---|
1242 | cerr << "PIStdImgApp::MBProcess6() BUG?? Msg= " << msg << endl;
|
---|
1243 | break;
|
---|
1244 | }
|
---|
1245 | return;
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 |
|
---|
1249 | /* --Methode-- */
|
---|
1250 | void PIStdImgApp::SetColAtt(PIColors fg, PIColors bg)
|
---|
1251 | {
|
---|
1252 | mFCol = fg;
|
---|
1253 | mBCol = bg;
|
---|
1254 | }
|
---|
1255 | /* --Methode-- */
|
---|
1256 | void PIStdImgApp::SetLineAtt(PILineAtt lat)
|
---|
1257 | {
|
---|
1258 | mLAtt = lat;
|
---|
1259 | }
|
---|
1260 | /* --Methode-- */
|
---|
1261 | void PIStdImgApp::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
|
---|
1262 | {
|
---|
1263 | mFSz = fsz;
|
---|
1264 | mFAtt = fat;
|
---|
1265 | }
|
---|
1266 | /* --Methode-- */
|
---|
1267 | void PIStdImgApp::SetMarkerAtt(int sz, PIMarker mrk)
|
---|
1268 | {
|
---|
1269 | mMSz = sz;
|
---|
1270 | mMrk = mrk;
|
---|
1271 | }
|
---|
1272 | /* --Methode-- */
|
---|
1273 | void PIStdImgApp::SetColMapId(CMapId cid)
|
---|
1274 | {
|
---|
1275 | mCmapid = cid;
|
---|
1276 | }
|
---|
1277 | /* --Methode-- */
|
---|
1278 | void PIStdImgApp::SetZoomAtt(int zoom)
|
---|
1279 | {
|
---|
1280 | if ( (zoom > 10) || (zoom < -10) ) zoom = 0;
|
---|
1281 | mZoom = zoom;
|
---|
1282 | }
|
---|
1283 | /* --Methode-- */
|
---|
1284 | void PIStdImgApp::SetAxesAtt(unsigned int axfl)
|
---|
1285 | {
|
---|
1286 | mAxesFlags = axfl;
|
---|
1287 | }
|
---|
1288 | /* --Methode-- */
|
---|
1289 | void PIStdImgApp::SetXYLimits(double xmin, double xmax, double ymin, double ymax)
|
---|
1290 | {
|
---|
1291 | mXmin = xmin; mXmax= xmax;
|
---|
1292 | mYmin = ymin; mYmax= ymax;
|
---|
1293 | }
|
---|
1294 |
|
---|
1295 | /* --Methode-- */
|
---|
1296 | void PIStdImgApp::SaveGraphicAtt()
|
---|
1297 | {
|
---|
1298 | mSFCol = mFCol;
|
---|
1299 | mSBCol = mBCol;
|
---|
1300 | mSLAtt = mLAtt;
|
---|
1301 | mSFSz = mFSz;
|
---|
1302 | mSFAtt = mFAtt;
|
---|
1303 | mSMSz = mMSz;
|
---|
1304 | mSMrk = mMrk;
|
---|
1305 | mSCmapid = mCmapid;
|
---|
1306 | mSZoom = mZoom;
|
---|
1307 | mSAxesFlags = mAxesFlags;
|
---|
1308 | mSXmin = mXmin; mSXmax = mXmax;
|
---|
1309 | mSYmin = mYmin; mSYmax = mYmax;
|
---|
1310 | mSFXYlim = mFXYlim;
|
---|
1311 | mSaXlog = maXlog;
|
---|
1312 | mSaYlog = maYlog;
|
---|
1313 | }
|
---|
1314 |
|
---|
1315 | /* --Methode-- */
|
---|
1316 | void PIStdImgApp::RestoreGraphicAtt()
|
---|
1317 | {
|
---|
1318 | mFCol = mSFCol;
|
---|
1319 | mBCol = mSBCol;
|
---|
1320 | mLAtt = mSLAtt;
|
---|
1321 | mFSz = mSFSz;
|
---|
1322 | mFAtt = mSFAtt;
|
---|
1323 | mMSz = mSMSz;
|
---|
1324 | mMrk = mSMrk;
|
---|
1325 | mCmapid = mSCmapid;
|
---|
1326 | mZoom = mSZoom;
|
---|
1327 | mAxesFlags = mSAxesFlags;
|
---|
1328 | mXmin = mSXmin; mXmax = mSXmax;
|
---|
1329 | mYmin = mSYmin; mYmax = mSYmax;
|
---|
1330 | mFXYlim = mSFXYlim;
|
---|
1331 | maXlog = mSaXlog;
|
---|
1332 | maYlog = mSaYlog;
|
---|
1333 | }
|
---|