| 1 | #include <stdio.h>
|
|---|
| 2 | #include <stdlib.h>
|
|---|
| 3 | #include <ctype.h>
|
|---|
| 4 |
|
|---|
| 5 | #include <typeinfo>
|
|---|
| 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"
|
|---|
| 16 | #include "nomgadapter.h"
|
|---|
| 17 | #include "pistdimgapp.h"
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 | // EVOL-PLANCK
|
|---|
| 21 | #ifdef SANS_EVOLPLANCK
|
|---|
| 22 | #include "fitsimage.h"
|
|---|
| 23 | #endif
|
|---|
| 24 |
|
|---|
| 25 | #include "pisurfdr.h"
|
|---|
| 26 | #include "pipodrw.h"
|
|---|
| 27 |
|
|---|
| 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 | //
|
|---|
| 39 | // Cette classe fournit les services nécéssaires à la gestion des objets
|
|---|
| 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 ............
|
|---|
| 54 | struct nobj_diritem {
|
|---|
| 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
|
|---|
| 59 | };
|
|---|
| 60 |
|
|---|
| 61 | typedef map<string, nobj_diritem, less<string> > NObjDirList;
|
|---|
| 62 |
|
|---|
| 63 | struct nobj_item {
|
|---|
| 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)
|
|---|
| 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 |
|
|---|
| 76 | static NObjDirList* myDirs = NULL;
|
|---|
| 77 | static NObjList* myObjs = NULL;
|
|---|
| 78 | static int fgOInit = 0;
|
|---|
| 79 | static int myNObj = 0;
|
|---|
| 80 | static int myDirId = 0;
|
|---|
| 81 | static string* currDir;
|
|---|
| 82 |
|
|---|
| 83 | static PIStdImgApp* myImgApp=NULL;
|
|---|
| 84 | static Services2NObjMgr* servnobjm=NULL;
|
|---|
| 85 |
|
|---|
| 86 | static string* TmpDir; // Repertoire pour les compilations / link dynamique
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 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 |
|
|---|
| 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) {
|
|---|
| 110 | myNObj = 0;
|
|---|
| 111 | myDirId = 0;
|
|---|
| 112 | myDirs = new NObjDirList;
|
|---|
| 113 | myObjs = new NObjList;
|
|---|
| 114 | currDir = new string("home");
|
|---|
| 115 | string dirn = "home";
|
|---|
| 116 | CreateDir(dirn);
|
|---|
| 117 | SetKeepOldDirAtt(dirn, true);
|
|---|
| 118 | dirn = "tmp";
|
|---|
| 119 | CreateDir(dirn);
|
|---|
| 120 | SetKeepOldDirAtt(dirn, false);
|
|---|
| 121 | dirn = "autoc";
|
|---|
| 122 | CreateDir(dirn);
|
|---|
| 123 | SetKeepOldDirAtt(dirn, false);
|
|---|
| 124 | dirn = "old";
|
|---|
| 125 | CreateDir(dirn);
|
|---|
| 126 | SetKeepOldDirAtt(dirn, false);
|
|---|
| 127 | dirn = "home";
|
|---|
| 128 | SetCurrentDir(dirn);
|
|---|
| 129 | myDirId = 50;
|
|---|
| 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) += '/';
|
|---|
| 136 | servnobjm = new Services2NObjMgr(this, (*TmpDir));
|
|---|
| 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);
|
|---|
| 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 | }
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 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 |
|
|---|
| 180 | /* --Methode-- */
|
|---|
| 181 | PIStdImgApp* NamedObjMgr::GetImgApp()
|
|---|
| 182 | {
|
|---|
| 183 | return(myImgApp);
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | /* --Methode-- */
|
|---|
| 187 | Services2NObjMgr* NamedObjMgr::GetServiceObj()
|
|---|
| 188 | {
|
|---|
| 189 | return(servnobjm);
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | /* --Methode-- */
|
|---|
| 193 | bool NamedObjMgr::CreateDir(string & dirname)
|
|---|
| 194 | {
|
|---|
| 195 | if ( !CheckDirName(dirname) ) {
|
|---|
| 196 | cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
|
|---|
| 197 | return(false);
|
|---|
| 198 | }
|
|---|
| 199 | NObjDirList::iterator it = myDirs->find(dirname);
|
|---|
| 200 | if (it != myDirs->end()) {
|
|---|
| 201 | cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
|
|---|
| 202 | return(false);
|
|---|
| 203 | }
|
|---|
| 204 | myDirId++;
|
|---|
| 205 | nobj_diritem di;
|
|---|
| 206 | di.id = myDirId;
|
|---|
| 207 | di.nobj = 0;
|
|---|
| 208 | di.lock = false;
|
|---|
| 209 | di.keepold = false;
|
|---|
| 210 | (*myDirs)[dirname] = di;
|
|---|
| 211 | if (myImgApp) {
|
|---|
| 212 | string str = '/' + dirname;
|
|---|
| 213 | (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
|
|---|
| 214 | }
|
|---|
| 215 | if (verbeux) cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
|
|---|
| 216 | return(true);
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | /* --Methode-- */
|
|---|
| 220 | bool NamedObjMgr::DeleteDir(string & dirname)
|
|---|
| 221 | {
|
|---|
| 222 | if ( !CheckDirName(dirname) ) {
|
|---|
| 223 | cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
|
|---|
| 224 | return(false);
|
|---|
| 225 | }
|
|---|
| 226 | NObjDirList::iterator it = myDirs->find(dirname);
|
|---|
| 227 | if (it == myDirs->end()) {
|
|---|
| 228 | cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
|
|---|
| 229 | return(false);
|
|---|
| 230 | }
|
|---|
| 231 | if ((*it).second.nobj > 0) {
|
|---|
| 232 | cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
|
|---|
| 233 | return(false);
|
|---|
| 234 | }
|
|---|
| 235 | if ((*it).second.lock ) {
|
|---|
| 236 | cout << "NamedObjMgr::DeleteDir() " << dirname << " locked ! " << endl;
|
|---|
| 237 | return(false);
|
|---|
| 238 | }
|
|---|
| 239 | if ((*it).second.id < 50) {
|
|---|
| 240 | cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
|
|---|
| 241 | return(false);
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | if (myImgApp)
|
|---|
| 245 | (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
|
|---|
| 246 | myDirs->erase(it);
|
|---|
| 247 | if (verbeux) cout << "NamedObjMgr::DeleteDir() " << dirname << " deleted " << endl;
|
|---|
| 248 | return(true);
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | /* --Methode-- */
|
|---|
| 252 | void NamedObjMgr::LockDir(string & dirname)
|
|---|
| 253 | {
|
|---|
| 254 | if ( !CheckDirName(dirname) ) return;
|
|---|
| 255 | NObjDirList::iterator it = myDirs->find(dirname);
|
|---|
| 256 | if (it == myDirs->end()) return;
|
|---|
| 257 | (*it).second.lock = true;
|
|---|
| 258 | if (verbeux) cout << "NamedObjMgr::LockDir() " << dirname << " Locked " << endl;
|
|---|
| 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;
|
|---|
| 269 | if (verbeux) cout << "NamedObjMgr::UnlockDir() " << dirname << " Unlocked " << endl;
|
|---|
| 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;
|
|---|
| 280 | if (!verbeux) return;
|
|---|
| 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 | {
|
|---|
| 291 | if ( !CheckDirName(dirname) ) {
|
|---|
| 292 | cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
|
|---|
| 293 | return(false);
|
|---|
| 294 | }
|
|---|
| 295 | NObjDirList::iterator it = myDirs->find(dirname);
|
|---|
| 296 | if (it == myDirs->end()) {
|
|---|
| 297 | cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
|
|---|
| 298 | return(false);
|
|---|
| 299 | }
|
|---|
| 300 | *currDir = dirname;
|
|---|
| 301 | if (verbeux) cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
|
|---|
| 302 | return(true);
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | /* --Methode-- */
|
|---|
| 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++;
|
|---|
| 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 |
|
|---|
| 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-- */
|
|---|
| 343 | void NamedObjMgr::CleanDir(string & dirname)
|
|---|
| 344 | {
|
|---|
| 345 | if ( !CheckDirName(dirname) ) {
|
|---|
| 346 | cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - Invalid name !" << endl;
|
|---|
| 347 | // return(false); $CHECK$ illegal return value in void function
|
|---|
| 348 | }
|
|---|
| 349 | NObjDirList::iterator itr = myDirs->find(dirname);
|
|---|
| 350 | if (itr == myDirs->end()) {
|
|---|
| 351 | cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - No such directory !" << endl;
|
|---|
| 352 | // return(false); $CHECK$ illegal return value in void function
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 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);
|
|---|
| 370 | if (myImgApp)
|
|---|
| 371 | (myImgApp->ObjMgrW())->UpdateList(did);
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 | //++
|
|---|
| 377 | // Titre Gestion de la liste des objets
|
|---|
| 378 | //--
|
|---|
| 379 | //++
|
|---|
| 380 | // void AddObj(AnyDataObj* obj, string& nom)
|
|---|
| 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"
|
|---|
| 389 | // AnyDataObj* GetObj(string const& nom)
|
|---|
| 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.
|
|---|
| 394 | // void CopyObj(string const& nom, string& nomcp)
|
|---|
| 395 | // Copy l'objet "nom" de la liste dans l'objet "nomcp" de la liste.
|
|---|
| 396 | //--
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 | /* --Methode-- */
|
|---|
| 400 | bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
|
|---|
| 401 | {
|
|---|
| 402 |
|
|---|
| 403 | if (obj == NULL) return(false);
|
|---|
| 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;
|
|---|
| 409 | return(false);
|
|---|
| 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;
|
|---|
| 419 | return(false);
|
|---|
| 420 | }
|
|---|
| 421 | else { CreateDir(nrep); did = myDirId; }
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | // Si c'est le repertoire /autoc, on nettoie
|
|---|
| 425 | if (nrep == "autoc") {
|
|---|
| 426 | CleanDir(nrep);
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | myNObj++;
|
|---|
| 430 | if (nobj.length() < 1) {
|
|---|
| 431 | sprintf(buff,"O%d", myNObj);
|
|---|
| 432 | nobj = buff;
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | nom = '/' + nrep + '/' + nobj;
|
|---|
| 436 | NObjDirList::iterator itr = myDirs->find(nrep);
|
|---|
| 437 | if ((*itr).second.lock) {
|
|---|
| 438 | cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl;
|
|---|
| 439 | return(false);
|
|---|
| 440 | }
|
|---|
| 441 | it = myObjs->find(nom);
|
|---|
| 442 | if (it != myObjs->end()) { // l'objet existe deja
|
|---|
| 443 | if (nrep == "autoc") { // Dans /autoc , on garde les objets affiches, donc del. par Clean
|
|---|
| 444 | sprintf(buff, "%d", (*it).second.oid);
|
|---|
| 445 | string nomnew = "/autoc/" + nobj + buff;
|
|---|
| 446 | RenameObj(nom, nomnew);
|
|---|
| 447 | }
|
|---|
| 448 | else if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
|
|---|
| 449 | string on,od;
|
|---|
| 450 | // ParseObjectName((*it).first, od, on);
|
|---|
| 451 | sprintf(buff, "%d", (*it).second.oid);
|
|---|
| 452 | string nomnew = "/old/" + nobj + buff;
|
|---|
| 453 | RenameObj(nom, nomnew);
|
|---|
| 454 | }
|
|---|
| 455 | else { // Sinon, on remplace l'objet
|
|---|
| 456 | cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
|
|---|
| 457 | DelObj(nom);
|
|---|
| 458 | }
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | nobj_item no;
|
|---|
| 462 | no.obj = obj;
|
|---|
| 463 | no.obja = servnobjm->GetAdapter(obj); // L'adaptateur
|
|---|
| 464 | no.oid = myNObj;
|
|---|
| 465 | no.dirid = did;
|
|---|
| 466 | (*myObjs)[nom] = no;
|
|---|
| 467 |
|
|---|
| 468 | (*itr).second.nobj++;
|
|---|
| 469 |
|
|---|
| 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 | }
|
|---|
| 474 | if (verbeux) cout << "NamedObjMgr::AddObj() Object " << nom << " ( "
|
|---|
| 475 | << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;
|
|---|
| 476 | return(true);
|
|---|
| 477 | }
|
|---|
| 478 |
|
|---|
| 479 | /* --Methode-- */
|
|---|
| 480 | bool NamedObjMgr::RenameObj(string & nom, string& nomnew)
|
|---|
| 481 | {
|
|---|
| 482 | string n1,r1,n2,r2;
|
|---|
| 483 | int dids = ParseObjectName(nom, r1, n1);
|
|---|
| 484 | NObjDirList::iterator itr1 = myDirs->find(r1);
|
|---|
| 485 | int did = ParseObjectName(nomnew, r2, n2);
|
|---|
| 486 | NObjDirList::iterator itr2 = myDirs->find(r2);
|
|---|
| 487 |
|
|---|
| 488 | if (did == 0) {
|
|---|
| 489 | cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
|
|---|
| 490 | return(false);
|
|---|
| 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;
|
|---|
| 497 | return(false);
|
|---|
| 498 | }
|
|---|
| 499 | NObjList::iterator it2 = myObjs->find(nomnew);
|
|---|
| 500 | if (it2 != myObjs->end()) {
|
|---|
| 501 | cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl;
|
|---|
| 502 | return(false);
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 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 |
|
|---|
| 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++;
|
|---|
| 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 | }
|
|---|
| 526 | if (verbeux)
|
|---|
| 527 | cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
|
|---|
| 528 | return(true);
|
|---|
| 529 | }
|
|---|
| 530 |
|
|---|
| 531 | /* --Methode-- */
|
|---|
| 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-- */
|
|---|
| 548 | bool NamedObjMgr::DelObj(string & nom, bool fgd)
|
|---|
| 549 | {
|
|---|
| 550 | string n1,r1;
|
|---|
| 551 | int did = ParseObjectName(nom, r1, n1);
|
|---|
| 552 | nom = '/' + r1 + '/' + n1;
|
|---|
| 553 | NObjList::iterator it = myObjs->find(nom);
|
|---|
| 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 | }
|
|---|
| 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 | }
|
|---|
| 566 | delete (*it).second.obja; // destruction de l'adaptateur
|
|---|
| 567 | if (fgd) delete (*it).second.obj;
|
|---|
| 568 |
|
|---|
| 569 | if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
|
|---|
| 570 | int olid = (*it).second.oid;
|
|---|
| 571 | (myImgApp->ObjMgrW())->DelObjList(did, olid);
|
|---|
| 572 | }
|
|---|
| 573 | myObjs->erase(it);
|
|---|
| 574 | (*itr).second.nobj--;
|
|---|
| 575 |
|
|---|
| 576 |
|
|---|
| 577 | if (!verbeux) return(true);
|
|---|
| 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;
|
|---|
| 580 | return(true);
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | /* --Methode-- */
|
|---|
| 584 | bool NamedObjMgr::DelObj_Id(int oid)
|
|---|
| 585 | {
|
|---|
| 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 | }
|
|---|
| 594 | if (of) return(DelObj(nom, true));
|
|---|
| 595 | else return(false);
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | /* --Methode-- */
|
|---|
| 599 | void NamedObjMgr::DelObjects(string & patt, bool fgd)
|
|---|
| 600 | {
|
|---|
| 601 | string n1,r1;
|
|---|
| 602 | ParseObjectName(patt, r1, n1);
|
|---|
| 603 | patt = '/' + r1 + '/' + n1;
|
|---|
| 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-- */
|
|---|
| 616 | AnyDataObj* NamedObjMgr::GetObj(string & nom)
|
|---|
| 617 | {
|
|---|
| 618 | string n1,r1;
|
|---|
| 619 | ParseObjectName(nom, r1, n1);
|
|---|
| 620 | nom = '/' + r1 + '/' + n1;
|
|---|
| 621 | NObjList::iterator it = myObjs->find(nom);
|
|---|
| 622 | if (it == myObjs->end()) return(NULL);
|
|---|
| 623 | return((*it).second.obj);
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | /* --Methode-- */
|
|---|
| 627 | NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
|
|---|
| 628 | {
|
|---|
| 629 | string n1,r1;
|
|---|
| 630 | ParseObjectName(nom, r1, n1);
|
|---|
| 631 | nom = '/' + r1 + '/' + n1;
|
|---|
| 632 | NObjList::iterator it = myObjs->find(nom);
|
|---|
| 633 | if (it == myObjs->end()) return(NULL);
|
|---|
| 634 | return((*it).second.obja);
|
|---|
| 635 | }
|
|---|
| 636 |
|
|---|
| 637 | /* --Methode-- */
|
|---|
| 638 | void NamedObjMgr::ListObjs(string & patt)
|
|---|
| 639 | {
|
|---|
| 640 | int k;
|
|---|
| 641 | AnyDataObj* obj=NULL;
|
|---|
| 642 | string ctyp;
|
|---|
| 643 | char strg[256];
|
|---|
| 644 |
|
|---|
| 645 | string n1,r1;
|
|---|
| 646 | ParseObjectName(patt, r1, n1);
|
|---|
| 647 | patt = '/' + r1 + '/' + n1;
|
|---|
| 648 | cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
|
|---|
| 649 | NObjList::iterator it; k = 0;
|
|---|
| 650 | string cn;
|
|---|
| 651 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
|---|
| 652 | cn = (*it).first;
|
|---|
| 653 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
|---|
| 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;
|
|---|
| 662 | return;
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|
| 665 | /* --Methode-- */
|
|---|
| 666 | void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
|
|---|
| 667 | {
|
|---|
| 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 | }
|
|---|
| 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-- */
|
|---|
| 701 | void NamedObjMgr::ReadObj(string const & flnm, string & nobj)
|
|---|
| 702 | {
|
|---|
| 703 | PPersist* ppobj=NULL;
|
|---|
| 704 | bool ok = true;
|
|---|
| 705 | #ifdef SANS_EVOLPLANCK
|
|---|
| 706 | TRY{
|
|---|
| 707 | PInPersist pis(flnm);
|
|---|
| 708 | ppobj = PPersistMgr::ReadObject(pis);
|
|---|
| 709 | if (ppobj == NULL) ok = false;
|
|---|
| 710 | } CATCH(merr)
|
|---|
| 711 | { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n",
|
|---|
| 712 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
|---|
| 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
|
|---|
| 723 | if (!ok) return;
|
|---|
| 724 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
|---|
| 725 | AddObj(ppobj->DataObj(), nobj, true);
|
|---|
| 726 | cout << "NamedObjMgr::ReadObj(...) object " << nobj << " read from file " << endl;
|
|---|
| 727 | return;
|
|---|
| 728 | }
|
|---|
| 729 |
|
|---|
| 730 | /* --Methode-- */
|
|---|
| 731 | void NamedObjMgr::ReadObj(PInPersist& s, int num)
|
|---|
| 732 | {
|
|---|
| 733 | int_4 i, cid, key, ln; // $CHECK$ int -> int_4 a cause de TagKey
|
|---|
| 734 | int n0, n1;
|
|---|
| 735 | bool ok = true;
|
|---|
| 736 | PPersist* obj=NULL;
|
|---|
| 737 | string nom;
|
|---|
| 738 |
|
|---|
| 739 | int nread = 0;
|
|---|
| 740 | if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
|
|---|
| 741 | if (num >= 0) {
|
|---|
| 742 | cerr << "NamedObjMgr::ReadObj(PInPersist, " << num << " Error! NbTags ="
|
|---|
| 743 | << s.NbTags() << endl;
|
|---|
| 744 | return;
|
|---|
| 745 | }
|
|---|
| 746 |
|
|---|
| 747 | #ifdef SANS_EVOLPLANCK
|
|---|
| 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;
|
|---|
| 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 |
|
|---|
| 765 | if (!ok) return;
|
|---|
| 766 | nom = "";
|
|---|
| 767 | AddObj(obj->DataObj(), nom);
|
|---|
| 768 | nread++;
|
|---|
| 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++) {
|
|---|
| 774 | #ifdef SANS_EVOLPLANCK
|
|---|
| 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;
|
|---|
| 786 | #else
|
|---|
| 787 | s.GotoTagNum(i);
|
|---|
| 788 | nom = s.GetTagName(i);
|
|---|
| 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
|
|---|
| 797 | if (ok) { AddObj(obj->DataObj(), nom, true); nread++; }
|
|---|
| 798 | }
|
|---|
| 799 |
|
|---|
| 800 | cout << "NamedObjMgr::ReadObj(...) " << nread << " Objects read " << endl;
|
|---|
| 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;
|
|---|
| 810 | #ifdef SANS_EVOLPLANCK
|
|---|
| 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;
|
|---|
| 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
|
|---|
| 829 | if (!ok) return;
|
|---|
| 830 | if (obj) {
|
|---|
| 831 | string nom = servnobjm->FileName2Name(flnm);
|
|---|
| 832 | AddObj(obj->DataObj(), nom);
|
|---|
| 833 | }
|
|---|
| 834 | else ReadObj((*ppin), -1);
|
|---|
| 835 | delete ppin;
|
|---|
| 836 | return;
|
|---|
| 837 | }
|
|---|
| 838 |
|
|---|
| 839 | /* --Methode-- */
|
|---|
| 840 | void NamedObjMgr::ReadFits(string const & flnm, string & nobj)
|
|---|
| 841 | {
|
|---|
| 842 | bool ok = false;
|
|---|
| 843 |
|
|---|
| 844 | #ifdef SANS_EVOLPLANCK
|
|---|
| 845 | RzImage* obj=NULL;
|
|---|
| 846 | TRY{
|
|---|
| 847 | obj = RzReadFits((char*)flnm.c_str());
|
|---|
| 848 | if (obj == NULL) ok = false;
|
|---|
| 849 | else ok = true;
|
|---|
| 850 | } CATCH(merr) {
|
|---|
| 851 | printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
|---|
| 852 | ok = false;
|
|---|
| 853 | } ENDTRY;
|
|---|
| 854 |
|
|---|
| 855 | if (ok && (obj != NULL)) {
|
|---|
| 856 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
|---|
| 857 | AddObj((AnyDataObj*)obj, nobj);
|
|---|
| 858 | }
|
|---|
| 859 | #else
|
|---|
| 860 | cerr << " NamedObjMgr::ReadFits() Vide ! A faire Reza ! " << endl;
|
|---|
| 861 | #endif
|
|---|
| 862 |
|
|---|
| 863 | return;
|
|---|
| 864 | }
|
|---|
| 865 |
|
|---|
| 866 |
|
|---|
| 867 | static int key_for_write = 5000;
|
|---|
| 868 | /* --Methode-- */
|
|---|
| 869 | void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
|
|---|
| 870 | {
|
|---|
| 871 | if (nom.length() < 1) return;
|
|---|
| 872 | string nob,rep;
|
|---|
| 873 | ParseObjectName(nom, rep, nob);
|
|---|
| 874 | nom = '/' + rep + '/' + nob;
|
|---|
| 875 | NObjMgrAdapter* obja=NULL;
|
|---|
| 876 | string nomf = (keeppath) ? nom : nob;
|
|---|
| 877 | obja = GetObjAdapter(nom);
|
|---|
| 878 | if (obja == NULL) return;
|
|---|
| 879 | printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
|
|---|
| 880 | nom.c_str(), typeid(*(obja->GetDataObj())).name());
|
|---|
| 881 | obja->SavePPF(s, nomf);
|
|---|
| 882 | return;
|
|---|
| 883 | }
|
|---|
| 884 |
|
|---|
| 885 | /* --Methode-- */
|
|---|
| 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;
|
|---|
| 896 | #ifdef SANS_EVOLPLANCK
|
|---|
| 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;
|
|---|
| 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
|
|---|
| 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-- */
|
|---|
| 924 | void NamedObjMgr::SaveAll(string const& flnm)
|
|---|
| 925 | {
|
|---|
| 926 | bool ok = true;
|
|---|
| 927 |
|
|---|
| 928 | POutPersist* pout;
|
|---|
| 929 | #ifdef SANS_EVOLPLANCK
|
|---|
| 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;
|
|---|
| 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
|
|---|
| 944 | if (!ok) return;
|
|---|
| 945 | NObjList::iterator it;
|
|---|
| 946 | string no;
|
|---|
| 947 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
|---|
| 948 | no = (*it).first;
|
|---|
| 949 | SaveObj(no, (*pout), true);
|
|---|
| 950 | }
|
|---|
| 951 | delete pout;
|
|---|
| 952 | return;
|
|---|
| 953 | }
|
|---|
| 954 |
|
|---|
| 955 | /* --Methode-- */
|
|---|
| 956 | void NamedObjMgr::SaveFits(string& nom, string const & flnm)
|
|---|
| 957 | {
|
|---|
| 958 | NObjMgrAdapter* obja=NULL;
|
|---|
| 959 | obja = GetObjAdapter(nom);
|
|---|
| 960 | if (obja == NULL) return;
|
|---|
| 961 | obja->SaveFits(flnm);
|
|---|
| 962 | return;
|
|---|
| 963 | }
|
|---|
| 964 |
|
|---|
| 965 |
|
|---|
| 966 |
|
|---|
| 967 | /* --Methode-- */
|
|---|
| 968 | void NamedObjMgr::PrintObj(string& nom)
|
|---|
| 969 | {
|
|---|
| 970 | NObjMgrAdapter* obja=NULL;
|
|---|
| 971 | obja = GetObjAdapter(nom);
|
|---|
| 972 | if (obja == NULL) return;
|
|---|
| 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();
|
|---|
| 979 | cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
|
|---|
| 980 | obja->Print(cout);
|
|---|
| 981 |
|
|---|
| 982 | return;
|
|---|
| 983 | }
|
|---|
| 984 |
|
|---|
| 985 | /* --Methode-- */
|
|---|
| 986 | void NamedObjMgr::DisplayObj(string& nom, string dopt)
|
|---|
| 987 | {
|
|---|
| 988 | NObjMgrAdapter* obja=NULL;
|
|---|
| 989 | obja = GetObjAdapter(nom);
|
|---|
| 990 | if (obja == NULL) {
|
|---|
| 991 | cout << "NamedObjMgr::DisplayObj() Error , No object with name " << nom << endl;
|
|---|
| 992 | return;
|
|---|
| 993 | }
|
|---|
| 994 | if (obja->GetDataObj() == NULL) {
|
|---|
| 995 | cerr << "NamedObjMgr::DisplayObj() / Error - NULL object ! in " << nom << endl;
|
|---|
| 996 | return;
|
|---|
| 997 | }
|
|---|
| 998 | if (!myImgApp) return;
|
|---|
| 999 |
|
|---|
| 1000 | PIDrawer * dr = NULL;
|
|---|
| 1001 | P2DArrayAdapter* arr = NULL;
|
|---|
| 1002 | dr = obja->GetDrawer(dopt);
|
|---|
| 1003 | if (!dr) arr = obja->Get2DArray(dopt);
|
|---|
| 1004 |
|
|---|
| 1005 | if (!dr && !arr) {
|
|---|
| 1006 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
|---|
| 1007 | cout << "NamedObjMgr::DisplayObj() Error , No display for " << ctyp << endl;
|
|---|
| 1008 | return;
|
|---|
| 1009 | }
|
|---|
| 1010 |
|
|---|
| 1011 | int wrsid = 0;
|
|---|
| 1012 | bool fgsr = true;
|
|---|
| 1013 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
|---|
| 1014 |
|
|---|
| 1015 | string n1,r1;
|
|---|
| 1016 | ParseObjectName(nom, r1, n1);
|
|---|
| 1017 |
|
|---|
| 1018 | if (dr) {
|
|---|
| 1019 | PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
|
|---|
| 1020 | if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt);
|
|---|
| 1021 | else wrsid = myImgApp->DispScDrawer( dr, n1, opt);
|
|---|
| 1022 | }
|
|---|
| 1023 | else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt);
|
|---|
| 1024 |
|
|---|
| 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 | }
|
|---|
| 1033 |
|
|---|
| 1034 | /* --Methode-- */
|
|---|
| 1035 | void NamedObjMgr::DisplayImage(string& nom, string dopt)
|
|---|
| 1036 | {
|
|---|
| 1037 | NObjMgrAdapter* obja=NULL;
|
|---|
| 1038 | obja = GetObjAdapter(nom);
|
|---|
| 1039 | if (obja == NULL) {
|
|---|
| 1040 | cout << "NamedObjMgr::DisplayImage() Error , No such object " << nom << endl;
|
|---|
| 1041 | return;
|
|---|
| 1042 | }
|
|---|
| 1043 | if (obja->GetDataObj() == NULL) {
|
|---|
| 1044 | cerr << "NamedObjMgr::DisplayImage() / Error - NULL object ! in " << nom << endl;
|
|---|
| 1045 | return;
|
|---|
| 1046 | }
|
|---|
| 1047 | if (!myImgApp) return;
|
|---|
| 1048 |
|
|---|
| 1049 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
|---|
| 1050 |
|
|---|
| 1051 | if (!arr) {
|
|---|
| 1052 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
|---|
| 1053 | cout << "NamedObjMgr::DisplayImage() Error , Not supported for " << ctyp << endl;
|
|---|
| 1054 | return;
|
|---|
| 1055 | }
|
|---|
| 1056 |
|
|---|
| 1057 | string n1,r1;
|
|---|
| 1058 | ParseObjectName(nom, r1, n1);
|
|---|
| 1059 |
|
|---|
| 1060 | int wrsid = 0;
|
|---|
| 1061 | bool fgsr = true;
|
|---|
| 1062 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
|---|
| 1063 | wrsid = myImgApp->DispImage(arr, n1, opt);
|
|---|
| 1064 |
|
|---|
| 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-- */
|
|---|
| 1074 | void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
|
|---|
| 1075 | {
|
|---|
| 1076 | NObjMgrAdapter* obja=NULL;
|
|---|
| 1077 | obja = GetObjAdapter(nom);
|
|---|
| 1078 | if (obja == NULL) {
|
|---|
| 1079 | cout << "NamedObjMgr::DisplaySurf3D() Error , No such object " << nom << endl;
|
|---|
| 1080 | return;
|
|---|
| 1081 | }
|
|---|
| 1082 | if (obja->GetDataObj() == NULL) {
|
|---|
| 1083 | cerr << "NamedObjMgr::DisplaySurf3D() / Error - NULL object ! in " << nom << endl;
|
|---|
| 1084 | return;
|
|---|
| 1085 | }
|
|---|
| 1086 | if (!myImgApp) return;
|
|---|
| 1087 |
|
|---|
| 1088 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
|---|
| 1089 |
|
|---|
| 1090 | if (!arr) {
|
|---|
| 1091 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
|---|
| 1092 | cout << "NamedObjMgr::DisplaySurf3D() Error , Not supported " << ctyp << endl;
|
|---|
| 1093 | return;
|
|---|
| 1094 | }
|
|---|
| 1095 |
|
|---|
| 1096 | if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
|
|---|
| 1097 | cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
|
|---|
| 1098 | << "x" << arr->YSize() << ") too big (max=250x250)" << endl;
|
|---|
| 1099 | delete arr;
|
|---|
| 1100 | return;
|
|---|
| 1101 | }
|
|---|
| 1102 |
|
|---|
| 1103 | string n1,r1;
|
|---|
| 1104 | ParseObjectName(nom, r1, n1);
|
|---|
| 1105 |
|
|---|
| 1106 | int wrsid = 0;
|
|---|
| 1107 | bool fgsr = true;
|
|---|
| 1108 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
|---|
| 1109 | PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
|
|---|
| 1110 | wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt);
|
|---|
| 1111 | if(wrsid >= 0) {
|
|---|
| 1112 | NObjList::iterator it = myObjs->find(nom);
|
|---|
| 1113 | if (it == myObjs->end()) return;
|
|---|
| 1114 | (*it).second.wrsid.push_back(wrsid);
|
|---|
| 1115 | }
|
|---|
| 1116 |
|
|---|
| 1117 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
|---|
| 1118 | return;
|
|---|
| 1119 | }
|
|---|
| 1120 |
|
|---|
| 1121 | /* --Methode-- */
|
|---|
| 1122 | void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
|
|---|
| 1123 | string& erx, string& ery, string& erz, string& wt,
|
|---|
| 1124 | string& label, string dopt, bool fg3d)
|
|---|
| 1125 | {
|
|---|
| 1126 | AnyDataObj* obj=GetObj(nom);
|
|---|
| 1127 | if (obj == NULL) {
|
|---|
| 1128 | cout << "NamedObjMgr::DisplayNT() Error , No such object " << nom << endl;
|
|---|
| 1129 | return;
|
|---|
| 1130 | }
|
|---|
| 1131 | if (!myImgApp) return;
|
|---|
| 1132 |
|
|---|
| 1133 | NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
|
|---|
| 1134 | if (nt == NULL) {
|
|---|
| 1135 | // if (typeid(*obj) != typeid(NTupleInterface)) {
|
|---|
| 1136 | string ctyp = typeid(*obj).name();
|
|---|
| 1137 | cout << "NamedObjMgr::DisplayNT() Error , Object not an NTuple " << ctyp << endl;
|
|---|
| 1138 | return;
|
|---|
| 1139 | }
|
|---|
| 1140 |
|
|---|
| 1141 | int wrsid = 0;
|
|---|
| 1142 | bool fgsr = true;
|
|---|
| 1143 | dopt = "defline," + dopt;
|
|---|
| 1144 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
|---|
| 1145 |
|
|---|
| 1146 | string n1,r1;
|
|---|
| 1147 | ParseObjectName(nom, r1, n1);
|
|---|
| 1148 |
|
|---|
| 1149 | if ( fg3d && (nmz.length()>0) ) { // Display 3D
|
|---|
| 1150 | PINTuple3D* pin = new PINTuple3D(nt, false);
|
|---|
| 1151 | pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
|
|---|
| 1152 | pin->SelectWt(wt.c_str());
|
|---|
| 1153 | pin->SelectLabel(label.c_str());
|
|---|
| 1154 | pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
|
|---|
| 1155 | string titre = nmz + "%" + nmy + "%" + nmz;
|
|---|
| 1156 | wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre);
|
|---|
| 1157 | }
|
|---|
| 1158 | else {
|
|---|
| 1159 | PINTuple* pin = new PINTuple(nt, false);
|
|---|
| 1160 | pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));
|
|---|
| 1161 | pin->SelectXY(nmx.c_str(), nmy.c_str());
|
|---|
| 1162 | pin->SelectWt(wt.c_str());
|
|---|
| 1163 | pin->SelectLabel(label.c_str());
|
|---|
| 1164 | pin->SelectErrBar(erx.c_str(), ery.c_str());
|
|---|
| 1165 | string titre = nmy + "%" + nmx;
|
|---|
| 1166 | wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre);
|
|---|
| 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 |
|
|---|
| 1179 | /* --Methode-- cmv 13/10/98 : Obsolete mais ne pas virer SVP */
|
|---|
| 1180 | void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
|
|---|
| 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 | {
|
|---|
| 1193 | AnyDataObj* obj=GetObj(nom);
|
|---|
| 1194 | if(obj == NULL)
|
|---|
| 1195 | {cout << "NamedObjMgr::DisplayGFD() Error , No such object " << nom << endl;
|
|---|
| 1196 | return;}
|
|---|
| 1197 | if(!myImgApp) return;
|
|---|
| 1198 | if(typeid(*obj) != typeid(GeneralFitData))
|
|---|
| 1199 | {string ctyp = typeid(*obj).name();
|
|---|
| 1200 | cout<<"NamedObjMgr::DisplayGFD() Error , Object not a GeneralFitData "<<ctyp<<endl;
|
|---|
| 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
|
|---|
| 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 |
|
|---|
| 1219 | string n1,r1;
|
|---|
| 1220 | ParseObjectName(nom, r1, n1);
|
|---|
| 1221 |
|
|---|
| 1222 | int wrsid = 0;
|
|---|
| 1223 | if(numvy>=0) { // display 3D
|
|---|
| 1224 | PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
|
|---|
| 1225 | pigfd->SelectXY(numvx,numvy);
|
|---|
| 1226 | pigfd->SelectErrBar(errx,erry,errz);
|
|---|
| 1227 | wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt);
|
|---|
| 1228 | } else { // display 2D
|
|---|
| 1229 | PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
|
|---|
| 1230 | pigfd->SelectX(numvx);
|
|---|
| 1231 | pigfd->SelectErrBar(errx,erry);
|
|---|
| 1232 | wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt);
|
|---|
| 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--
|
|---|
| 1245 | void NamedObjMgr::DisplayImage(string& nom, string dopt)
|
|---|
| 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);
|
|---|
| 1259 | Services2NObjMgr::SetDefaultStatsOption(Services2NObjMgr::GetStatsOption(gratt));
|
|---|
| 1260 | }
|
|---|
| 1261 |
|
|---|
| 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-- */
|
|---|
| 1271 | void NamedObjMgr::AddWRsId(string & nom, int wrsid)
|
|---|
| 1272 | {
|
|---|
| 1273 | if(wrsid != 0) {
|
|---|
| 1274 | NObjList::iterator it = myObjs->find(nom);
|
|---|
| 1275 | if (it == myObjs->end()) return;
|
|---|
| 1276 | (*it).second.wrsid.push_back(wrsid);
|
|---|
| 1277 | }
|
|---|
| 1278 | return;
|
|---|
| 1279 | }
|
|---|
| 1280 |
|
|---|
| 1281 | /* --Methode-- */
|
|---|
| 1282 | void NamedObjMgr::UpdateObjMgrWindow(int did)
|
|---|
| 1283 | {
|
|---|
| 1284 | if (!myImgApp) return;
|
|---|
| 1285 | (myImgApp->ObjMgrW())->ClearObjList();
|
|---|
| 1286 |
|
|---|
| 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() + ")" ;
|
|---|
| 1293 | (myImgApp->ObjMgrW())->AddObj(cn.c_str(), (*it).second.oid);
|
|---|
| 1294 | }
|
|---|
| 1295 | }
|
|---|
| 1296 |
|
|---|
| 1297 |
|
|---|
| 1298 | /* Nouvelle-Fonction */
|
|---|
| 1299 | void RemoveSpacesFromName(string & nom)
|
|---|
| 1300 | {
|
|---|
| 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);
|
|---|
| 1308 | }
|
|---|
| 1309 |
|
|---|
| 1310 | /* Nouvelle-Fonction */
|
|---|
| 1311 | bool CheckDirName(string & nom)
|
|---|
| 1312 | {
|
|---|
| 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);
|
|---|
| 1320 | }
|
|---|
| 1321 |
|
|---|
| 1322 | /* Nouvelle-Fonction */
|
|---|
| 1323 | int ParseObjectName(string & nom, string & nomrep, string & nomobj)
|
|---|
| 1324 | {
|
|---|
| 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; }
|
|---|
| 1328 | else {
|
|---|
| 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);
|
|---|
| 1334 | }
|
|---|
| 1335 | else {
|
|---|
| 1336 | nomrep = xx;
|
|---|
| 1337 | nomobj = "";
|
|---|
| 1338 | }
|
|---|
| 1339 | }
|
|---|
| 1340 | int rc = 0;
|
|---|
| 1341 | NObjDirList::iterator it = myDirs->find(nomrep);
|
|---|
| 1342 | if (it != myDirs->end()) rc = (*it).second.id;
|
|---|
| 1343 | return(rc);
|
|---|
| 1344 | }
|
|---|
| 1345 |
|
|---|