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