| [2615] | 1 | #include "sopnamsp.h" | 
|---|
| [293] | 2 | #include "piacmd.h" | 
|---|
| [165] | 3 | #include <stdio.h> | 
|---|
|  | 4 | #include <stdlib.h> | 
|---|
| [349] | 5 | #include <ctype.h> | 
|---|
| [165] | 6 | #include <math.h> | 
|---|
|  | 7 |  | 
|---|
|  | 8 |  | 
|---|
| [293] | 9 | #include "pdlmgr.h" | 
|---|
| [165] | 10 | #include "ctimer.h" | 
|---|
| [2214] | 11 | #include "strutil.h" | 
|---|
| [2215] | 12 | #include "strutilxx.h" | 
|---|
| [293] | 13 | // #include "dlftypes.h" | 
|---|
| [2307] | 14 | #ifdef SANS_EVOLPLANCK | 
|---|
| [2308] | 15 | #include "nbrandom.h" | 
|---|
| [2307] | 16 | #else | 
|---|
|  | 17 | #include "srandgen.h" | 
|---|
|  | 18 | #endif | 
|---|
| [165] | 19 |  | 
|---|
| [293] | 20 | #include "pistdimgapp.h" | 
|---|
| [165] | 21 | #include "nobjmgr.h" | 
|---|
| [2781] | 22 |  | 
|---|
|  | 23 | // Les differentes classes CommandExecutor | 
|---|
|  | 24 | #include "basexecut.h" | 
|---|
|  | 25 | #include "graphexecut.h" | 
|---|
| [361] | 26 | #include "piafitting.h" | 
|---|
| [463] | 27 | #include "pawexecut.h" | 
|---|
| [1224] | 28 | #include "cxxexecutor.h" | 
|---|
| [1251] | 29 | #include "cxxexecwin.h" | 
|---|
| [1828] | 30 | #include "contmodex.h" | 
|---|
| [1920] | 31 | #include "flowmodex.h" | 
|---|
| [165] | 32 |  | 
|---|
| [293] | 33 | #include PISTDWDG_H | 
|---|
|  | 34 | #include PILIST_H | 
|---|
| [165] | 35 |  | 
|---|
| [293] | 36 | // ------------------------------------------------------------ | 
|---|
| [349] | 37 | //         Gestion d'une fenetre d'aide interactive | 
|---|
|  | 38 | //                    Classe   PIAHelpWind | 
|---|
| [293] | 39 | // ------------------------------------------------------------ | 
|---|
| [165] | 40 |  | 
|---|
| [2474] | 41 | #define HGRPMSGOFFSET  100000 | 
|---|
|  | 42 |  | 
|---|
| [293] | 43 | class PIAHelpWind : public PIWindow { | 
|---|
|  | 44 | public : | 
|---|
|  | 45 | PIAHelpWind(PIStdImgApp* par, PIACmd* piacmd); | 
|---|
|  | 46 | virtual       ~PIAHelpWind(); | 
|---|
| [330] | 47 | virtual void  Show(); | 
|---|
| [293] | 48 | virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL); | 
|---|
| [330] | 49 | inline  void  AddHelpGroup(const char * hgrp, int gid) | 
|---|
| [2474] | 50 | { hgrpom->AppendItem(hgrp, HGRPMSGOFFSET+gid); } | 
|---|
| [2465] | 51 | inline  void  AddHelpGroup(string const & hgrp, int gid) | 
|---|
| [2474] | 52 | { hgrpom->AppendItem(hgrp.c_str(), HGRPMSGOFFSET+gid); } | 
|---|
| [330] | 53 | inline  void  ClearHelpList() | 
|---|
|  | 54 | { mNitem=0; hitemlist->DeleteAllItems(); } | 
|---|
| [293] | 55 | inline  void  AddHelpItem(const char * hitem) | 
|---|
| [330] | 56 | { mNitem++;  hitemlist->AppendItem(hitem, 100+mNitem); } | 
|---|
| [2465] | 57 | inline  void  SetHelpTextLabel(string const & htxt, string const & hlab) | 
|---|
|  | 58 | { mTxt->SetText(htxt); mLab->SetLabel(hlab); } | 
|---|
|  | 59 |  | 
|---|
| [293] | 60 | protected : | 
|---|
|  | 61 | PIStdImgApp* dap; | 
|---|
|  | 62 | PIACmd* piac; | 
|---|
|  | 63 | int mNitem; | 
|---|
|  | 64 | PIList* hitemlist; | 
|---|
| [330] | 65 | PIOptMenu* hgrpom; | 
|---|
| [293] | 66 | PIButton * mBut; | 
|---|
|  | 67 | PILabel * mLab; | 
|---|
|  | 68 | PIText* mTxt; | 
|---|
|  | 69 | }; | 
|---|
| [165] | 70 |  | 
|---|
| [293] | 71 | /* --Methode-- */ | 
|---|
|  | 72 | PIAHelpWind::PIAHelpWind(PIStdImgApp *par, PIACmd* piacmd) | 
|---|
|  | 73 | : PIWindow((PIMsgHandler *)par, "Help-PIApp", PIWK_normal,  400, 300, 100, 350) | 
|---|
|  | 74 | { | 
|---|
|  | 75 | dap = par; | 
|---|
|  | 76 | piac = piacmd; | 
|---|
|  | 77 | mNitem = 0; | 
|---|
| [330] | 78 | SetMsg(77); | 
|---|
| [165] | 79 |  | 
|---|
| [293] | 80 | int bsx, bsy; | 
|---|
|  | 81 | int tsx, tsy; | 
|---|
|  | 82 | int spx, spy; | 
|---|
|  | 83 | PIApplicationPrefCompSize(bsx, bsy); | 
|---|
|  | 84 | spx = bsx/6;   spy = bsy/6; | 
|---|
|  | 85 | tsx = 10*bsx+2*spx;  tsy = 7*bsy+3*spy; | 
|---|
|  | 86 | SetSize(tsx,tsy); | 
|---|
| [330] | 87 | hgrpom = new PIOptMenu(this, "hgrpoptmen", bsx*2.0, bsy, spx/2, spy); | 
|---|
|  | 88 | hgrpom->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
|  | 89 | hitemlist = new PIList(this, "hitemlist", bsx*2.0, tsy-3*spy-bsy, spx/2, 2*spy+bsy); | 
|---|
| [293] | 90 | hitemlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
|  | 91 | // hitemlist->SetBorderWidth(2); | 
|---|
| [324] | 92 | mTxt = new PIText(this, "helptext", true, true, bsx*8.0, 6*bsy, bsx*2.0+1.5*spx, spy); | 
|---|
|  | 93 | // mTxt->SetMutiLineMode(true); | 
|---|
| [293] | 94 | mTxt->SetTextEditable(false); | 
|---|
|  | 95 | mTxt->SetText(""); | 
|---|
|  | 96 | mTxt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
|  | 97 | mLab = new PILabel(this, "helpitem", bsx*4, bsy, bsx*2.5+2*spx, tsy-spy-bsy); | 
|---|
|  | 98 | mLab->SetBorderWidth(1); | 
|---|
|  | 99 | mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
|  | 100 | mLab->SetLabel(""); | 
|---|
| [330] | 101 | mBut = new PIButton(this, "Close", 70, bsx, bsy, tsx-bsx*1.5-spx, tsy-spy-bsy); | 
|---|
| [293] | 102 | mBut->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
|  | 103 | } | 
|---|
| [165] | 104 |  | 
|---|
|  | 105 | /* --Methode-- */ | 
|---|
| [293] | 106 | PIAHelpWind::~PIAHelpWind() | 
|---|
|  | 107 | { | 
|---|
| [330] | 108 | delete hgrpom; | 
|---|
| [293] | 109 | delete hitemlist; | 
|---|
|  | 110 | delete mTxt; | 
|---|
|  | 111 | delete mLab; | 
|---|
|  | 112 | delete mBut; | 
|---|
|  | 113 | } | 
|---|
|  | 114 |  | 
|---|
|  | 115 | /* --Methode-- */ | 
|---|
|  | 116 | void PIAHelpWind::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/) | 
|---|
|  | 117 | { | 
|---|
|  | 118 | PIMessage um = UserMsg(msg); | 
|---|
| [330] | 119 | if (((um == 77) && (ModMsg(msg) == PIMsg_Close)) || (um == 70) ) { | 
|---|
| [293] | 120 | Hide(); | 
|---|
|  | 121 | return; | 
|---|
|  | 122 | } | 
|---|
| [2474] | 123 | else if ( (um >= HGRPMSGOFFSET) && (sender == hgrpom)) {  // Selection de groupe de Help | 
|---|
| [330] | 124 | mTxt->SetText(""); | 
|---|
|  | 125 | mLab->SetLabel(""); | 
|---|
| [2474] | 126 | piac->UpdateHelpList(this, um-HGRPMSGOFFSET); | 
|---|
| [330] | 127 | } | 
|---|
|  | 128 | else if ( (um > 100) && (sender == hitemlist) && (ModMsg(msg) == PIMsg_Select) ) { | 
|---|
| [293] | 129 | string s = hitemlist->GetSelectionStr(); | 
|---|
|  | 130 | mTxt->SetText(piac->GetUsage(s)); | 
|---|
|  | 131 | mLab->SetLabel(s); | 
|---|
|  | 132 | } | 
|---|
|  | 133 | } | 
|---|
|  | 134 |  | 
|---|
| [330] | 135 | /* --Methode-- */ | 
|---|
|  | 136 | void PIAHelpWind::Show() | 
|---|
|  | 137 | { | 
|---|
| [2474] | 138 | hgrpom->SetValue(HGRPMSGOFFSET);   // Groupe All | 
|---|
| [330] | 139 | mTxt->SetText(""); | 
|---|
|  | 140 | mLab->SetLabel(""); | 
|---|
|  | 141 | piac->UpdateHelpList(this, 0); | 
|---|
|  | 142 | PIWindow::Show(); | 
|---|
|  | 143 | } | 
|---|
| [293] | 144 |  | 
|---|
| [349] | 145 |  | 
|---|
|  | 146 | // ------------------------------------------------------------ | 
|---|
|  | 147 | //         Classe PIACmd | 
|---|
|  | 148 | // ------------------------------------------------------------ | 
|---|
|  | 149 |  | 
|---|
| [2463] | 150 | // static PIACmd* curpiacmd = NULL; | 
|---|
| [293] | 151 | /* --Methode-- */ | 
|---|
| [2490] | 152 | PIACmd::PIACmd(PIStdImgApp* app) | 
|---|
| [2463] | 153 | : Commander() | 
|---|
| [165] | 154 | { | 
|---|
| [2490] | 155 | mObjMgr = new NamedObjMgr; | 
|---|
| [165] | 156 | mImgApp = app; | 
|---|
| [293] | 157 | helpwin = new PIAHelpWind(app, this); | 
|---|
| [2465] | 158 | helpwin_initdone = false; | 
|---|
| [293] | 159 |  | 
|---|
| [2305] | 160 | string grp = "PIACmd"; | 
|---|
| [2465] | 161 | string gdesc = "piapp interpreter (class PIACmd) additional builtin commands"; | 
|---|
|  | 162 | AddHelpGroup(grp, gdesc); | 
|---|
|  | 163 |  | 
|---|
| [2672] | 164 | string kw = "exitpiapp"; | 
|---|
| [2463] | 165 | string usage = "To end the piapp session "; | 
|---|
| [2419] | 166 | RegisterCommand(kw, usage, NULL, grp); | 
|---|
| [2463] | 167 | kw = "helpwindow"; | 
|---|
|  | 168 | usage = "To display the Help window "; | 
|---|
| [2419] | 169 | RegisterCommand(kw, usage, NULL, grp); | 
|---|
| [2677] | 170 | kw = "stop"; | 
|---|
|  | 171 | usage = "To stop (break) interpreter (PIACmd/Commander) execution"; | 
|---|
| [2672] | 172 | RegisterCommand(kw, usage, NULL, grp); | 
|---|
| [2203] | 173 |  | 
|---|
| [2490] | 174 | basexec = new PIABaseExecutor(this, mObjMgr, app); | 
|---|
| [2781] | 175 | graphexec = new PIAGraphicExecutor(this, mObjMgr, app); | 
|---|
| [361] | 176 | fitexec = new PIAFitter(this, app); | 
|---|
| [463] | 177 | pawexec = new PAWExecutor(this, app); | 
|---|
| [1251] | 178 | CxxExecutor * cxxe = new CxxExecutor(this, app); | 
|---|
|  | 179 | cxxexec = cxxe; | 
|---|
| [1828] | 180 |  | 
|---|
|  | 181 | ContModExecutor *cntxx = new ContModExecutor(this, app);//_OP_ | 
|---|
|  | 182 | cntexec = cntxx; //_OP_ | 
|---|
| [1920] | 183 | FlowModExecutor *flwxx = new FlowModExecutor(this, app);//_OP_ | 
|---|
|  | 184 | flwexec = flwxx; //_OP_ | 
|---|
| [1828] | 185 |  | 
|---|
| [1251] | 186 | cxxoptwin = new  CxxOptionWind(app, cxxe); | 
|---|
|  | 187 | cxxexwin  = new  CxxExecWind(app, cxxe); | 
|---|
|  | 188 |  | 
|---|
| [2465] | 189 | InitializeHelpWindowMenu(); | 
|---|
| [2486] | 190 | // <ZThread>  Thread control attributes | 
|---|
|  | 191 | fg_thrstop = false; | 
|---|
|  | 192 | fg_threxe = false; | 
|---|
| [165] | 193 | } | 
|---|
|  | 194 |  | 
|---|
|  | 195 | /* --Methode-- */ | 
|---|
|  | 196 | PIACmd::~PIACmd() | 
|---|
|  | 197 | { | 
|---|
| [2490] | 198 | delete mObjMgr; | 
|---|
| [293] | 199 | delete helpwin; | 
|---|
| [1251] | 200 | delete cxxexwin; | 
|---|
|  | 201 | delete cxxoptwin; | 
|---|
| [361] | 202 | delete basexec; | 
|---|
| [2781] | 203 | delete graphexec; | 
|---|
| [361] | 204 | delete fitexec; | 
|---|
| [463] | 205 | delete pawexec; | 
|---|
| [1224] | 206 | delete cxxexec; | 
|---|
| [165] | 207 | } | 
|---|
|  | 208 |  | 
|---|
|  | 209 |  | 
|---|
| [293] | 210 | /* --Methode-- */ | 
|---|
| [2486] | 211 | void PIACmd::AddInputLine(string const & line) | 
|---|
|  | 212 | { | 
|---|
| [2677] | 213 | if (line == "stop")  { | 
|---|
| [2672] | 214 | StopExecution(); | 
|---|
|  | 215 | return; | 
|---|
|  | 216 | } | 
|---|
| [2486] | 217 | mutx_inps.lock(); | 
|---|
| [2536] | 218 | inputlines.push(line);   // Ajout d'un element en fin de queue | 
|---|
| [2486] | 219 | mutx_inps.unlock(); | 
|---|
|  | 220 | mutx_inps.broadcast(); | 
|---|
|  | 221 | } | 
|---|
|  | 222 |  | 
|---|
|  | 223 | /* --Methode-- */ | 
|---|
|  | 224 | void PIACmd::StopThread() | 
|---|
|  | 225 | { | 
|---|
|  | 226 | fg_thrstop = true; | 
|---|
|  | 227 | mutx_inps.broadcast(); | 
|---|
|  | 228 | } | 
|---|
|  | 229 |  | 
|---|
|  | 230 | /* --Methode-- */ | 
|---|
|  | 231 | void PIACmd::run() | 
|---|
|  | 232 | { | 
|---|
|  | 233 | while (!fg_thrstop) { | 
|---|
|  | 234 | mutx_inps.lock(); | 
|---|
|  | 235 | while (inputlines.empty()) { | 
|---|
|  | 236 | fg_threxe = false; | 
|---|
|  | 237 | mutx_inps.wait(); | 
|---|
|  | 238 | } | 
|---|
| [2536] | 239 | string line = inputlines.front();   // On recupere l'element de tete | 
|---|
|  | 240 | inputlines.pop();    // On supprime l'element de tete | 
|---|
| [2486] | 241 | fg_threxe = true; | 
|---|
|  | 242 | mutx_inps.unlock(); | 
|---|
| [2606] | 243 | try { | 
|---|
|  | 244 | Interpret(line); | 
|---|
|  | 245 | } | 
|---|
|  | 246 | catch (PThrowable& pex) {  // Catching SOPHYA exceptions | 
|---|
|  | 247 | cerr << "PIACmd::run() SOPHYA exception in call to Interpret(" << line << ")\n" | 
|---|
|  | 248 | << (string)typeid(pex).name() << " Msg= " << pex.Msg() << endl; | 
|---|
|  | 249 | } | 
|---|
|  | 250 | catch (std::exception& sex) { | 
|---|
|  | 251 | cerr << "PIACmd::run() std::exception in call to Interpret(" << line << ")\n" | 
|---|
|  | 252 | << (string)typeid(sex).name() << " Msg= " << sex.what() << endl; | 
|---|
|  | 253 | } | 
|---|
|  | 254 | catch (...) { | 
|---|
|  | 255 | cerr << "PIACmd::run() unknown exception (...) in call to Interpret(" | 
|---|
|  | 256 | << line << ")" << endl; | 
|---|
|  | 257 | } | 
|---|
| [2486] | 258 | } | 
|---|
|  | 259 | } | 
|---|
|  | 260 |  | 
|---|
|  | 261 | /* --Methode-- */ | 
|---|
| [2465] | 262 | bool PIACmd::CheckHelpGrp(string& grp, int& gid, string& desc) | 
|---|
| [330] | 263 | { | 
|---|
| [2465] | 264 | bool fgnewgrp = Commander::CheckHelpGrp(grp, gid, desc); | 
|---|
|  | 265 | if (helpwin_initdone && fgnewgrp) helpwin->AddHelpGroup(grp.c_str(), gid); | 
|---|
|  | 266 | return fgnewgrp; | 
|---|
| [330] | 267 | } | 
|---|
|  | 268 |  | 
|---|
|  | 269 | /* --Methode-- */ | 
|---|
|  | 270 | void PIACmd::UpdateHelpList(PIAHelpWind* hw, int gid) | 
|---|
|  | 271 | { | 
|---|
|  | 272 | helpwin->ClearHelpList(); | 
|---|
| [2465] | 273 | if (gid == 0) { | 
|---|
|  | 274 | string htxt = "All registered commands"; | 
|---|
|  | 275 | string hlab = "All (HelpGroup)"; | 
|---|
|  | 276 | helpwin->SetHelpTextLabel(htxt, hlab); | 
|---|
|  | 277 | } | 
|---|
|  | 278 | else { | 
|---|
|  | 279 | CmdHGroup::iterator ith; | 
|---|
|  | 280 | for(ith = cmdhgrp.begin(); ith != cmdhgrp.end(); ith++) { | 
|---|
|  | 281 | if ((*ith).second.gid == gid) { | 
|---|
|  | 282 | string hlab = (*ith).first; | 
|---|
|  | 283 | hlab += " (HelpGroup)"; | 
|---|
|  | 284 | helpwin->SetHelpTextLabel((*ith).second.desc, hlab); | 
|---|
|  | 285 | break; | 
|---|
|  | 286 | } | 
|---|
|  | 287 | } | 
|---|
|  | 288 | } | 
|---|
| [330] | 289 | CmdExmap::iterator it; | 
|---|
|  | 290 | for(it = helpexmap.begin(); it != helpexmap.end(); it++) { | 
|---|
|  | 291 | if ( (gid != 0) && ((*it).second.group != gid) ) continue; | 
|---|
|  | 292 | helpwin->AddHelpItem((*it).first.c_str()); | 
|---|
|  | 293 | } | 
|---|
|  | 294 | for(it = cmdexmap.begin(); it != cmdexmap.end(); it++) { | 
|---|
|  | 295 | if ( (gid != 0) && ((*it).second.group != gid) ) continue; | 
|---|
|  | 296 | helpwin->AddHelpItem((*it).first.c_str()); | 
|---|
|  | 297 | } | 
|---|
|  | 298 | } | 
|---|
|  | 299 |  | 
|---|
| [2465] | 300 | /* --Methode-- */ | 
|---|
|  | 301 | void PIACmd::InitializeHelpWindowMenu() | 
|---|
|  | 302 | { | 
|---|
|  | 303 | helpwin->AddHelpGroup("All", 0); | 
|---|
|  | 304 | CmdHGroup::iterator it; | 
|---|
|  | 305 | for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++) | 
|---|
|  | 306 | helpwin->AddHelpGroup((*it).first, (*it).second.gid); | 
|---|
|  | 307 | helpwin_initdone = true; | 
|---|
|  | 308 | } | 
|---|
| [165] | 309 |  | 
|---|
| [357] | 310 | /* Fonction */ | 
|---|
| [368] | 311 | static string GetStringFrStdin(PIACmd* piac) | 
|---|
| [357] | 312 | { | 
|---|
| [368] | 313 | PIStdImgApp* piapp = piac->GetImgApp(); | 
|---|
|  | 314 | if (piapp) { | 
|---|
|  | 315 | PIBaseWdg* wdg = piapp->CurrentBaseWdg(); | 
|---|
|  | 316 | if (wdg)  wdg->Refresh(); | 
|---|
|  | 317 | } | 
|---|
| [357] | 318 | char buff[128]; | 
|---|
|  | 319 | fgets(buff, 128, stdin); | 
|---|
|  | 320 | buff[127] = '\0'; | 
|---|
|  | 321 | return((string)buff); | 
|---|
|  | 322 | } | 
|---|
|  | 323 |  | 
|---|
| [2999] | 324 | /* --Methode-- */ | 
|---|
|  | 325 | bool PIACmd::GetVarApp(string const & vn, string & vv) | 
|---|
|  | 326 | { | 
|---|
|  | 327 | vv = ""; | 
|---|
|  | 328 | if (mObjMgr == NULL) return false; | 
|---|
|  | 329 | vector<string> opts; | 
|---|
|  | 330 | SplitStringToVString(vn, opts, '.'); | 
|---|
|  | 331 | string nom = opts[0]; | 
|---|
|  | 332 | opts.erase(opts.begin()); | 
|---|
|  | 333 | NObjMgrAdapter* obja = mObjMgr->GetObjAdapter(nom); | 
|---|
|  | 334 | if (obja == NULL) return false; | 
|---|
|  | 335 | vv = obja->GetInfoString(opts); | 
|---|
|  | 336 | return true; | 
|---|
|  | 337 | } | 
|---|
| [165] | 338 |  | 
|---|
| [1262] | 339 | /* --Methode-- */ | 
|---|
|  | 340 | int PIACmd::ExecuteCommandLine(string & kw, vector<string> & tokens, string & toks) | 
|---|
|  | 341 | { | 
|---|
|  | 342 | int rc = 0; | 
|---|
|  | 343 | NamedObjMgr omg; | 
|---|
| [349] | 344 |  | 
|---|
| [165] | 345 | // >>>>>>>>>>> Commande d'interpreteur | 
|---|
| [2812] | 346 | if ( (kw == "helpwindow") && (mImgApp))  { | 
|---|
|  | 347 | ZSync zs(mImgApp->getMutex()); | 
|---|
| [2465] | 348 | ShowHelpWindow(); | 
|---|
| [2812] | 349 | zs.NOp(); | 
|---|
| [2465] | 350 | return 0; | 
|---|
|  | 351 | } | 
|---|
| [2307] | 352 | // ----> Sortie d'application | 
|---|
| [2812] | 353 | else if ((kw == "exitpiapp") && (mImgApp)) { | 
|---|
| [2307] | 354 | mImgApp->Stop(); | 
|---|
| [2465] | 355 | return 0; | 
|---|
| [2307] | 356 | } | 
|---|
| [2463] | 357 | else return Commander::ExecuteCommandLine(kw, tokens, toks); | 
|---|
| [2465] | 358 | return 0; | 
|---|
| [165] | 359 | } | 
|---|
|  | 360 |  | 
|---|
| [333] | 361 |  | 
|---|
| [165] | 362 | /* --Methode-- */ | 
|---|
| [293] | 363 | void PIACmd::ShowHelpWindow() | 
|---|
| [165] | 364 | { | 
|---|
| [2812] | 365 | helpwin->Show(); | 
|---|
| [165] | 366 | } | 
|---|
| [357] | 367 |  | 
|---|
| [463] | 368 | /* --Methode-- */ | 
|---|
| [1251] | 369 | void PIACmd::ShowCxxOptionWindow() | 
|---|
|  | 370 | { | 
|---|
| [2812] | 371 | cxxoptwin->Show(); | 
|---|
| [1251] | 372 | } | 
|---|
|  | 373 |  | 
|---|
|  | 374 | /* --Methode-- */ | 
|---|
|  | 375 | void PIACmd::ShowCxxExecWindow() | 
|---|
|  | 376 | { | 
|---|
| [2812] | 377 | cxxexwin->Show(); | 
|---|
| [1251] | 378 | } | 
|---|
|  | 379 |  | 
|---|
| [2463] | 380 | /* --Methode-- */ | 
|---|
|  | 381 | void PIACmd::SetCurrentPrompt(const char* pr) | 
|---|
| [2377] | 382 | { | 
|---|
| [2463] | 383 | Commander::SetCurrentPrompt(pr); | 
|---|
| [2489] | 384 | if (mImgApp) { | 
|---|
| [2755] | 385 | ZSync zs(mImgApp->getMutex()); zs.NOp(); | 
|---|
| [2489] | 386 | mImgApp->GetConsole()->SetPrompt(pr); | 
|---|
|  | 387 | } | 
|---|
| [2377] | 388 | } | 
|---|
|  | 389 |  | 
|---|
| [1251] | 390 | /* --Methode-- */ | 
|---|
| [2463] | 391 | void PIACmd::ShowMessage(const char * msg, int att) | 
|---|
| [463] | 392 | { | 
|---|
| [2489] | 393 | /* | 
|---|
|  | 394 | Il faut faire quelque chose pour gerer correctement ca en multithread | 
|---|
| [2463] | 395 | char va = (att == 0) ? 0 : PIVA_Magenta; | 
|---|
| [2489] | 396 | if (mImgApp) { | 
|---|
| [2755] | 397 | ZSync(mImgApp->getMutex()); zs.NOp(); | 
|---|
| [2489] | 398 | mImgApp->GetConsole()->AddStr(msg, va); | 
|---|
|  | 399 | } | 
|---|
|  | 400 | */ | 
|---|
|  | 401 | Commander::ShowMessage(msg, att); | 
|---|
| [2263] | 402 | } | 
|---|
| [3366] | 403 |  | 
|---|
|  | 404 |  | 
|---|
|  | 405 | /* --Methode-- */ | 
|---|
|  | 406 | SOpExObj::SOpExObj(PIStdImgApp* app) | 
|---|
|  | 407 | { | 
|---|
|  | 408 | mImgApp = app; | 
|---|
|  | 409 | fg_thrstop = false; | 
|---|
|  | 410 | fg_threxe = false; | 
|---|
|  | 411 | } | 
|---|
|  | 412 |  | 
|---|
|  | 413 | /* --Methode-- */ | 
|---|
|  | 414 | SOpExObj::~SOpExObj() | 
|---|
|  | 415 | { | 
|---|
|  | 416 | } | 
|---|
|  | 417 |  | 
|---|
|  | 418 | /* --Methode-- */ | 
|---|
|  | 419 | void SOpExObj::AddOpe(string const & line) | 
|---|
|  | 420 | { | 
|---|
|  | 421 | mutx_inps.lock(); | 
|---|
|  | 422 | inputlines.push(line);   // Ajout d'un element en fin de queue | 
|---|
|  | 423 | mutx_inps.unlock(); | 
|---|
|  | 424 | mutx_inps.broadcast(); | 
|---|
|  | 425 | } | 
|---|
|  | 426 |  | 
|---|
|  | 427 | /* --Methode-- */ | 
|---|
|  | 428 | void SOpExObj::run() | 
|---|
|  | 429 | { | 
|---|
|  | 430 | NamedObjMgr omg; | 
|---|
|  | 431 | while (!fg_thrstop) { | 
|---|
|  | 432 | mutx_inps.lock(); | 
|---|
|  | 433 | while (inputlines.empty()) { | 
|---|
|  | 434 | fg_threxe = false; | 
|---|
|  | 435 | mutx_inps.wait(); | 
|---|
|  | 436 | } | 
|---|
|  | 437 | string cmd = inputlines.front().substr(0,3);   // On recupere l'element de tete | 
|---|
|  | 438 | string nom = inputlines.front().substr(4);   // On recupere l'element de tete | 
|---|
|  | 439 | inputlines.pop();    // On supprime l'element de tete | 
|---|
|  | 440 | fg_threxe = true; | 
|---|
|  | 441 | mutx_inps.unlock(); | 
|---|
|  | 442 | try { | 
|---|
| [3374] | 443 | if (cmd == "UPD") {  // UpdateObjMgrWindow() | 
|---|
|  | 444 | int did = atoi(nom.c_str()); | 
|---|
|  | 445 | omg.UpdateObjMgrWindow(did); | 
|---|
|  | 446 | } | 
|---|
|  | 447 | else if (cmd == "SCO") {  // set cobj | 
|---|
| [3366] | 448 | string ss = "set cobj "; | 
|---|
|  | 449 | ss += nom; | 
|---|
|  | 450 | cout << " Defining cobj : " << ss << endl; | 
|---|
|  | 451 | mImgApp->CmdInterpreter()->AddInputLine(ss); | 
|---|
|  | 452 | } | 
|---|
|  | 453 | else if (cmd == "DIS") {  // display obj | 
|---|
|  | 454 | omg.DisplayObj(nom); | 
|---|
|  | 455 | } | 
|---|
|  | 456 | else if (cmd == "PRT") {  // print obj | 
|---|
|  | 457 | omg.PrintObj(nom); | 
|---|
|  | 458 | } | 
|---|
|  | 459 | else if (cmd == "DEL") {  // delete obj | 
|---|
|  | 460 | omg.DelObj(nom); | 
|---|
|  | 461 | } | 
|---|
|  | 462 | else if (cmd == "SAV") {  // saveppf obj | 
|---|
|  | 463 | if (mImgApp->mPpfout)  omg.SaveObj(nom, *(mImgApp->mPpfout), false); | 
|---|
|  | 464 | } | 
|---|
|  | 465 | else cerr << "SOpExObj::run() ERROR CMD= " << cmd << endl; | 
|---|
|  | 466 | } | 
|---|
|  | 467 | catch (PThrowable& pex) {  // Catching SOPHYA exceptions | 
|---|
|  | 468 | cerr << "SOpExObj::run() SOPHYA exception CMD=" << cmd << " NOM=" << nom << "\n" | 
|---|
|  | 469 | << (string)typeid(pex).name() << " Msg= " << pex.Msg() << endl; | 
|---|
|  | 470 | } | 
|---|
|  | 471 | catch (std::exception& sex) { | 
|---|
|  | 472 | cerr << "SOpExObj::run() std::exception CMD=" << cmd << " NOM=" << nom << "\n" | 
|---|
|  | 473 | << (string)typeid(sex).name() << " Msg= " << sex.what() << endl; | 
|---|
|  | 474 | } | 
|---|
|  | 475 | catch (...) { | 
|---|
|  | 476 | cerr << "SOpExObj::run() unknown exception (...) CMD=" | 
|---|
|  | 477 | << cmd << " NOM=" << nom << endl; | 
|---|
|  | 478 | } | 
|---|
|  | 479 | } | 
|---|
|  | 480 | } | 
|---|