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