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