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