| [2615] | 1 | #include "sopnamsp.h" | 
|---|
| [293] | 2 | #include "machdefs.h" | 
|---|
| [165] | 3 | #include <stdlib.h> | 
|---|
|  | 4 | #include <stdio.h> | 
|---|
| [2492] | 5 | #include <unistd.h> | 
|---|
| [165] | 6 | #include <string.h> | 
|---|
|  | 7 |  | 
|---|
| [295] | 8 | #include <typeinfo> | 
|---|
|  | 9 |  | 
|---|
| [165] | 10 | #include <string> | 
|---|
|  | 11 | #include <vector> | 
|---|
|  | 12 |  | 
|---|
|  | 13 | #include "strutil.h" | 
|---|
|  | 14 | #include "timing.h" | 
|---|
|  | 15 | #include "perrors.h" | 
|---|
|  | 16 | #include "ctimer.h" | 
|---|
|  | 17 |  | 
|---|
|  | 18 | #include "psighand.h" | 
|---|
|  | 19 |  | 
|---|
|  | 20 | #include "cimage.h" // pour pouvoir faire extract | 
|---|
|  | 21 |  | 
|---|
|  | 22 | #include "pistdimgapp.h" | 
|---|
| [2263] | 23 | #include "servnobjm.h" | 
|---|
| [1856] | 24 | // #include "pihisto2d.h" | 
|---|
| [165] | 25 | #include "psfile.h" | 
|---|
|  | 26 | #include "piimgtools.h" | 
|---|
|  | 27 | #include "pidrwtools.h" | 
|---|
| [1590] | 28 | #include "piaxestools.h" | 
|---|
| [165] | 29 |  | 
|---|
|  | 30 | #include "pistzwin.h" | 
|---|
|  | 31 |  | 
|---|
| [295] | 32 | #include "piinit.h" | 
|---|
| [374] | 33 | #include "piversion.h" | 
|---|
|  | 34 | #include "piaversion.h" | 
|---|
| [165] | 35 |  | 
|---|
| [295] | 36 |  | 
|---|
| [165] | 37 | static char ImgDir[256]; | 
|---|
|  | 38 | static char WorkDir[256]; | 
|---|
| [692] | 39 | // Initialiseur | 
|---|
|  | 40 | static PIAppInitiator * glst_piai = NULL; | 
|---|
| [165] | 41 |  | 
|---|
| [686] | 42 | // Pour la creation de fenetre info (about piapp) | 
|---|
|  | 43 | static void createInfoWindow(PIStdImgApp* app); | 
|---|
|  | 44 | static void deleteInfoWindow(); | 
|---|
|  | 45 | static void showInfoWindow(PIStdImgApp* app); | 
|---|
|  | 46 | static void hideInfoWindow(PIStdImgApp* app); | 
|---|
| [165] | 47 |  | 
|---|
| [2383] | 48 | // Pour compter le nombre de display same a la suite | 
|---|
|  | 49 | static int nb_disp_same = 0; | 
|---|
| [2106] | 50 |  | 
|---|
| [165] | 51 | /* ........................................................... */ | 
|---|
| [2106] | 52 | /*    Classe SIA_RU__Periodic : mise a jour periodique de      */ | 
|---|
|  | 53 | /*    la fenetre Stat/Ressource info                           */ | 
|---|
| [2188] | 54 | /*    + execution de commande soumis de l'exterieur            */ | 
|---|
| [2106] | 55 | /* ........................................................... */ | 
|---|
|  | 56 |  | 
|---|
|  | 57 | class SIA_RU__Periodic : public PIPeriodic | 
|---|
|  | 58 | { | 
|---|
|  | 59 | public: | 
|---|
|  | 60 | SIA_RU__Periodic(PIStdImgApp* app); | 
|---|
|  | 61 | virtual ~SIA_RU__Periodic(); | 
|---|
|  | 62 | virtual void DoPeriodic(); | 
|---|
|  | 63 | private: | 
|---|
|  | 64 | PIStdImgApp* _app; | 
|---|
|  | 65 | }; | 
|---|
|  | 66 |  | 
|---|
|  | 67 | SIA_RU__Periodic::SIA_RU__Periodic(PIStdImgApp* app) | 
|---|
|  | 68 | : PIPeriodX(1) | 
|---|
|  | 69 | { | 
|---|
|  | 70 | _app = app; | 
|---|
|  | 71 | } | 
|---|
|  | 72 |  | 
|---|
|  | 73 | SIA_RU__Periodic::~SIA_RU__Periodic() | 
|---|
|  | 74 | { | 
|---|
|  | 75 | } | 
|---|
|  | 76 |  | 
|---|
|  | 77 | void SIA_RU__Periodic::DoPeriodic() | 
|---|
|  | 78 | { | 
|---|
| [2188] | 79 | if (_app) { | 
|---|
| [2489] | 80 | // RZDEL: Normalement, il ne devrait plus y avoir besoin de cette | 
|---|
|  | 81 | // methode avec le thread separe de l'interpreteur - Reza 27/12/2003 | 
|---|
|  | 82 | //    _app->ExecuteExtCommand(); | 
|---|
| [2188] | 83 | _app->UpdateStatResourceInfo(); | 
|---|
|  | 84 | } | 
|---|
| [2106] | 85 | } | 
|---|
|  | 86 |  | 
|---|
|  | 87 | /* ............................................................. */ | 
|---|
|  | 88 |  | 
|---|
|  | 89 |  | 
|---|
|  | 90 | /* ........................................................... */ | 
|---|
| [165] | 91 | /*                    Classe PIStdImgApp                         */ | 
|---|
|  | 92 | /* ........................................................... */ | 
|---|
|  | 93 |  | 
|---|
|  | 94 | /* --Methode-- */ | 
|---|
| [2944] | 95 | PIStdImgApp::PIStdImgApp(bool fgsmall, int narg, char* arg[]) | 
|---|
|  | 96 | : PIApplication(420, (fgsmall)?320:220, narg, arg) , resusg(ResourceUsage::RU_All) | 
|---|
| [165] | 97 | { | 
|---|
|  | 98 |  | 
|---|
|  | 99 | // Les menus | 
|---|
|  | 100 | m[0] = new PIMenu(Menubar(),"Fichier"); | 
|---|
| [686] | 101 | m[0]->AppendItem("About piapp", 10150); | 
|---|
| [165] | 102 | m[0]->AppendItem("Open-Fits", 10120); | 
|---|
|  | 103 | m[0]->AppendItem("Open-PPF", 10130); | 
|---|
| [2263] | 104 | #ifndef SANS_EVOLPLANCK | 
|---|
|  | 105 | m[0]->AppendItem("Open-ASCII", 10140); | 
|---|
|  | 106 | #endif | 
|---|
| [165] | 107 | // m[0]->AppendItem("Options", 10101); | 
|---|
| [686] | 108 | m[0]->AppendItem("Help", 10100); | 
|---|
| [1513] | 109 | m[0]->AppendSeparator(); | 
|---|
| [165] | 110 | m[0]->AppendItem("Exit", 10105); | 
|---|
|  | 111 |  | 
|---|
|  | 112 | m[1] = new PIMenu(Menubar(),"Objets"); | 
|---|
|  | 113 | m[1]->AppendItem("ObjectManager", 10201); | 
|---|
|  | 114 | m[1]->AppendItem("OpenOutPPF", 10220); | 
|---|
|  | 115 | m[1]->AppendItem("CloseOutPPF", 10230); | 
|---|
| [686] | 116 | m[1]->AppendItem("Delete CurWdg", 10270); | 
|---|
| [165] | 117 |  | 
|---|
|  | 118 | m[2] = new PIMenu(Menubar(),"Tools"); | 
|---|
|  | 119 | m[2]->AppendItem("Show ImageTools", 10301); | 
|---|
|  | 120 | m[2]->AppendItem("Show DrawerTools", 10302); | 
|---|
| [1590] | 121 | m[2]->AppendItem("Show AxesTools", 10303); | 
|---|
|  | 122 | m[2]->AppendItem("CxxExecutorWindow", 10304); | 
|---|
|  | 123 | m[2]->AppendItem("Ext.Pave", 10311); | 
|---|
|  | 124 | m[2]->SetSensitivityMsg(10311, false); | 
|---|
|  | 125 | m[2]->AppendItem("Ext.Pave+Org", 10312); | 
|---|
|  | 126 | m[2]->SetSensitivityMsg(10312, false); | 
|---|
|  | 127 | m[2]->AppendItem("Cuts X,Y", 10313); | 
|---|
|  | 128 | m[2]->SetSensitivityMsg(10313, false); | 
|---|
| [165] | 129 | mc = new PIMenu(m[2], "StackTools"); | 
|---|
|  | 130 | mc->AppendItem("DispNext", 10320); | 
|---|
| [191] | 131 | mc->AppendItem("Blink 0.5s", 10321); | 
|---|
|  | 132 | mc->AppendItem("Blink 1s", 10322); | 
|---|
|  | 133 | mc->AppendItem("Blink 2s", 10324); | 
|---|
| [165] | 134 | mc->AppendItem("Stop Blink", 10329); | 
|---|
|  | 135 | mc->AppendItem("RemoveCurrent", 10330); | 
|---|
|  | 136 | m[2]->AppendPDMenu(mc); | 
|---|
|  | 137 | m[2]->SetSensitivity("StackTools", false); | 
|---|
|  | 138 |  | 
|---|
|  | 139 | m[3] = new PIMenu(Menubar(),"Window"); | 
|---|
|  | 140 | m[3]->AppendItem("StackWindow", 10400); | 
|---|
|  | 141 | m[3]->AppendItem("Window", 10411); | 
|---|
|  | 142 | m[3]->AppendItem("Window 2x1", 10421); | 
|---|
| [1971] | 143 | // m[3]->AppendItem("Window 1x2", 10412); | 
|---|
| [165] | 144 | m[3]->AppendItem("Window 2x2", 10422); | 
|---|
| [1971] | 145 | // m[3]->AppendItem("Window 3x1", 10431); | 
|---|
| [165] | 146 | m[3]->AppendItem("Window 3x3", 10433); | 
|---|
| [558] | 147 | m[3]->AppendItem("Cur->LastWdg", 10441); | 
|---|
| [686] | 148 | m[3]->AppendItem("Close CurWin", 10460); | 
|---|
| [1971] | 149 | m[3]->AppendCheckItem("StatZoomWin", 10470); | 
|---|
|  | 150 | m[3]->SetStateMsg(10470, true); | 
|---|
| [165] | 151 |  | 
|---|
|  | 152 | m[4] = new PIMenu(Menubar(),"PostScript"); | 
|---|
|  | 153 | m[4]->AppendItem("OpenPS", 10501); | 
|---|
|  | 154 | m[4]->AppendItem("ClosePS", 10505); | 
|---|
|  | 155 | m[4]->AppendItem("Window->PS", 10511); | 
|---|
|  | 156 | m[4]->AppendItem("Image->PS", 10515); | 
|---|
|  | 157 | m[4]->AppendItem("Window->EPS", 10512); | 
|---|
|  | 158 | m[4]->AppendItem("Image->EPS", 10516); | 
|---|
|  | 159 | m[4]->SetSensitivityMsg(10515, false); | 
|---|
|  | 160 | m[4]->SetSensitivityMsg(10516, false); | 
|---|
|  | 161 |  | 
|---|
|  | 162 | m[5] = new PIMenu(Menubar(),"Special"); | 
|---|
|  | 163 | m[5]->AppendItem("CloseAll", 10601); | 
|---|
| [3370] | 164 | // m[5]->AppendCheckItem("Red.Out/Err", 10602); | 
|---|
| [374] | 165 | m[5]->AppendCheckItem("Catch SigFPE", 10603); | 
|---|
|  | 166 | m[5]->AppendCheckItem("Catch SigSEGV", 10604); | 
|---|
| [449] | 167 | m[5]->AppendCheckItem("ObjMgr Verb", 10605); | 
|---|
| [1319] | 168 | m[5]->AppendItem("CxxExecOption", 10606); | 
|---|
| [165] | 169 |  | 
|---|
| [293] | 170 | m[6] = new PIMenu(Menubar(),"Modules"); | 
|---|
|  | 171 |  | 
|---|
| [165] | 172 | AppendMenu(m[0]); | 
|---|
|  | 173 | AppendMenu(m[1]); | 
|---|
|  | 174 | AppendMenu(m[2]); | 
|---|
|  | 175 | AppendMenu(m[3]); | 
|---|
|  | 176 | AppendMenu(m[4]); | 
|---|
|  | 177 | AppendMenu(m[5]); | 
|---|
| [374] | 178 | // AppendMenu(m[6]);  Menu Modules vide pour le moment | 
|---|
| [165] | 179 |  | 
|---|
|  | 180 | int scsx, scsy; | 
|---|
| [1593] | 181 | ScreenSize(scsx, scsy); | 
|---|
| [165] | 182 | if (scsy <= 600)  mFgScSz = 0; | 
|---|
|  | 183 | else if (scsy <= 800)  mFgScSz = 1; | 
|---|
|  | 184 | else if (scsy <= 1024)  mFgScSz = 2; | 
|---|
|  | 185 | else   mFgScSz = 3; | 
|---|
|  | 186 | int msx = 420+mFgScSz*60; | 
|---|
|  | 187 | int msy = 320+mFgScSz*40; | 
|---|
| [2944] | 188 | int sfgsz = mFgScSz; | 
|---|
|  | 189 | if (fgsmall) {  // Flag petite taille de fenetre | 
|---|
|  | 190 | if (mFgScSz > 1) mFgScSz = 1; | 
|---|
|  | 191 | msx = 420+mFgScSz*40; | 
|---|
|  | 192 | msy = 220+mFgScSz*20; | 
|---|
|  | 193 | } | 
|---|
| [165] | 194 | MainWin()->SetSize(msx, msy); | 
|---|
|  | 195 |  | 
|---|
| [1971] | 196 | //------------------------------------------------------ | 
|---|
|  | 197 | // On cree un container intermediaire permettant de gerer | 
|---|
|  | 198 | // le widget zoom, colormap, stats, ... | 
|---|
|  | 199 |  | 
|---|
| [2486] | 200 | int bss = 105+mFgScSz*15; | 
|---|
| [1971] | 201 |  | 
|---|
|  | 202 | int statc_szy = bss+10+14+mFgScSz*2+5; | 
|---|
|  | 203 | statcont = new PIContainer(MainWin(), "ZGCSCont", msx, statc_szy, 0, 0); | 
|---|
|  | 204 | statcont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); | 
|---|
|  | 205 |  | 
|---|
|  | 206 | gimv = new PIPixmap(statcont, "GloV", bss, bss, 5, 5); | 
|---|
| [165] | 207 | gimv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free); | 
|---|
| [1971] | 208 | zoom = new PIPixmap(statcont, "Zoom", bss, bss, bss+10, 5); | 
|---|
| [165] | 209 | zoom->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free); | 
|---|
| [1971] | 210 | cmapv = new PICMapView(statcont, "CMapView", msx-10, 14+mFgScSz*2, 5, bss+10); | 
|---|
| [165] | 211 | cmapv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); | 
|---|
| [2106] | 212 |  | 
|---|
|  | 213 | // Widget pour affichage des stats / ressources | 
|---|
| [2486] | 214 | lab_mem = new PILabel(statcont, "memlab", msx-2*(bss+20), 20, 2*bss+20, 5); | 
|---|
| [2106] | 215 | lab_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); | 
|---|
|  | 216 | lab_mem->SetLabel("MemoryUsage"); | 
|---|
|  | 217 | lab_mem->SetForegroundColor(PI_Red); | 
|---|
|  | 218 | lab_mem->SetBorderWidth(1); | 
|---|
| [2486] | 219 | therm_mem = new PIThermometer(statcont, "memtherm", msx-2*(bss+20), 15, 2*bss+20, 30); | 
|---|
| [2106] | 220 | therm_mem->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); | 
|---|
|  | 221 | therm_mem->SetThreshold(0.5, 0.75); | 
|---|
|  | 222 |  | 
|---|
| [2486] | 223 | lab_cpu = new PILabel(statcont, "cpulab", msx-2*(bss+20), 20, 2*bss+20, 50); | 
|---|
| [2106] | 224 | lab_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); | 
|---|
|  | 225 | lab_cpu->SetLabel("CPUUsage"); | 
|---|
|  | 226 | lab_cpu->SetForegroundColor(PI_Black); | 
|---|
|  | 227 | lab_cpu->SetBorderWidth(1); | 
|---|
| [2486] | 228 | therm_cpu = new PIThermometer(statcont, "cputherm", msx-2*(bss+20), 15, 2*bss+20, 75); | 
|---|
| [2106] | 229 | therm_cpu->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); | 
|---|
|  | 230 | therm_cpu->SetThreshold(0.75, 0.90); | 
|---|
| [2486] | 231 | lab_thrcmd = new PILabel(statcont, "thrcmdlab", msx-2*(bss+20), 20, 2*bss+20, 95); | 
|---|
|  | 232 | lab_thrcmd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); | 
|---|
|  | 233 | lab_thrcmd->SetLabel("CommandThread"); | 
|---|
|  | 234 | lab_thrcmd->SetForegroundColor(PI_Green); | 
|---|
|  | 235 | lab_thrcmd->SetBorderWidth(1); | 
|---|
| [2106] | 236 |  | 
|---|
| [2486] | 237 | fg_exc_cmd = false; | 
|---|
|  | 238 | mCmd = NULL;  // Avant d'appeler UpdateStatResource() si PIACmd non cree | 
|---|
| [3366] | 239 | mSopex = NULL; | 
|---|
| [2106] | 240 | UpdateStatResourceInfo(); | 
|---|
|  | 241 | resupd_periodic = new SIA_RU__Periodic(this); | 
|---|
|  | 242 | //resupd_periodic->SetIntervalms(500); | 
|---|
|  | 243 | resupd_periodic->Start(); | 
|---|
|  | 244 |  | 
|---|
| [1971] | 245 | statcont->Show(); | 
|---|
|  | 246 | // StatZoomWindowSetVisible(true); | 
|---|
|  | 247 | //------------------------------------------------------ | 
|---|
| [165] | 248 |  | 
|---|
| [1971] | 249 | //int cpy = bss+10+14+mFgScSz*2+5; | 
|---|
|  | 250 | int cpy = statc_szy; | 
|---|
| [165] | 251 |  | 
|---|
|  | 252 | // Creation d'une console avec gestion des commandes | 
|---|
| [1971] | 253 | consolecont = new PIContainer(MainWin(), "ConsoleCont", msx, msy-cpy, 0, cpy ); | 
|---|
|  | 254 | consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); | 
|---|
|  | 255 | mCons = new PIConsole(consolecont, "Console", 30200, 512, 132, msx, msy-cpy, 0, 0 ); | 
|---|
| [165] | 256 | mCons->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); | 
|---|
|  | 257 | mCons->AcceptCmd(true, 50); | 
|---|
| [1971] | 258 | consolecont->Show(); | 
|---|
| [3370] | 259 | redirecout = NORED_OE; | 
|---|
|  | 260 | RedirectStdOutErr(NORED_OE);  // pas de redirect par defaut | 
|---|
| [2944] | 261 |  | 
|---|
|  | 262 | mFgScSz = sfgsz; | 
|---|
| [165] | 263 |  | 
|---|
| [2490] | 264 | mObjMgr = new NamedObjMgr(true); | 
|---|
|  | 265 | mCmd = new PIACmd(this); | 
|---|
| [3366] | 266 | mSopex = new SOpExObj(this); | 
|---|
| [165] | 267 |  | 
|---|
| [449] | 268 | // Pas trop de message de la part de NamedObjMgr | 
|---|
|  | 269 | m[5]->SetStateMsg(10605, false); | 
|---|
|  | 270 | mObjMgr->SetVerbose(false); | 
|---|
|  | 271 |  | 
|---|
| [165] | 272 | char* varenv; | 
|---|
|  | 273 | ImgDir[0] = WorkDir[0] = '\0'; | 
|---|
|  | 274 | if ( (varenv=getenv("PEIDA_IMAGES")) != NULL )   strncpy(ImgDir, varenv, 256); | 
|---|
|  | 275 | if ( (varenv=getenv("PEIDA_WORK")) != NULL )  strncpy(WorkDir, varenv, 256); | 
|---|
|  | 276 |  | 
|---|
| [685] | 277 | pfc_fits = new PIFileChooser(this,"FITS-FileChooser", 10125); | 
|---|
|  | 278 | pfc_ppf = new PIFileChooser(this,"PPF-FileChooser", 10135); | 
|---|
| [2263] | 279 | pfc_ascii = new PIFileChooser(this,"ASCII-FileChooser", 10145); | 
|---|
| [685] | 280 | pfc_ps = new PIFileChooser(this,"PS-FileChooser", 10525); | 
|---|
| [165] | 281 |  | 
|---|
|  | 282 | mObjmgrw = new ObjMgrWind(this); | 
|---|
|  | 283 | mPpinmgrw = new PPInMgrWind(this); | 
|---|
|  | 284 |  | 
|---|
| [333] | 285 | // Attention : A faire apres creation de ObjMgrWind !!! | 
|---|
|  | 286 | mObjMgr->SetImgApp(this); | 
|---|
|  | 287 |  | 
|---|
| [165] | 288 | // Gestion des feneteres widgets et drawers | 
|---|
|  | 289 | mWId = mDId = mBWId = 0; | 
|---|
|  | 290 | mCurWin = NULL; | 
|---|
|  | 291 | mCurWdg = NULL; | 
|---|
|  | 292 | mLastWdg = NULL; | 
|---|
|  | 293 | mGrW = NULL; | 
|---|
|  | 294 | mStW = NULL; | 
|---|
|  | 295 | mGrIdx = mStIdx = -1; | 
|---|
|  | 296 |  | 
|---|
|  | 297 | mFCMsg = 0; | 
|---|
|  | 298 | mFgCWImg = false; | 
|---|
|  | 299 |  | 
|---|
|  | 300 | // Gestion fichiers PS | 
|---|
|  | 301 | num_eps = 0; | 
|---|
|  | 302 | name_ps = ""; | 
|---|
|  | 303 | name_ps = "pia.ps"; | 
|---|
|  | 304 | mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.); | 
|---|
|  | 305 |  | 
|---|
|  | 306 | // Gestion OUT-PPF | 
|---|
|  | 307 | mPpfout = NULL; | 
|---|
|  | 308 | name_outppf = ""; | 
|---|
|  | 309 |  | 
|---|
|  | 310 | // Attributs graphiques courants | 
|---|
| [2350] | 311 | mAxesFlags = kAxesDflt; | 
|---|
| [548] | 312 | SetInsetLimits(0.4, 0.6, 0.4, 0.6); | 
|---|
| [1131] | 313 | mAddTitle = true; | 
|---|
| [165] | 314 |  | 
|---|
| [295] | 315 | // Initialisation | 
|---|
| [692] | 316 | glst_piai = new PIAppInitiator(this); | 
|---|
| [600] | 317 |  | 
|---|
|  | 318 | char buff[128]; | 
|---|
|  | 319 | mCons->AddStr("  ............  starting piapp .............\n", PIVA_Blue ); | 
|---|
|  | 320 | #ifdef SANS_EVOLPLANCK | 
|---|
|  | 321 | sprintf(buff, "Version: piapp=%g  PI=%g  PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER, | 
|---|
|  | 322 | (double)PI_VERSIONNUMBER, (float)PeidaVersion()); | 
|---|
| [3024] | 323 | mCons->AddStr(buff, PIVA_Blue ); | 
|---|
| [600] | 324 | #else | 
|---|
| [3024] | 325 | string svers; | 
|---|
|  | 326 | SophyaInitiator::GetVersion(svers); | 
|---|
|  | 327 | mCons->AddStr(svers.c_str(), PIVA_Blue ); | 
|---|
| [600] | 328 | #endif | 
|---|
|  | 329 | mCons->AddStr("  ..........................................\n", PIVA_Blue ); | 
|---|
|  | 330 | // PrintPeidaVersion(); | 
|---|
|  | 331 |  | 
|---|
| [685] | 332 | pfc_fits->SetPath(ImgDir); | 
|---|
|  | 333 | pfc_ppf->SetPath(WorkDir); | 
|---|
|  | 334 | pfc_ps->SetPath(WorkDir); | 
|---|
|  | 335 |  | 
|---|
| [165] | 336 | SetReady(); | 
|---|
| [2490] | 337 | fg_glsynlock = false; | 
|---|
| [165] | 338 | } | 
|---|
|  | 339 |  | 
|---|
|  | 340 | /* --Methode-- */ | 
|---|
|  | 341 | PIStdImgApp::~PIStdImgApp() | 
|---|
|  | 342 | { | 
|---|
|  | 343 | int i; | 
|---|
|  | 344 |  | 
|---|
| [1075] | 345 | // On inactive la fenetre principale | 
|---|
|  | 346 | //  Sinon, ca peut provoquer un SEGV ds delete de console ?? - Reza 07/2000 | 
|---|
|  | 347 | MainWin()->Hide(); | 
|---|
|  | 348 |  | 
|---|
| [558] | 349 | // Destrucion de tous les objets de NameObjMgr | 
|---|
|  | 350 | string patt = "/*/*"; | 
|---|
|  | 351 | mObjMgr->DelObjects(patt, true); | 
|---|
|  | 352 |  | 
|---|
| [205] | 353 | delete mc; | 
|---|
| [293] | 354 | for(i=0; i<7; i++) | 
|---|
| [165] | 355 | if (m[i]) delete m[i]; | 
|---|
|  | 356 |  | 
|---|
|  | 357 | WindMList::iterator it; | 
|---|
|  | 358 | for(it = mWList.begin(); it != mWList.end(); it++)  delete (*it).second; | 
|---|
|  | 359 |  | 
|---|
|  | 360 | delete mObjMgr; | 
|---|
|  | 361 | delete mCmd; | 
|---|
|  | 362 |  | 
|---|
|  | 363 | delete zoom; | 
|---|
|  | 364 | delete gimv; | 
|---|
|  | 365 | delete cmapv; | 
|---|
|  | 366 |  | 
|---|
| [2106] | 367 | delete lab_mem; | 
|---|
|  | 368 | delete therm_mem; | 
|---|
|  | 369 | delete lab_cpu; | 
|---|
|  | 370 | delete therm_cpu; | 
|---|
| [2486] | 371 | delete lab_thrcmd; | 
|---|
| [2106] | 372 |  | 
|---|
| [1971] | 373 | delete statcont; | 
|---|
|  | 374 |  | 
|---|
| [685] | 375 | delete pfc_fits; | 
|---|
|  | 376 | delete pfc_ppf; | 
|---|
| [2263] | 377 | delete pfc_ascii; | 
|---|
| [685] | 378 | delete pfc_ps; | 
|---|
| [165] | 379 |  | 
|---|
|  | 380 | delete mCons; | 
|---|
| [2106] | 381 | delete consolecont; | 
|---|
| [165] | 382 |  | 
|---|
|  | 383 | delete mObjmgrw; | 
|---|
|  | 384 | delete mPpinmgrw; | 
|---|
|  | 385 |  | 
|---|
| [686] | 386 | deleteInfoWindow(); | 
|---|
|  | 387 |  | 
|---|
| [165] | 388 | // Les fichiers | 
|---|
|  | 389 | if (mpsfile) delete mpsfile; | 
|---|
|  | 390 | if (mPpfout) delete mPpfout; | 
|---|
|  | 391 |  | 
|---|
| [2106] | 392 | if (resupd_periodic) delete resupd_periodic; | 
|---|
|  | 393 |  | 
|---|
| [692] | 394 | if (glst_piai) delete glst_piai;   glst_piai = NULL; | 
|---|
| [2106] | 395 |  | 
|---|
| [165] | 396 | } | 
|---|
|  | 397 |  | 
|---|
| [2491] | 398 | /* | 
|---|
| [2489] | 399 | class RunAlarm : public Periodic { | 
|---|
|  | 400 | public: | 
|---|
|  | 401 | RunAlarm(PIStdImgApp* app) : | 
|---|
|  | 402 | Periodic(1) | 
|---|
|  | 403 | { _app = app; SetIntervalms(1); } | 
|---|
|  | 404 | ~RunAlarm() { } | 
|---|
|  | 405 | virtual void DoPeriodic() | 
|---|
|  | 406 | { _app->getMutex().broadcast(); } | 
|---|
|  | 407 | PIStdImgApp* _app; | 
|---|
|  | 408 | }; | 
|---|
| [2491] | 409 | */ | 
|---|
| [2489] | 410 |  | 
|---|
| [2491] | 411 | class Reveil : public ZThread { | 
|---|
|  | 412 | public: | 
|---|
|  | 413 | Reveil(PIStdImgApp* app) : | 
|---|
|  | 414 | ZThread() | 
|---|
| [3431] | 415 | { _app = app; _fgstop = false; _running = false; } | 
|---|
| [2491] | 416 | virtual ~Reveil() { } | 
|---|
|  | 417 | inline void Stop() { _fgstop = true; } | 
|---|
| [3431] | 418 | inline bool IsRunning() { return _running; } | 
|---|
| [2491] | 419 | virtual void run() | 
|---|
|  | 420 | { | 
|---|
| [3431] | 421 | _running = true; | 
|---|
| [2491] | 422 | while (!_fgstop) { | 
|---|
| [2948] | 423 | usleep(2000); | 
|---|
|  | 424 | _app->LockMutex(); | 
|---|
|  | 425 | bool fgb = false; | 
|---|
|  | 426 | if (_app->CheckPendingEvents() != 0)  fgb = true; | 
|---|
|  | 427 | _app->UnlockMutex(fgb); | 
|---|
| [2491] | 428 | } | 
|---|
| [3431] | 429 | _running = false; | 
|---|
| [2491] | 430 | } | 
|---|
|  | 431 |  | 
|---|
|  | 432 | PIStdImgApp* _app; | 
|---|
|  | 433 | bool _fgstop; | 
|---|
| [3431] | 434 | bool _running; | 
|---|
| [2491] | 435 | }; | 
|---|
| [2494] | 436 |  | 
|---|
|  | 437 | int PIStdImgApp::CheckPendingEvents() | 
|---|
|  | 438 | { | 
|---|
|  | 439 | return XtAppPending(*_appctx); | 
|---|
|  | 440 | } | 
|---|
|  | 441 |  | 
|---|
| [2800] | 442 | void PIStdImgApp::CkEvt_LockMutex() | 
|---|
|  | 443 | { | 
|---|
|  | 444 | for(int i=0; i<5; i++) {   // On tente 5 fois de vider le buffer d'evenements | 
|---|
|  | 445 | LockMutex(); | 
|---|
|  | 446 | int nev = CheckPendingEvents(); | 
|---|
|  | 447 | bool fgbr = (nev > 0) ? true : false; | 
|---|
|  | 448 | UnlockMutex(fgbr); | 
|---|
|  | 449 | if (nev < 1) break; | 
|---|
|  | 450 | } | 
|---|
|  | 451 | LockMutex(); | 
|---|
|  | 452 | } | 
|---|
|  | 453 |  | 
|---|
| [165] | 454 | /* --Methode-- */ | 
|---|
| [2486] | 455 | void PIStdImgApp::Run() | 
|---|
|  | 456 | { | 
|---|
|  | 457 | XEvent evt; | 
|---|
|  | 458 | int szx, szy, szf; | 
|---|
|  | 459 | XtAppContext * appctx = PIXtAppCtx(szx, szy, szf); | 
|---|
| [2494] | 460 | _appctx = appctx;   // Pour CheckPendingEvents() | 
|---|
| [2486] | 461 | // Pour appeler FinishCreate() des objets dans la fenetre principale | 
|---|
|  | 462 | if (mStop) { // C'est la premiere fois | 
|---|
|  | 463 | topcont->SetSize(topcont->XSize(), topcont->YSize()); | 
|---|
|  | 464 | MBCont()->FinishCreate(); | 
|---|
|  | 465 | } | 
|---|
|  | 466 | else mStop = true;   // On rerentre apres un stop | 
|---|
|  | 467 |  | 
|---|
| [2489] | 468 | // Creation et demarrage de l'objet de reveil periodique | 
|---|
|  | 469 | // de la boucle d'evts | 
|---|
| [2491] | 470 | /* RunAlarm * mru = new RunAlarm(this); | 
|---|
|  | 471 | mru->Start(); */ | 
|---|
|  | 472 | Reveil* mrv = new Reveil(this); | 
|---|
|  | 473 | mrv->start(); | 
|---|
| [2489] | 474 | // Demarrage du thread de l'interpreteur | 
|---|
|  | 475 | CmdInterpreter()->start(); | 
|---|
| [3366] | 476 | // Demarrage du thread de l'executeur de commandes simples | 
|---|
|  | 477 | getSOpExObj()->start(); | 
|---|
| [2486] | 478 |  | 
|---|
| [2489] | 479 |  | 
|---|
| [2491] | 480 | thr_glsyn.lock(); //  <ZThread> | 
|---|
| [2492] | 481 | //DEL-DBG int klp = 0; | 
|---|
| [2486] | 482 | while (mStop) { | 
|---|
| [2490] | 483 | fg_glsynlock = true; | 
|---|
| [2491] | 484 | int nevtproc = 0; | 
|---|
| [2701] | 485 | while (XtAppPending(*appctx) != 0) {   // Boucle XtAppPending() | 
|---|
|  | 486 | try { | 
|---|
|  | 487 | XtAppNextEvent(*appctx, &evt); | 
|---|
|  | 488 | XtDispatchEvent(&evt); | 
|---|
|  | 489 | // Soumission de la commande exterieur a executer | 
|---|
|  | 490 | if (fg_exc_cmd) { | 
|---|
|  | 491 | fg_exc_cmd = false; | 
|---|
|  | 492 | CmdInterpreter()->AddInputLine(exc_command); | 
|---|
|  | 493 | } | 
|---|
|  | 494 | nevtproc++; | 
|---|
| [2800] | 495 | if (nevtproc >= 300)  break; | 
|---|
| [2673] | 496 | } | 
|---|
| [2701] | 497 | catch ( PThrowable & exc ) { | 
|---|
|  | 498 | cerr << "\nPIStdImgApp::Run()/ Exception catched in event loop: \n   " | 
|---|
|  | 499 | << (string)typeid(exc).name() << " Msg= " << exc.Msg() << endl; | 
|---|
|  | 500 | cerr << "  Trying to continue event loop ... " << endl; | 
|---|
|  | 501 | } | 
|---|
|  | 502 | catch ( std::exception & sexc ) { | 
|---|
|  | 503 | cerr << "\nPIStdImgApp::Run()/ Exception catched in event loop: \n   " | 
|---|
|  | 504 | << (string)typeid(sexc).name() << " what()= " << sexc.what() << endl; | 
|---|
|  | 505 | cerr << "  Trying to continue event loop ... " << endl; | 
|---|
|  | 506 | } | 
|---|
|  | 507 | catch ( ... ) { | 
|---|
|  | 508 | cerr << "\nPIStdImgApp::Run()/ Unknown Exception (...) catched in event loop ! " << endl; | 
|---|
|  | 509 | cerr << "  Trying to continue event loop ... " << endl; | 
|---|
|  | 510 | } | 
|---|
|  | 511 | }   // FIN Boucle XtAppPending() | 
|---|
| [2490] | 512 | fg_glsynlock = false; | 
|---|
| [2492] | 513 | //DBG cout << " "DBG-Run:: Going to wait ... " << klp << endl; | 
|---|
| [2491] | 514 | thr_glsyn.wait();  //  <ZThread> | 
|---|
| [2492] | 515 | //DBG cout << "DBG-Run:: Out of wait " << ++klp << endl; | 
|---|
| [2491] | 516 | //  usleep(1000); | 
|---|
| [2486] | 517 | } | 
|---|
| [2489] | 518 |  | 
|---|
| [2491] | 519 | thr_glsyn.unlock();  //  <ZThread> | 
|---|
|  | 520 | mrv->Stop(); | 
|---|
| [3431] | 521 | // Reza- Dec07 : On attend que le tread Reveil soit arrete avant de le supprimer | 
|---|
|  | 522 | while (mrv->IsRunning())  usleep(2000); | 
|---|
| [2491] | 523 | delete mrv; | 
|---|
|  | 524 | // delete mru; | 
|---|
| [2486] | 525 | return; | 
|---|
|  | 526 | } | 
|---|
|  | 527 |  | 
|---|
|  | 528 | /* --Methode-- */ | 
|---|
| [165] | 529 | void PIStdImgApp::Process(PIMessage msg, PIMsgHandler* sender, void* data) | 
|---|
|  | 530 | { | 
|---|
|  | 531 | PIWdg *sndw; | 
|---|
|  | 532 | PIMessage tmsg, smm; | 
|---|
|  | 533 |  | 
|---|
|  | 534 | tmsg = msg; | 
|---|
|  | 535 | msg = UserMsg(msg); | 
|---|
|  | 536 | smm = ModMsg(tmsg); | 
|---|
|  | 537 |  | 
|---|
|  | 538 | //printf("SuperDebug: msg=%d Mod=%d  State=%d\n", (int)msg, (int)smm, (int)GetState()); | 
|---|
|  | 539 | if  ((GetState()) && (msg != mFCMsg)) { PIBeep(); return; } | 
|---|
|  | 540 |  | 
|---|
| [2606] | 541 | #ifdef SANS_EVOLPLANCK | 
|---|
|  | 542 | TRY { | 
|---|
|  | 543 | #else | 
|---|
|  | 544 | try { | 
|---|
|  | 545 | #endif | 
|---|
|  | 546 |  | 
|---|
| [165] | 547 | //   Messages active-window | 
|---|
|  | 548 | if (smm == PIMsg_Active) | 
|---|
|  | 549 | { | 
|---|
| [293] | 550 | sndw = dynamic_cast<PIWdg *>(sender); | 
|---|
| [165] | 551 | switch(sndw->kind()) | 
|---|
|  | 552 | { | 
|---|
|  | 553 | case PIWindow::ClassId : | 
|---|
| [293] | 554 | mCurWin = dynamic_cast<PIWindow *>(sndw); | 
|---|
| [165] | 555 | break; | 
|---|
|  | 556 |  | 
|---|
|  | 557 | case PIScDrawWdg::ClassId : | 
|---|
|  | 558 | case PIDraw3DWdg::ClassId : | 
|---|
| [293] | 559 | mCurWdg = dynamic_cast<PIBaseWdg *>(sender); | 
|---|
| [165] | 560 | //      cerr << "*DBG11* ImgTools -> NonSensitive " << sndw->kind() << endl; | 
|---|
|  | 561 | if (mFgCWImg) { | 
|---|
|  | 562 | //        cerr << "*DBG* ImgTools -> NonSensitive " << endl; | 
|---|
| [1590] | 563 | m[2]->SetSensitivityMsg(10311, false); | 
|---|
|  | 564 | m[2]->SetSensitivityMsg(10312, false); | 
|---|
|  | 565 | m[2]->SetSensitivityMsg(10313, false); | 
|---|
| [165] | 566 | m[4]->SetSensitivityMsg(10515, false); | 
|---|
|  | 567 | m[4]->SetSensitivityMsg(10516, false); | 
|---|
|  | 568 | mFgCWImg = false; | 
|---|
|  | 569 | } | 
|---|
|  | 570 | break; | 
|---|
|  | 571 | case PIImage::ClassId : | 
|---|
| [293] | 572 | mCurWdg = dynamic_cast<PIBaseWdg *>(sender); | 
|---|
| [165] | 573 | if (!mFgCWImg) { | 
|---|
|  | 574 | //        cerr << "*DBG* ImgTools -> Sensitive " << endl; | 
|---|
| [1590] | 575 | m[2]->SetSensitivityMsg(10311, true); | 
|---|
|  | 576 | m[2]->SetSensitivityMsg(10312, true); | 
|---|
|  | 577 | m[2]->SetSensitivityMsg(10313, true); | 
|---|
| [165] | 578 | m[4]->SetSensitivityMsg(10515, true); | 
|---|
|  | 579 | m[4]->SetSensitivityMsg(10516, true); | 
|---|
|  | 580 | mFgCWImg = true; | 
|---|
|  | 581 | } | 
|---|
|  | 582 | break; | 
|---|
| [293] | 583 | /* | 
|---|
|  | 584 | default : | 
|---|
|  | 585 | mCurWdg = NULL; | 
|---|
|  | 586 | if (mFgCWImg) { | 
|---|
| [1590] | 587 | m[2]->SetSensitivityMsg(10311, false); | 
|---|
|  | 588 | m[2]->SetSensitivityMsg(10312, false); | 
|---|
|  | 589 | m[2]->SetSensitivityMsg(10313, false); | 
|---|
| [293] | 590 | m[4]->SetSensitivityMsg(10515, false); | 
|---|
|  | 591 | m[4]->SetSensitivityMsg(10516, false); | 
|---|
|  | 592 | mFgCWImg = false; | 
|---|
|  | 593 | } | 
|---|
|  | 594 | break; | 
|---|
|  | 595 | */ | 
|---|
| [165] | 596 | } | 
|---|
|  | 597 | } | 
|---|
|  | 598 | //  Message window-close | 
|---|
|  | 599 | else if (smm == PIMsg_Close) | 
|---|
|  | 600 | { | 
|---|
|  | 601 | sndw = (PIWdg *)sender; | 
|---|
|  | 602 | if(sndw->kind() == PIWindow::ClassId) | 
|---|
|  | 603 | { | 
|---|
|  | 604 | mCurWin = (PIWindow *)sender; | 
|---|
|  | 605 | if (mCurWin == mStW) m[2]->SetSensitivity("StackTools", false); | 
|---|
|  | 606 | DeleteWindow(mCurWin); | 
|---|
|  | 607 | } | 
|---|
|  | 608 | else | 
|---|
|  | 609 | printf("PIStdImgApp/Bug ? CloseMsd received from NonWindow (%d %d %lx) \n", | 
|---|
|  | 610 | (int)tmsg,  (int)sndw->kind(), (long)sender); | 
|---|
|  | 611 | } | 
|---|
|  | 612 |  | 
|---|
|  | 613 | // Traitement des messages des menus | 
|---|
|  | 614 | else if ( (msg >= 10100) && (msg < 10200) )  MBProcess1(msg, sender, data); | 
|---|
|  | 615 | else if ( (msg >= 10200) && (msg < 10300) )  MBProcess2(msg, sender, data); | 
|---|
|  | 616 | else if ( (msg >= 10300) && (msg < 10400) )  MBProcess3(msg, sender, data); | 
|---|
|  | 617 | else if ( (msg >= 10400) && (msg < 10500) )  MBProcess4(msg, sender, data); | 
|---|
|  | 618 | else if ( (msg >= 10500) && (msg < 10600) )  MBProcess5(msg, sender, data); | 
|---|
|  | 619 | else if ( (msg >= 10600) && (msg < 10700) )  MBProcess6(msg, sender, data); | 
|---|
| [2677] | 620 | else if ( (msg == 30200) && (smm == PIMsg_Cancel) )  // <Cntrl C> appuye sur Console | 
|---|
|  | 621 | CmdInterpreter()->StopExecution(); | 
|---|
|  | 622 | else if ( (msg == 30200 ) && (smm == PIMsg_OK) ){    // Objet PIConsole avec <Return>/<Enter> | 
|---|
| [165] | 623 | string s = mCons->GetCmdString(); | 
|---|
| [1265] | 624 | //  string s2 = "\nExecuting " + s + "\n"; | 
|---|
|  | 625 | mCons->AddStr("Cmd> ", PIVA_Blue, false); | 
|---|
|  | 626 | //  s2 = s + "\n"; | 
|---|
|  | 627 | mCons->AddStr(s.c_str(), PIVA_Blue|PIVA_Bold, false); | 
|---|
|  | 628 | mCons->AddChar('\n', PIVA_Def, true); | 
|---|
| [165] | 629 | SetBusy(); | 
|---|
| [495] | 630 | #ifdef SANS_EVOLPLANCK | 
|---|
| [165] | 631 | TRY { | 
|---|
| [293] | 632 | mCmd->Interpret(s); | 
|---|
| [165] | 633 | }  CATCH(merr) { | 
|---|
|  | 634 | fflush(stdout); | 
|---|
|  | 635 | cout << endl; | 
|---|
|  | 636 | cerr << endl; | 
|---|
|  | 637 | string es = PeidaExc(merr); | 
|---|
| [495] | 638 | cerr << "PIStdImgApp::Process()/ Cmd->Do() Exception :" << es << " (" << merr << ")" << endl ; | 
|---|
|  | 639 | } | 
|---|
|  | 640 | #else | 
|---|
|  | 641 | try { | 
|---|
| [2486] | 642 | //    mCmd->Interpret(s); | 
|---|
| [2489] | 643 | CmdInterpreter()->AddInputLine(s); | 
|---|
| [495] | 644 | } | 
|---|
| [1276] | 645 | catch ( PThrowable & exc ) { | 
|---|
|  | 646 | cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Exception :" | 
|---|
|  | 647 | << (string)typeid(exc).name() << " Msg= " | 
|---|
|  | 648 | << exc.Msg() << endl; | 
|---|
| [495] | 649 | cout << endl; | 
|---|
| [165] | 650 | } | 
|---|
| [1276] | 651 | catch ( ... ) { | 
|---|
|  | 652 | cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Catched Exception ..." | 
|---|
|  | 653 | << endl; | 
|---|
|  | 654 | cout << endl; | 
|---|
|  | 655 | } | 
|---|
|  | 656 |  | 
|---|
| [495] | 657 | #endif | 
|---|
| [165] | 658 | SetReady(); | 
|---|
|  | 659 | } | 
|---|
|  | 660 |  | 
|---|
|  | 661 | else printf("PIStdImgApp::Process() BUG?? Msg %d (%d-%d) \n", | 
|---|
|  | 662 | (int)tmsg,(int)msg,(int)smm); | 
|---|
|  | 663 |  | 
|---|
| [2606] | 664 | #ifdef SANS_EVOLPLANCK | 
|---|
|  | 665 | }  CATCH(merr) { | 
|---|
|  | 666 | fflush(stdout); | 
|---|
|  | 667 | cout << endl; | 
|---|
|  | 668 | cerr << endl; | 
|---|
|  | 669 | string es = PeidaExc(merr); | 
|---|
|  | 670 | cerr << "PIStdImgApp::Process()/  Exception :" << es << " (" << merr << ")" << endl ; | 
|---|
|  | 671 | SetReady(); | 
|---|
|  | 672 | } | 
|---|
|  | 673 | #else | 
|---|
|  | 674 | } | 
|---|
|  | 675 | catch ( PThrowable & exc ) { | 
|---|
|  | 676 | cerr << "\n PIStdImgApp::Process() SOPHYA Exception :" | 
|---|
|  | 677 | << (string)typeid(exc).name() << "\n Msg= " | 
|---|
|  | 678 | << exc.Msg() << endl; | 
|---|
|  | 679 | SetReady(); | 
|---|
|  | 680 | } | 
|---|
|  | 681 | catch ( std::exception & sex ) { | 
|---|
|  | 682 | cerr << "\n PIStdImgApp::Process() std::exception :" | 
|---|
|  | 683 | << (string)typeid(sex).name() << "\n msg= " | 
|---|
|  | 684 | << sex.what() << endl; | 
|---|
|  | 685 | SetReady(); | 
|---|
|  | 686 | } | 
|---|
|  | 687 | catch ( ... ) { | 
|---|
|  | 688 | cerr << "\n PIStdImgApp::Process()/  Catched unknown (...) Exception " << endl; | 
|---|
|  | 689 | SetReady(); | 
|---|
|  | 690 | } | 
|---|
| [165] | 691 |  | 
|---|
| [2606] | 692 | #endif | 
|---|
|  | 693 |  | 
|---|
| [165] | 694 | return; | 
|---|
|  | 695 | } | 
|---|
|  | 696 |  | 
|---|
| [194] | 697 | /* --Methode-- */ | 
|---|
|  | 698 | void PIStdImgApp::SetReady() | 
|---|
|  | 699 | { | 
|---|
|  | 700 | mCons->SetSensitive(); | 
|---|
|  | 701 | gimv->SetSensitive(); | 
|---|
|  | 702 | PIApplication::SetReady(); | 
|---|
|  | 703 | } | 
|---|
| [165] | 704 |  | 
|---|
| [194] | 705 | /* --Methode-- */ | 
|---|
|  | 706 | void PIStdImgApp::SetBusy() | 
|---|
|  | 707 | { | 
|---|
|  | 708 | mCons->SetUnSensitive(); | 
|---|
|  | 709 | gimv->SetUnSensitive(); | 
|---|
|  | 710 | PIApplication::SetBusy(); | 
|---|
| [1321] | 711 | // Attention : Appel XSync specifique X11 -  en attendant multi-thread | 
|---|
| [2651] | 712 | // XSync(PIXDisplay(), False);  RZDEL | 
|---|
| [194] | 713 | } | 
|---|
| [165] | 714 |  | 
|---|
| [194] | 715 | /* --Methode-- */ | 
|---|
|  | 716 | void PIStdImgApp::SetBlocked() | 
|---|
|  | 717 | { | 
|---|
|  | 718 | mCons->SetUnSensitive(); | 
|---|
|  | 719 | gimv->SetUnSensitive(); | 
|---|
|  | 720 | PIApplication::SetBlocked(); | 
|---|
| [1321] | 721 | // Attention : Appel XSync specifique X11 -  en attendant multi-thread | 
|---|
| [2651] | 722 | // XSync(PIXDisplay(), False);  RZDEL | 
|---|
| [194] | 723 | } | 
|---|
| [165] | 724 |  | 
|---|
| [2492] | 725 | class SyncPIS { | 
|---|
|  | 726 | public: | 
|---|
|  | 727 | explicit SyncPIS(ZMutex & mtx, bool fglock=true, int sigbr=0) | 
|---|
|  | 728 | { | 
|---|
|  | 729 | _mtx = &mtx; _sigbr = sigbr; | 
|---|
|  | 730 | _fglock = fglock; | 
|---|
|  | 731 | if (_fglock)  mtx.lock(); | 
|---|
|  | 732 | } | 
|---|
|  | 733 | ~SyncPIS() | 
|---|
|  | 734 | { | 
|---|
|  | 735 | if (_fglock && (_mtx != NULL) ) { | 
|---|
|  | 736 | if (_sigbr == 1) _mtx->signal(); | 
|---|
|  | 737 | else  if (_sigbr == 2) _mtx->broadcast(); | 
|---|
|  | 738 | _mtx->unlock(); | 
|---|
|  | 739 | } | 
|---|
|  | 740 | } | 
|---|
| [194] | 741 |  | 
|---|
| [2492] | 742 | private: | 
|---|
|  | 743 | ZMutex * _mtx; | 
|---|
|  | 744 | int _sigbr; | 
|---|
|  | 745 | bool _fglock; | 
|---|
|  | 746 | inline        SyncPIS() {_mtx = NULL; _sigbr = 0; _fglock = false; } | 
|---|
|  | 747 | }; | 
|---|
|  | 748 |  | 
|---|
|  | 749 |  | 
|---|
| [165] | 750 | /* --Methode-- */ | 
|---|
| [2491] | 751 | int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, string const& sop, | 
|---|
| [2651] | 752 | bool fgimagnav, int oid, bool fglock) | 
|---|
| [165] | 753 | { | 
|---|
| [2651] | 754 | PIImage* pii=NULL; | 
|---|
|  | 755 | PIImageNavigator* piin=NULL; | 
|---|
| [165] | 756 | PIWindow* win; | 
|---|
|  | 757 | int sx, sy, px, py, flag; | 
|---|
|  | 758 |  | 
|---|
|  | 759 | if (nouv == NULL) | 
|---|
|  | 760 | { | 
|---|
|  | 761 | printf("PIStdImgApp::DispImage_Error  Cannot Display  NULL image \n"); | 
|---|
|  | 762 | return(-1); | 
|---|
|  | 763 | } | 
|---|
|  | 764 |  | 
|---|
|  | 765 | if ( (nouv->XSize() <= 0)  || (nouv->YSize() <= 0)) | 
|---|
|  | 766 | { | 
|---|
|  | 767 | printf("PIStdImgApp::DispImage_Error Pb Size Sz=%d*%d  \n", | 
|---|
|  | 768 | nouv->XSize(), nouv->YSize()); | 
|---|
|  | 769 | return(-1); | 
|---|
|  | 770 | } | 
|---|
|  | 771 |  | 
|---|
| [3355] | 772 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
|  | 773 | SyncPIS zs(getMutex(), fglock, 2); | 
|---|
|  | 774 |  | 
|---|
| [1971] | 775 | // On decode les options graphiques | 
|---|
|  | 776 | vector<string> opts; | 
|---|
| [3355] | 777 | string wname = name; | 
|---|
|  | 778 | DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname); | 
|---|
| [165] | 779 |  | 
|---|
| [1971] | 780 | // Pas de same ou inset pour DispImage | 
|---|
|  | 781 | if ((dwopt == Disp_Same) || (dwopt == Disp_Inset) ) dwopt = Disp_Next; | 
|---|
| [165] | 782 |  | 
|---|
| [1971] | 783 | // Choix de la taille de fenetre | 
|---|
|  | 784 | #define MINPIIMGSIZE 100 | 
|---|
|  | 785 | sx = (nouv->XSize() > MINPIIMGSIZE) ? nouv->XSize() : MINPIIMGSIZE; | 
|---|
|  | 786 | sy = (nouv->YSize() > MINPIIMGSIZE) ? nouv->XSize() : MINPIIMGSIZE; | 
|---|
| [165] | 787 | if (sx > 400+mFgScSz*100) sx = 400+mFgScSz*100; | 
|---|
|  | 788 | if (sy > 400+mFgScSz*100) sy = 400+mFgScSz*100; | 
|---|
|  | 789 | px = py = 0; | 
|---|
| [3355] | 790 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str()); | 
|---|
| [2651] | 791 | if (fgimagnav) {  // Creation de naviguateur d'image | 
|---|
| [3355] | 792 | piin = new PIImageNavigator(win, (char *)wname.c_str(), sx, sy, px,py); | 
|---|
| [2651] | 793 | piin->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic); | 
|---|
| [2778] | 794 | piin->Show(); | 
|---|
| [2651] | 795 | piin->ImageWdg()->ShowCursor(true); | 
|---|
|  | 796 | pii = piin->ImageWdg(); | 
|---|
| [2762] | 797 | piin->SetUserData(NULL, oid); | 
|---|
| [2651] | 798 | pii->SetUserData(NULL, oid); | 
|---|
|  | 799 | } | 
|---|
|  | 800 | else { // Creation de widget PIImage normal | 
|---|
| [3355] | 801 | pii = new PIImage(win, (char *)wname.c_str(), sx, sy, px,py); | 
|---|
| [2651] | 802 | pii->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic); | 
|---|
|  | 803 | pii->SetZoomWin(zoom, false); | 
|---|
|  | 804 | pii->SetGloVWin(gimv, false); | 
|---|
|  | 805 | pii->SetCMapWin(cmapv, false); | 
|---|
|  | 806 | pii->ShowCursor(true); | 
|---|
|  | 807 | pii->SetUserData(NULL, oid); | 
|---|
|  | 808 | } | 
|---|
| [1971] | 809 |  | 
|---|
| [2778] | 810 |  | 
|---|
|  | 811 | pii->SetImage(nouv, true, false); | 
|---|
|  | 812 |  | 
|---|
|  | 813 | // decode des options en chaine de caracteres | 
|---|
|  | 814 | if (mAxesAtt.size() > 0) | 
|---|
|  | 815 | pii->DecodeOptionString(mAxesAtt, false);   // Les options d'axe | 
|---|
|  | 816 | if (mDefaultAtt.size() > 0) | 
|---|
|  | 817 | pii->DecodeOptionString(mDefaultAtt, false);  // d'abord les options par defaut | 
|---|
|  | 818 | if (opts.size() > 0) | 
|---|
|  | 819 | pii->DecodeOptionString(opts);    // ensuite, les options specifies en argument | 
|---|
|  | 820 |  | 
|---|
| [1971] | 821 | // On recalcule la taille de la fenetre si Disp_Win | 
|---|
|  | 822 | if (dwopt == Disp_Win) { | 
|---|
|  | 823 | int sx2 = (int)((float)nouv->XSize()*pii->GetZoomF()); | 
|---|
|  | 824 | int sy2 = (int)((float)nouv->YSize()*pii->GetZoomF()); | 
|---|
|  | 825 |  | 
|---|
|  | 826 | if (sx2 > 400+mFgScSz*100) sx2 = 400+mFgScSz*100; | 
|---|
|  | 827 | if (sy2 > 400+mFgScSz*100) sy2 = 400+mFgScSz*100; | 
|---|
|  | 828 | if (sx2 < MINPIIMGSIZE) sx = MINPIIMGSIZE; | 
|---|
|  | 829 | if (sy2 < MINPIIMGSIZE) sy = MINPIIMGSIZE; | 
|---|
|  | 830 | if ((sx2 != sx) || (sy2 != sy))  win->SetSize(sx2, sy2); | 
|---|
|  | 831 | } | 
|---|
|  | 832 |  | 
|---|
| [165] | 833 | // printf("!!DBG!! PIImage Pos= %d %d  Size= %d %d \n", pii->XPos(), pii->YPos(), pii->XSize(), pii->YSize()   ); | 
|---|
|  | 834 | mCurWin = win; | 
|---|
|  | 835 | mCurWdg = pii; | 
|---|
|  | 836 | mLastWdg = pii; | 
|---|
|  | 837 | mBWId++; | 
|---|
| [2778] | 838 | if (fgimagnav)  mBWList[mBWId] = piin; | 
|---|
| [2762] | 839 | else mBWList[mBWId] = pii; | 
|---|
| [2118] | 840 | // pii->Refresh(); | 
|---|
| [2651] | 841 | pii->Apply(true); | 
|---|
|  | 842 | //  cmapv->Refresh();  Pas besoin ? , Reza Fev 2005 | 
|---|
| [165] | 843 | return(mBWId); | 
|---|
|  | 844 | } | 
|---|
|  | 845 |  | 
|---|
|  | 846 |  | 
|---|
|  | 847 | /* --Methode-- */ | 
|---|
| [1971] | 848 | int PIStdImgApp::DispScDrawer(PIDrawer* scd, string const & name, string const& sop, | 
|---|
| [2491] | 849 | string title, int oid, bool fglock) | 
|---|
| [165] | 850 | { | 
|---|
|  | 851 | if (scd == NULL) | 
|---|
|  | 852 | { | 
|---|
|  | 853 | printf("PIStdImgApp::DispScDrawer_Error  Cannot Add NULL ScDrawer \n"); | 
|---|
|  | 854 | return(-1); | 
|---|
|  | 855 | } | 
|---|
|  | 856 |  | 
|---|
| [3355] | 857 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
|  | 858 | SyncPIS zs(getMutex(), fglock, 2); | 
|---|
|  | 859 |  | 
|---|
| [1971] | 860 | // On decode les options graphiques | 
|---|
|  | 861 | vector<string> opts; | 
|---|
| [3355] | 862 | string wname = name; | 
|---|
|  | 863 | DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname); | 
|---|
| [1971] | 864 | if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next; | 
|---|
| [2486] | 865 |  | 
|---|
| [1971] | 866 | // Trace en superpoistion | 
|---|
|  | 867 | if ( (dwopt == Disp_Same) && (mLastWdg) ) { | 
|---|
|  | 868 | // Les options | 
|---|
|  | 869 | scd->DecodeOptionString(mDefaultAtt, false); | 
|---|
| [2383] | 870 | if (nb_disp_same > 0) { | 
|---|
|  | 871 | vector<string> ostatpos; | 
|---|
|  | 872 | int spo = nb_disp_same%4; | 
|---|
|  | 873 | if (spo == 1) ostatpos.push_back("statposoff=-0.01,-0.26"); | 
|---|
|  | 874 | else if (spo == 2)  ostatpos.push_back("statposoff=-0.36,-0.01"); | 
|---|
|  | 875 | else  ostatpos.push_back("statposoff=-0.36,-0.26"); | 
|---|
|  | 876 | scd->DecodeOptionString(ostatpos, true); | 
|---|
|  | 877 | } | 
|---|
| [1971] | 878 | scd->DecodeOptionString(opts, true); | 
|---|
| [165] | 879 |  | 
|---|
|  | 880 | if (mLastWdg->kind() == PIScDrawWdg::ClassId)  ((PIScDrawWdg*)mLastWdg)->AddScDrawer(scd, true); | 
|---|
|  | 881 | else mLastWdg->AddDrawer(scd, true, true, true); | 
|---|
| [548] | 882 | scd->Refresh(); | 
|---|
|  | 883 | mDId++; | 
|---|
|  | 884 | mDrwList[mDId] = scd; | 
|---|
|  | 885 | return(-mDId); | 
|---|
|  | 886 | } | 
|---|
|  | 887 | // Trace en medaillon | 
|---|
| [1971] | 888 | else if ( (dwopt == Disp_Inset) && (mLastWdg) ) { | 
|---|
| [548] | 889 | PIGrCoord x1, x2, y1, y2; | 
|---|
|  | 890 | x1 = mIXmin;  x2 = mIXmax; | 
|---|
|  | 891 | y2 = 1.-mIYmin;  y1 = 1.-mIYmax; | 
|---|
| [1971] | 892 | // Les options | 
|---|
|  | 893 | scd->DecodeOptionString(mDefaultAtt, false); | 
|---|
|  | 894 | scd->DecodeOptionString(opts, true); | 
|---|
|  | 895 |  | 
|---|
| [548] | 896 | scd->SetAxesFlags(mAxesFlags); | 
|---|
| [1971] | 897 | scd->UpdateLimits(); | 
|---|
| [548] | 898 | mLastWdg->AddDrawer(scd, x1, y1, x2, y2, true, false, true); | 
|---|
| [165] | 899 | scd->Refresh(); | 
|---|
|  | 900 | mDId++; | 
|---|
|  | 901 | mDrwList[mDId] = scd; | 
|---|
|  | 902 | return(-mDId); | 
|---|
|  | 903 | } | 
|---|
|  | 904 |  | 
|---|
| [1971] | 905 | // Creation d'un nouveau PIScDrawWdg | 
|---|
| [165] | 906 | PIWindow* win; | 
|---|
|  | 907 | PIScDrawWdg* scw; | 
|---|
|  | 908 | int sx, sy, px, py, flag; | 
|---|
|  | 909 | sx = 200+mFgScSz*100; | 
|---|
|  | 910 | sy = 200+mFgScSz*100; | 
|---|
| [3355] | 911 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str()); | 
|---|
| [1971] | 912 |  | 
|---|
| [3355] | 913 | scw = new PIScDrawWdg(win, (char *)wname.c_str(), sx, sy, px, py); | 
|---|
| [165] | 914 | scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic); | 
|---|
| [331] | 915 | scw->SetUserData(NULL, oid); | 
|---|
| [1971] | 916 |  | 
|---|
|  | 917 | // Decodage des options : | 
|---|
|  | 918 | vector<string> scwatt; | 
|---|
| [203] | 919 | scw->SetAxesFlags(mAxesFlags); | 
|---|
| [1971] | 920 | if ( mDefaultAtt.size() > 0) { | 
|---|
|  | 921 | scwatt = mDefaultAtt; | 
|---|
| [2217] | 922 | scd->DecodeOptionString(scwatt, true); | 
|---|
| [1971] | 923 | scw->DecodeOptionString(scwatt, true); | 
|---|
|  | 924 | } | 
|---|
|  | 925 | if ( mAxesAtt.size() > 0) { | 
|---|
|  | 926 | scwatt = mAxesAtt; | 
|---|
|  | 927 | scw->DecodeOptionString(scwatt, true); | 
|---|
|  | 928 | } | 
|---|
|  | 929 | if (opts.size() > 0) | 
|---|
|  | 930 | scd->DecodeOptionString(opts, true); | 
|---|
|  | 931 | if (opts.size() > 0) | 
|---|
|  | 932 | scw->DecodeOptionString(opts, false); | 
|---|
|  | 933 |  | 
|---|
| [165] | 934 | //   Titre du plot | 
|---|
| [1131] | 935 | if (mAddTitle) { | 
|---|
| [3355] | 936 | if (title.length() <= 0)  title = wname;  string t2=""; | 
|---|
| [1131] | 937 | scw->SetTitles(title, t2); | 
|---|
|  | 938 | } | 
|---|
| [1569] | 939 |  | 
|---|
| [1971] | 940 | scw->AddScDrawer(scd, true); | 
|---|
| [293] | 941 | // scw->Refresh();   ? Pas necessaire  Reza 19/08/98, 05/05/99 $CHECK$ | 
|---|
| [1971] | 942 |  | 
|---|
| [165] | 943 | mCurWin = win; | 
|---|
|  | 944 | mCurWdg = scw; | 
|---|
|  | 945 | mLastWdg = scw; | 
|---|
|  | 946 | mBWId++; | 
|---|
|  | 947 | mBWList[mBWId] = scw; | 
|---|
|  | 948 | return(mBWId); | 
|---|
|  | 949 | } | 
|---|
|  | 950 |  | 
|---|
|  | 951 | /* --Methode-- */ | 
|---|
| [1971] | 952 | int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, string const& sop, | 
|---|
| [2491] | 953 | string title, int oid, bool fglock) | 
|---|
| [165] | 954 | { | 
|---|
|  | 955 | if (dr3 == NULL) | 
|---|
|  | 956 | { | 
|---|
|  | 957 | printf("PIStdImgApp::Disp3DDrawer_Error  Cannot Add NULL 3DDrawer \n"); | 
|---|
|  | 958 | return(-1); | 
|---|
|  | 959 | } | 
|---|
|  | 960 |  | 
|---|
| [3355] | 961 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
|  | 962 | SyncPIS zs(getMutex(), fglock, 2); | 
|---|
|  | 963 |  | 
|---|
| [1971] | 964 | // On decode les options graphiques | 
|---|
|  | 965 | vector<string> opts; | 
|---|
| [3355] | 966 | string wname = name; | 
|---|
|  | 967 | DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname); | 
|---|
| [165] | 968 |  | 
|---|
| [1971] | 969 | if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next; | 
|---|
| [2486] | 970 |  | 
|---|
| [548] | 971 | // Trace en superpoistion | 
|---|
| [1971] | 972 | if ( (dwopt == Disp_Same) && (mLastWdg) ) { | 
|---|
|  | 973 | // Les options | 
|---|
|  | 974 | dr3->DecodeOptionString(mDefaultAtt, false); | 
|---|
| [2383] | 975 | if (nb_disp_same > 1) { | 
|---|
|  | 976 | vector<string> ostatpos; | 
|---|
|  | 977 | int spo = nb_disp_same%4; | 
|---|
|  | 978 | if (spo == 1) ostatpos.push_back("statposoff=-0.01,-0.26"); | 
|---|
|  | 979 | else if (spo == 2)  ostatpos.push_back("statposoff=-0.36,-0.01"); | 
|---|
|  | 980 | else  ostatpos.push_back("statposoff=-0.36,-0.26"); | 
|---|
|  | 981 | dr3->DecodeOptionString(ostatpos, true); | 
|---|
|  | 982 | } | 
|---|
|  | 983 |  | 
|---|
| [1971] | 984 | dr3->DecodeOptionString(opts, true); | 
|---|
|  | 985 |  | 
|---|
| [165] | 986 | if (mLastWdg->kind() == PIDraw3DWdg::ClassId)  ((PIDraw3DWdg*)mLastWdg)->AddDrawer3D(dr3, true); | 
|---|
|  | 987 | else mLastWdg->AddDrawer(dr3, true, true, true); | 
|---|
|  | 988 | dr3->Refresh(); | 
|---|
|  | 989 | mDId++; | 
|---|
|  | 990 | mDrwList[mDId] = dr3; | 
|---|
|  | 991 | return(-mDId); | 
|---|
|  | 992 | } | 
|---|
| [548] | 993 | // Trace en medaillon | 
|---|
| [1971] | 994 | else if ( (dwopt == Disp_Inset) && (mLastWdg) ) { | 
|---|
| [548] | 995 | PIGrCoord x1, x2, y1, y2; | 
|---|
|  | 996 | x1 = mIXmin;  x2 = mIXmax; | 
|---|
|  | 997 | y2 = 1.-mIYmin;  y1 = 1.-mIYmax; | 
|---|
| [1971] | 998 | // Les options | 
|---|
|  | 999 | dr3->DecodeOptionString(mDefaultAtt, false); | 
|---|
|  | 1000 | dr3->DecodeOptionString(opts, true); | 
|---|
|  | 1001 |  | 
|---|
| [548] | 1002 | dr3->SetAxesFlags(mAxesFlags); | 
|---|
|  | 1003 | dr3->UpdateLimits(); | 
|---|
|  | 1004 | mLastWdg->AddDrawer(dr3, x1, y1, x2, y2, true, false, true); | 
|---|
|  | 1005 | dr3->Refresh(); | 
|---|
|  | 1006 | mDId++; | 
|---|
|  | 1007 | mDrwList[mDId] = dr3; | 
|---|
|  | 1008 | return(-mDId); | 
|---|
|  | 1009 | } | 
|---|
| [165] | 1010 |  | 
|---|
| [548] | 1011 |  | 
|---|
| [165] | 1012 | PIWindow* win; | 
|---|
|  | 1013 | int sx, sy, px, py, flag; | 
|---|
|  | 1014 | sx = 200+mFgScSz*100; | 
|---|
|  | 1015 | sy = 200+mFgScSz*100; | 
|---|
| [3355] | 1016 | win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str()); | 
|---|
|  | 1017 | PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)wname.c_str(), sx, sy, px, py); | 
|---|
| [165] | 1018 | wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic); | 
|---|
| [331] | 1019 | wd3->SetUserData(NULL, oid); | 
|---|
| [1971] | 1020 |  | 
|---|
|  | 1021 | // Decodage des options : | 
|---|
|  | 1022 | vector<string> scwatt; | 
|---|
|  | 1023 | // wd3->SetAxesFlags(mAxesFlags);  Attributs d'axes 3D a faire | 
|---|
|  | 1024 | if ( mDefaultAtt.size() > 0) { | 
|---|
|  | 1025 | scwatt = mDefaultAtt; | 
|---|
| [2217] | 1026 | dr3->DecodeOptionString(scwatt, true); | 
|---|
| [1971] | 1027 | wd3->DecodeOptionString(scwatt, true); | 
|---|
|  | 1028 | } | 
|---|
|  | 1029 | if ( mAxesAtt.size() > 0) { | 
|---|
|  | 1030 | scwatt = mAxesAtt; | 
|---|
|  | 1031 | wd3->DecodeOptionString(scwatt, true); | 
|---|
|  | 1032 | } | 
|---|
|  | 1033 | if (opts.size() > 0) | 
|---|
|  | 1034 | dr3->DecodeOptionString(opts, true); | 
|---|
|  | 1035 | if (opts.size() > 0) | 
|---|
|  | 1036 | wd3->DecodeOptionString(opts, false); | 
|---|
|  | 1037 |  | 
|---|
| [165] | 1038 | //   Titre du plot | 
|---|
| [1131] | 1039 | if (mAddTitle) { | 
|---|
| [3355] | 1040 | if (title.length() <= 0)  title = wname;  string t2=""; | 
|---|
| [1131] | 1041 | wd3->SetTitles(title, t2); | 
|---|
|  | 1042 | } | 
|---|
| [1971] | 1043 |  | 
|---|
|  | 1044 | wd3->AddDrawer3D(dr3, true); | 
|---|
| [293] | 1045 | // wd3->Refresh();   ?Pas necessaire   $CHECK$ 05/05/99 | 
|---|
| [1971] | 1046 |  | 
|---|
| [165] | 1047 | mCurWin = win; | 
|---|
|  | 1048 | mCurWdg = wd3; | 
|---|
|  | 1049 | mLastWdg = wd3; | 
|---|
|  | 1050 | mBWId++; | 
|---|
|  | 1051 | mBWList[mBWId] = wd3; | 
|---|
|  | 1052 | return(mBWId); | 
|---|
|  | 1053 | } | 
|---|
|  | 1054 |  | 
|---|
| [2489] | 1055 | // RZDEL: Normalement, il ne devrait plus y avoir besoin de cette | 
|---|
|  | 1056 | // methode avec le thread separe de l'interpreteur - Reza 27/12/2003 | 
|---|
| [349] | 1057 | /* --Methode-- */ | 
|---|
| [2188] | 1058 | int PIStdImgApp::ExecuteExtCommand() | 
|---|
|  | 1059 | { | 
|---|
|  | 1060 | if (!fg_exc_cmd) return(0); | 
|---|
|  | 1061 | else { | 
|---|
|  | 1062 | fg_exc_cmd = false; | 
|---|
|  | 1063 | return CmdInterpreter()->Interpret(exc_command); | 
|---|
|  | 1064 | } | 
|---|
|  | 1065 | } | 
|---|
|  | 1066 |  | 
|---|
|  | 1067 | /* --Methode-- */ | 
|---|
| [2263] | 1068 | void PIStdImgApp::AddText(string const & txt, double xp, double yp, string const& sop, bool fgcn) | 
|---|
| [349] | 1069 | { | 
|---|
| [2489] | 1070 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1071 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1072 |  | 
|---|
| [2165] | 1073 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
| [1642] | 1074 | if (eld == NULL) return; | 
|---|
| [2165] | 1075 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1076 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1077 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1078 | PIElDrwMgr* elmgr; | 
|---|
|  | 1079 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1080 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
|  | 1081 | if (elmgr == NULL) return; | 
|---|
| [1642] | 1082 |  | 
|---|
| [1971] | 1083 | vector<string> opts; | 
|---|
|  | 1084 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1085 | PIGraphicAtt gratt(opts); | 
|---|
| [2243] | 1086 | unsigned long tpd = 0; | 
|---|
|  | 1087 | gratt.DecodeTextPosDirAtt(opts, tpd, false); | 
|---|
| [2263] | 1088 | elmgr->ElAddText(xp,yp,txt.c_str(), gratt, tpd, fgcn); | 
|---|
| [1642] | 1089 | eld->Refresh(); | 
|---|
| [349] | 1090 | } | 
|---|
| [1642] | 1091 |  | 
|---|
| [1131] | 1092 | /* --Methode-- */ | 
|---|
| [2263] | 1093 | void PIStdImgApp::AddCompText(string const & txt, string const & txtup, string const & txtdn, | 
|---|
|  | 1094 | double xp, double yp, string const& sop, | 
|---|
|  | 1095 | string const& optss, bool fgcn) | 
|---|
|  | 1096 | { | 
|---|
| [2489] | 1097 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1098 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1099 |  | 
|---|
| [2263] | 1100 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
|  | 1101 | if (eld == NULL) return; | 
|---|
|  | 1102 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1103 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1104 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1105 | PIElDrwMgr* elmgr; | 
|---|
|  | 1106 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1107 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
|  | 1108 | if (elmgr == NULL) return; | 
|---|
|  | 1109 |  | 
|---|
|  | 1110 | vector<string> opts; | 
|---|
|  | 1111 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1112 | PIGraphicAtt gratt(opts); | 
|---|
|  | 1113 | unsigned long tpd = 0; | 
|---|
|  | 1114 | gratt.DecodeTextPosDirAtt(opts, tpd, false); | 
|---|
|  | 1115 | ParseDisplayOption(optss, opts); | 
|---|
|  | 1116 | PIGraphicAtt grattss(opts); | 
|---|
|  | 1117 | elmgr->ElAddCompText(xp,yp,txt.c_str(), gratt, txtup, txtdn, grattss, tpd, fgcn); | 
|---|
|  | 1118 | eld->Refresh(); | 
|---|
|  | 1119 | } | 
|---|
|  | 1120 |  | 
|---|
|  | 1121 | /* --Methode-- */ | 
|---|
| [2243] | 1122 | void PIStdImgApp::AddLine(double xp1, double yp1, double xp2, double yp2, | 
|---|
| [2263] | 1123 | string const& sop, bool fgarrow, bool fgcn) | 
|---|
| [1642] | 1124 | { | 
|---|
| [2489] | 1125 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1126 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1127 |  | 
|---|
| [2165] | 1128 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
| [1642] | 1129 | if (eld == NULL) return; | 
|---|
| [2165] | 1130 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1131 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1132 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1133 | PIElDrwMgr* elmgr = NULL; | 
|---|
|  | 1134 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1135 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
|  | 1136 | if (elmgr == NULL) return; | 
|---|
| [1642] | 1137 |  | 
|---|
| [1971] | 1138 | vector<string> opts; | 
|---|
|  | 1139 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1140 | PIGraphicAtt gratt(opts); | 
|---|
| [2243] | 1141 | if (fgarrow) | 
|---|
| [2263] | 1142 | elmgr->ElAddArrow(xp1, yp1, xp2, yp2, gratt, fgcn); | 
|---|
|  | 1143 | else elmgr->ElAddLine(xp1, yp1, xp2, yp2, gratt, fgcn); | 
|---|
| [1642] | 1144 | eld->Refresh(); | 
|---|
|  | 1145 | } | 
|---|
|  | 1146 |  | 
|---|
|  | 1147 | /* --Methode-- */ | 
|---|
| [1971] | 1148 | void PIStdImgApp::AddRectangle(double xp1, double yp1, double xp2, double yp2, | 
|---|
| [2263] | 1149 | string const& sop, bool fgfill, bool fgcn) | 
|---|
| [1642] | 1150 | { | 
|---|
| [2489] | 1151 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1152 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1153 |  | 
|---|
| [2165] | 1154 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
| [1642] | 1155 | if (eld == NULL) return; | 
|---|
| [2165] | 1156 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1157 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1158 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1159 | PIElDrwMgr* elmgr = NULL; | 
|---|
|  | 1160 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1161 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
| [1642] | 1162 |  | 
|---|
|  | 1163 | double xp,yp; | 
|---|
|  | 1164 | double dx, dy; | 
|---|
|  | 1165 | if (xp1 < xp2) { | 
|---|
|  | 1166 | xp = xp1; dx = xp2-xp1; | 
|---|
|  | 1167 | } | 
|---|
|  | 1168 | else { | 
|---|
|  | 1169 | xp = xp2; dx = xp1-xp2; | 
|---|
|  | 1170 | } | 
|---|
|  | 1171 | if (yp1 < yp2) { | 
|---|
|  | 1172 | yp = yp1; dy = yp2-yp1; | 
|---|
|  | 1173 | } | 
|---|
|  | 1174 | else { | 
|---|
|  | 1175 | yp = yp2; dy = yp1-yp2; | 
|---|
|  | 1176 | } | 
|---|
| [1971] | 1177 |  | 
|---|
|  | 1178 | vector<string> opts; | 
|---|
|  | 1179 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1180 | PIGraphicAtt gratt(opts); | 
|---|
|  | 1181 |  | 
|---|
| [2263] | 1182 | if (fgfill) elmgr->ElAddFRect(xp, yp, dx, dy, gratt, fgcn); | 
|---|
|  | 1183 | else elmgr->ElAddRect(xp, yp, dx, dy, gratt, fgcn); | 
|---|
| [1642] | 1184 | eld->Refresh(); | 
|---|
|  | 1185 | } | 
|---|
|  | 1186 |  | 
|---|
|  | 1187 | /* --Methode-- */ | 
|---|
| [2263] | 1188 | void PIStdImgApp::AddCircle(double xc, double yc, double r, string const& sop, | 
|---|
|  | 1189 | bool fgfill, bool fgcn) | 
|---|
| [1642] | 1190 | { | 
|---|
| [2489] | 1191 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1192 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1193 |  | 
|---|
| [2165] | 1194 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
| [1642] | 1195 | if (eld == NULL) return; | 
|---|
| [2165] | 1196 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1197 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1198 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1199 | PIElDrwMgr* elmgr = NULL; | 
|---|
|  | 1200 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1201 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
| [1642] | 1202 |  | 
|---|
| [1971] | 1203 | vector<string> opts; | 
|---|
|  | 1204 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1205 | PIGraphicAtt gratt(opts); | 
|---|
| [2243] | 1206 | if (r < -0.5) | 
|---|
|  | 1207 | elmgr->ElAddMarker(xc, yc, gratt); | 
|---|
|  | 1208 | else { | 
|---|
| [2263] | 1209 | if (fgfill) elmgr->ElAddFCirc(xc, yc, r, gratt, fgcn); | 
|---|
|  | 1210 | else elmgr->ElAddCirc(xc, yc, r, gratt, fgcn); | 
|---|
| [2243] | 1211 | } | 
|---|
|  | 1212 | eld->Refresh(); | 
|---|
|  | 1213 | } | 
|---|
| [2265] | 1214 | /* --Methode-- */ | 
|---|
| [2638] | 1215 | void PIStdImgApp::AddOval(double xp, double yp, double dx, double dy, | 
|---|
|  | 1216 | string const& sop, bool fgfill, bool fgcn) | 
|---|
|  | 1217 | { | 
|---|
|  | 1218 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1219 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2638] | 1220 |  | 
|---|
|  | 1221 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
|  | 1222 | if (eld == NULL) return; | 
|---|
|  | 1223 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1224 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1225 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1226 | PIElDrwMgr* elmgr = NULL; | 
|---|
|  | 1227 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1228 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
|  | 1229 |  | 
|---|
|  | 1230 |  | 
|---|
|  | 1231 | vector<string> opts; | 
|---|
|  | 1232 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1233 | PIGraphicAtt gratt(opts); | 
|---|
|  | 1234 |  | 
|---|
|  | 1235 | if (fgfill) elmgr->ElAddFOval(xp, yp, dx, dy, gratt, fgcn); | 
|---|
|  | 1236 | else elmgr->ElAddOval(xp, yp, dx, dy, gratt, fgcn); | 
|---|
|  | 1237 | eld->Refresh(); | 
|---|
|  | 1238 | } | 
|---|
|  | 1239 |  | 
|---|
|  | 1240 | /* --Methode-- */ | 
|---|
| [2265] | 1241 | void PIStdImgApp::AddArc(double xc, double yc, double r, double a, double da, | 
|---|
|  | 1242 | string const& sop, bool fgfill, bool fgcn) | 
|---|
|  | 1243 | { | 
|---|
| [2489] | 1244 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1245 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1246 |  | 
|---|
| [2265] | 1247 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
|  | 1248 | if (eld == NULL) return; | 
|---|
|  | 1249 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1250 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1251 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1252 | PIElDrwMgr* elmgr = NULL; | 
|---|
|  | 1253 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1254 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
| [1971] | 1255 |  | 
|---|
| [2265] | 1256 | vector<string> opts; | 
|---|
|  | 1257 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1258 | PIGraphicAtt gratt(opts); | 
|---|
|  | 1259 | if (fgfill) elmgr->ElAddFArc(xc, yc, r, a, da, gratt, fgcn); | 
|---|
|  | 1260 | else elmgr->ElAddArc(xc, yc, r, a, da, gratt, fgcn); | 
|---|
|  | 1261 | eld->Refresh(); | 
|---|
|  | 1262 | } | 
|---|
|  | 1263 |  | 
|---|
| [2243] | 1264 | /* --Methode-- */ | 
|---|
|  | 1265 | void PIStdImgApp::AddArc(double x1, double y1, double x2, double y2, | 
|---|
| [2263] | 1266 | double x3, double y3, string const& sop, bool fgfill, bool fgcn) | 
|---|
| [2243] | 1267 | { | 
|---|
| [2489] | 1268 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1269 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1270 |  | 
|---|
| [2243] | 1271 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
|  | 1272 | if (eld == NULL) return; | 
|---|
|  | 1273 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1274 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1275 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1276 | PIElDrwMgr* elmgr = NULL; | 
|---|
|  | 1277 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1278 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
|  | 1279 | if (elmgr == NULL) return; | 
|---|
|  | 1280 |  | 
|---|
|  | 1281 | vector<string> opts; | 
|---|
|  | 1282 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1283 | PIGraphicAtt gratt(opts); | 
|---|
|  | 1284 | if (fgfill) | 
|---|
| [2263] | 1285 | elmgr->ElAddFArc(x1, y1, x2, y2, x3, y3, gratt, fgcn); | 
|---|
|  | 1286 | else  elmgr->ElAddArc(x1, y1, x2, y2, x3, y3, gratt, fgcn); | 
|---|
| [1642] | 1287 | eld->Refresh(); | 
|---|
|  | 1288 | } | 
|---|
|  | 1289 |  | 
|---|
|  | 1290 | /* --Methode-- */ | 
|---|
| [2263] | 1291 | void PIStdImgApp::AddPoly(vector<double>& xpol, vector<double>& ypol, | 
|---|
|  | 1292 | string const& sop, bool fgfill, bool fgcn) | 
|---|
|  | 1293 | { | 
|---|
| [2489] | 1294 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1295 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1296 |  | 
|---|
| [2263] | 1297 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
|  | 1298 | if (eld == NULL) return; | 
|---|
|  | 1299 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1300 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1301 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
|  | 1302 | PIElDrwMgr* elmgr = NULL; | 
|---|
|  | 1303 | if (eld2) elmgr = &(eld2->ElDrwMgr()); | 
|---|
|  | 1304 | else if (eld3) elmgr = &(eld3->ElDrwMgr()); | 
|---|
|  | 1305 | if (elmgr == NULL) return; | 
|---|
|  | 1306 |  | 
|---|
|  | 1307 | vector<string> opts; | 
|---|
|  | 1308 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1309 | PIGraphicAtt gratt(opts); | 
|---|
|  | 1310 | if (fgfill) | 
|---|
|  | 1311 | elmgr->ElAddFPoly(xpol, ypol, gratt, fgcn); | 
|---|
|  | 1312 | else  elmgr->ElAddPoly(xpol, ypol, gratt, fgcn); | 
|---|
|  | 1313 | eld->Refresh(); | 
|---|
|  | 1314 |  | 
|---|
|  | 1315 | } | 
|---|
|  | 1316 |  | 
|---|
|  | 1317 |  | 
|---|
|  | 1318 | /* --Methode-- */ | 
|---|
| [2165] | 1319 | void PIStdImgApp::SetTitle(string const & titletop, string const & titlebottom, string const& sop) | 
|---|
| [1131] | 1320 | { | 
|---|
| [2489] | 1321 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1322 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1323 |  | 
|---|
| [2165] | 1324 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
| [1642] | 1325 | if (eld == NULL) return; | 
|---|
| [2165] | 1326 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1327 | PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld); | 
|---|
|  | 1328 | if ((eld2 == NULL) && (eld3 == NULL)) return; | 
|---|
| [1642] | 1329 |  | 
|---|
| [2165] | 1330 | vector<string> opts; | 
|---|
|  | 1331 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1332 | PIGraphicAtt gratt(opts); | 
|---|
|  | 1333 |  | 
|---|
|  | 1334 | if (eld2) { | 
|---|
|  | 1335 | eld2->SetTitles(titletop, titlebottom, gratt); | 
|---|
|  | 1336 | eld2->ShowTitles(true); | 
|---|
|  | 1337 | } | 
|---|
|  | 1338 | else if (eld3) { | 
|---|
|  | 1339 | eld3->SetTitles(titletop, titlebottom, gratt); | 
|---|
|  | 1340 | eld3->ShowTitles(true); | 
|---|
|  | 1341 | } | 
|---|
| [1642] | 1342 | eld->Refresh(); | 
|---|
|  | 1343 | } | 
|---|
| [2165] | 1344 | /* --Methode-- */ | 
|---|
|  | 1345 | void PIStdImgApp::SetAxeLabels(string const & xLabel, string const & yLabel, string const& sop) | 
|---|
|  | 1346 | { | 
|---|
| [2489] | 1347 | // <ZThread> global PIApplication event loop synchronisation | 
|---|
| [2755] | 1348 | ZSync zs(thr_glsyn, 2);  zs.NOp(); | 
|---|
| [2489] | 1349 |  | 
|---|
| [2165] | 1350 | PIDrawer *eld=CurrentElDrawer(); | 
|---|
|  | 1351 | if (eld == NULL) return; | 
|---|
|  | 1352 | PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld); | 
|---|
|  | 1353 | if (eld2 == NULL) return; | 
|---|
| [1642] | 1354 |  | 
|---|
| [2165] | 1355 | vector<string> opts; | 
|---|
|  | 1356 | ParseDisplayOption(sop, opts); | 
|---|
|  | 1357 | PIGraphicAtt gratt(opts); | 
|---|
|  | 1358 |  | 
|---|
|  | 1359 | eld2->SetAxesLabels(xLabel, yLabel, gratt); | 
|---|
|  | 1360 | eld2->ShowAxesLabels(true); | 
|---|
|  | 1361 |  | 
|---|
|  | 1362 | eld->Refresh(); | 
|---|
|  | 1363 | } | 
|---|
|  | 1364 |  | 
|---|
| [1642] | 1365 | /* --Methode-- */ | 
|---|
| [2165] | 1366 | PIDrawer* PIStdImgApp::CurrentElDrawer() | 
|---|
| [1642] | 1367 | { | 
|---|
| [2165] | 1368 | PIDrawer *eld=NULL; | 
|---|
| [1642] | 1369 | if (!mLastWdg)  return(eld); | 
|---|
| [1131] | 1370 | PIScDrawWdg* sdw=NULL; | 
|---|
|  | 1371 | PIDraw3DWdg* w3d=NULL; | 
|---|
|  | 1372 | PIImage* imgw; | 
|---|
|  | 1373 | switch(mLastWdg->kind()) { | 
|---|
|  | 1374 | case PIScDrawWdg::ClassId : | 
|---|
|  | 1375 | sdw = dynamic_cast<PIScDrawWdg *>(mLastWdg); | 
|---|
|  | 1376 | if (sdw) eld = sdw->BaseDrawer(); | 
|---|
|  | 1377 | break; | 
|---|
|  | 1378 | case PIDraw3DWdg::ClassId : | 
|---|
|  | 1379 | w3d = dynamic_cast<PIDraw3DWdg *>(mLastWdg); | 
|---|
|  | 1380 | if (w3d) eld = w3d->BaseDrawer(); | 
|---|
|  | 1381 | break; | 
|---|
|  | 1382 | case PIImage::ClassId : | 
|---|
|  | 1383 | imgw = dynamic_cast<PIImage *>(mLastWdg); | 
|---|
| [1642] | 1384 | if (imgw) eld = imgw->BaseDrawer(); | 
|---|
| [1131] | 1385 | break; | 
|---|
|  | 1386 | default : | 
|---|
|  | 1387 | break; | 
|---|
|  | 1388 | } | 
|---|
| [1642] | 1389 | return(eld); | 
|---|
| [1131] | 1390 | } | 
|---|
| [165] | 1391 |  | 
|---|
|  | 1392 | /* --Methode-- */ | 
|---|
|  | 1393 | void PIStdImgApp::CreateGraphWin(int nx, int ny, int sx, int sy) | 
|---|
|  | 1394 | { | 
|---|
|  | 1395 | if (nx < 1)  nx = 1; | 
|---|
|  | 1396 | if (ny < 1)  ny = 1; | 
|---|
|  | 1397 | if (nx > 8)  nx = 8; | 
|---|
|  | 1398 | if (ny > 8)  ny = 8; | 
|---|
|  | 1399 | if ( (sx < 50) && (sy < 50) )   sx = sy = 400+mFgScSz*100; | 
|---|
|  | 1400 | char buff[64]; | 
|---|
|  | 1401 | mWId++; | 
|---|
| [210] | 1402 | int px, py; | 
|---|
|  | 1403 | MainWin()->GetScreenPos(px, py); | 
|---|
|  | 1404 | sprintf(buff, "PI-GraphicWin (%d)",mWId); | 
|---|
|  | 1405 | PIZoneWindow* win = new PIZoneWindow(this,  buff, PIWK_normal, nx, ny, sx, sy, px+MainWin()->XSize()+30, 0); | 
|---|
| [165] | 1406 | win->SetUserData(NULL, ny*10+nx);  // UserFlag= nY*10 + nX | 
|---|
|  | 1407 | mWList[mWId*10+1] = (PIWindow*)win; | 
|---|
|  | 1408 | win->SetAutoDelChilds(true); | 
|---|
| [293] | 1409 | // win->Show(); | 
|---|
| [165] | 1410 | mGrW = win; | 
|---|
|  | 1411 | mGrIdx = 0; | 
|---|
|  | 1412 | } | 
|---|
|  | 1413 |  | 
|---|
|  | 1414 | /* --Methode-- */ | 
|---|
|  | 1415 | void PIStdImgApp::CreateStackWin(int sx, int sy) | 
|---|
|  | 1416 | { | 
|---|
|  | 1417 | if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; | 
|---|
|  | 1418 | char buff[64]; | 
|---|
|  | 1419 | mWId++; | 
|---|
| [210] | 1420 | int px, py; | 
|---|
|  | 1421 | MainWin()->GetScreenPos(px, py); | 
|---|
| [165] | 1422 | sprintf(buff, "PI-StackWin (%d)",mWId); | 
|---|
| [210] | 1423 | PIStackWindow* win = new PIStackWindow(this,  buff, PIWK_normal, sx, sy, px+MainWin()->XSize()+30, 100); | 
|---|
| [165] | 1424 | win->SetUserData(NULL, 9999);  // UserFlag= 9999 | 
|---|
|  | 1425 | mWList[mWId*10+2] = (PIWindow*)win; | 
|---|
|  | 1426 | win->SetAutoDelChilds(true); | 
|---|
| [293] | 1427 | // win->Show(); | 
|---|
| [165] | 1428 | mStW = win; | 
|---|
|  | 1429 | m[2]->SetSensitivity("StackTools", true); | 
|---|
|  | 1430 | mStIdx = 0; | 
|---|
|  | 1431 | } | 
|---|
|  | 1432 |  | 
|---|
|  | 1433 | /* --Methode-- */ | 
|---|
| [1971] | 1434 | PIWindow* PIStdImgApp::GetWindow(DispWinEnum typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom) | 
|---|
| [165] | 1435 | { | 
|---|
|  | 1436 | PIWindow* rw; | 
|---|
|  | 1437 |  | 
|---|
|  | 1438 | switch (typ) { | 
|---|
|  | 1439 | case Disp_Next :  // Fenetre graphique courante | 
|---|
| [1971] | 1440 | case Disp_Default : | 
|---|
| [165] | 1441 | { | 
|---|
|  | 1442 | if (mGrW == NULL) CreateGraphWin(); | 
|---|
|  | 1443 | int nx, ny; | 
|---|
|  | 1444 | mGrW->NbZone(nx, ny); | 
|---|
|  | 1445 | PIWdg* nw = mGrW->NextChildPosSize(px, py, sx, sy); | 
|---|
|  | 1446 | //    cerr << "**DBG** PIStdImgApp::GetWindow() DispNext : nw = " << (long)nw << endl; | 
|---|
| [2651] | 1447 | if (nw) DeleteWidget(nw, false, false); | 
|---|
| [165] | 1448 | flag = mGrIdx; | 
|---|
|  | 1449 | mGrIdx = (mGrIdx+1)%(nx*ny); | 
|---|
|  | 1450 | rw = mGrW; | 
|---|
|  | 1451 | break; | 
|---|
|  | 1452 | } | 
|---|
|  | 1453 |  | 
|---|
|  | 1454 | case Disp_Stack :  // Fenetre de type stack (empilement) | 
|---|
|  | 1455 | { | 
|---|
|  | 1456 | if (mStW == NULL) CreateStackWin(sx, sy); | 
|---|
|  | 1457 | px = py = 0; | 
|---|
|  | 1458 | sx = mStW->XSize(); | 
|---|
|  | 1459 | sy = mStW->YSize(); | 
|---|
|  | 1460 | flag = mStIdx; | 
|---|
|  | 1461 | mStIdx++; | 
|---|
|  | 1462 | rw = mStW; | 
|---|
|  | 1463 | } | 
|---|
|  | 1464 | break; | 
|---|
|  | 1465 |  | 
|---|
|  | 1466 | default :      // Fenetre ordinaire | 
|---|
|  | 1467 | { | 
|---|
| [210] | 1468 | int pwx, pwy; | 
|---|
|  | 1469 | MainWin()->GetScreenPos(pwx, pwy); | 
|---|
| [165] | 1470 | if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; | 
|---|
| [210] | 1471 | rw = new PIWindow(this,  nom, PIWK_normal, sx, sy, pwx+MainWin()->XSize()+30, 300); | 
|---|
| [165] | 1472 | rw->SetUserData(NULL, 0);  // UserFlag= 0 | 
|---|
|  | 1473 | mWId++; | 
|---|
|  | 1474 | mWList[mWId*10] = rw; | 
|---|
|  | 1475 | rw->SetAutoDelChilds(true); | 
|---|
| [293] | 1476 | //    rw->Show(); | 
|---|
| [165] | 1477 | px = py = 0; | 
|---|
|  | 1478 | flag = 0; | 
|---|
|  | 1479 | break; | 
|---|
|  | 1480 | } | 
|---|
|  | 1481 | } | 
|---|
|  | 1482 |  | 
|---|
| [293] | 1483 | rw->Show(); | 
|---|
| [165] | 1484 | mCurWin = rw; | 
|---|
|  | 1485 | return(rw); | 
|---|
|  | 1486 | } | 
|---|
|  | 1487 |  | 
|---|
|  | 1488 | /* --Methode-- */ | 
|---|
|  | 1489 | void PIStdImgApp::SetZone(int nzx, int nzy) | 
|---|
|  | 1490 | { | 
|---|
|  | 1491 | if (!mGrW) CreateGraphWin(nzx, nzy); | 
|---|
|  | 1492 | else { | 
|---|
|  | 1493 | int k; | 
|---|
|  | 1494 | PIWdg* cwd; | 
|---|
|  | 1495 | for(k=0; k<mGrW->NbChilds(); k++) { | 
|---|
|  | 1496 | if ((cwd = mGrW->GetChild(k)) == NULL)  continue; | 
|---|
| [2651] | 1497 | DeleteWidget(cwd, false, false); | 
|---|
| [165] | 1498 | } | 
|---|
|  | 1499 | mGrW->SetZone(nzx, nzy); | 
|---|
|  | 1500 | } | 
|---|
|  | 1501 | } | 
|---|
|  | 1502 |  | 
|---|
|  | 1503 | /* --Methode-- */ | 
|---|
|  | 1504 | void PIStdImgApp::StackWinNext() | 
|---|
|  | 1505 | { | 
|---|
|  | 1506 | if (mStW)  mStW->DispNext(); | 
|---|
|  | 1507 | } | 
|---|
|  | 1508 |  | 
|---|
|  | 1509 | /* --Methode-- */ | 
|---|
| [3355] | 1510 | void PIStdImgApp::SelectLastWidget(string & nom) | 
|---|
|  | 1511 | { | 
|---|
|  | 1512 |  | 
|---|
|  | 1513 | if ( (mLastWdg != NULL) && (mLastWdg->Nom() == nom) ) return; | 
|---|
|  | 1514 | if ( (mCurWdg != NULL) && (mCurWdg->Nom() == nom) ) { | 
|---|
|  | 1515 | mLastWdg = mCurWdg; | 
|---|
|  | 1516 | return; | 
|---|
|  | 1517 | } | 
|---|
|  | 1518 |  | 
|---|
|  | 1519 | PIWdg* bw = NULL; | 
|---|
|  | 1520 | long wsid = -1; | 
|---|
|  | 1521 | BWMList::iterator it; | 
|---|
|  | 1522 | for(it = mBWList.begin(); it != mBWList.end(); it++) { | 
|---|
|  | 1523 | if ( ((*it).second->Nom() == nom) && ((*it).first > wsid)) { | 
|---|
|  | 1524 | bw = (*it).second; wsid = (*it).first; | 
|---|
|  | 1525 | } | 
|---|
|  | 1526 | } | 
|---|
|  | 1527 | if (bw != NULL) { | 
|---|
|  | 1528 | if (bw->kind() == PIImageNavigator::ClassId) | 
|---|
|  | 1529 | mLastWdg = dynamic_cast<PIImageNavigator *>(bw)->ImageWdg(); | 
|---|
|  | 1530 | else mLastWdg = dynamic_cast<PIBaseWdg *>(bw); | 
|---|
|  | 1531 | } | 
|---|
|  | 1532 | return; | 
|---|
|  | 1533 | } | 
|---|
|  | 1534 |  | 
|---|
|  | 1535 | /* --Methode-- */ | 
|---|
|  | 1536 | void PIStdImgApp::SelectLastWidgetByObjName(string & nom) | 
|---|
|  | 1537 | { | 
|---|
|  | 1538 | int oid = ObjMgr()->NameToOId(nom); | 
|---|
|  | 1539 | if (oid < 0) return; | 
|---|
|  | 1540 |  | 
|---|
|  | 1541 | if ( (mLastWdg != NULL) && (mLastWdg->UserFlag() == oid) ) return; | 
|---|
|  | 1542 | if ( (mCurWdg != NULL) && (mCurWdg->UserFlag() == oid) ) { | 
|---|
|  | 1543 | mLastWdg = mCurWdg; | 
|---|
|  | 1544 | return; | 
|---|
|  | 1545 | } | 
|---|
|  | 1546 |  | 
|---|
|  | 1547 | PIWdg* bw = NULL; | 
|---|
|  | 1548 | long wsid = -1; | 
|---|
|  | 1549 | BWMList::iterator it; | 
|---|
|  | 1550 | for(it = mBWList.begin(); it != mBWList.end(); it++) { | 
|---|
|  | 1551 | if ( ((*it).second->UserFlag() == oid) && ((*it).first > wsid)) { | 
|---|
|  | 1552 | bw = (*it).second; wsid = (*it).first; | 
|---|
|  | 1553 | } | 
|---|
|  | 1554 | } | 
|---|
|  | 1555 | if (bw != NULL) { | 
|---|
|  | 1556 | if (bw->kind() == PIImageNavigator::ClassId) | 
|---|
|  | 1557 | mLastWdg = dynamic_cast<PIImageNavigator *>(bw)->ImageWdg(); | 
|---|
|  | 1558 | else mLastWdg = dynamic_cast<PIBaseWdg *>(bw); | 
|---|
|  | 1559 | } | 
|---|
|  | 1560 | return; | 
|---|
|  | 1561 | } | 
|---|
|  | 1562 |  | 
|---|
|  | 1563 | /* --Methode-- */ | 
|---|
| [165] | 1564 | void PIStdImgApp::DeleteWindow(PIWindow* w) | 
|---|
|  | 1565 | { | 
|---|
|  | 1566 | if (w == NULL)  return; | 
|---|
|  | 1567 | w->Hide(); | 
|---|
| [344] | 1568 | bool ownwindow=false;  // To Check if this is one of our windows | 
|---|
| [165] | 1569 | WindMList::iterator it; | 
|---|
|  | 1570 | for(it = mWList.begin(); it != mWList.end(); it++) | 
|---|
| [344] | 1571 | if ((*it).second == w)  { mWList.erase(it);  ownwindow = true; break; } | 
|---|
| [165] | 1572 | if (w == mGrW) { mGrW = NULL;  mGrIdx = -1; } | 
|---|
|  | 1573 | if (w == mStW) { mStW = NULL;  mStIdx = -1; m[2]->SetSensitivity("StackTools", false); } | 
|---|
|  | 1574 | if (w == mCurWin) mCurWin = NULL; | 
|---|
| [344] | 1575 |  | 
|---|
|  | 1576 | if (!ownwindow) return; // We do nothing if this is not a window we have created ... | 
|---|
|  | 1577 |  | 
|---|
| [165] | 1578 | int k; | 
|---|
|  | 1579 | PIWdg* cwd; | 
|---|
|  | 1580 | for(k=0; k<w->NbChilds(); k++) { | 
|---|
|  | 1581 | if ((cwd = w->GetChild(k)) == NULL)  continue; | 
|---|
| [2651] | 1582 | DeleteWidget(cwd,false,false); | 
|---|
| [165] | 1583 | } | 
|---|
|  | 1584 | delete w; | 
|---|
|  | 1585 | return; | 
|---|
|  | 1586 | } | 
|---|
|  | 1587 |  | 
|---|
|  | 1588 | /* --Methode-- */ | 
|---|
| [2651] | 1589 | void PIStdImgApp::DeleteWidget(PIWdg* w, bool dw, bool dwin) | 
|---|
| [165] | 1590 | { | 
|---|
|  | 1591 | if (w == NULL)  return; | 
|---|
|  | 1592 | BWMList::iterator it; | 
|---|
|  | 1593 | for(it = mBWList.begin(); it != mBWList.end(); it++) | 
|---|
|  | 1594 | if ((*it).second == w)  { mBWList.erase(it);  break; } | 
|---|
| [2762] | 1595 | PIBaseWdg* bw = NULL; | 
|---|
|  | 1596 | if (w->kind() == PIImageNavigator::ClassId) { | 
|---|
|  | 1597 | PIImageNavigator* piin = dynamic_cast<PIImageNavigator *>(w); | 
|---|
|  | 1598 | if (piin) bw = piin->ImageWdg(); | 
|---|
|  | 1599 | } | 
|---|
|  | 1600 | else bw = dynamic_cast<PIBaseWdg *>(w); | 
|---|
| [2651] | 1601 | if (bw != NULL) { | 
|---|
|  | 1602 | PIDrawer* drw; | 
|---|
|  | 1603 | int k; | 
|---|
|  | 1604 | for(k=0; k<bw->NbDrawers(); k++) { | 
|---|
|  | 1605 | if ((drw = bw->GetDrawer(k)) == NULL)  continue; | 
|---|
|  | 1606 | DrwMList::iterator itt; | 
|---|
|  | 1607 | for(itt = mDrwList.begin(); itt != mDrwList.end(); itt++) | 
|---|
|  | 1608 | if ((*itt).second == drw)  { mDrwList.erase(itt);  break; } | 
|---|
| [165] | 1609 | } | 
|---|
| [2651] | 1610 | } | 
|---|
| [165] | 1611 |  | 
|---|
| [2762] | 1612 | if ( (w == mCurWdg) || (bw == mCurWdg) ) { | 
|---|
| [165] | 1613 | mCurWdg = NULL; | 
|---|
|  | 1614 | if (mFgCWImg) { | 
|---|
|  | 1615 | m[4]->SetSensitivityMsg(10515, false); | 
|---|
|  | 1616 | m[4]->SetSensitivityMsg(10516, false); | 
|---|
|  | 1617 | mFgCWImg = false; | 
|---|
|  | 1618 | } | 
|---|
|  | 1619 | } | 
|---|
|  | 1620 |  | 
|---|
| [2762] | 1621 | if ( (w == mLastWdg) || (bw == mLastWdg) ) mLastWdg = NULL; | 
|---|
| [165] | 1622 |  | 
|---|
|  | 1623 | PIWdg* pw=NULL; | 
|---|
| [2651] | 1624 | pw = (PIWdg*)(w->Parent()); | 
|---|
|  | 1625 | //DBG printf("DeleteWidget(%lx)-DBG kind = %d - %d %d \n", (long)w, w->kind(), (int)dw, (int)dwin); | 
|---|
| [2762] | 1626 | if (dw)  delete w; | 
|---|
|  | 1627 |  | 
|---|
|  | 1628 | if (dwin && pw) { | 
|---|
|  | 1629 | PIWindow* pww = dynamic_cast<PIWindow *>(pw); | 
|---|
|  | 1630 | if (pww && (pww != (PIWindow*)mGrW) && (pww != (PIWindow*)mStW) && (pww->NbChilds()==0)) | 
|---|
| [165] | 1631 | DeleteWindow((PIWindow*)pw); | 
|---|
| [2762] | 1632 | } | 
|---|
| [165] | 1633 | return; | 
|---|
|  | 1634 | } | 
|---|
|  | 1635 |  | 
|---|
|  | 1636 |  | 
|---|
|  | 1637 |  | 
|---|
|  | 1638 | /* --Methode-- */ | 
|---|
|  | 1639 | void PIStdImgApp::DelWRsId(int k) | 
|---|
|  | 1640 | { | 
|---|
|  | 1641 | //DBG cerr << "-DBG- PIStdImgApp::DelWRsId(" << k << ")" << endl; | 
|---|
|  | 1642 | if (k > 0) { // C'est un BaseWidget | 
|---|
|  | 1643 | BWMList::iterator it; | 
|---|
|  | 1644 | it  = mBWList.find(k); | 
|---|
|  | 1645 | if (it == mBWList.end())  return; | 
|---|
| [2651] | 1646 | PIWdg* wd = (*it).second; | 
|---|
| [165] | 1647 | //DBG cerr << "-DBG- PIStdImgApp::DelWRsId Deleting BaseWidget " << (long)(wd) << endl ; | 
|---|
| [2651] | 1648 | DeleteWidget(wd, true, true); | 
|---|
| [165] | 1649 | } | 
|---|
|  | 1650 | else {  // C'est un drawer | 
|---|
|  | 1651 | DrwMList::iterator it; | 
|---|
|  | 1652 | it  = mDrwList.find(-k); | 
|---|
|  | 1653 | if (it == mDrwList.end())  return; | 
|---|
| [2231] | 1654 | (*it).second->SetAutoRefreshOnDelete(true); | 
|---|
| [165] | 1655 | delete (*it).second; | 
|---|
|  | 1656 | mDrwList.erase(it); | 
|---|
| [2402] | 1657 | //DBG cerr << "+DBG+ PIStdImgApp::DelWRsId Deleting Drawer " << (long)((*it).second) << endl ; | 
|---|
| [165] | 1658 | } | 
|---|
|  | 1659 | } | 
|---|
| [368] | 1660 | /* --Methode-- */ | 
|---|
|  | 1661 | bool PIStdImgApp::CheckWRsId(int k) | 
|---|
|  | 1662 | { | 
|---|
|  | 1663 | if (k > 0) { // C'est un BaseWidget | 
|---|
|  | 1664 | BWMList::iterator it; | 
|---|
|  | 1665 | it  = mBWList.find(k); | 
|---|
|  | 1666 | if (it == mBWList.end())  return(false); | 
|---|
|  | 1667 | else return(true); | 
|---|
|  | 1668 | } | 
|---|
|  | 1669 | else {  // C'est un drawer | 
|---|
|  | 1670 | DrwMList::iterator it; | 
|---|
|  | 1671 | it  = mDrwList.find(-k); | 
|---|
|  | 1672 | if (it == mDrwList.end())  return(false); | 
|---|
|  | 1673 | else return(true); | 
|---|
|  | 1674 | } | 
|---|
|  | 1675 | } | 
|---|
| [165] | 1676 |  | 
|---|
| [1971] | 1677 | /* --Methode-- */ | 
|---|
|  | 1678 | void PIStdImgApp::StatZoomWindowSetVisible(bool fg) | 
|---|
|  | 1679 | { | 
|---|
| [165] | 1680 |  | 
|---|
| [1971] | 1681 | if (fg) { | 
|---|
| [2778] | 1682 | consolecont->Hide(); | 
|---|
| [1971] | 1683 | consolecont->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free); | 
|---|
|  | 1684 | int szy = MainWin()->YSize(); | 
|---|
|  | 1685 | MainWin()->SetSize(MainWin()->XSize(), szy+statcont->YSize()); | 
|---|
|  | 1686 | consolecont->SetPos(0, statcont->YSize()); | 
|---|
|  | 1687 | consolecont->SetSize(MainWin()->XSize(), szy); | 
|---|
|  | 1688 | consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); | 
|---|
| [2778] | 1689 | consolecont->Show(); | 
|---|
| [1971] | 1690 | statcont->Show(); | 
|---|
|  | 1691 | m[3]->SetStateMsg(10470, true); | 
|---|
|  | 1692 | } | 
|---|
|  | 1693 | else { | 
|---|
|  | 1694 | statcont->Hide(); | 
|---|
| [2778] | 1695 | consolecont->Hide(); | 
|---|
| [1971] | 1696 | consolecont->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free); | 
|---|
|  | 1697 | MainWin()->SetSize(MainWin()->XSize(), MainWin()->YSize()-statcont->YSize()); | 
|---|
|  | 1698 | consolecont->SetPos(0, 0); | 
|---|
|  | 1699 | consolecont->SetSize(MainWin()->XSize(), MainWin()->YSize()); | 
|---|
|  | 1700 | consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); | 
|---|
| [2778] | 1701 | consolecont->Show(); | 
|---|
| [1971] | 1702 | m[3]->SetStateMsg(10470, false); | 
|---|
|  | 1703 | } | 
|---|
|  | 1704 |  | 
|---|
|  | 1705 | } | 
|---|
|  | 1706 |  | 
|---|
| [165] | 1707 | /* --Methode-- */ | 
|---|
| [2106] | 1708 | void PIStdImgApp::UpdateStatResourceInfo() | 
|---|
|  | 1709 | { | 
|---|
|  | 1710 | resusg.Update(); | 
|---|
|  | 1711 | char buff[256]; | 
|---|
|  | 1712 | string lab; | 
|---|
|  | 1713 | double frac; | 
|---|
| [2158] | 1714 | sprintf(buff, "Mem: %ld/Max= %ld kb" , (long)resusg.getMemorySize(), | 
|---|
|  | 1715 | (long)resusg.getMaxMemorySize()); | 
|---|
| [2106] | 1716 | lab = buff; | 
|---|
|  | 1717 | lab_mem->SetLabel(lab); | 
|---|
|  | 1718 | frac = (double)resusg.getMemorySize()/(double)resusg.getMaxMemorySize(); | 
|---|
|  | 1719 | therm_mem->SetValue(frac); | 
|---|
|  | 1720 |  | 
|---|
| [2158] | 1721 | sprintf(buff, "CPU: %ld/elap= %ld ms" , (long)resusg.getCPUTime(), | 
|---|
|  | 1722 | (long)resusg.getElapsedTime()); | 
|---|
| [2106] | 1723 | lab = buff; | 
|---|
|  | 1724 | lab_cpu->SetLabel(lab); | 
|---|
| [2259] | 1725 | if (resusg.getCPULoad() > resusg.getAverageCPULoad()) | 
|---|
|  | 1726 | therm_cpu->SetValue(resusg.getCPULoad()); | 
|---|
|  | 1727 | else | 
|---|
|  | 1728 | therm_cpu->SetValue(resusg.getAverageCPULoad()); | 
|---|
| [2486] | 1729 | int nlx = 0; | 
|---|
|  | 1730 | bool fgx = false; | 
|---|
| [2489] | 1731 | if ( CmdInterpreter() ) fgx = CmdInterpreter()->isRunning(nlx); | 
|---|
| [2486] | 1732 | if (!fgx) { | 
|---|
|  | 1733 | lab = "PIACmdThread Idle"; | 
|---|
|  | 1734 | lab_thrcmd->SetLabel(lab); | 
|---|
|  | 1735 | lab_thrcmd->SetForegroundColor(PI_Green); | 
|---|
|  | 1736 | } | 
|---|
|  | 1737 | else { | 
|---|
|  | 1738 | sprintf(buff, "PIACmdThread Running - NL=%d" , nlx); | 
|---|
|  | 1739 | lab = buff; | 
|---|
|  | 1740 | lab_thrcmd->SetLabel(lab); | 
|---|
|  | 1741 | if (nlx < 3)     lab_thrcmd->SetForegroundColor(PI_Yellow); | 
|---|
|  | 1742 | else     lab_thrcmd->SetForegroundColor(PI_Red); | 
|---|
|  | 1743 | } | 
|---|
| [2106] | 1744 | } | 
|---|
|  | 1745 |  | 
|---|
|  | 1746 | /* --Methode-- */ | 
|---|
| [3370] | 1747 | void PIStdImgApp::RedirectStdOutErr(RED_OUTERR_FLG redflg) | 
|---|
| [165] | 1748 | { | 
|---|
| [3370] | 1749 | if (redflg == redirecout) return; | 
|---|
|  | 1750 | string fnout = ObjMgr()->GetTmpDir() + "/sout.log"; | 
|---|
|  | 1751 | string fnerr = ObjMgr()->GetTmpDir() + "/serr.log"; | 
|---|
|  | 1752 | bool drfg = false; | 
|---|
|  | 1753 | PIConsole* pcons = NULL; | 
|---|
|  | 1754 | switch (redflg) { | 
|---|
|  | 1755 | case NORED_OE : | 
|---|
|  | 1756 | pcons = NULL; | 
|---|
|  | 1757 | break; | 
|---|
|  | 1758 | case CONSRED_OE : | 
|---|
|  | 1759 | pcons = mCons; | 
|---|
|  | 1760 | drfg = false; | 
|---|
|  | 1761 | break; | 
|---|
|  | 1762 | case DOUBLERED_OE: | 
|---|
|  | 1763 | pcons = mCons; | 
|---|
|  | 1764 | drfg = true; | 
|---|
|  | 1765 | break; | 
|---|
|  | 1766 | } | 
|---|
|  | 1767 |  | 
|---|
|  | 1768 | char piva =  PIVA_Def; | 
|---|
|  | 1769 | RedirectOutStream(pcons, fnout, drfg, piva); | 
|---|
|  | 1770 | // ancienne maniere redirect, avec pipe : RedirectOutStream(pcons, piva); | 
|---|
|  | 1771 | piva = PIVA_Red; | 
|---|
|  | 1772 | RedirectErrStream(pcons, fnerr, drfg, piva); | 
|---|
|  | 1773 | // ancienne maniere redirect, avec pipe : RedirectErrStream(pcons, piva); | 
|---|
|  | 1774 |  | 
|---|
|  | 1775 | //  m[5]->SetStateMsg(10602, false); | 
|---|
|  | 1776 | redirecout = redflg; | 
|---|
| [165] | 1777 | return; | 
|---|
|  | 1778 | } | 
|---|
|  | 1779 |  | 
|---|
|  | 1780 | /* --Methode-- */ | 
|---|
| [374] | 1781 | void PIStdImgApp::CatchSignals(bool fgfpe, bool fgsegv) | 
|---|
| [165] | 1782 | { | 
|---|
| [912] | 1783 | #ifdef SANS_EVOLPLANCK | 
|---|
| [374] | 1784 | PeidaConfigureSignalhandling(fgfpe, fgsegv, true, true); | 
|---|
| [912] | 1785 | #else | 
|---|
| [2944] | 1786 | // On active aussi SIGUSR1 pour stopthr | 
|---|
| [2954] | 1787 | SophyaConfigureSignalhandling(fgfpe, fgsegv, true, true); | 
|---|
| [912] | 1788 | #endif | 
|---|
| [374] | 1789 | m[5]->SetStateMsg(10603, fgfpe); | 
|---|
|  | 1790 | m[5]->SetStateMsg(10604, fgsegv); | 
|---|
| [165] | 1791 | } | 
|---|
|  | 1792 |  | 
|---|
|  | 1793 | /* --Methode-- */ | 
|---|
|  | 1794 | void PIStdImgApp::CloseAllWindows() | 
|---|
|  | 1795 | { | 
|---|
|  | 1796 | WindMList::iterator it; | 
|---|
|  | 1797 | for(it = mWList.begin(); it != mWList.end(); it++)   delete (*it).second; | 
|---|
|  | 1798 | mWList.clear(); | 
|---|
|  | 1799 | mBWList.clear(); | 
|---|
|  | 1800 | mDrwList.clear(); | 
|---|
| [454] | 1801 | mGrW = NULL; | 
|---|
|  | 1802 | mStW = NULL; | 
|---|
|  | 1803 | mCurWin = NULL; | 
|---|
|  | 1804 | mCurWdg = NULL; | 
|---|
|  | 1805 | mLastWdg = NULL; | 
|---|
|  | 1806 | m[4]->SetSensitivityMsg(10515, false); | 
|---|
|  | 1807 | m[4]->SetSensitivityMsg(10516, false); | 
|---|
| [165] | 1808 | } | 
|---|
|  | 1809 |  | 
|---|
| [1971] | 1810 | //--------------------------------------------------------------------------- | 
|---|
|  | 1811 | //--------- Gestion des attributs graphiques et autres options de trace ----- | 
|---|
|  | 1812 |  | 
|---|
| [165] | 1813 | /* --Methode-- */ | 
|---|
| [1971] | 1814 | void PIStdImgApp::SetInsetLimits(double xmin, double xmax, double ymin, double ymax) | 
|---|
|  | 1815 | { | 
|---|
|  | 1816 | mIXmin = xmin;  mIXmax= xmax; | 
|---|
|  | 1817 | mIYmin = ymin;  mIYmax= ymax; | 
|---|
|  | 1818 | } | 
|---|
|  | 1819 |  | 
|---|
|  | 1820 | /* --Methode-- */ | 
|---|
|  | 1821 | void PIStdImgApp::SetDefaultGraphicAttributes(string const & opt) | 
|---|
|  | 1822 | { | 
|---|
|  | 1823 | ParseDisplayOption(opt, mDefaultAtt); | 
|---|
|  | 1824 | } | 
|---|
|  | 1825 |  | 
|---|
|  | 1826 | /* --Methode-- */ | 
|---|
|  | 1827 | void PIStdImgApp::SetDefaultAxesAttributes(string const & opt) | 
|---|
|  | 1828 | { | 
|---|
|  | 1829 | ParseDisplayOption(opt, mAxesAtt); | 
|---|
|  | 1830 | } | 
|---|
|  | 1831 |  | 
|---|
|  | 1832 | /* --Methode-- */ | 
|---|
| [3355] | 1833 | DispWinEnum PIStdImgApp::ParseDisplayOption(string const & sop, vector<string>& opts, string& wname) | 
|---|
| [1971] | 1834 | { | 
|---|
|  | 1835 | DispWinEnum rc = Disp_Next; | 
|---|
|  | 1836 | //DBG  cerr << " DBG-Parse-A sop=" << sop << " sop.length()= " << sop.length() << endl; | 
|---|
|  | 1837 | if (opts.size() > 0)  opts.erase(opts.begin(), opts.end()); | 
|---|
|  | 1838 | if (sop.length() < 1) return(rc); | 
|---|
|  | 1839 | string gratt = sop; | 
|---|
|  | 1840 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]); | 
|---|
|  | 1841 | if ( (gratt == "def") || (gratt == "default") ) return(rc); | 
|---|
|  | 1842 | // On separe en mots espaces par des blancs ou tabulation | 
|---|
|  | 1843 | size_t p = 0; | 
|---|
|  | 1844 | size_t q = 0; | 
|---|
|  | 1845 | size_t l = gratt.length(); | 
|---|
|  | 1846 | string token; | 
|---|
|  | 1847 | while (q < l)  { | 
|---|
|  | 1848 | p = gratt.find_first_not_of(" \t",q);   // au debut d'un token | 
|---|
|  | 1849 | if (p >= l) break; | 
|---|
|  | 1850 | q = gratt.find_first_of(" \t",p);       // Premier blanc ou tab suivant | 
|---|
|  | 1851 | if (q<l) token = gratt.substr(p,q-p); | 
|---|
|  | 1852 | else token = gratt.substr(p); | 
|---|
|  | 1853 | if (token == "") continue; | 
|---|
|  | 1854 | // Decodage option fenetre d'affichage (win, next, ...) | 
|---|
|  | 1855 | if (token == "win")   rc =  Disp_Win; | 
|---|
|  | 1856 | else if (token == "same")  rc = Disp_Same; | 
|---|
|  | 1857 | else if (token == "inset")   rc = Disp_Inset; | 
|---|
| [3355] | 1858 | else if (token == "stack")   rc = Disp_Stack; | 
|---|
|  | 1859 | else if (token == "next")   rc = Disp_Next; | 
|---|
|  | 1860 | else if (token.substr(0,6)=="samew=") { | 
|---|
|  | 1861 | string snom=token.substr(6); | 
|---|
|  | 1862 | SelectLastWidget(snom); | 
|---|
|  | 1863 | rc = Disp_Same; | 
|---|
|  | 1864 | } | 
|---|
|  | 1865 | else if (token.substr(0,6)=="inset=") { | 
|---|
|  | 1866 | double fx1,fx2,fy1,fy2; | 
|---|
|  | 1867 | fx1=fy1=0.4; fx2=fy2=0.6; | 
|---|
|  | 1868 | sscanf(token.substr(6).c_str(),"%lg,%lg,%lg,%lg",&fx1,&fx2,&fy1,&fy2); | 
|---|
|  | 1869 | SetInsetLimits(fx1, fx2, fy1, fy2); | 
|---|
|  | 1870 | rc = Disp_Inset; | 
|---|
|  | 1871 | } | 
|---|
|  | 1872 | else if (token.substr(0,6)=="wname=") {   // specification de nom de widget | 
|---|
|  | 1873 | wname=token.substr(6); | 
|---|
|  | 1874 | } | 
|---|
| [1971] | 1875 | // Option a etre decode par les drawers, etc ... | 
|---|
|  | 1876 | else  opts.push_back(token); | 
|---|
|  | 1877 | } | 
|---|
|  | 1878 |  | 
|---|
|  | 1879 | //DBG  cerr << " DBG-Parse-B opts.size()=" << opts.size() << endl; | 
|---|
| [2383] | 1880 | if (rc == Disp_Same) nb_disp_same++; | 
|---|
|  | 1881 | else nb_disp_same = 0; | 
|---|
| [1971] | 1882 | return (rc); | 
|---|
|  | 1883 | } | 
|---|
|  | 1884 |  | 
|---|
|  | 1885 | //--------------------------------------------------------------------------- | 
|---|
|  | 1886 | //------------       Methodes privees (MBProcessx, ...)    ---------- | 
|---|
|  | 1887 |  | 
|---|
|  | 1888 | /* --Methode-- */ | 
|---|
| [165] | 1889 | void PIStdImgApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data) | 
|---|
|  | 1890 | { | 
|---|
|  | 1891 |  | 
|---|
|  | 1892 | switch(msg) | 
|---|
|  | 1893 | { | 
|---|
| [686] | 1894 | case 10150 : | 
|---|
|  | 1895 | showInfoWindow(this); | 
|---|
|  | 1896 | break; | 
|---|
|  | 1897 |  | 
|---|
|  | 1898 | case 10155 : | 
|---|
|  | 1899 | hideInfoWindow(this); | 
|---|
|  | 1900 | break; | 
|---|
|  | 1901 |  | 
|---|
| [293] | 1902 | case 10100 : | 
|---|
| [2489] | 1903 | CmdInterpreter()->ShowHelpWindow(); | 
|---|
| [293] | 1904 | break; | 
|---|
|  | 1905 |  | 
|---|
| [165] | 1906 | case 10120 : | 
|---|
| [685] | 1907 | pfc_fits->AcceptNewFile(false); | 
|---|
| [165] | 1908 | mFCMsg = 10125; | 
|---|
| [685] | 1909 | pfc_fits->SetMsg(mFCMsg); | 
|---|
| [165] | 1910 | SetBlocked(); | 
|---|
| [685] | 1911 | pfc_fits->Show(); | 
|---|
| [165] | 1912 | break; | 
|---|
|  | 1913 |  | 
|---|
|  | 1914 | case 10125 : | 
|---|
|  | 1915 | SetBusy(); | 
|---|
|  | 1916 | if (data)  { | 
|---|
| [2904] | 1917 | string cmd = "readfits "; | 
|---|
|  | 1918 | cmd += pfc_fits->GetFileName(); | 
|---|
|  | 1919 | try { | 
|---|
|  | 1920 | CmdInterpreter()->AddInputLine(cmd); | 
|---|
|  | 1921 | // CmdInterpreter()->ExecuteCommand(kw, args, toks); | 
|---|
|  | 1922 | } | 
|---|
|  | 1923 | catch ( PThrowable & exc ) { | 
|---|
|  | 1924 | cerr << "\n PIStdImgApp::Process()/ Cmd->ExecuteCommand(readfits) Exception :" | 
|---|
|  | 1925 | << (string)typeid(exc).name() << " Msg= " | 
|---|
|  | 1926 | << exc.Msg() << endl; | 
|---|
|  | 1927 | cout << endl; | 
|---|
|  | 1928 | } | 
|---|
|  | 1929 | catch ( ... ) { | 
|---|
|  | 1930 | cerr << "\n PIStdImgApp::Process()/ Cmd->ExecuteCommand(readfits) Catched Exception ... " << endl; | 
|---|
|  | 1931 | cout << endl; | 
|---|
|  | 1932 | } | 
|---|
| [165] | 1933 | } | 
|---|
|  | 1934 | mFCMsg = 0; | 
|---|
|  | 1935 | SetReady(); | 
|---|
|  | 1936 | break; | 
|---|
|  | 1937 |  | 
|---|
|  | 1938 | case 10130 : | 
|---|
| [685] | 1939 | pfc_ppf->AcceptNewFile(false); | 
|---|
| [165] | 1940 | mFCMsg = 10135; | 
|---|
| [685] | 1941 | pfc_ppf->SetMsg(mFCMsg); | 
|---|
| [165] | 1942 | SetBlocked(); | 
|---|
| [685] | 1943 | pfc_ppf->Show(); | 
|---|
| [165] | 1944 | break; | 
|---|
|  | 1945 |  | 
|---|
|  | 1946 | case 10135 : | 
|---|
|  | 1947 | mFCMsg = 0; | 
|---|
|  | 1948 | if (data)  { | 
|---|
| [685] | 1949 | PPInMgrW()->SetFile(pfc_ppf->GetFileName()); | 
|---|
| [165] | 1950 | PPInMgrW()->Show(); | 
|---|
|  | 1951 | } | 
|---|
|  | 1952 | SetReady(); | 
|---|
|  | 1953 | break; | 
|---|
|  | 1954 |  | 
|---|
| [2263] | 1955 | #ifndef SANS_EVOLPLANCK | 
|---|
|  | 1956 | case 10140 : | 
|---|
|  | 1957 | pfc_ascii->AcceptNewFile(false); | 
|---|
|  | 1958 | mFCMsg = 10145; | 
|---|
|  | 1959 | pfc_ascii->SetMsg(mFCMsg); | 
|---|
|  | 1960 | SetBlocked(); | 
|---|
|  | 1961 | pfc_ascii->Show(); | 
|---|
|  | 1962 | break; | 
|---|
|  | 1963 |  | 
|---|
|  | 1964 | case 10145 : | 
|---|
|  | 1965 | SetBusy(); | 
|---|
|  | 1966 | if (data)  { | 
|---|
|  | 1967 | string afname = pfc_ascii->GetFileName(); | 
|---|
|  | 1968 | string nomobj = ObjMgr()->GetServiceObj()->FileName2Name(afname); | 
|---|
|  | 1969 | string cmd = "mtxfrascii "; | 
|---|
|  | 1970 | cmd += nomobj;  cmd += " ";  cmd += afname; | 
|---|
|  | 1971 | try { | 
|---|
| [2489] | 1972 | CmdInterpreter()->AddInputLine(cmd); | 
|---|
|  | 1973 | //      mCmd->Interpret(cmd); | 
|---|
| [2263] | 1974 | } | 
|---|
|  | 1975 | catch ( PThrowable & exc ) { | 
|---|
|  | 1976 | cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Exception :" | 
|---|
|  | 1977 | << (string)typeid(exc).name() << " Msg= " | 
|---|
|  | 1978 | << exc.Msg() << endl; | 
|---|
|  | 1979 | cout << endl; | 
|---|
|  | 1980 | } | 
|---|
|  | 1981 | catch ( ... ) { | 
|---|
|  | 1982 | cerr << "\n PIStdImgApp::Process()/ Cmd->Interpret() Catched Exception ... " << endl; | 
|---|
|  | 1983 | cout << endl; | 
|---|
|  | 1984 | } | 
|---|
|  | 1985 |  | 
|---|
|  | 1986 | } | 
|---|
|  | 1987 | mFCMsg = 0; | 
|---|
|  | 1988 | SetReady(); | 
|---|
|  | 1989 | break; | 
|---|
|  | 1990 | #endif | 
|---|
|  | 1991 |  | 
|---|
| [165] | 1992 | case 10105: | 
|---|
|  | 1993 | Stop(); | 
|---|
|  | 1994 | break; | 
|---|
|  | 1995 |  | 
|---|
|  | 1996 | } | 
|---|
|  | 1997 | return; | 
|---|
|  | 1998 | } | 
|---|
|  | 1999 |  | 
|---|
|  | 2000 |  | 
|---|
|  | 2001 |  | 
|---|
|  | 2002 | /* --Methode-- */ | 
|---|
|  | 2003 | void PIStdImgApp::MBProcess2(PIMessage msg, PIMsgHandler* /*sender*/, void* data) | 
|---|
|  | 2004 | { | 
|---|
|  | 2005 |  | 
|---|
|  | 2006 | switch (msg)  { | 
|---|
|  | 2007 | case 10201 : | 
|---|
|  | 2008 | ObjMgrW()->Show(); | 
|---|
|  | 2009 | break; | 
|---|
|  | 2010 |  | 
|---|
|  | 2011 | case 10220 : | 
|---|
| [685] | 2012 | pfc_ppf->AcceptNewFile(true); | 
|---|
| [165] | 2013 | mFCMsg = 10225; | 
|---|
| [685] | 2014 | pfc_ppf->SetMsg(mFCMsg); | 
|---|
| [165] | 2015 | SetBlocked(); | 
|---|
| [685] | 2016 | pfc_ppf->Show(); | 
|---|
| [165] | 2017 | break; | 
|---|
|  | 2018 |  | 
|---|
|  | 2019 | case 10225 : | 
|---|
|  | 2020 | SetBusy(); | 
|---|
|  | 2021 | if (data) { | 
|---|
|  | 2022 | if (mPpfout) { | 
|---|
|  | 2023 | printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str()); | 
|---|
|  | 2024 | delete mPpfout; | 
|---|
|  | 2025 | } | 
|---|
| [685] | 2026 | name_outppf = pfc_ppf->GetFileName(); | 
|---|
| [165] | 2027 | mPpfout = NULL; | 
|---|
|  | 2028 | printf("PIStdImg/Info: Opening POutPersist-File %s \n", name_outppf.c_str()); | 
|---|
|  | 2029 | mPpfout = new POutPersist(name_outppf); | 
|---|
|  | 2030 | } | 
|---|
|  | 2031 | mFCMsg = 0; | 
|---|
|  | 2032 | SetReady(); | 
|---|
|  | 2033 | break; | 
|---|
|  | 2034 |  | 
|---|
|  | 2035 | case 10230 : | 
|---|
|  | 2036 | if (!mPpfout)  break; | 
|---|
|  | 2037 | printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str()); | 
|---|
|  | 2038 | delete mPpfout; | 
|---|
|  | 2039 | name_outppf = ""; | 
|---|
|  | 2040 | mPpfout = NULL; | 
|---|
|  | 2041 | break; | 
|---|
|  | 2042 |  | 
|---|
| [686] | 2043 | case 10270 : | 
|---|
|  | 2044 | if (mCurWdg) { | 
|---|
| [3366] | 2045 | string ssob = "DEL "; | 
|---|
|  | 2046 | ssob += mCurWdg->Nom(); | 
|---|
|  | 2047 | getSOpExObj()->AddOpe(ssob); | 
|---|
| [686] | 2048 | } | 
|---|
|  | 2049 | break; | 
|---|
| [165] | 2050 |  | 
|---|
|  | 2051 | default: | 
|---|
|  | 2052 | cerr << "PIStdImgApp::MBProcess2() BUG?? Msg= " <<  msg << endl; | 
|---|
|  | 2053 | break; | 
|---|
|  | 2054 | } | 
|---|
|  | 2055 |  | 
|---|
|  | 2056 | return; | 
|---|
|  | 2057 | } | 
|---|
|  | 2058 |  | 
|---|
|  | 2059 | /* --Methode-- */ | 
|---|
|  | 2060 | void PIStdImgApp::MBProcess3(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/) | 
|---|
|  | 2061 | { | 
|---|
|  | 2062 |  | 
|---|
|  | 2063 | switch (msg)  { | 
|---|
|  | 2064 | case 10301 : | 
|---|
|  | 2065 | PIImgTools::ShowPIImgTools(); | 
|---|
|  | 2066 | break; | 
|---|
|  | 2067 | case 10302 : | 
|---|
|  | 2068 | PIDrwTools::ShowPIDrwTools(); | 
|---|
|  | 2069 | break; | 
|---|
| [1590] | 2070 | case 10303 : | 
|---|
|  | 2071 | PIAxesTools::ShowPIAxesTools(); | 
|---|
|  | 2072 | break; | 
|---|
| [165] | 2073 |  | 
|---|
| [1590] | 2074 | case 10304 : | 
|---|
| [2489] | 2075 | CmdInterpreter()->ShowCxxExecWindow(); | 
|---|
| [1251] | 2076 | break; | 
|---|
|  | 2077 |  | 
|---|
| [1590] | 2078 | case 10311 : | 
|---|
|  | 2079 | case 10312 : | 
|---|
| [165] | 2080 | { | 
|---|
|  | 2081 | PIImage* curpimg = NULL; | 
|---|
|  | 2082 | if (!mCurWdg)  return; | 
|---|
|  | 2083 | if (mCurWdg->kind() != PIImage::ClassId)  return; | 
|---|
|  | 2084 | curpimg = (PIImage*)mCurWdg; | 
|---|
|  | 2085 | if (curpimg == NULL)   return; | 
|---|
|  | 2086 | P2DArrayAdapter* img = curpimg->Image(); | 
|---|
|  | 2087 | if (img == NULL) return; | 
|---|
|  | 2088 | int dx = curpimg->XSzPave(); | 
|---|
|  | 2089 | int dy = curpimg->YSzPave(); | 
|---|
|  | 2090 | int x0 = curpimg->XPave()-dx/2; | 
|---|
|  | 2091 | int y0 = curpimg->YPave()-dy/2; | 
|---|
|  | 2092 | if (x0 < 0)  x0 = 0; | 
|---|
|  | 2093 | if (y0 < 0)  y0 = 0; | 
|---|
|  | 2094 | int x1 = x0+dx; | 
|---|
|  | 2095 | int y1 = y0+dy; | 
|---|
|  | 2096 | if (x1 > img->XSize()) x1 = img->XSize(); | 
|---|
|  | 2097 | if (y1 > img->YSize()) y1 = img->YSize(); | 
|---|
|  | 2098 | dx = x1-x0;  dy = y1-y0; | 
|---|
|  | 2099 | ImageR4* pim = new ImageR4(dx, dy); | 
|---|
|  | 2100 | int ii, jj; | 
|---|
|  | 2101 | for(jj=0; jj<dy; jj++) | 
|---|
|  | 2102 | for(ii=0; ii<dx; ii++) (*pim)(ii,jj) = (*img)(ii+x0, jj+y0); | 
|---|
| [338] | 2103 | if (msg == 10305) {  // Calcul des coordonnees du sous-pave | 
|---|
|  | 2104 | double xc1, yc1; | 
|---|
|  | 2105 | img->Coord(x0, y0, xc1, yc1); | 
|---|
|  | 2106 | pim->SetOrg((int)xc1, (int)yc1); | 
|---|
|  | 2107 | } | 
|---|
| [165] | 2108 | string nom = mCurWdg->Nom() + "_pave"; | 
|---|
|  | 2109 | ObjMgr()->AddObj(pim, nom); | 
|---|
|  | 2110 | ObjMgr()->DisplayObj(nom, "w"); | 
|---|
| [293] | 2111 | break; | 
|---|
| [165] | 2112 | } | 
|---|
|  | 2113 |  | 
|---|
| [1590] | 2114 | case 10313 : | 
|---|
| [293] | 2115 | { | 
|---|
|  | 2116 | PIImage* curpimg = NULL; | 
|---|
|  | 2117 | if (!mCurWdg)  return; | 
|---|
|  | 2118 | if (mCurWdg->kind() != PIImage::ClassId)  return; | 
|---|
|  | 2119 | curpimg = (PIImage*)mCurWdg; | 
|---|
|  | 2120 | if (curpimg == NULL)   return; | 
|---|
|  | 2121 | curpimg->ShowCuts(true); | 
|---|
|  | 2122 | break; | 
|---|
|  | 2123 | } | 
|---|
|  | 2124 |  | 
|---|
| [165] | 2125 | case 10320 : | 
|---|
|  | 2126 | if (mStW)  mStW->DispNext(); | 
|---|
|  | 2127 | break; | 
|---|
|  | 2128 |  | 
|---|
|  | 2129 | case 10321 : | 
|---|
|  | 2130 | case 10322 : | 
|---|
|  | 2131 | case 10324 : | 
|---|
|  | 2132 | //  case 10328 : | 
|---|
| [191] | 2133 | if (mStW) mStW->StartAutoDisp((msg-10320)*500); | 
|---|
| [165] | 2134 | break; | 
|---|
|  | 2135 |  | 
|---|
|  | 2136 | case 10329 : | 
|---|
|  | 2137 | if (mStW) mStW->StopAutoDisp(); | 
|---|
|  | 2138 | break; | 
|---|
|  | 2139 |  | 
|---|
|  | 2140 | case 103330 : | 
|---|
|  | 2141 | if (mStW) { | 
|---|
|  | 2142 | PIWdg* cw =  mStW->CurrentWdg(); | 
|---|
| [2651] | 2143 | if (cw) DeleteWidget(cw); | 
|---|
| [165] | 2144 | } | 
|---|
|  | 2145 | break; | 
|---|
|  | 2146 |  | 
|---|
|  | 2147 | default: | 
|---|
|  | 2148 | cerr << "PIStdImgApp::MBProcess3() BUG?? Msg= " <<  msg << endl; | 
|---|
|  | 2149 | break; | 
|---|
|  | 2150 | } | 
|---|
|  | 2151 | return; | 
|---|
|  | 2152 | } | 
|---|
|  | 2153 |  | 
|---|
|  | 2154 | /* --Methode-- */ | 
|---|
|  | 2155 | void PIStdImgApp::MBProcess4(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/) | 
|---|
|  | 2156 | { | 
|---|
|  | 2157 |  | 
|---|
|  | 2158 | switch (msg)  { | 
|---|
|  | 2159 |  | 
|---|
|  | 2160 | case 10400 : | 
|---|
|  | 2161 | CreateStackWin(); | 
|---|
|  | 2162 | break; | 
|---|
|  | 2163 |  | 
|---|
|  | 2164 | case 10411 : | 
|---|
|  | 2165 | CreateGraphWin(1,1); | 
|---|
|  | 2166 | break; | 
|---|
|  | 2167 | case 10421 : | 
|---|
|  | 2168 | CreateGraphWin(1,2); | 
|---|
|  | 2169 | break; | 
|---|
|  | 2170 | case 10412 : | 
|---|
|  | 2171 | CreateGraphWin(2,1); | 
|---|
|  | 2172 | break; | 
|---|
|  | 2173 | case 10422 : | 
|---|
|  | 2174 | CreateGraphWin(2,2); | 
|---|
|  | 2175 | break; | 
|---|
|  | 2176 | case 10431 : | 
|---|
|  | 2177 | CreateGraphWin(1,3); | 
|---|
|  | 2178 | break; | 
|---|
|  | 2179 | case 10433 : | 
|---|
|  | 2180 | CreateGraphWin(3,3); | 
|---|
|  | 2181 | break; | 
|---|
| [558] | 2182 | case 10441 : | 
|---|
|  | 2183 | if (mCurWdg)  { | 
|---|
|  | 2184 | mLastWdg = mCurWdg; | 
|---|
|  | 2185 | cout << " Using current widget as last-widget (display same) " << endl; | 
|---|
|  | 2186 | } | 
|---|
|  | 2187 | else  cout << " No current widget - select widget with mouse " << endl; | 
|---|
|  | 2188 | break; | 
|---|
| [686] | 2189 | case 10460 : | 
|---|
|  | 2190 | DeleteWindow(mCurWin); | 
|---|
|  | 2191 | break; | 
|---|
| [1971] | 2192 | case 10470 : | 
|---|
|  | 2193 | StatZoomWindowSetVisible(m[3]->GetStateMsg(10470)); | 
|---|
|  | 2194 | break; | 
|---|
| [165] | 2195 | default: | 
|---|
|  | 2196 | cerr << "PIStdImgApp::MBProcess4() BUG?? Msg= " <<  msg << endl; | 
|---|
|  | 2197 | break; | 
|---|
|  | 2198 | } | 
|---|
|  | 2199 | return; | 
|---|
|  | 2200 | } | 
|---|
|  | 2201 |  | 
|---|
|  | 2202 |  | 
|---|
|  | 2203 | /* --Methode-- */ | 
|---|
|  | 2204 | void PIStdImgApp::MBProcess5(PIMessage msg, PIMsgHandler* /*sender*/, void* data) | 
|---|
|  | 2205 | { | 
|---|
|  | 2206 | char nomps[64],strg[512]; | 
|---|
|  | 2207 | PSFile *mps; | 
|---|
|  | 2208 | int sxt, syt, syo, syo1, sx[4], sy[4]; | 
|---|
|  | 2209 |  | 
|---|
|  | 2210 | switch (msg) | 
|---|
|  | 2211 | { | 
|---|
|  | 2212 | case 10501 : | 
|---|
| [685] | 2213 | pfc_ps->AcceptNewFile(true); | 
|---|
| [165] | 2214 | mFCMsg = 10525; | 
|---|
| [685] | 2215 | pfc_ps->SetMsg(mFCMsg); | 
|---|
| [165] | 2216 | SetBlocked(); | 
|---|
| [685] | 2217 | pfc_ps->Show(); | 
|---|
| [165] | 2218 | break; | 
|---|
|  | 2219 |  | 
|---|
|  | 2220 | case 10525 : | 
|---|
|  | 2221 | SetBusy(); | 
|---|
|  | 2222 | if (data) { | 
|---|
|  | 2223 | if (mpsfile) { | 
|---|
|  | 2224 | printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str()); | 
|---|
|  | 2225 | delete mpsfile; | 
|---|
|  | 2226 | } | 
|---|
| [685] | 2227 | name_ps = pfc_ps->GetFileName(); | 
|---|
| [165] | 2228 | printf("PIStdImg/Info: Opening PS-File %s \n", name_ps.c_str()); | 
|---|
|  | 2229 | mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 2., 2.); | 
|---|
|  | 2230 | } | 
|---|
|  | 2231 | mFCMsg = 0; | 
|---|
|  | 2232 | SetReady(); | 
|---|
|  | 2233 | break; | 
|---|
|  | 2234 |  | 
|---|
|  | 2235 | case 10505 : | 
|---|
|  | 2236 | if (!mpsfile)  break; | 
|---|
|  | 2237 | printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str()); | 
|---|
|  | 2238 | delete mpsfile; | 
|---|
|  | 2239 | mpsfile = NULL; | 
|---|
|  | 2240 | name_ps = ""; | 
|---|
|  | 2241 | break; | 
|---|
|  | 2242 |  | 
|---|
|  | 2243 | case 10511 :     // Window -> PS | 
|---|
|  | 2244 | case 10512 :     // Window -> EPS | 
|---|
|  | 2245 | if (CurrentWindow() == NULL)  break; | 
|---|
|  | 2246 | if (msg == 10512) | 
|---|
|  | 2247 | { | 
|---|
|  | 2248 | num_eps++; | 
|---|
|  | 2249 | sprintf(nomps,"pia%d.eps", num_eps); | 
|---|
|  | 2250 | printf("PIStdImg/Info: Creating EPSFile %s (CurWin-> EPS) \n", nomps); | 
|---|
|  | 2251 | mps = new PSFile(nomps); | 
|---|
|  | 2252 | } | 
|---|
|  | 2253 | else { | 
|---|
|  | 2254 | if (mpsfile == NULL) { | 
|---|
|  | 2255 | name_ps = "pia.ps"; | 
|---|
|  | 2256 | mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 0., 0.); | 
|---|
|  | 2257 | printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str()); | 
|---|
|  | 2258 | } | 
|---|
|  | 2259 | printf("PIStdImg/Info: CurWin-> PSFile %s\n", name_ps.c_str()); | 
|---|
|  | 2260 | mps = mpsfile; | 
|---|
|  | 2261 | } | 
|---|
|  | 2262 | CurrentWindow()->PSPrint(mps,0,0); | 
|---|
|  | 2263 |  | 
|---|
|  | 2264 | if (msg == 10512)   delete mps;   // fichier eps | 
|---|
|  | 2265 | break; | 
|---|
|  | 2266 |  | 
|---|
|  | 2267 | case 10515 :    // Image -> PS | 
|---|
|  | 2268 | case 10516 :    // Image -> EPS | 
|---|
|  | 2269 | { | 
|---|
|  | 2270 | PIImage* curpimg = NULL; | 
|---|
|  | 2271 | if (!mCurWdg)  return; | 
|---|
|  | 2272 | if (mCurWdg->kind() != PIImage::ClassId)  return; | 
|---|
|  | 2273 | curpimg = (PIImage*)mCurWdg; | 
|---|
|  | 2274 | if (curpimg == NULL)   return; | 
|---|
|  | 2275 | if (msg == 10516) | 
|---|
|  | 2276 | { | 
|---|
|  | 2277 | num_eps++; | 
|---|
|  | 2278 | sprintf(nomps,"pia%d.eps", num_eps); | 
|---|
|  | 2279 | printf("PIStdImg/Info: Creating EPSFile %s (CurImage-> EPS)\n", nomps); | 
|---|
|  | 2280 | mps = new PSFile(nomps); | 
|---|
|  | 2281 | } | 
|---|
|  | 2282 | else { | 
|---|
|  | 2283 | if (mpsfile == NULL) { | 
|---|
|  | 2284 | name_ps = "pia.ps"; | 
|---|
|  | 2285 | mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.); | 
|---|
|  | 2286 | printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str()); | 
|---|
|  | 2287 | } | 
|---|
|  | 2288 | printf("PIStdImg/Info: CurImage-> PSFile %s\n", name_ps.c_str()); | 
|---|
|  | 2289 | mps = mpsfile; | 
|---|
|  | 2290 | } | 
|---|
|  | 2291 |  | 
|---|
|  | 2292 | sx[0] = gimv->XSize(); | 
|---|
|  | 2293 | sy[0] = gimv->YSize(); | 
|---|
|  | 2294 | sx[1] = zoom->XSize(); | 
|---|
|  | 2295 | sy[1] = zoom->YSize(); | 
|---|
|  | 2296 | sx[2] = cmapv->XSize(); | 
|---|
|  | 2297 | sy[2] = cmapv->YSize(); | 
|---|
|  | 2298 | sx[3] = curpimg->XSize(); | 
|---|
|  | 2299 | sy[3] = curpimg->YSize(); | 
|---|
|  | 2300 | if (sy[1] > sy[0])  { syo1 = sy[1]+50;  syo = sy[1]+sy[2]+60; } | 
|---|
|  | 2301 | else  { syo1 = sy[0]+50;  syo = sy[0]+sy[2]+60; } | 
|---|
|  | 2302 | syt = sy[3]+syo; | 
|---|
|  | 2303 | sxt = sx[3]; | 
|---|
|  | 2304 | if (sxt < (sx[0]+sx[1]+20))  sxt = sx[0]+sx[1]+20; | 
|---|
|  | 2305 | if (sxt < sx[2])  sxt = sx[2]; | 
|---|
|  | 2306 |  | 
|---|
|  | 2307 | // Pour ecrire le titre | 
|---|
|  | 2308 | mps->NewPage((float)sxt, (float)syt, PI_Portrait); | 
|---|
|  | 2309 | mps->NewBloc(0,0, (float)sxt, 30., (float)sxt, 30.); | 
|---|
|  | 2310 | sprintf(strg,"Image: %s -  Pave %d %d \n",  curpimg->Nom().c_str(), | 
|---|
|  | 2311 | curpimg->XPave(),  curpimg->YPave()); | 
|---|
| [384] | 2312 | mps->DrawString(10., 25., strg, PI_Black, PI_DefaultFont, PI_BoldFont, 20); | 
|---|
| [165] | 2313 | mps->EndBloc(); | 
|---|
|  | 2314 |  | 
|---|
|  | 2315 | // Les quatre fenetres glovimage, zoom, cmap, image | 
|---|
|  | 2316 | gimv->PSPrint(mps, -gimv->XPos(), -gimv->YPos()+40); | 
|---|
|  | 2317 | zoom->PSPrint(mps, -zoom->XPos()+sx[0]+20, -zoom->YPos()+40); | 
|---|
|  | 2318 | cmapv->PSPrint(mps, -cmapv->XPos(), -cmapv->YPos()+syo1); | 
|---|
|  | 2319 | curpimg->PSPrint(mps, -curpimg->XPos(), -curpimg->YPos()+syo); | 
|---|
|  | 2320 |  | 
|---|
|  | 2321 | if (msg == 10516)   delete mps;    // fichier eps | 
|---|
|  | 2322 | break; | 
|---|
|  | 2323 | } | 
|---|
|  | 2324 |  | 
|---|
|  | 2325 | default: | 
|---|
|  | 2326 | cerr << "PIStdImgApp::MBProcess5() BUG?? Msg= " <<  msg << endl; | 
|---|
|  | 2327 | break; | 
|---|
|  | 2328 | } | 
|---|
|  | 2329 |  | 
|---|
|  | 2330 | } | 
|---|
|  | 2331 |  | 
|---|
|  | 2332 |  | 
|---|
|  | 2333 | /* --Methode-- */ | 
|---|
|  | 2334 | void PIStdImgApp::MBProcess6(PIMessage msg, PIMsgHandler* /*sender*/, void* data) | 
|---|
|  | 2335 | { | 
|---|
|  | 2336 | switch (msg)  { | 
|---|
|  | 2337 | case 10601: | 
|---|
|  | 2338 | CloseAllWindows(); | 
|---|
|  | 2339 | break; | 
|---|
| [3370] | 2340 | /* | 
|---|
|  | 2341 | case 10602: | 
|---|
| [165] | 2342 | RedirectStdOutErr(*((bool*)data)); | 
|---|
|  | 2343 | break; | 
|---|
| [3370] | 2344 | */ | 
|---|
| [165] | 2345 | case 10603: | 
|---|
| [374] | 2346 | case 10604: | 
|---|
|  | 2347 | CatchSignals(m[5]->GetStateMsg(10603), m[5]->GetStateMsg(10604)); | 
|---|
| [165] | 2348 | break; | 
|---|
| [449] | 2349 | case 10605: | 
|---|
|  | 2350 | mObjMgr->SetVerbose(m[5]->GetStateMsg(10605)); | 
|---|
|  | 2351 | break; | 
|---|
| [1251] | 2352 | case 10606: | 
|---|
| [2489] | 2353 | CmdInterpreter()->ShowCxxOptionWindow(); | 
|---|
| [1251] | 2354 | break; | 
|---|
| [165] | 2355 | default: | 
|---|
|  | 2356 | cerr << "PIStdImgApp::MBProcess6() BUG?? Msg= " <<  msg << endl; | 
|---|
|  | 2357 | break; | 
|---|
|  | 2358 | } | 
|---|
|  | 2359 | return; | 
|---|
|  | 2360 | } | 
|---|
|  | 2361 |  | 
|---|
|  | 2362 |  | 
|---|
| [1569] | 2363 |  | 
|---|
| [686] | 2364 | //  ------------------------------------------------- | 
|---|
|  | 2365 | //        Fenetre info piapp (About piapp) | 
|---|
|  | 2366 | //  ------------------------------------------------- | 
|---|
|  | 2367 | static PIWindow* infow_win = NULL; | 
|---|
|  | 2368 | static PIText* infow_txt = NULL; | 
|---|
|  | 2369 | static PICMapView* infow_cmap = NULL; | 
|---|
|  | 2370 | static PIButton* infow_but = NULL; | 
|---|
|  | 2371 |  | 
|---|
|  | 2372 | /* Nouvelle-Fonction */ | 
|---|
|  | 2373 | static void createInfoWindow(PIStdImgApp* app) | 
|---|
|  | 2374 | { | 
|---|
|  | 2375 | if (infow_win) return; | 
|---|
|  | 2376 |  | 
|---|
|  | 2377 | int bsx, bsy; | 
|---|
|  | 2378 | PIApplicationPrefCompSize(bsx, bsy); | 
|---|
|  | 2379 | int spx, spy; | 
|---|
|  | 2380 | spx = bsx/6;   spy = bsy/6; | 
|---|
|  | 2381 |  | 
|---|
|  | 2382 | infow_win = new PIWindow((PIMsgHandler *)app, "About piapp", | 
|---|
|  | 2383 | PIWK_dialog, bsx*5+3*spx, bsy*4+spy*3, 200, 200); | 
|---|
|  | 2384 | infow_win->SetAutoDelChilds(true); | 
|---|
| [3024] | 2385 | infow_txt = new PIText(infow_win,"about_piapp_text", true, false, bsx*5+spx, bsy*3, spx, spy); | 
|---|
| [686] | 2386 | infow_txt->SetMutiLineMode(true); | 
|---|
|  | 2387 | infow_txt->SetTextEditable(false); | 
|---|
|  | 2388 | infow_txt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
|  | 2389 | infow_cmap = new PICMapView(infow_win, "about_piapp_cmap", bsx*4, bsy*0.7, spx, 2*spy+bsy*3.15); | 
|---|
|  | 2390 | infow_cmap->SetColMapId(CMAP_COLBR32, 1., -1., false); | 
|---|
|  | 2391 | infow_cmap->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
|  | 2392 | infow_but = new PIButton(infow_win,"OK", 10155, bsx, bsy, bsx*4+2*spx, 2*spy+bsy*3); | 
|---|
|  | 2393 | infow_but->SetMsgParent((PIMsgHandler *)app); | 
|---|
|  | 2394 | infow_but->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| [3024] | 2395 |  | 
|---|
|  | 2396 | string info = "piapp : Interactive analysis program\n"; | 
|---|
| [686] | 2397 | char buff[128]; | 
|---|
|  | 2398 | #ifdef SANS_EVOLPLANCK | 
|---|
|  | 2399 | sprintf(buff, "Version: piapp=%g  PI=%g  PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER, | 
|---|
|  | 2400 | (double)PI_VERSIONNUMBER, (float)PeidaVersion()); | 
|---|
| [3024] | 2401 | info += buff; | 
|---|
| [686] | 2402 | #else | 
|---|
| [3024] | 2403 | string svers; | 
|---|
|  | 2404 | SophyaInitiator::GetVersion(svers); | 
|---|
|  | 2405 | info += svers; | 
|---|
|  | 2406 | sprintf(buff, "\n Version: PI=%g  --  PIext/piapp= %g \n", (double)PI_VERSIONNUMBER, | 
|---|
|  | 2407 | (double)PIAPP_VERSIONNUMBER); | 
|---|
|  | 2408 | info += buff; | 
|---|
| [686] | 2409 | #endif | 
|---|
| [3024] | 2410 | info += "(C) LAL-IN2P3/CNRS  1996-2006\n"; | 
|---|
|  | 2411 | info += "(C) SPP-DAPNIA/CEA 1996-2006\n"; | 
|---|
| [2427] | 2412 | #ifndef SANS_EVOLPLANCK | 
|---|
|  | 2413 | info += "Check http://www.sophya.org for more information"; | 
|---|
|  | 2414 | #endif | 
|---|
| [686] | 2415 | infow_txt->SetText(info); | 
|---|
|  | 2416 | } | 
|---|
|  | 2417 |  | 
|---|
|  | 2418 | /* Nouvelle-Fonction */ | 
|---|
|  | 2419 | static void showInfoWindow(PIStdImgApp* app) | 
|---|
|  | 2420 | { | 
|---|
| [692] | 2421 | if (!infow_win) createInfoWindow(app); | 
|---|
|  | 2422 | if (infow_win) infow_win->Show(); | 
|---|
| [686] | 2423 | } | 
|---|
|  | 2424 | /* Nouvelle-Fonction */ | 
|---|
|  | 2425 | static void hideInfoWindow(PIStdImgApp* app) | 
|---|
|  | 2426 | { | 
|---|
| [692] | 2427 | if (infow_win) infow_win->Hide(); | 
|---|
| [686] | 2428 | } | 
|---|
|  | 2429 |  | 
|---|
|  | 2430 | /* Nouvelle-Fonction */ | 
|---|
|  | 2431 | static void deleteInfoWindow() | 
|---|
|  | 2432 | { | 
|---|
|  | 2433 | if (!infow_win) return; | 
|---|
|  | 2434 | delete infow_win; | 
|---|
|  | 2435 | infow_win = NULL; | 
|---|
|  | 2436 | infow_txt = NULL; | 
|---|
|  | 2437 | infow_cmap = NULL; | 
|---|
|  | 2438 | infow_but = NULL; | 
|---|
|  | 2439 | } | 
|---|
|  | 2440 |  | 
|---|
| [2106] | 2441 |  | 
|---|