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