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