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