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