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