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