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