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