[165] | 1 | #include <stdio.h>
|
---|
| 2 | #include <stdlib.h>
|
---|
| 3 | #include <ctype.h>
|
---|
| 4 |
|
---|
[295] | 5 | #include <typeinfo>
|
---|
[165] | 6 | #include <iostream.h>
|
---|
| 7 | #include <string>
|
---|
| 8 | #include <list>
|
---|
| 9 | #include <map>
|
---|
| 10 |
|
---|
| 11 | #include "strutil.h"
|
---|
| 12 | #include "datatypes.h"
|
---|
| 13 |
|
---|
| 14 | #include "nobjmgr.h"
|
---|
| 15 | #include "servnobjm.h"
|
---|
[330] | 16 | #include "nomgadapter.h"
|
---|
[165] | 17 | #include "pistdimgapp.h"
|
---|
| 18 |
|
---|
[1164] | 19 | #include "dvlist.h"
|
---|
[165] | 20 |
|
---|
[293] | 21 | // EVOL-PLANCK
|
---|
| 22 | #ifdef SANS_EVOLPLANCK
|
---|
| 23 | #include "fitsimage.h"
|
---|
| 24 | #endif
|
---|
| 25 |
|
---|
[295] | 26 | #include "pisurfdr.h"
|
---|
[165] | 27 | #include "pipodrw.h"
|
---|
[333] | 28 |
|
---|
[165] | 29 | #include "pintuple.h"
|
---|
| 30 | #include "pintup3d.h"
|
---|
| 31 | #include "pigfd1.h"
|
---|
| 32 | #include "pigfd2.h"
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | //++
|
---|
| 36 | // Class NamedObjMgr
|
---|
| 37 | // Lib PI
|
---|
| 38 | // include nobjmgr.h
|
---|
| 39 | //
|
---|
[344] | 40 | // Cette classe fournit les services nécéssaires à la gestion des objets
|
---|
[165] | 41 | // (l'ensemble des objets PPersist de PEIDA++) au sein du programme
|
---|
| 42 | // d'analyse interactive *piapp* . Elle constitue en outre l'interface
|
---|
| 43 | // entre les fonctions utilisateur et l'application graphique.
|
---|
| 44 | //--
|
---|
| 45 | //++
|
---|
| 46 | // Links Voir aussi
|
---|
| 47 | // PIStdImgApp
|
---|
| 48 | // Services2NObjMgr
|
---|
| 49 | // PIACmd
|
---|
| 50 | //--
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | // ..................................................................
|
---|
| 54 | // ...... Gestion des objets nommes, variables globales ............
|
---|
[331] | 55 | struct nobj_diritem {
|
---|
[344] | 56 | int id; // Directory Id
|
---|
| 57 | int nobj; // Number of objects in directory
|
---|
| 58 | bool lock; // True -> directory locked, No Add, del or rename
|
---|
| 59 | bool keepold; // True -> When duplicate object name, old object moved to /old
|
---|
[331] | 60 | };
|
---|
| 61 |
|
---|
| 62 | typedef map<string, nobj_diritem, less<string> > NObjDirList;
|
---|
| 63 |
|
---|
[165] | 64 | struct nobj_item {
|
---|
[344] | 65 | AnyDataObj* obj; // Object pointer
|
---|
| 66 | NObjMgrAdapter* obja; // Object adapter pointer
|
---|
| 67 | int oid; // object Id
|
---|
| 68 | int dirid; // Directory Id
|
---|
| 69 | list<int> wrsid; // List of Window Resource Id (Drawer, PIBaseWdg, ...)
|
---|
| 70 | // (for PIStdImgApp)
|
---|
[165] | 71 | bool operator==(nobj_item const& b) const
|
---|
| 72 | { return (this->obj == b.obj); }
|
---|
| 73 | };
|
---|
| 74 |
|
---|
| 75 | typedef map<string, nobj_item, less<string> > NObjList;
|
---|
| 76 |
|
---|
[331] | 77 | static NObjDirList* myDirs = NULL;
|
---|
| 78 | static NObjList* myObjs = NULL;
|
---|
[165] | 79 | static int fgOInit = 0;
|
---|
| 80 | static int myNObj = 0;
|
---|
[331] | 81 | static int myDirId = 0;
|
---|
| 82 | static string* currDir;
|
---|
[165] | 83 |
|
---|
| 84 | static PIStdImgApp* myImgApp=NULL;
|
---|
| 85 | static Services2NObjMgr* servnobjm=NULL;
|
---|
| 86 |
|
---|
[1164] | 87 | static DVList* myVars = NULL; // Pour stocker les variables
|
---|
| 88 |
|
---|
[165] | 89 | static string* TmpDir; // Repertoire pour les compilations / link dynamique
|
---|
| 90 |
|
---|
[333] | 91 | // ..................................................................
|
---|
| 92 |
|
---|
[165] | 93 | //++
|
---|
| 94 | // Titre Constructeurs
|
---|
| 95 | //--
|
---|
| 96 | //++
|
---|
| 97 | // NamedObjMgr()
|
---|
| 98 | // Constructeur. Les différents instantiation de la classe "NamedObjMgr"
|
---|
| 99 | // dans une même application créent des objets qui travaillent sur la même
|
---|
| 100 | // liste d'objets. Les objets de cette classe ne possedent en effet pas
|
---|
| 101 | // de variables membres.
|
---|
| 102 | //--
|
---|
| 103 |
|
---|
| 104 | /* --Methode-- */
|
---|
| 105 | NamedObjMgr::NamedObjMgr()
|
---|
| 106 | {
|
---|
| 107 | if (fgOInit == 0) {
|
---|
[333] | 108 | myNObj = 0;
|
---|
| 109 | myDirId = 0;
|
---|
[331] | 110 | myDirs = new NObjDirList;
|
---|
[165] | 111 | myObjs = new NObjList;
|
---|
[1164] | 112 | myVars = new DVList;
|
---|
[331] | 113 | currDir = new string("home");
|
---|
[333] | 114 | string dirn = "home";
|
---|
| 115 | CreateDir(dirn);
|
---|
[344] | 116 | SetKeepOldDirAtt(dirn, true);
|
---|
[333] | 117 | dirn = "tmp";
|
---|
| 118 | CreateDir(dirn);
|
---|
[344] | 119 | SetKeepOldDirAtt(dirn, false);
|
---|
[466] | 120 | dirn = "autoc";
|
---|
[368] | 121 | CreateDir(dirn);
|
---|
| 122 | SetKeepOldDirAtt(dirn, false);
|
---|
[333] | 123 | dirn = "old";
|
---|
| 124 | CreateDir(dirn);
|
---|
[344] | 125 | SetKeepOldDirAtt(dirn, false);
|
---|
[333] | 126 | dirn = "home";
|
---|
| 127 | SetCurrentDir(dirn);
|
---|
| 128 | myDirId = 50;
|
---|
[165] | 129 | char* varenv;
|
---|
| 130 | TmpDir = new string("");
|
---|
| 131 | if ( (varenv=getenv("PEIDA_TMP")) != NULL ) (*TmpDir) = varenv;
|
---|
| 132 | else if ( (varenv=getenv("TMPDIR")) != NULL ) (*TmpDir) = varenv;
|
---|
| 133 | int l = (*TmpDir).length();
|
---|
| 134 | if ( (l>0) && ((*TmpDir)[l-1] != '/') ) (*TmpDir) += '/';
|
---|
[333] | 135 | servnobjm = new Services2NObjMgr(this, (*TmpDir));
|
---|
[165] | 136 | }
|
---|
| 137 | fgOInit++;
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 | /* --Methode-- */
|
---|
| 142 | NamedObjMgr::~NamedObjMgr()
|
---|
| 143 | {
|
---|
| 144 | fgOInit--;
|
---|
[1164] | 145 | if (fgOInit == 0) {
|
---|
| 146 | string patt = "/*/*";
|
---|
| 147 | DelObjects(patt, true);
|
---|
| 148 | delete myObjs;
|
---|
| 149 | delete myDirs;
|
---|
| 150 | delete myVars;
|
---|
[165] | 151 | }
|
---|
[1164] | 152 | }
|
---|
[165] | 153 |
|
---|
| 154 | //++
|
---|
| 155 | // Titre Méthodes
|
---|
| 156 | //--
|
---|
| 157 | //++
|
---|
| 158 | // void SetImgApp(PIStdImgApp* app)
|
---|
| 159 | // Spécifie l'objet "PIStdImgApp" associé.
|
---|
| 160 | // PIStdImgApp* GetImgApp()
|
---|
| 161 | // Accès à l'objet "PIStdImgApp" associé.
|
---|
| 162 | //--
|
---|
| 163 |
|
---|
| 164 | /* --Methode-- */
|
---|
| 165 | void NamedObjMgr::SetImgApp(PIStdImgApp* app)
|
---|
| 166 | {
|
---|
| 167 | myImgApp = app;
|
---|
| 168 | servnobjm->SetImgApp(app);
|
---|
[333] | 169 |
|
---|
| 170 | NObjDirList::iterator it;
|
---|
| 171 | string cn;
|
---|
| 172 | for(it= myDirs->begin(); it != myDirs->end(); it++) {
|
---|
| 173 | cn = '/' + (*it).first;
|
---|
| 174 | (myImgApp->ObjMgrW())->AddDirectory(cn.c_str(), (*it).second.id);
|
---|
| 175 | }
|
---|
[165] | 176 | }
|
---|
| 177 |
|
---|
[449] | 178 |
|
---|
| 179 | static bool verbeux = false; // true -> plus de message (creation/suppression d'objets)
|
---|
| 180 | void NamedObjMgr::SetVerbose(bool fg)
|
---|
| 181 | {
|
---|
| 182 | verbeux = fg;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
[165] | 185 | /* --Methode-- */
|
---|
| 186 | PIStdImgApp* NamedObjMgr::GetImgApp()
|
---|
| 187 | {
|
---|
| 188 | return(myImgApp);
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | /* --Methode-- */
|
---|
| 192 | Services2NObjMgr* NamedObjMgr::GetServiceObj()
|
---|
| 193 | {
|
---|
| 194 | return(servnobjm);
|
---|
| 195 | }
|
---|
| 196 |
|
---|
[331] | 197 | /* --Methode-- */
|
---|
[1164] | 198 | bool NamedObjMgr::SetVar(string const & key, string const & val)
|
---|
| 199 | {
|
---|
[1199] | 200 | #ifdef SANS_EVOLPLANCK
|
---|
| 201 | bool fg = true;
|
---|
| 202 | #else
|
---|
[1164] | 203 | bool fg = myVars->HasKey(key);
|
---|
[1199] | 204 | #endif
|
---|
[1164] | 205 | myVars->SetS(key, val);
|
---|
[1224] | 206 | // cout << " DEBUG::SetVar " << *myVars << endl;
|
---|
[1164] | 207 | return(fg);
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | /* --Methode-- */
|
---|
| 211 | bool NamedObjMgr::HasVar(string const & key)
|
---|
| 212 | {
|
---|
[1199] | 213 | #ifdef SANS_EVOLPLANCK
|
---|
| 214 | return(false);
|
---|
| 215 | #else
|
---|
[1164] | 216 | return(myVars->HasKey(key));
|
---|
[1199] | 217 | #endif
|
---|
[1164] | 218 | }
|
---|
| 219 |
|
---|
| 220 | /* --Methode-- */
|
---|
| 221 | bool NamedObjMgr::DeleteVar(string const & key)
|
---|
| 222 | {
|
---|
[1199] | 223 | #ifdef SANS_EVOLPLANCK
|
---|
| 224 | return(false);
|
---|
| 225 | #else
|
---|
[1164] | 226 | return(myVars->DeleteKey(key));
|
---|
[1199] | 227 | #endif
|
---|
[1164] | 228 | }
|
---|
| 229 |
|
---|
| 230 | /* --Methode-- */
|
---|
| 231 | string NamedObjMgr::GetVar(string const & key)
|
---|
| 232 | {
|
---|
[1224] | 233 | // cout << " DEBUG::GetVar " << *myVars << endl;
|
---|
[1164] | 234 | return(myVars->GetS(key));
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | /* --Methode-- */
|
---|
| 238 | DVList& NamedObjMgr::GetVarList()
|
---|
| 239 | {
|
---|
[1224] | 240 | // cout << " DEBUG::GetVarList " << *myVars << endl;
|
---|
[1164] | 241 | return(*myVars);
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | /* --Methode-- */
|
---|
[344] | 245 | bool NamedObjMgr::CreateDir(string & dirname)
|
---|
[331] | 246 | {
|
---|
[333] | 247 | if ( !CheckDirName(dirname) ) {
|
---|
| 248 | cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
[344] | 249 | return(false);
|
---|
[333] | 250 | }
|
---|
| 251 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 252 | if (it != myDirs->end()) {
|
---|
| 253 | cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
|
---|
[344] | 254 | return(false);
|
---|
[333] | 255 | }
|
---|
| 256 | myDirId++;
|
---|
| 257 | nobj_diritem di;
|
---|
| 258 | di.id = myDirId;
|
---|
| 259 | di.nobj = 0;
|
---|
[344] | 260 | di.lock = false;
|
---|
| 261 | di.keepold = false;
|
---|
[333] | 262 | (*myDirs)[dirname] = di;
|
---|
| 263 | if (myImgApp) {
|
---|
| 264 | string str = '/' + dirname;
|
---|
| 265 | (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
|
---|
| 266 | }
|
---|
[449] | 267 | if (verbeux) cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
|
---|
[344] | 268 | return(true);
|
---|
[331] | 269 | }
|
---|
| 270 |
|
---|
| 271 | /* --Methode-- */
|
---|
[344] | 272 | bool NamedObjMgr::DeleteDir(string & dirname)
|
---|
[331] | 273 | {
|
---|
[333] | 274 | if ( !CheckDirName(dirname) ) {
|
---|
| 275 | cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
[344] | 276 | return(false);
|
---|
[333] | 277 | }
|
---|
| 278 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 279 | if (it == myDirs->end()) {
|
---|
| 280 | cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
|
---|
[344] | 281 | return(false);
|
---|
[333] | 282 | }
|
---|
| 283 | if ((*it).second.nobj > 0) {
|
---|
| 284 | cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
|
---|
[344] | 285 | return(false);
|
---|
[333] | 286 | }
|
---|
[344] | 287 | if ((*it).second.lock ) {
|
---|
| 288 | cout << "NamedObjMgr::DeleteDir() " << dirname << " locked ! " << endl;
|
---|
| 289 | return(false);
|
---|
| 290 | }
|
---|
[333] | 291 | if ((*it).second.id < 50) {
|
---|
| 292 | cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
|
---|
[344] | 293 | return(false);
|
---|
[333] | 294 | }
|
---|
| 295 |
|
---|
| 296 | if (myImgApp)
|
---|
| 297 | (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
|
---|
| 298 | myDirs->erase(it);
|
---|
[449] | 299 | if (verbeux) cout << "NamedObjMgr::DeleteDir() " << dirname << " deleted " << endl;
|
---|
[344] | 300 | return(true);
|
---|
[331] | 301 | }
|
---|
| 302 |
|
---|
| 303 | /* --Methode-- */
|
---|
[344] | 304 | void NamedObjMgr::LockDir(string & dirname)
|
---|
[331] | 305 | {
|
---|
[344] | 306 | if ( !CheckDirName(dirname) ) return;
|
---|
| 307 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 308 | if (it == myDirs->end()) return;
|
---|
| 309 | (*it).second.lock = true;
|
---|
[449] | 310 | if (verbeux) cout << "NamedObjMgr::LockDir() " << dirname << " Locked " << endl;
|
---|
[344] | 311 | return;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | /* --Methode-- */
|
---|
| 315 | void NamedObjMgr::UnlockDir(string & dirname)
|
---|
| 316 | {
|
---|
| 317 | if ( !CheckDirName(dirname) ) return;
|
---|
| 318 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 319 | if (it == myDirs->end()) return;
|
---|
| 320 | (*it).second.lock = true;
|
---|
[449] | 321 | if (verbeux) cout << "NamedObjMgr::UnlockDir() " << dirname << " Unlocked " << endl;
|
---|
[344] | 322 | return;
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | /* --Methode-- */
|
---|
| 326 | void NamedObjMgr::SetKeepOldDirAtt(string & dirname, bool keepold)
|
---|
| 327 | {
|
---|
| 328 | if ( !CheckDirName(dirname) ) return;
|
---|
| 329 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 330 | if (it == myDirs->end()) return;
|
---|
| 331 | (*it).second.keepold = keepold;
|
---|
[449] | 332 | if (!verbeux) return;
|
---|
[344] | 333 | cout << "NamedObjMgr::SetKeepOldDirAtt() " << dirname << " -> ";
|
---|
| 334 | if ( keepold ) cout << " True " << endl;
|
---|
| 335 | else cout << " False " << endl;
|
---|
| 336 | return;
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 |
|
---|
| 340 | /* --Methode-- */
|
---|
| 341 | bool NamedObjMgr::SetCurrentDir(string & dirname)
|
---|
| 342 | {
|
---|
[333] | 343 | if ( !CheckDirName(dirname) ) {
|
---|
| 344 | cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
[344] | 345 | return(false);
|
---|
[333] | 346 | }
|
---|
| 347 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 348 | if (it == myDirs->end()) {
|
---|
| 349 | cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
|
---|
[344] | 350 | return(false);
|
---|
[333] | 351 | }
|
---|
| 352 | *currDir = dirname;
|
---|
[449] | 353 | if (verbeux) cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
|
---|
[344] | 354 | return(true);
|
---|
[331] | 355 | }
|
---|
| 356 |
|
---|
| 357 | /* --Methode-- */
|
---|
[333] | 358 | void NamedObjMgr::GetCurrentDir(string & dirname)
|
---|
| 359 | {
|
---|
| 360 | dirname = *currDir;
|
---|
| 361 | }
|
---|
| 362 |
|
---|
| 363 | /* --Methode-- */
|
---|
| 364 | void NamedObjMgr::ListDirs(string & patt)
|
---|
| 365 | {
|
---|
| 366 | NObjDirList::iterator it;
|
---|
| 367 | string cn;
|
---|
| 368 | cout << "NamedObjMgr::ListDirs( " << patt << " ) " << endl;
|
---|
| 369 | int k = 0;
|
---|
| 370 | for(it= myDirs->begin(); it != myDirs->end(); it++) {
|
---|
| 371 | cn = (*it).first;
|
---|
| 372 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 373 | k++;
|
---|
[344] | 374 | cout << k << "- " << (*it).first;
|
---|
| 375 | if ( (*it).second.lock ) cout << " Locked " ;
|
---|
| 376 | if ( (*it).second.keepold ) cout << " KeepOld " ;
|
---|
| 377 | cout << " (Id= " << (*it).second.id << " NbObj= " << (*it).second.nobj << ")" << endl;
|
---|
| 378 |
|
---|
[333] | 379 | }
|
---|
| 380 | }
|
---|
| 381 |
|
---|
| 382 | /* --Methode-- */
|
---|
| 383 | void NamedObjMgr::GetDirList(string & patt, vector<string>& lstd)
|
---|
| 384 | {
|
---|
| 385 | NObjDirList::iterator it;
|
---|
| 386 | string cn;
|
---|
| 387 | for(it= myDirs->begin(); it != myDirs->end(); it++) {
|
---|
| 388 | cn = (*it).first;
|
---|
| 389 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 390 | lstd.push_back(cn);
|
---|
| 391 | }
|
---|
| 392 | }
|
---|
| 393 |
|
---|
| 394 | /* --Methode-- */
|
---|
[368] | 395 | void NamedObjMgr::CleanDir(string & dirname)
|
---|
[331] | 396 | {
|
---|
[368] | 397 | if ( !CheckDirName(dirname) ) {
|
---|
| 398 | cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
[380] | 399 | // return(false); $CHECK$ illegal return value in void function
|
---|
[368] | 400 | }
|
---|
| 401 | NObjDirList::iterator itr = myDirs->find(dirname);
|
---|
| 402 | if (itr == myDirs->end()) {
|
---|
| 403 | cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - No such directory !" << endl;
|
---|
[380] | 404 | // return(false); $CHECK$ illegal return value in void function
|
---|
[368] | 405 | }
|
---|
[331] | 406 |
|
---|
[368] | 407 | int did = (*itr).second.id;
|
---|
| 408 | NObjList::iterator it;
|
---|
| 409 | list<int>::iterator iwr;
|
---|
| 410 | bool nodisp = true;
|
---|
| 411 | list<string> odel;
|
---|
| 412 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 413 | if ((*it).second.dirid != did) continue;
|
---|
| 414 | nodisp = true;
|
---|
| 415 | if (myImgApp)
|
---|
| 416 | for(iwr=(*it).second.wrsid.begin(); iwr != (*it).second.wrsid.end(); iwr++)
|
---|
| 417 | if (myImgApp->CheckWRsId(*iwr)) { nodisp = false; break; }
|
---|
| 418 | if (nodisp) odel.push_back((*it).first);
|
---|
| 419 | }
|
---|
| 420 | list<string>::iterator ii;
|
---|
| 421 | for(ii=odel.begin(); ii != odel.end(); ii++) DelObj(*ii,true);
|
---|
[685] | 422 | if (myImgApp)
|
---|
| 423 | (myImgApp->ObjMgrW())->UpdateList(did);
|
---|
[331] | 424 | }
|
---|
| 425 |
|
---|
[333] | 426 |
|
---|
[368] | 427 |
|
---|
[165] | 428 | //++
|
---|
| 429 | // Titre Gestion de la liste des objets
|
---|
| 430 | //--
|
---|
| 431 | //++
|
---|
[295] | 432 | // void AddObj(AnyDataObj* obj, string& nom)
|
---|
[165] | 433 | // Ajoute l'objet "obj" à la liste, identifié par "nom".
|
---|
| 434 | // Si un objet de même nom existe, l'ancien objet est renommé en concaténant
|
---|
| 435 | // un numéro à son nom.
|
---|
| 436 | // void DelObj(string const& nom, bool fgd=true)
|
---|
| 437 | // Supprime l'objet "nom" de la liste. L'objet est détruit si "fgd==true" ("delete obj")
|
---|
| 438 | // void DelObjects(string const& patt, bool fgd=true)
|
---|
| 439 | // Supprime l'ensemble des objets dont le nom correspond au patron "patt".
|
---|
| 440 | // Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
|
---|
[295] | 441 | // AnyDataObj* GetObj(string const& nom)
|
---|
[165] | 442 | // Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est
|
---|
| 443 | // pas dans la liste.
|
---|
| 444 | // void RenameObj(string const& nom, string& nomnew)
|
---|
| 445 | // Change le nom d'un objet dans la liste.
|
---|
[463] | 446 | // void CopyObj(string const& nom, string& nomcp)
|
---|
| 447 | // Copy l'objet "nom" de la liste dans l'objet "nomcp" de la liste.
|
---|
[165] | 448 | //--
|
---|
| 449 |
|
---|
| 450 |
|
---|
| 451 | /* --Methode-- */
|
---|
[344] | 452 | bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
|
---|
[165] | 453 | {
|
---|
| 454 |
|
---|
[344] | 455 | if (obj == NULL) return(false);
|
---|
[333] | 456 | // On verifie si l'objet est deja dans la liste
|
---|
| 457 | NObjList::iterator it;
|
---|
| 458 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 459 | if ((*it).second.obj == obj) {
|
---|
| 460 | cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl;
|
---|
[344] | 461 | return(false);
|
---|
[333] | 462 | }
|
---|
| 463 | }
|
---|
| 464 | string nobj;
|
---|
| 465 | string nrep;
|
---|
| 466 | char buff[32];
|
---|
| 467 | int did = ParseObjectName(nom, nrep, nobj);
|
---|
| 468 | if (did == 0) {
|
---|
| 469 | if (!crd) {
|
---|
| 470 | cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl;
|
---|
[344] | 471 | return(false);
|
---|
[333] | 472 | }
|
---|
| 473 | else { CreateDir(nrep); did = myDirId; }
|
---|
| 474 | }
|
---|
[165] | 475 |
|
---|
[466] | 476 | // Si c'est le repertoire /autoc, on nettoie
|
---|
| 477 | if (nrep == "autoc") {
|
---|
[368] | 478 | CleanDir(nrep);
|
---|
| 479 | }
|
---|
| 480 |
|
---|
[165] | 481 | myNObj++;
|
---|
[333] | 482 | if (nobj.length() < 1) {
|
---|
| 483 | sprintf(buff,"O%d", myNObj);
|
---|
| 484 | nobj = buff;
|
---|
| 485 | }
|
---|
| 486 |
|
---|
| 487 | nom = '/' + nrep + '/' + nobj;
|
---|
[344] | 488 | NObjDirList::iterator itr = myDirs->find(nrep);
|
---|
| 489 | if ((*itr).second.lock) {
|
---|
| 490 | cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl;
|
---|
| 491 | return(false);
|
---|
| 492 | }
|
---|
[333] | 493 | it = myObjs->find(nom);
|
---|
[165] | 494 | if (it != myObjs->end()) { // l'objet existe deja
|
---|
[466] | 495 | if (nrep == "autoc") { // Dans /autoc , on garde les objets affiches, donc del. par Clean
|
---|
[368] | 496 | sprintf(buff, "%d", (*it).second.oid);
|
---|
[466] | 497 | string nomnew = "/autoc/" + nobj + buff;
|
---|
[368] | 498 | RenameObj(nom, nomnew);
|
---|
| 499 | }
|
---|
| 500 | else if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
|
---|
[333] | 501 | string on,od;
|
---|
[335] | 502 | // ParseObjectName((*it).first, od, on);
|
---|
[333] | 503 | sprintf(buff, "%d", (*it).second.oid);
|
---|
[335] | 504 | string nomnew = "/old/" + nobj + buff;
|
---|
[333] | 505 | RenameObj(nom, nomnew);
|
---|
| 506 | }
|
---|
[344] | 507 | else { // Sinon, on remplace l'objet
|
---|
| 508 | cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
|
---|
| 509 | DelObj(nom);
|
---|
| 510 | }
|
---|
[165] | 511 | }
|
---|
| 512 |
|
---|
| 513 | nobj_item no;
|
---|
| 514 | no.obj = obj;
|
---|
[295] | 515 | no.obja = servnobjm->GetAdapter(obj); // L'adaptateur
|
---|
[333] | 516 | no.oid = myNObj;
|
---|
| 517 | no.dirid = did;
|
---|
[331] | 518 | (*myObjs)[nom] = no;
|
---|
[333] | 519 |
|
---|
| 520 | (*itr).second.nobj++;
|
---|
| 521 |
|
---|
[685] | 522 | if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
|
---|
| 523 | string oln = nobj + " (T= " + typeid(*obj).name() + ")" ;
|
---|
| 524 | (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
|
---|
| 525 | }
|
---|
[449] | 526 | if (verbeux) cout << "NamedObjMgr::AddObj() Object " << nom << " ( "
|
---|
[295] | 527 | << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;
|
---|
[344] | 528 | return(true);
|
---|
[165] | 529 | }
|
---|
| 530 |
|
---|
[1224] | 531 | bool NamedObjMgr::AddObj(AnyDataObj& obj, string & nom, bool crd)
|
---|
| 532 | {
|
---|
| 533 | NObjMgrAdapter* adap = GetServiceObj()->GetAdapter(&obj);
|
---|
| 534 | if (adap == NULL) {
|
---|
| 535 | cout << "NamedObjMgr::AddObj() No Adapter ! " << nom << endl;
|
---|
| 536 | return(false);
|
---|
| 537 | }
|
---|
| 538 | AnyDataObj * cloneobj = adap->CloneDataObj();
|
---|
| 539 | delete adap;
|
---|
| 540 | if (cloneobj == NULL) {
|
---|
| 541 | cout << "NamedObjMgr::AddObj() Pb cloning object ! " << nom << endl;
|
---|
| 542 | return(false);
|
---|
| 543 | }
|
---|
| 544 | return ( AddObj(cloneobj , nom, crd) );
|
---|
| 545 | }
|
---|
| 546 |
|
---|
[165] | 547 | /* --Methode-- */
|
---|
[344] | 548 | bool NamedObjMgr::RenameObj(string & nom, string& nomnew)
|
---|
[165] | 549 | {
|
---|
[333] | 550 | string n1,r1,n2,r2;
|
---|
[344] | 551 | int dids = ParseObjectName(nom, r1, n1);
|
---|
| 552 | NObjDirList::iterator itr1 = myDirs->find(r1);
|
---|
[333] | 553 | int did = ParseObjectName(nomnew, r2, n2);
|
---|
[344] | 554 | NObjDirList::iterator itr2 = myDirs->find(r2);
|
---|
| 555 |
|
---|
[333] | 556 | if (did == 0) {
|
---|
| 557 | cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
|
---|
[344] | 558 | return(false);
|
---|
[333] | 559 | }
|
---|
| 560 | nom = '/' + r1 + '/' + n1;
|
---|
| 561 | nomnew = '/' + r2 + '/' + n2;
|
---|
| 562 | NObjList::iterator it1 = myObjs->find(nom);
|
---|
| 563 | if (it1 == myObjs->end()) {
|
---|
| 564 | cout << "NamedObjMgr::RenameObj() Error - No " << nom << " object !" << endl;
|
---|
[344] | 565 | return(false);
|
---|
[333] | 566 | }
|
---|
| 567 | NObjList::iterator it2 = myObjs->find(nomnew);
|
---|
| 568 | if (it2 != myObjs->end()) {
|
---|
| 569 | cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl;
|
---|
[344] | 570 | return(false);
|
---|
[333] | 571 | }
|
---|
| 572 |
|
---|
[344] | 573 | if ( (*itr1).second.lock || (*itr2).second.lock ) {
|
---|
| 574 | cout << "NamedObjMgr::RenameObj() Error - Source or destination directory locked !"
|
---|
| 575 | << endl;
|
---|
| 576 | return(false);
|
---|
| 577 | }
|
---|
| 578 |
|
---|
| 579 |
|
---|
[333] | 580 | nobj_item no = (*it1).second;
|
---|
| 581 | no.dirid = did;
|
---|
| 582 | myObjs->erase(it1);
|
---|
| 583 | NObjDirList::iterator itr = myDirs->find(r1);
|
---|
| 584 | (*itr).second.nobj--;
|
---|
| 585 | (*myObjs)[nomnew] = no;
|
---|
| 586 | itr = myDirs->find(r2);
|
---|
| 587 | (*itr).second.nobj++;
|
---|
[685] | 588 |
|
---|
| 589 | if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
|
---|
| 590 | (myImgApp->ObjMgrW())->DelObjList(dids, no.oid);
|
---|
| 591 | string oln = n2 + " (T= " + typeid(*(no.obj)).name() + ")" ;
|
---|
| 592 | (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
|
---|
| 593 | }
|
---|
[449] | 594 | if (verbeux)
|
---|
| 595 | cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
|
---|
[344] | 596 | return(true);
|
---|
[331] | 597 | }
|
---|
| 598 |
|
---|
| 599 | /* --Methode-- */
|
---|
[463] | 600 | bool NamedObjMgr::CopyObj(string & nom, string& nomcp)
|
---|
| 601 | {
|
---|
| 602 | if(nomcp.length()<=0)
|
---|
| 603 | {cout<<"NamedObjMgr::CopyObj() Error, copied obj name "<<nomcp<<" not valid"<<endl;
|
---|
| 604 | return(false);}
|
---|
| 605 | NObjMgrAdapter* obnom = GetObjAdapter(nom);
|
---|
| 606 | if(obnom==NULL)
|
---|
| 607 | {cout<<"NamedObjMgr::CopyObj() Error - No "<<nom<<" object !"<<endl;
|
---|
| 608 | return(false);}
|
---|
[1165] | 609 | AnyDataObj* obnomcp = obnom->CloneDataObj();
|
---|
[463] | 610 | if(obnomcp==NULL) return(false);
|
---|
| 611 | if(! AddObj(obnomcp,nomcp) ) {delete obnomcp; return(false);}
|
---|
| 612 | return true;
|
---|
| 613 | }
|
---|
| 614 |
|
---|
[1164] | 615 |
|
---|
[463] | 616 | /* --Methode-- */
|
---|
[344] | 617 | bool NamedObjMgr::DelObj(string & nom, bool fgd)
|
---|
[331] | 618 | {
|
---|
[333] | 619 | string n1,r1;
|
---|
[685] | 620 | int did = ParseObjectName(nom, r1, n1);
|
---|
[333] | 621 | nom = '/' + r1 + '/' + n1;
|
---|
[165] | 622 | NObjList::iterator it = myObjs->find(nom);
|
---|
[344] | 623 | if (it == myObjs->end()) return(false);
|
---|
| 624 | NObjDirList::iterator itr = myDirs->find(r1);
|
---|
| 625 | if ( (*itr).second.lock ) {
|
---|
| 626 | cout << "NamedObjMgr::DelObj() Error - Locked directory " << r1 << endl;
|
---|
| 627 | return(false);
|
---|
| 628 | }
|
---|
[165] | 629 | list<int>::iterator ii;
|
---|
| 630 | if (myImgApp) {
|
---|
| 631 | //DBG cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl;
|
---|
| 632 | for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++)
|
---|
| 633 | myImgApp->DelWRsId((*ii));
|
---|
| 634 | }
|
---|
[314] | 635 | delete (*it).second.obja; // destruction de l'adaptateur
|
---|
[165] | 636 | if (fgd) delete (*it).second.obj;
|
---|
[333] | 637 |
|
---|
[685] | 638 | if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
|
---|
| 639 | int olid = (*it).second.oid;
|
---|
| 640 | (myImgApp->ObjMgrW())->DelObjList(did, olid);
|
---|
| 641 | }
|
---|
[165] | 642 | myObjs->erase(it);
|
---|
[333] | 643 | (*itr).second.nobj--;
|
---|
| 644 |
|
---|
[685] | 645 |
|
---|
[449] | 646 | if (!verbeux) return(true);
|
---|
[165] | 647 | if (fgd) cout << "NamedObjMgr::DelObj() Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
|
---|
| 648 | else cout << "NamedObjMgr::DelObj() Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
|
---|
[344] | 649 | return(true);
|
---|
[165] | 650 | }
|
---|
| 651 |
|
---|
| 652 | /* --Methode-- */
|
---|
[344] | 653 | bool NamedObjMgr::DelObj_Id(int oid)
|
---|
[165] | 654 | {
|
---|
[333] | 655 | NObjList::iterator it;
|
---|
| 656 | string nom;
|
---|
| 657 | bool of = false;
|
---|
| 658 | for(it = myObjs->begin(); it != myObjs->end(); it++)
|
---|
| 659 | if ( (*it).second.oid == oid ) {
|
---|
| 660 | of = true; nom = (*it).first;
|
---|
| 661 | break;
|
---|
| 662 | }
|
---|
[344] | 663 | if (of) return(DelObj(nom, true));
|
---|
| 664 | else return(false);
|
---|
[331] | 665 | }
|
---|
| 666 |
|
---|
| 667 | /* --Methode-- */
|
---|
| 668 | void NamedObjMgr::DelObjects(string & patt, bool fgd)
|
---|
| 669 | {
|
---|
[333] | 670 | string n1,r1;
|
---|
| 671 | ParseObjectName(patt, r1, n1);
|
---|
| 672 | patt = '/' + r1 + '/' + n1;
|
---|
[165] | 673 | NObjList::iterator it;
|
---|
| 674 | list<string> odel;
|
---|
| 675 | string cn;
|
---|
| 676 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 677 | cn = (*it).first;
|
---|
| 678 | if (csh_parse(cn.c_str(), patt.c_str()) != 0) odel.push_back(cn);
|
---|
| 679 | }
|
---|
| 680 | list<string>::iterator ii;
|
---|
| 681 | for(ii=odel.begin(); ii != odel.end(); ii++) DelObj(*ii, fgd);
|
---|
| 682 | }
|
---|
| 683 |
|
---|
| 684 | /* --Methode-- */
|
---|
[331] | 685 | AnyDataObj* NamedObjMgr::GetObj(string & nom)
|
---|
[165] | 686 | {
|
---|
[333] | 687 | string n1,r1;
|
---|
| 688 | ParseObjectName(nom, r1, n1);
|
---|
| 689 | nom = '/' + r1 + '/' + n1;
|
---|
[165] | 690 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 691 | if (it == myObjs->end()) return(NULL);
|
---|
| 692 | return((*it).second.obj);
|
---|
| 693 | }
|
---|
| 694 |
|
---|
| 695 | /* --Methode-- */
|
---|
[331] | 696 | NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
|
---|
[295] | 697 | {
|
---|
[333] | 698 | string n1,r1;
|
---|
| 699 | ParseObjectName(nom, r1, n1);
|
---|
| 700 | nom = '/' + r1 + '/' + n1;
|
---|
[295] | 701 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 702 | if (it == myObjs->end()) return(NULL);
|
---|
| 703 | return((*it).second.obja);
|
---|
| 704 | }
|
---|
| 705 |
|
---|
| 706 | /* --Methode-- */
|
---|
[331] | 707 | void NamedObjMgr::ListObjs(string & patt)
|
---|
[165] | 708 | {
|
---|
[331] | 709 | int k;
|
---|
| 710 | AnyDataObj* obj=NULL;
|
---|
| 711 | string ctyp;
|
---|
| 712 | char strg[256];
|
---|
| 713 |
|
---|
[333] | 714 | string n1,r1;
|
---|
| 715 | ParseObjectName(patt, r1, n1);
|
---|
| 716 | patt = '/' + r1 + '/' + n1;
|
---|
| 717 | cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
|
---|
[331] | 718 | NObjList::iterator it; k = 0;
|
---|
[333] | 719 | string cn;
|
---|
[331] | 720 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
[333] | 721 | cn = (*it).first;
|
---|
| 722 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
[331] | 723 | obj = (*it).second.obj;
|
---|
| 724 | ctyp = typeid(*obj).name();
|
---|
| 725 | sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str());
|
---|
| 726 | ctyp = strg;
|
---|
| 727 | cout << ctyp << "\n" ;
|
---|
| 728 | k++;
|
---|
| 729 | }
|
---|
| 730 | cout << endl;
|
---|
[165] | 731 | return;
|
---|
| 732 | }
|
---|
| 733 |
|
---|
| 734 | /* --Methode-- */
|
---|
[333] | 735 | void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
|
---|
[165] | 736 | {
|
---|
[333] | 737 | string n1,r1;
|
---|
| 738 | if (patt.length() < 1) return;
|
---|
| 739 | bool fgr = (patt[0] == '/') ? true : false;
|
---|
| 740 | ParseObjectName(patt, r1, n1);
|
---|
| 741 | patt = '/' + r1 + '/' + n1;
|
---|
| 742 | NObjList::iterator it;
|
---|
| 743 | string cn;
|
---|
| 744 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 745 | cn = (*it).first;
|
---|
| 746 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 747 | if (fgr) lst.push_back(cn);
|
---|
| 748 | else {
|
---|
| 749 | ParseObjectName(cn, r1, n1);
|
---|
| 750 | lst.push_back(n1);
|
---|
| 751 | }
|
---|
| 752 | }
|
---|
[165] | 753 | }
|
---|
| 754 |
|
---|
| 755 | //++
|
---|
| 756 | // Titre Entrées-Sorties (I/O) sur les objets
|
---|
| 757 | //--
|
---|
| 758 | //++
|
---|
| 759 | // void ReadObj(PInPersist& s, int num=-1)
|
---|
| 760 | // Lit l'objet à partir avec le tag numéro "num" dans le flot "PInPersist s"
|
---|
| 761 | // et l'ajoute à la liste. Si "num" est négatif, tous les objets présents
|
---|
| 762 | // sur le flot "s" sont créés et ajoutés à la liste.
|
---|
| 763 | // void ReadObj(string const & nomppf, string nobj="")
|
---|
| 764 | // Lit le premier objet à partir du fichier PPF "nomppf". L'objet est ajouté
|
---|
| 765 | // à la liste avec le nom "nobj". Si "nobj" est une chaîne vide, un nom est
|
---|
| 766 | // composé à partir du nom de fichier.
|
---|
| 767 | //--
|
---|
| 768 |
|
---|
| 769 | /* --Methode-- */
|
---|
[331] | 770 | void NamedObjMgr::ReadObj(string const & flnm, string & nobj)
|
---|
[165] | 771 | {
|
---|
[495] | 772 | PPersist* ppobj=NULL;
|
---|
[165] | 773 | bool ok = true;
|
---|
[495] | 774 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 775 | TRY{
|
---|
| 776 | PInPersist pis(flnm);
|
---|
[495] | 777 | ppobj = PPersistMgr::ReadObject(pis);
|
---|
| 778 | if (ppobj == NULL) ok = false;
|
---|
[165] | 779 | } CATCH(merr)
|
---|
| 780 | { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n",
|
---|
| 781 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
[495] | 782 | #else
|
---|
| 783 | try {
|
---|
| 784 | PInPersist pis(flnm);
|
---|
| 785 | ppobj = pis.ReadObject();
|
---|
| 786 | }
|
---|
| 787 | catch (IOExc iox) {
|
---|
| 788 | cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 789 | ok = false;
|
---|
| 790 | }
|
---|
| 791 | #endif
|
---|
[165] | 792 | if (!ok) return;
|
---|
| 793 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
---|
[495] | 794 | AddObj(ppobj->DataObj(), nobj, true);
|
---|
[685] | 795 | cout << "NamedObjMgr::ReadObj(...) object " << nobj << " read from file " << endl;
|
---|
[165] | 796 | return;
|
---|
| 797 | }
|
---|
| 798 |
|
---|
| 799 | /* --Methode-- */
|
---|
| 800 | void NamedObjMgr::ReadObj(PInPersist& s, int num)
|
---|
| 801 | {
|
---|
[380] | 802 | int_4 i, cid, key, ln; // $CHECK$ int -> int_4 a cause de TagKey
|
---|
[165] | 803 | int n0, n1;
|
---|
| 804 | bool ok = true;
|
---|
| 805 | PPersist* obj=NULL;
|
---|
| 806 | string nom;
|
---|
| 807 |
|
---|
[449] | 808 | int nread = 0;
|
---|
[165] | 809 | if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
|
---|
| 810 | if (num >= 0) {
|
---|
[495] | 811 | cerr << "NamedObjMgr::ReadObj(PInPersist, " << num << " Error! NbTags ="
|
---|
| 812 | << s.NbTags() << endl;
|
---|
[165] | 813 | return;
|
---|
| 814 | }
|
---|
[495] | 815 |
|
---|
| 816 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 817 | TRY {
|
---|
| 818 | obj = PPersistMgr::ReadObject(s);
|
---|
| 819 | if (obj == NULL) ok = false;
|
---|
| 820 | } CATCH(merr) {
|
---|
| 821 | printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 822 | ok = false;
|
---|
| 823 | } ENDTRY;
|
---|
[495] | 824 | #else
|
---|
| 825 | try {
|
---|
| 826 | obj = s.ReadObject();
|
---|
| 827 | }
|
---|
| 828 | catch (IOExc iox) {
|
---|
| 829 | cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 830 | ok = false;
|
---|
| 831 | }
|
---|
| 832 | #endif
|
---|
| 833 |
|
---|
[165] | 834 | if (!ok) return;
|
---|
| 835 | nom = "";
|
---|
[295] | 836 | AddObj(obj->DataObj(), nom);
|
---|
[449] | 837 | nread++;
|
---|
[165] | 838 | }
|
---|
| 839 |
|
---|
| 840 | if (num < 0) { n0 = 0; n1 = s.NbTags(); }
|
---|
| 841 | else { n0 = num; n1 = num+1; }
|
---|
| 842 | for(i=n0; i<n1; i++) {
|
---|
[495] | 843 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 844 | key = s.TagKey(i, cid, ln);
|
---|
| 845 | if (ln <= 0) nom = "";
|
---|
| 846 | else nom = s.TagName(i);
|
---|
| 847 | s.GotoTag(i);
|
---|
| 848 | TRY {
|
---|
| 849 | obj = PPersistMgr::ReadObject(s);
|
---|
| 850 | if (obj == NULL) ok = false;
|
---|
| 851 | } CATCH(merr) {
|
---|
| 852 | printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 853 | ok = false;
|
---|
| 854 | } ENDTRY;
|
---|
[495] | 855 | #else
|
---|
| 856 | s.GotoTagNum(i);
|
---|
[584] | 857 | nom = s.GetTagName(i);
|
---|
[495] | 858 | try {
|
---|
| 859 | obj = s.ReadObject();
|
---|
| 860 | }
|
---|
| 861 | catch (IOExc iox) {
|
---|
| 862 | cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 863 | ok = false;
|
---|
| 864 | }
|
---|
| 865 | #endif
|
---|
[449] | 866 | if (ok) { AddObj(obj->DataObj(), nom, true); nread++; }
|
---|
[165] | 867 | }
|
---|
| 868 |
|
---|
[449] | 869 | cout << "NamedObjMgr::ReadObj(...) " << nread << " Objects read " << endl;
|
---|
[165] | 870 | return;
|
---|
| 871 | }
|
---|
| 872 | /* --Methode-- */
|
---|
| 873 | void NamedObjMgr::ReadAll(string const & flnm)
|
---|
| 874 | {
|
---|
| 875 | bool ok = true;
|
---|
| 876 | PPersist* obj=NULL;
|
---|
| 877 |
|
---|
| 878 | PInPersist* ppin;
|
---|
[495] | 879 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 880 | TRY{
|
---|
| 881 | ppin = new PInPersist(flnm);
|
---|
| 882 | if (ppin->NbTags() < 1) obj = PPersistMgr::ReadObject((*ppin));
|
---|
| 883 | else obj = NULL;
|
---|
| 884 | } CATCH(merr)
|
---|
| 885 | { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n",
|
---|
| 886 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
[495] | 887 | #else
|
---|
| 888 | try {
|
---|
| 889 | ppin = new PInPersist(flnm);
|
---|
| 890 | if (ppin->NbTags() < 1) obj = ppin->ReadObject();
|
---|
| 891 | else obj = NULL;
|
---|
| 892 | }
|
---|
| 893 | catch (IOExc iox) {
|
---|
| 894 | cerr << "NamedObjMgr::ReadAll()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 895 | ok = false;
|
---|
| 896 | }
|
---|
| 897 | #endif
|
---|
[165] | 898 | if (!ok) return;
|
---|
| 899 | if (obj) {
|
---|
| 900 | string nom = servnobjm->FileName2Name(flnm);
|
---|
[295] | 901 | AddObj(obj->DataObj(), nom);
|
---|
[165] | 902 | }
|
---|
| 903 | else ReadObj((*ppin), -1);
|
---|
| 904 | delete ppin;
|
---|
| 905 | return;
|
---|
| 906 | }
|
---|
| 907 |
|
---|
| 908 | /* --Methode-- */
|
---|
[331] | 909 | void NamedObjMgr::ReadFits(string const & flnm, string & nobj)
|
---|
[165] | 910 | {
|
---|
[709] | 911 | bool ok = false;
|
---|
[165] | 912 |
|
---|
[293] | 913 | #ifdef SANS_EVOLPLANCK
|
---|
[709] | 914 | RzImage* obj=NULL;
|
---|
[495] | 915 | TRY{
|
---|
[165] | 916 | obj = RzReadFits((char*)flnm.c_str());
|
---|
| 917 | if (obj == NULL) ok = false;
|
---|
[709] | 918 | else ok = true;
|
---|
[165] | 919 | } CATCH(merr) {
|
---|
| 920 | printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 921 | ok = false;
|
---|
| 922 | } ENDTRY;
|
---|
[709] | 923 |
|
---|
| 924 | if (ok && (obj != NULL)) {
|
---|
[165] | 925 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
---|
[295] | 926 | AddObj((AnyDataObj*)obj, nobj);
|
---|
[165] | 927 | }
|
---|
[1105] | 928 | #else
|
---|
| 929 | cerr << " NamedObjMgr::ReadFits() Vide ! A faire Reza ! " << endl;
|
---|
| 930 | #endif
|
---|
| 931 |
|
---|
[165] | 932 | return;
|
---|
| 933 | }
|
---|
| 934 |
|
---|
| 935 |
|
---|
| 936 | static int key_for_write = 5000;
|
---|
| 937 | /* --Methode-- */
|
---|
[333] | 938 | void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
|
---|
[165] | 939 | {
|
---|
[333] | 940 | if (nom.length() < 1) return;
|
---|
| 941 | string nob,rep;
|
---|
| 942 | ParseObjectName(nom, rep, nob);
|
---|
| 943 | nom = '/' + rep + '/' + nob;
|
---|
[295] | 944 | NObjMgrAdapter* obja=NULL;
|
---|
[333] | 945 | string nomf = (keeppath) ? nom : nob;
|
---|
[295] | 946 | obja = GetObjAdapter(nom);
|
---|
| 947 | if (obja == NULL) return;
|
---|
[165] | 948 | printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
|
---|
[295] | 949 | nom.c_str(), typeid(*(obja->GetDataObj())).name());
|
---|
[333] | 950 | obja->SavePPF(s, nomf);
|
---|
[165] | 951 | return;
|
---|
| 952 | }
|
---|
| 953 |
|
---|
| 954 | /* --Methode-- */
|
---|
[333] | 955 | void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
|
---|
| 956 | {
|
---|
| 957 | string n1,r1;
|
---|
| 958 | if (patt.length() < 1) return;
|
---|
| 959 | bool keeppath = (patt[0] == '/') ? true : false;
|
---|
| 960 | ParseObjectName(patt, r1, n1);
|
---|
| 961 | patt = '/' + r1 + '/' + n1;
|
---|
| 962 |
|
---|
| 963 | bool ok = true;
|
---|
| 964 | POutPersist* pout;
|
---|
[495] | 965 | #ifdef SANS_EVOLPLANCK
|
---|
[333] | 966 | TRY{
|
---|
| 967 | pout = new POutPersist(flnm);
|
---|
| 968 | } CATCH(merr)
|
---|
| 969 | { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n",
|
---|
| 970 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
[495] | 971 | #else
|
---|
| 972 | try {
|
---|
| 973 | pout = new POutPersist(flnm);
|
---|
| 974 | }
|
---|
| 975 | catch (IOExc iox) {
|
---|
| 976 | cerr << "NamedObjMgr::SaveObjects()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 977 | ok = false;
|
---|
| 978 | }
|
---|
| 979 | #endif
|
---|
[333] | 980 | if (!ok) return;
|
---|
| 981 | NObjList::iterator it;
|
---|
| 982 | string cn;
|
---|
| 983 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 984 | cn = (*it).first;
|
---|
| 985 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 986 | SaveObj(cn, (*pout), keeppath);
|
---|
| 987 | }
|
---|
| 988 | delete pout;
|
---|
| 989 | return;
|
---|
| 990 | }
|
---|
| 991 |
|
---|
| 992 | /* --Methode-- */
|
---|
[165] | 993 | void NamedObjMgr::SaveAll(string const& flnm)
|
---|
| 994 | {
|
---|
| 995 | bool ok = true;
|
---|
| 996 |
|
---|
| 997 | POutPersist* pout;
|
---|
[495] | 998 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 999 | TRY{
|
---|
| 1000 | pout = new POutPersist(flnm);
|
---|
| 1001 | } CATCH(merr)
|
---|
| 1002 | { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n",
|
---|
| 1003 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
[495] | 1004 | #else
|
---|
| 1005 | try {
|
---|
| 1006 | pout = new POutPersist(flnm);
|
---|
| 1007 | }
|
---|
| 1008 | catch (IOExc iox) {
|
---|
| 1009 | cerr << "NamedObjMgr::SaveAll()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 1010 | ok = false;
|
---|
| 1011 | }
|
---|
| 1012 | #endif
|
---|
[165] | 1013 | if (!ok) return;
|
---|
[332] | 1014 | NObjList::iterator it;
|
---|
| 1015 | string no;
|
---|
| 1016 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 1017 | no = (*it).first;
|
---|
[333] | 1018 | SaveObj(no, (*pout), true);
|
---|
[332] | 1019 | }
|
---|
[165] | 1020 | delete pout;
|
---|
| 1021 | return;
|
---|
| 1022 | }
|
---|
| 1023 |
|
---|
| 1024 | /* --Methode-- */
|
---|
[331] | 1025 | void NamedObjMgr::SaveFits(string& nom, string const & flnm)
|
---|
[165] | 1026 | {
|
---|
[295] | 1027 | NObjMgrAdapter* obja=NULL;
|
---|
| 1028 | obja = GetObjAdapter(nom);
|
---|
| 1029 | if (obja == NULL) return;
|
---|
| 1030 | obja->SaveFits(flnm);
|
---|
[293] | 1031 | return;
|
---|
[165] | 1032 | }
|
---|
| 1033 |
|
---|
| 1034 |
|
---|
| 1035 |
|
---|
| 1036 | /* --Methode-- */
|
---|
[331] | 1037 | void NamedObjMgr::PrintObj(string& nom)
|
---|
[165] | 1038 | {
|
---|
[295] | 1039 | NObjMgrAdapter* obja=NULL;
|
---|
| 1040 | obja = GetObjAdapter(nom);
|
---|
| 1041 | if (obja == NULL) return;
|
---|
[594] | 1042 | AnyDataObj* ob = obja->GetDataObj();
|
---|
| 1043 | if (ob == NULL) {
|
---|
| 1044 | cerr << "NamedObjMgr::PrintObj() / Error - NULL object ! in " << nom << endl;
|
---|
| 1045 | return;
|
---|
| 1046 | }
|
---|
| 1047 | string ctyp = typeid(*ob).name();
|
---|
[295] | 1048 | cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
|
---|
| 1049 | obja->Print(cout);
|
---|
[165] | 1050 |
|
---|
| 1051 | return;
|
---|
| 1052 | }
|
---|
| 1053 |
|
---|
| 1054 | /* --Methode-- */
|
---|
[331] | 1055 | void NamedObjMgr::DisplayObj(string& nom, string dopt)
|
---|
[165] | 1056 | {
|
---|
[295] | 1057 | NObjMgrAdapter* obja=NULL;
|
---|
| 1058 | obja = GetObjAdapter(nom);
|
---|
| 1059 | if (obja == NULL) {
|
---|
[594] | 1060 | cout << "NamedObjMgr::DisplayObj() Error , No object with name " << nom << endl;
|
---|
[165] | 1061 | return;
|
---|
| 1062 | }
|
---|
[594] | 1063 | if (obja->GetDataObj() == NULL) {
|
---|
| 1064 | cerr << "NamedObjMgr::DisplayObj() / Error - NULL object ! in " << nom << endl;
|
---|
| 1065 | return;
|
---|
| 1066 | }
|
---|
[165] | 1067 | if (!myImgApp) return;
|
---|
| 1068 |
|
---|
[295] | 1069 | PIDrawer * dr = NULL;
|
---|
| 1070 | P2DArrayAdapter* arr = NULL;
|
---|
| 1071 | dr = obja->GetDrawer(dopt);
|
---|
| 1072 | if (!dr) arr = obja->Get2DArray(dopt);
|
---|
[165] | 1073 |
|
---|
[295] | 1074 | if (!dr && !arr) {
|
---|
| 1075 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
[594] | 1076 | cout << "NamedObjMgr::DisplayObj() Error , No display for " << ctyp << endl;
|
---|
[295] | 1077 | return;
|
---|
| 1078 | }
|
---|
| 1079 |
|
---|
[165] | 1080 | int wrsid = 0;
|
---|
| 1081 | bool fgsr = true;
|
---|
| 1082 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 1083 |
|
---|
[344] | 1084 | string n1,r1;
|
---|
| 1085 | ParseObjectName(nom, r1, n1);
|
---|
| 1086 |
|
---|
[295] | 1087 | if (dr) {
|
---|
| 1088 | PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
|
---|
[344] | 1089 | if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt);
|
---|
| 1090 | else wrsid = myImgApp->DispScDrawer( dr, n1, opt);
|
---|
[295] | 1091 | }
|
---|
[344] | 1092 | else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt);
|
---|
[165] | 1093 |
|
---|
[295] | 1094 | if(wrsid != 0) {
|
---|
| 1095 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1096 | if (it == myObjs->end()) return;
|
---|
| 1097 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1098 | }
|
---|
| 1099 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 1100 | return;
|
---|
| 1101 | }
|
---|
[165] | 1102 |
|
---|
[295] | 1103 | /* --Methode-- */
|
---|
[331] | 1104 | void NamedObjMgr::DisplayImage(string& nom, string dopt)
|
---|
[295] | 1105 | {
|
---|
| 1106 | NObjMgrAdapter* obja=NULL;
|
---|
| 1107 | obja = GetObjAdapter(nom);
|
---|
| 1108 | if (obja == NULL) {
|
---|
[449] | 1109 | cout << "NamedObjMgr::DisplayImage() Error , No such object " << nom << endl;
|
---|
[295] | 1110 | return;
|
---|
| 1111 | }
|
---|
[594] | 1112 | if (obja->GetDataObj() == NULL) {
|
---|
| 1113 | cerr << "NamedObjMgr::DisplayImage() / Error - NULL object ! in " << nom << endl;
|
---|
| 1114 | return;
|
---|
| 1115 | }
|
---|
[295] | 1116 | if (!myImgApp) return;
|
---|
| 1117 |
|
---|
| 1118 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
---|
[165] | 1119 |
|
---|
[295] | 1120 | if (!arr) {
|
---|
| 1121 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
[449] | 1122 | cout << "NamedObjMgr::DisplayImage() Error , Not supported for " << ctyp << endl;
|
---|
[295] | 1123 | return;
|
---|
| 1124 | }
|
---|
[165] | 1125 |
|
---|
[344] | 1126 | string n1,r1;
|
---|
| 1127 | ParseObjectName(nom, r1, n1);
|
---|
| 1128 |
|
---|
[295] | 1129 | int wrsid = 0;
|
---|
| 1130 | bool fgsr = true;
|
---|
| 1131 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
[344] | 1132 | wrsid = myImgApp->DispImage(arr, n1, opt);
|
---|
[165] | 1133 |
|
---|
[295] | 1134 | if(wrsid != 0) {
|
---|
| 1135 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1136 | if (it == myObjs->end()) return;
|
---|
| 1137 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1138 | }
|
---|
| 1139 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 1140 | return;
|
---|
| 1141 | }
|
---|
| 1142 | /* --Methode-- */
|
---|
[331] | 1143 | void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
|
---|
[295] | 1144 | {
|
---|
| 1145 | NObjMgrAdapter* obja=NULL;
|
---|
| 1146 | obja = GetObjAdapter(nom);
|
---|
| 1147 | if (obja == NULL) {
|
---|
[449] | 1148 | cout << "NamedObjMgr::DisplaySurf3D() Error , No such object " << nom << endl;
|
---|
[295] | 1149 | return;
|
---|
| 1150 | }
|
---|
[594] | 1151 | if (obja->GetDataObj() == NULL) {
|
---|
| 1152 | cerr << "NamedObjMgr::DisplaySurf3D() / Error - NULL object ! in " << nom << endl;
|
---|
| 1153 | return;
|
---|
| 1154 | }
|
---|
[295] | 1155 | if (!myImgApp) return;
|
---|
| 1156 |
|
---|
| 1157 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
---|
[165] | 1158 |
|
---|
[295] | 1159 | if (!arr) {
|
---|
| 1160 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
[449] | 1161 | cout << "NamedObjMgr::DisplaySurf3D() Error , Not supported " << ctyp << endl;
|
---|
[295] | 1162 | return;
|
---|
| 1163 | }
|
---|
[165] | 1164 |
|
---|
[295] | 1165 | if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
|
---|
| 1166 | cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
|
---|
[449] | 1167 | << "x" << arr->YSize() << ") too big (max=250x250)" << endl;
|
---|
[295] | 1168 | delete arr;
|
---|
| 1169 | return;
|
---|
[165] | 1170 | }
|
---|
| 1171 |
|
---|
[344] | 1172 | string n1,r1;
|
---|
| 1173 | ParseObjectName(nom, r1, n1);
|
---|
| 1174 |
|
---|
[295] | 1175 | int wrsid = 0;
|
---|
| 1176 | bool fgsr = true;
|
---|
| 1177 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 1178 | PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
|
---|
[344] | 1179 | wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt);
|
---|
[295] | 1180 | if(wrsid >= 0) {
|
---|
[165] | 1181 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1182 | if (it == myObjs->end()) return;
|
---|
| 1183 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1184 | }
|
---|
[295] | 1185 |
|
---|
| 1186 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 1187 | return;
|
---|
[165] | 1188 | }
|
---|
| 1189 |
|
---|
| 1190 | /* --Methode-- */
|
---|
[331] | 1191 | void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
|
---|
[486] | 1192 | string& erx, string& ery, string& erz, string& wt,
|
---|
| 1193 | string& label, string dopt, bool fg3d)
|
---|
[165] | 1194 | {
|
---|
[295] | 1195 | AnyDataObj* obj=GetObj(nom);
|
---|
[165] | 1196 | if (obj == NULL) {
|
---|
[449] | 1197 | cout << "NamedObjMgr::DisplayNT() Error , No such object " << nom << endl;
|
---|
[165] | 1198 | return;
|
---|
| 1199 | }
|
---|
| 1200 | if (!myImgApp) return;
|
---|
| 1201 |
|
---|
[326] | 1202 | NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
|
---|
| 1203 | if (nt == NULL) {
|
---|
| 1204 | // if (typeid(*obj) != typeid(NTupleInterface)) {
|
---|
[295] | 1205 | string ctyp = typeid(*obj).name();
|
---|
[449] | 1206 | cout << "NamedObjMgr::DisplayNT() Error , Object not an NTuple " << ctyp << endl;
|
---|
[165] | 1207 | return;
|
---|
| 1208 | }
|
---|
| 1209 |
|
---|
| 1210 | int wrsid = 0;
|
---|
| 1211 | bool fgsr = true;
|
---|
[326] | 1212 | dopt = "defline," + dopt;
|
---|
[165] | 1213 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 1214 |
|
---|
[344] | 1215 | string n1,r1;
|
---|
| 1216 | ParseObjectName(nom, r1, n1);
|
---|
| 1217 |
|
---|
[333] | 1218 | if ( fg3d && (nmz.length()>0) ) { // Display 3D
|
---|
[326] | 1219 | PINTuple3D* pin = new PINTuple3D(nt, false);
|
---|
[165] | 1220 | pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
|
---|
[486] | 1221 | pin->SelectWt(wt.c_str());
|
---|
| 1222 | pin->SelectLabel(label.c_str());
|
---|
[165] | 1223 | pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
|
---|
| 1224 | string titre = nmz + "%" + nmy + "%" + nmz;
|
---|
[344] | 1225 | wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre);
|
---|
[165] | 1226 | }
|
---|
| 1227 | else {
|
---|
[326] | 1228 | PINTuple* pin = new PINTuple(nt, false);
|
---|
[546] | 1229 | pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));
|
---|
[165] | 1230 | pin->SelectXY(nmx.c_str(), nmy.c_str());
|
---|
[486] | 1231 | pin->SelectWt(wt.c_str());
|
---|
| 1232 | pin->SelectLabel(label.c_str());
|
---|
[165] | 1233 | pin->SelectErrBar(erx.c_str(), ery.c_str());
|
---|
[333] | 1234 | string titre = nmy + "%" + nmx;
|
---|
[344] | 1235 | wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre);
|
---|
[165] | 1236 | }
|
---|
| 1237 |
|
---|
| 1238 | if(wrsid >= 0) {
|
---|
| 1239 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1240 | if (it == myObjs->end()) return;
|
---|
| 1241 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1242 | }
|
---|
| 1243 |
|
---|
| 1244 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 1245 | return;
|
---|
| 1246 | }
|
---|
| 1247 |
|
---|
[339] | 1248 | /* --Methode-- cmv 13/10/98 : Obsolete mais ne pas virer SVP */
|
---|
[331] | 1249 | void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
|
---|
[165] | 1250 | // Pour le display 2D ou 3D d'un ``GeneralFitData''.
|
---|
| 1251 | //| nom = nom de l'objet GeneralFitData a representer.
|
---|
| 1252 | //| numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
|
---|
| 1253 | //| numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
|
---|
| 1254 | //| Pour le display 2D, numvary="" string vide.
|
---|
| 1255 | //| err = qu'elles erreurs faut il representer ?
|
---|
| 1256 | //| - 2D : x y xy (display y=f(x))
|
---|
| 1257 | //| - 3D : x y z xy xz yz xzy (display z=f(x,y))
|
---|
| 1258 | //| Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
|
---|
| 1259 | //| les barres d'erreurs sont representees.
|
---|
| 1260 | //| opt = options generales pour le display.
|
---|
| 1261 | {
|
---|
[295] | 1262 | AnyDataObj* obj=GetObj(nom);
|
---|
[165] | 1263 | if(obj == NULL)
|
---|
[449] | 1264 | {cout << "NamedObjMgr::DisplayGFD() Error , No such object " << nom << endl;
|
---|
[165] | 1265 | return;}
|
---|
| 1266 | if(!myImgApp) return;
|
---|
[295] | 1267 | if(typeid(*obj) != typeid(GeneralFitData))
|
---|
| 1268 | {string ctyp = typeid(*obj).name();
|
---|
[449] | 1269 | cout<<"NamedObjMgr::DisplayGFD() Error , Object not a GeneralFitData "<<ctyp<<endl;
|
---|
[165] | 1270 | return;}
|
---|
| 1271 |
|
---|
| 1272 | // Decodage des options classiques
|
---|
| 1273 | bool fgsr = true;
|
---|
| 1274 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 1275 | // Decodage des erreurs a representer
|
---|
| 1276 | bool errx=false, erry=false, errz=false;
|
---|
| 1277 | if(err.length()>0) {
|
---|
| 1278 | for(int i=0;i<err.length();i++)
|
---|
| 1279 | if (err[i]=='x' || err[i]=='X') errx = true;
|
---|
| 1280 | else if(err[i]=='y' || err[i]=='Y') erry = true;
|
---|
| 1281 | else if(err[i]=='z' || err[i]=='Z') errz = true;
|
---|
| 1282 | }
|
---|
| 1283 | // Decodage des numeros de variables en abscisse
|
---|
[339] | 1284 | int numvx=-1, numvy=-1;
|
---|
| 1285 | if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
|
---|
| 1286 | if(numvary.length()>0) numvy = atoi(numvary.c_str());
|
---|
| 1287 |
|
---|
[344] | 1288 | string n1,r1;
|
---|
| 1289 | ParseObjectName(nom, r1, n1);
|
---|
| 1290 |
|
---|
[339] | 1291 | int wrsid = 0;
|
---|
| 1292 | if(numvy>=0) { // display 3D
|
---|
[165] | 1293 | PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
|
---|
| 1294 | pigfd->SelectXY(numvx,numvy);
|
---|
| 1295 | pigfd->SelectErrBar(errx,erry,errz);
|
---|
[344] | 1296 | wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt);
|
---|
[339] | 1297 | } else { // display 2D
|
---|
[165] | 1298 | PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
|
---|
| 1299 | pigfd->SelectX(numvx);
|
---|
| 1300 | pigfd->SelectErrBar(errx,erry);
|
---|
[344] | 1301 | wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt);
|
---|
[165] | 1302 | }
|
---|
| 1303 |
|
---|
| 1304 | if(wrsid >= 0) {
|
---|
| 1305 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1306 | if (it == myObjs->end()) return;
|
---|
| 1307 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1308 | }
|
---|
| 1309 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 1310 | return;
|
---|
| 1311 | }
|
---|
| 1312 |
|
---|
| 1313 | /* --Methode--
|
---|
[331] | 1314 | void NamedObjMgr::DisplayImage(string& nom, string dopt)
|
---|
[165] | 1315 | {
|
---|
| 1316 | cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
|
---|
| 1317 | }
|
---|
| 1318 | */
|
---|
| 1319 |
|
---|
| 1320 |
|
---|
| 1321 |
|
---|
| 1322 |
|
---|
| 1323 | /* --Methode-- */
|
---|
| 1324 | void NamedObjMgr::SetGraphicAttributes(string gratt)
|
---|
| 1325 | {
|
---|
| 1326 | bool fg = false;
|
---|
| 1327 | servnobjm->DecodeDispOption(gratt, fg);
|
---|
[546] | 1328 | Services2NObjMgr::SetDefaultStatsOption(Services2NObjMgr::GetStatsOption(gratt));
|
---|
[165] | 1329 | }
|
---|
[333] | 1330 |
|
---|
[165] | 1331 | /* --Methode-- */
|
---|
| 1332 | void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
|
---|
| 1333 | {
|
---|
| 1334 | if (!myImgApp) return;
|
---|
| 1335 | if (fcr) myImgApp->CreateGraphWin(nzx, nzy);
|
---|
| 1336 | else myImgApp->SetZone(nzx, nzy);
|
---|
| 1337 | }
|
---|
| 1338 |
|
---|
| 1339 | /* --Methode-- */
|
---|
[333] | 1340 | void NamedObjMgr::AddWRsId(string & nom, int wrsid)
|
---|
[165] | 1341 | {
|
---|
[333] | 1342 | if(wrsid != 0) {
|
---|
| 1343 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1344 | if (it == myObjs->end()) return;
|
---|
| 1345 | (*it).second.wrsid.push_back(wrsid);
|
---|
[295] | 1346 | }
|
---|
[165] | 1347 | return;
|
---|
| 1348 | }
|
---|
| 1349 |
|
---|
| 1350 | /* --Methode-- */
|
---|
[333] | 1351 | void NamedObjMgr::UpdateObjMgrWindow(int did)
|
---|
[165] | 1352 | {
|
---|
[333] | 1353 | if (!myImgApp) return;
|
---|
[685] | 1354 | (myImgApp->ObjMgrW())->ClearObjList();
|
---|
[165] | 1355 |
|
---|
[333] | 1356 | NObjList::iterator it;
|
---|
| 1357 | string cn;
|
---|
| 1358 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 1359 | if ((*it).second.dirid != did) continue;
|
---|
| 1360 | cn = (*it).first.substr(1);
|
---|
| 1361 | cn = cn.substr(cn.find('/')+1) + " (T= " + typeid(*((*it).second.obj)).name() + ")" ;
|
---|
[685] | 1362 | (myImgApp->ObjMgrW())->AddObj(cn.c_str(), (*it).second.oid);
|
---|
[165] | 1363 | }
|
---|
[333] | 1364 | }
|
---|
[165] | 1365 |
|
---|
| 1366 |
|
---|
[333] | 1367 | /* Nouvelle-Fonction */
|
---|
[1207] | 1368 | void NamedObjMgr::RemoveSpacesFromName(string & nom)
|
---|
[165] | 1369 | {
|
---|
[333] | 1370 | // on supprime les blancs de debut et de fin
|
---|
| 1371 | size_t p = nom.find_first_not_of(" ");
|
---|
| 1372 | if(p>nom.length()) { nom = ""; return; }
|
---|
| 1373 | nom = nom.substr(p);
|
---|
| 1374 | p = nom.find(' ');
|
---|
| 1375 | if(p>nom.length()) p=nom.length();
|
---|
| 1376 | nom = nom.substr(0, p);
|
---|
[165] | 1377 | }
|
---|
| 1378 |
|
---|
[333] | 1379 | /* Nouvelle-Fonction */
|
---|
[1207] | 1380 | bool NamedObjMgr::CheckDirName(string & nom)
|
---|
[165] | 1381 | {
|
---|
[333] | 1382 | RemoveSpacesFromName(nom);
|
---|
| 1383 | if (nom.length() < 1) return(false);
|
---|
| 1384 | if (nom[0] == '/') nom = nom.substr(1) ;
|
---|
| 1385 | size_t p = nom.find('/');
|
---|
| 1386 | if (p < nom.length()) nom = nom.substr(0,p);
|
---|
| 1387 | if (nom.length() < 1) return(false);
|
---|
| 1388 | return(true);
|
---|
[165] | 1389 | }
|
---|
| 1390 |
|
---|
[333] | 1391 | /* Nouvelle-Fonction */
|
---|
[1207] | 1392 | int NamedObjMgr::ParseObjectName(string & nom, string & nomrep, string & nomobj)
|
---|
[165] | 1393 | {
|
---|
[333] | 1394 | RemoveSpacesFromName(nom);
|
---|
| 1395 | // Si le nom ne commence pas par un slash, c'est le repertoire courant
|
---|
| 1396 | if (nom[0] != '/') { nomrep = *currDir; nomobj = nom; }
|
---|
[165] | 1397 | else {
|
---|
[333] | 1398 | string xx = nom.substr(1);
|
---|
| 1399 | size_t p = xx.find('/');
|
---|
| 1400 | if (p < xx.length()) {
|
---|
| 1401 | nomrep = xx.substr(0,p);
|
---|
| 1402 | nomobj = xx.substr(p+1);
|
---|
[165] | 1403 | }
|
---|
[333] | 1404 | else {
|
---|
| 1405 | nomrep = xx;
|
---|
| 1406 | nomobj = "";
|
---|
[165] | 1407 | }
|
---|
| 1408 | }
|
---|
[333] | 1409 | int rc = 0;
|
---|
| 1410 | NObjDirList::iterator it = myDirs->find(nomrep);
|
---|
| 1411 | if (it != myDirs->end()) rc = (*it).second.id;
|
---|
| 1412 | return(rc);
|
---|
[165] | 1413 | }
|
---|
| 1414 |
|
---|