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