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