[2615] | 1 | #include "sopnamsp.h"
|
---|
[293] | 2 | #include "machdefs.h"
|
---|
[165] | 3 | #include <stdlib.h>
|
---|
| 4 | #include <stdio.h>
|
---|
| 5 | #include <string.h>
|
---|
| 6 |
|
---|
[295] | 7 | #include <typeinfo>
|
---|
| 8 |
|
---|
[165] | 9 | #include "perrors.h"
|
---|
| 10 | #include "ctimer.h"
|
---|
| 11 |
|
---|
| 12 | #include "nbmath.h"
|
---|
| 13 |
|
---|
| 14 | #include "pistdimgapp.h"
|
---|
| 15 | #include "nobjmgr.h"
|
---|
| 16 | #include "servnobjm.h"
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | /* ........................................................... */
|
---|
| 21 | /* Classe ObjMgrWind interface de gestion d'objets nommes */
|
---|
| 22 | /* ........................................................... */
|
---|
| 23 |
|
---|
| 24 | /* --Methode-- */
|
---|
| 25 | ObjMgrWind::ObjMgrWind(PIStdImgApp *par)
|
---|
[685] | 26 | : PIWindow((PIMsgHandler *)par, "objmgr", PIWK_normal,
|
---|
[165] | 27 | 400, 300, 250, 250)
|
---|
| 28 | {
|
---|
| 29 | int i;
|
---|
| 30 | dap = par;
|
---|
| 31 |
|
---|
| 32 | int bsx, bsy;
|
---|
| 33 | int tsx, tsy;
|
---|
| 34 | int spx, spy;
|
---|
| 35 | // On definit la taille a partir de la taille par defaut des composantes
|
---|
| 36 | PIApplicationPrefCompSize(bsx, bsy);
|
---|
[333] | 37 | spx = bsx/4; spy = bsy/4;
|
---|
| 38 | tsx = 4.0*bsx+3*spx; tsy = 6*bsy+7*spy;
|
---|
[165] | 39 | SetSize(tsx,tsy);
|
---|
[333] | 40 | dirlist = new PIOptMenu(this, "dirlist", 2.5*bsx, bsy, spx+0.25*bsx, spy);
|
---|
| 41 | dirlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 42 | objlist = new PIList(this, "objlist", 3*bsx, tsy-3*spy-bsy, spx, 2*spy+bsy);
|
---|
[165] | 43 | objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
[333] | 44 | // objlist->SetBorderWidth(2);
|
---|
[165] | 45 |
|
---|
[333] | 46 | int py = spy;
|
---|
| 47 | int px = 2*spx+3*bsx;
|
---|
[685] | 48 | mBut[0] = new PIButton(this, "SetCurObj", 10, bsx, bsy, px, py); py += (bsy+spy);
|
---|
[333] | 49 | mBut[1] = new PIButton(this, "Display", 20, bsx, bsy, px, py); py += (bsy+spy);
|
---|
| 50 | mBut[2] = new PIButton(this, "Print", 30, bsx, bsy, px, py); py += (bsy+spy);
|
---|
| 51 | mBut[3] = new PIButton(this, "SavePPF", 40, bsx, bsy, px, py); py += (bsy+spy);
|
---|
| 52 | mBut[4] = new PIButton(this, "Delete", 50, bsx, bsy, px, py); py += (bsy+spy);
|
---|
| 53 | mBut[5] = new PIButton(this, "Dismiss", 90, bsx, bsy, px, py); py += (bsy+spy);
|
---|
[165] | 54 |
|
---|
[338] | 55 | for(i=0; i<6; i++)
|
---|
[165] | 56 | mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 57 |
|
---|
| 58 | // FinishCreate(); pas necessaire ?
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | /* --Methode-- */
|
---|
| 62 | ObjMgrWind::~ObjMgrWind()
|
---|
| 63 | {
|
---|
| 64 | int i;
|
---|
[333] | 65 | delete dirlist;
|
---|
[165] | 66 | delete objlist;
|
---|
[333] | 67 | for(i=0; i<6; i++) delete mBut[i];
|
---|
[165] | 68 | }
|
---|
| 69 |
|
---|
| 70 | /* --Methode-- */
|
---|
| 71 | void ObjMgrWind::Show()
|
---|
| 72 | {
|
---|
[685] | 73 | // dap->SetBlocked(); Ce n'est plus necessaire - Reza 11/12/99
|
---|
[333] | 74 | string cdir;
|
---|
| 75 | dap->ObjMgr()->GetCurrentDir(cdir);
|
---|
| 76 | cdir = '/' + cdir;
|
---|
| 77 | dirlist->SetValueStr(cdir);
|
---|
[2762] | 78 | dap->ObjMgr()->UpdateObjMgrWindow( GetCurDirId() );
|
---|
[165] | 79 | PIWindow::Show();
|
---|
| 80 | return;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[685] | 83 |
|
---|
[165] | 84 | /* --Methode-- */
|
---|
[2380] | 85 | void ObjMgrWind::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
|
---|
[165] | 86 | {
|
---|
| 87 |
|
---|
[2380] | 88 | if (sender == objlist) return; // Changement de selection d'objet - on ne fait rien
|
---|
[165] | 89 | // PIMessage ssg = ModMsg(msg);
|
---|
| 90 | msg = UserMsg(msg);
|
---|
[333] | 91 | if (msg == 90) {
|
---|
[165] | 92 | dap->SetReady();
|
---|
| 93 | this->Hide();
|
---|
| 94 | return;
|
---|
[333] | 95 | }
|
---|
| 96 | else if (msg >= 30000) {
|
---|
| 97 | dap->ObjMgr()->UpdateObjMgrWindow(msg-30000);
|
---|
| 98 | return;
|
---|
| 99 | }
|
---|
[685] | 100 | /*
|
---|
| 101 | else if (msg == 10) {
|
---|
[333] | 102 | string cdir = dirlist->GetValueStr();
|
---|
| 103 | dap->ObjMgr()->SetCurrentDir(cdir);
|
---|
| 104 | return;
|
---|
| 105 | }
|
---|
[685] | 106 | */
|
---|
[165] | 107 |
|
---|
| 108 | string nom = "";
|
---|
[685] | 109 | string sel = "";
|
---|
| 110 | if ( (msg == 10) || (msg == 20) || (msg == 30) || (msg == 40) || (msg == 50) ) {
|
---|
| 111 | sel = objlist->GetSelectionStr();
|
---|
[165] | 112 | // size_t p = sel.find_first_not_of(" \t");
|
---|
| 113 | // if (p<0) p = 0;
|
---|
[206] | 114 | size_t l = sel.length();
|
---|
[165] | 115 | size_t q = sel.find_first_of(" \t");
|
---|
[206] | 116 | if (q > l) q = l;
|
---|
[333] | 117 | nom = dirlist->GetValueStr() + '/' + sel.substr(0, q);
|
---|
| 118 | }
|
---|
[165] | 119 |
|
---|
| 120 | NamedObjMgr* om = dap->ObjMgr();
|
---|
| 121 | if (om == NULL) return;
|
---|
[685] | 122 | if (sel.length() < 1) return;
|
---|
[333] | 123 | if (nom.length() < 1) return;
|
---|
[165] | 124 |
|
---|
| 125 | switch (msg)
|
---|
| 126 | {
|
---|
[685] | 127 | case 10:
|
---|
| 128 | {
|
---|
| 129 | string cmd = "set cobj " + nom ;
|
---|
| 130 | cout << " Setting current object ($cobj) to " << nom << endl;
|
---|
| 131 | dap->CmdInterpreter()->Interpret(cmd);
|
---|
| 132 | }
|
---|
| 133 | break;
|
---|
[333] | 134 | case 20:
|
---|
[165] | 135 | om->DisplayObj(nom);
|
---|
| 136 | break;
|
---|
[333] | 137 | case 30:
|
---|
[165] | 138 | om->PrintObj(nom);
|
---|
| 139 | break;
|
---|
[333] | 140 | case 40:
|
---|
| 141 | if (dap->mPpfout) om->SaveObj(nom, *(dap->mPpfout), false);
|
---|
[165] | 142 | break;
|
---|
[333] | 143 | case 50:
|
---|
[165] | 144 | om->DelObj(nom);
|
---|
[685] | 145 | // objlist->DeleteItemMsg(objlist->GetSelection());
|
---|
[333] | 146 | // dap->ObjMgr()->UpdateObjMgrWindow(dirlist->GetValue()-30000);
|
---|
[165] | 147 | break;
|
---|
| 148 |
|
---|
| 149 | default:
|
---|
| 150 | // printf("DEBUG/ObjMgrW::Process %d %d \n", (int)msg, (int)ssg);
|
---|
| 151 | break;
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | return;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[685] | 157 | /* --Methode-- */
|
---|
| 158 | void ObjMgrWind::UpdateList(int did)
|
---|
| 159 | {
|
---|
| 160 | if (!Visible()) return;
|
---|
[2762] | 161 | if (did != GetCurDirId() ) return;
|
---|
[685] | 162 | dap->ObjMgr()->UpdateObjMgrWindow(did);
|
---|
| 163 | return;
|
---|
| 164 | }
|
---|
[165] | 165 |
|
---|
[685] | 166 | /* --Methode-- */
|
---|
| 167 | void ObjMgrWind::AddObjList(int did, const char * objn, int oid)
|
---|
| 168 | {
|
---|
| 169 | if (!Visible()) return;
|
---|
| 170 | if (did != (dirlist->GetValue()-30000) ) return;
|
---|
| 171 | mNitem++; objlist->AppendItem(objn, oid);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | /* --Methode-- */
|
---|
| 175 | void ObjMgrWind::DelObjList(int did, int oid)
|
---|
| 176 | {
|
---|
| 177 | if (!Visible()) return;
|
---|
| 178 | //DBG printf("DBG-DelObjList %d , %d , (%d) \n", did, dirlist->GetValue()-30000, oid);
|
---|
| 179 | if (did != (dirlist->GetValue()-30000) ) return;
|
---|
| 180 | objlist->DeleteItemMsg(oid);
|
---|
| 181 | }
|
---|
| 182 |
|
---|
[165] | 183 | /* ........................................................... */
|
---|
| 184 | /* Classe PPInMgrWind interface de gestion d'objets nommes */
|
---|
| 185 | /* ........................................................... */
|
---|
| 186 |
|
---|
| 187 | /* --Methode-- */
|
---|
| 188 | PPInMgrWind::PPInMgrWind(PIStdImgApp *par)
|
---|
| 189 | : PIWindow((PIMsgHandler *)par, "PPF-FileManager", PIWK_dialog,
|
---|
| 190 | 400, 300, 250, 250)
|
---|
| 191 | {
|
---|
| 192 | int i;
|
---|
| 193 | dap = par;
|
---|
| 194 |
|
---|
| 195 | int bsx, bsy;
|
---|
| 196 | int tsx, tsy;
|
---|
| 197 | int spx, spy;
|
---|
| 198 | // On definit la taille a partir de la taille par defaut des composantes
|
---|
| 199 | PIApplicationPrefCompSize(bsx, bsy);
|
---|
| 200 | spx = bsx/4; spy = bsy/3;
|
---|
| 201 | bsx *= 1.25;
|
---|
| 202 | ttx = tsx = 3*bsx+8*spx; tty = tsy = 7*bsy+5*spy;
|
---|
| 203 | SetSize(tsx,tsy);
|
---|
| 204 |
|
---|
| 205 | mLab[0] = new PILabel(this, "filename", tsx-spx, bsy-spy, spx/2, spy/2);
|
---|
| 206 | mLab[0]->SetLabel("");
|
---|
[293] | 207 | mLab[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
[165] | 208 | mLab[0]->SetBorderWidth(1);
|
---|
| 209 |
|
---|
| 210 | polx = spx/2; poly = bsy+1.5*spy;
|
---|
| 211 | tolx = tsx-spx; toly = tsy-2*bsy-5*spy;
|
---|
| 212 | int py = tsy-2*spy-bsy;
|
---|
| 213 | int px = 2*spx;
|
---|
| 214 | mBut[0] = new PIButton(this, "Read", 2500, bsx, bsy, px, py); px += (bsx+2*spx);
|
---|
| 215 | mBut[1] = new PIButton(this, "ReadAll", 2600, bsx, bsy, px, py); px += (bsx+2*spx);
|
---|
| 216 | mBut[2] = new PIButton(this, "Close", 2700, bsx, bsy, px, py); px += (bsx+2*spx);
|
---|
| 217 |
|
---|
| 218 | for(i=0; i<3; i++)
|
---|
| 219 | mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 220 |
|
---|
| 221 | objlist = NULL;
|
---|
| 222 | mLab[1] = NULL;
|
---|
| 223 | mPin = NULL;
|
---|
| 224 |
|
---|
| 225 | // FinishCreate(); pas necessaire
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | /* --Methode-- */
|
---|
| 229 | PPInMgrWind::~PPInMgrWind()
|
---|
| 230 | {
|
---|
| 231 | int i;
|
---|
| 232 | if (objlist) delete objlist;
|
---|
| 233 | delete mLab[0];
|
---|
| 234 | for(i=0; i<3; i++) delete mBut[i];
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | /* --Methode-- */
|
---|
| 238 | void PPInMgrWind::SetFile(string flnm)
|
---|
| 239 | {
|
---|
| 240 | char strg[128];
|
---|
| 241 | char* nom;
|
---|
| 242 | char noms[32];
|
---|
| 243 | int i, cid, key, ln;
|
---|
| 244 |
|
---|
| 245 | bool ok = true;
|
---|
[495] | 246 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 247 | TRY {
|
---|
| 248 | mPin = new PInPersist(flnm);
|
---|
| 249 | } CATCH(merr)
|
---|
| 250 | { printf("ObjMgrWind::SetFile Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 251 | ok = false; } ENDTRY;
|
---|
[584] | 252 | #else
|
---|
| 253 | try {
|
---|
| 254 | mPin = new PInPersist(flnm);
|
---|
| 255 | }
|
---|
| 256 | catch (IOExc iox) {
|
---|
| 257 | cerr << "ObjMgrWind::SetFile/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 258 | ok = false;
|
---|
| 259 | }
|
---|
| 260 | #endif
|
---|
[165] | 261 |
|
---|
| 262 | if (!ok) { mPin = NULL; dap->SetReady(); return; }
|
---|
| 263 |
|
---|
[2460] | 264 | int nbtags = 0;
|
---|
| 265 | #ifdef SANS_EVOLPLANCK
|
---|
| 266 | nbtags = mPin->NbTags();
|
---|
| 267 | #else
|
---|
| 268 | nbtags = mPin->NbNameTags();
|
---|
| 269 | #endif
|
---|
| 270 |
|
---|
| 271 | if (nbtags < 1) {
|
---|
[165] | 272 | delete mPin; mPin = NULL;
|
---|
[332] | 273 | string no="";
|
---|
| 274 | dap->ObjMgr()->ReadObj(flnm,no);
|
---|
[165] | 275 | return;
|
---|
| 276 | }
|
---|
| 277 | if (objlist) delete objlist;
|
---|
| 278 | SetSize(ttx,tty);
|
---|
| 279 | mLab[0]->SetLabel(flnm);
|
---|
| 280 | objlist = new PIList(this, "infileobjlist", tolx, toly, polx, poly);
|
---|
| 281 | objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 282 | objlist->SetBorderWidth(2);
|
---|
| 283 |
|
---|
| 284 |
|
---|
[495] | 285 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 286 | for(i=0; i<mPin->NbTags(); i++) {
|
---|
[380] | 287 | key = mPin->TagKey(i, cid, ln); // $CHECK$ non-const & reference initialized to temporary, car int -> long&
|
---|
[165] | 288 | if (ln <= 0) nom = "?";
|
---|
| 289 | else { strncpy(noms, mPin->TagName(i).c_str(), 31); noms[31] = '\0'; nom = noms; }
|
---|
[333] | 290 | sprintf(strg, "%s (T=%s, Key=%d)", nom, dap->ObjMgr()->GetServiceObj()->PClassIdToClassName(cid), key);
|
---|
| 291 | // sprintf(strg, "%s (T=%s, Key=%d)", nom, " DataObject ?", key); Attention SANS_EVOLPLANCK
|
---|
[165] | 292 | objlist->AppendItem(strg, 5000+i);
|
---|
| 293 | }
|
---|
[584] | 294 | #else
|
---|
| 295 | string tn;
|
---|
[2460] | 296 | for(i=0; i<mPin->NbNameTags(); i++) {
|
---|
[584] | 297 | tn = mPin->GetTagName(i);
|
---|
| 298 | objlist->AppendItem(tn.c_str(), 5000+i);
|
---|
| 299 | }
|
---|
[495] | 300 | #endif
|
---|
[165] | 301 |
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | /* --Methode-- */
|
---|
| 305 | void PPInMgrWind::Show()
|
---|
| 306 | {
|
---|
| 307 | if (mPin == NULL) return;
|
---|
| 308 | dap->SetBlocked();
|
---|
| 309 | PIWindow::Show();
|
---|
| 310 | return;
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | /* --Methode-- */
|
---|
| 314 | void PPInMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
|
---|
| 315 | {
|
---|
| 316 |
|
---|
| 317 | int sel;
|
---|
| 318 | msg = UserMsg(msg);
|
---|
| 319 |
|
---|
| 320 | if (msg == 2700) {
|
---|
| 321 | delete mPin; mPin = NULL;
|
---|
| 322 | delete objlist; objlist = NULL;
|
---|
| 323 | dap->SetReady();
|
---|
| 324 | this->Hide();
|
---|
| 325 | return;
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | NamedObjMgr* om = dap->ObjMgr();
|
---|
| 329 | switch (msg)
|
---|
| 330 | {
|
---|
| 331 | case 2500:
|
---|
| 332 | sel = (PIMessage)objlist->GetSelection() - 5000;
|
---|
| 333 | if (sel >= 0) om->ReadObj((*mPin), sel);
|
---|
| 334 | break;
|
---|
| 335 | case 2600:
|
---|
| 336 | om->ReadObj((*mPin), -1);
|
---|
| 337 | dap->SetReady();
|
---|
| 338 | this->Hide();
|
---|
| 339 | break;
|
---|
| 340 |
|
---|
| 341 | default:
|
---|
| 342 | break;
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | return;
|
---|
| 346 | }
|
---|