[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"
|
---|
[1905] | 28 | #include "piyfxdrw.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);
|
---|
[2132] | 121 | SetKeepOldDirAtt(dirn, false);
|
---|
[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
|
---|
[1547] | 234 | DVList::ValList::const_iterator it;
|
---|
| 235 | for(it=myVars->Begin(); it!= myVars->End(); it++)
|
---|
| 236 | if ((*it).first == key) return true;
|
---|
[1199] | 237 | return(false);
|
---|
| 238 | #else
|
---|
[1164] | 239 | return(myVars->HasKey(key));
|
---|
[1199] | 240 | #endif
|
---|
[1164] | 241 | }
|
---|
| 242 |
|
---|
| 243 | /* --Methode-- */
|
---|
| 244 | bool NamedObjMgr::DeleteVar(string const & key)
|
---|
| 245 | {
|
---|
[1199] | 246 | #ifdef SANS_EVOLPLANCK
|
---|
| 247 | return(false);
|
---|
| 248 | #else
|
---|
[1164] | 249 | return(myVars->DeleteKey(key));
|
---|
[1199] | 250 | #endif
|
---|
[1164] | 251 | }
|
---|
| 252 |
|
---|
| 253 | /* --Methode-- */
|
---|
| 254 | string NamedObjMgr::GetVar(string const & key)
|
---|
| 255 | {
|
---|
[1224] | 256 | // cout << " DEBUG::GetVar " << *myVars << endl;
|
---|
[1164] | 257 | return(myVars->GetS(key));
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | /* --Methode-- */
|
---|
| 261 | DVList& NamedObjMgr::GetVarList()
|
---|
| 262 | {
|
---|
[1224] | 263 | // cout << " DEBUG::GetVarList " << *myVars << endl;
|
---|
[1164] | 264 | return(*myVars);
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | /* --Methode-- */
|
---|
[344] | 268 | bool NamedObjMgr::CreateDir(string & dirname)
|
---|
[331] | 269 | {
|
---|
[333] | 270 | if ( !CheckDirName(dirname) ) {
|
---|
| 271 | cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
[344] | 272 | return(false);
|
---|
[333] | 273 | }
|
---|
| 274 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 275 | if (it != myDirs->end()) {
|
---|
| 276 | cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
|
---|
[344] | 277 | return(false);
|
---|
[333] | 278 | }
|
---|
| 279 | myDirId++;
|
---|
| 280 | nobj_diritem di;
|
---|
| 281 | di.id = myDirId;
|
---|
| 282 | di.nobj = 0;
|
---|
[344] | 283 | di.lock = false;
|
---|
| 284 | di.keepold = false;
|
---|
[333] | 285 | (*myDirs)[dirname] = di;
|
---|
| 286 | if (myImgApp) {
|
---|
| 287 | string str = '/' + dirname;
|
---|
| 288 | (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
|
---|
| 289 | }
|
---|
[449] | 290 | if (verbeux) cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
|
---|
[344] | 291 | return(true);
|
---|
[331] | 292 | }
|
---|
| 293 |
|
---|
| 294 | /* --Methode-- */
|
---|
[344] | 295 | bool NamedObjMgr::DeleteDir(string & dirname)
|
---|
[331] | 296 | {
|
---|
[333] | 297 | if ( !CheckDirName(dirname) ) {
|
---|
| 298 | cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
[344] | 299 | return(false);
|
---|
[333] | 300 | }
|
---|
| 301 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 302 | if (it == myDirs->end()) {
|
---|
| 303 | cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
|
---|
[344] | 304 | return(false);
|
---|
[333] | 305 | }
|
---|
| 306 | if ((*it).second.nobj > 0) {
|
---|
| 307 | cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
|
---|
[344] | 308 | return(false);
|
---|
[333] | 309 | }
|
---|
[344] | 310 | if ((*it).second.lock ) {
|
---|
| 311 | cout << "NamedObjMgr::DeleteDir() " << dirname << " locked ! " << endl;
|
---|
| 312 | return(false);
|
---|
| 313 | }
|
---|
[333] | 314 | if ((*it).second.id < 50) {
|
---|
| 315 | cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
|
---|
[344] | 316 | return(false);
|
---|
[333] | 317 | }
|
---|
| 318 |
|
---|
| 319 | if (myImgApp)
|
---|
| 320 | (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
|
---|
| 321 | myDirs->erase(it);
|
---|
[449] | 322 | if (verbeux) cout << "NamedObjMgr::DeleteDir() " << dirname << " deleted " << endl;
|
---|
[344] | 323 | return(true);
|
---|
[331] | 324 | }
|
---|
| 325 |
|
---|
| 326 | /* --Methode-- */
|
---|
[344] | 327 | void NamedObjMgr::LockDir(string & dirname)
|
---|
[331] | 328 | {
|
---|
[344] | 329 | if ( !CheckDirName(dirname) ) return;
|
---|
| 330 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 331 | if (it == myDirs->end()) return;
|
---|
| 332 | (*it).second.lock = true;
|
---|
[449] | 333 | if (verbeux) cout << "NamedObjMgr::LockDir() " << dirname << " Locked " << endl;
|
---|
[344] | 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;
|
---|
[449] | 344 | if (verbeux) cout << "NamedObjMgr::UnlockDir() " << dirname << " Unlocked " << endl;
|
---|
[344] | 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;
|
---|
[449] | 355 | if (!verbeux) return;
|
---|
[344] | 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 | {
|
---|
[333] | 366 | if ( !CheckDirName(dirname) ) {
|
---|
| 367 | cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
[344] | 368 | return(false);
|
---|
[333] | 369 | }
|
---|
| 370 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 371 | if (it == myDirs->end()) {
|
---|
| 372 | cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
|
---|
[344] | 373 | return(false);
|
---|
[333] | 374 | }
|
---|
| 375 | *currDir = dirname;
|
---|
[449] | 376 | if (verbeux) cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
|
---|
[344] | 377 | return(true);
|
---|
[331] | 378 | }
|
---|
| 379 |
|
---|
| 380 | /* --Methode-- */
|
---|
[333] | 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++;
|
---|
[344] | 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 |
|
---|
[333] | 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-- */
|
---|
[368] | 418 | void NamedObjMgr::CleanDir(string & dirname)
|
---|
[331] | 419 | {
|
---|
[368] | 420 | if ( !CheckDirName(dirname) ) {
|
---|
| 421 | cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
[380] | 422 | // return(false); $CHECK$ illegal return value in void function
|
---|
[368] | 423 | }
|
---|
| 424 | NObjDirList::iterator itr = myDirs->find(dirname);
|
---|
| 425 | if (itr == myDirs->end()) {
|
---|
| 426 | cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - No such directory !" << endl;
|
---|
[380] | 427 | // return(false); $CHECK$ illegal return value in void function
|
---|
[368] | 428 | }
|
---|
[331] | 429 |
|
---|
[368] | 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);
|
---|
[685] | 445 | if (myImgApp)
|
---|
| 446 | (myImgApp->ObjMgrW())->UpdateList(did);
|
---|
[331] | 447 | }
|
---|
| 448 |
|
---|
[333] | 449 |
|
---|
[368] | 450 |
|
---|
[165] | 451 | //++
|
---|
| 452 | // Titre Gestion de la liste des objets
|
---|
| 453 | //--
|
---|
| 454 | //++
|
---|
[295] | 455 | // void AddObj(AnyDataObj* obj, string& nom)
|
---|
[165] | 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"
|
---|
[295] | 464 | // AnyDataObj* GetObj(string const& nom)
|
---|
[165] | 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.
|
---|
[463] | 469 | // void CopyObj(string const& nom, string& nomcp)
|
---|
| 470 | // Copy l'objet "nom" de la liste dans l'objet "nomcp" de la liste.
|
---|
[165] | 471 | //--
|
---|
| 472 |
|
---|
| 473 |
|
---|
| 474 | /* --Methode-- */
|
---|
[344] | 475 | bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
|
---|
[165] | 476 | {
|
---|
| 477 |
|
---|
[344] | 478 | if (obj == NULL) return(false);
|
---|
[333] | 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;
|
---|
[344] | 484 | return(false);
|
---|
[333] | 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;
|
---|
[344] | 494 | return(false);
|
---|
[333] | 495 | }
|
---|
| 496 | else { CreateDir(nrep); did = myDirId; }
|
---|
| 497 | }
|
---|
[165] | 498 |
|
---|
[466] | 499 | // Si c'est le repertoire /autoc, on nettoie
|
---|
| 500 | if (nrep == "autoc") {
|
---|
[368] | 501 | CleanDir(nrep);
|
---|
| 502 | }
|
---|
| 503 |
|
---|
[165] | 504 | myNObj++;
|
---|
[333] | 505 | if (nobj.length() < 1) {
|
---|
| 506 | sprintf(buff,"O%d", myNObj);
|
---|
| 507 | nobj = buff;
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 | nom = '/' + nrep + '/' + nobj;
|
---|
[344] | 511 | NObjDirList::iterator itr = myDirs->find(nrep);
|
---|
| 512 | if ((*itr).second.lock) {
|
---|
| 513 | cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl;
|
---|
| 514 | return(false);
|
---|
| 515 | }
|
---|
[333] | 516 | it = myObjs->find(nom);
|
---|
[165] | 517 | if (it != myObjs->end()) { // l'objet existe deja
|
---|
[466] | 518 | if (nrep == "autoc") { // Dans /autoc , on garde les objets affiches, donc del. par Clean
|
---|
[368] | 519 | sprintf(buff, "%d", (*it).second.oid);
|
---|
[466] | 520 | string nomnew = "/autoc/" + nobj + buff;
|
---|
[368] | 521 | RenameObj(nom, nomnew);
|
---|
| 522 | }
|
---|
| 523 | else if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
|
---|
[333] | 524 | string on,od;
|
---|
[335] | 525 | // ParseObjectName((*it).first, od, on);
|
---|
[333] | 526 | sprintf(buff, "%d", (*it).second.oid);
|
---|
[335] | 527 | string nomnew = "/old/" + nobj + buff;
|
---|
[333] | 528 | RenameObj(nom, nomnew);
|
---|
| 529 | }
|
---|
[344] | 530 | else { // Sinon, on remplace l'objet
|
---|
| 531 | cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
|
---|
| 532 | DelObj(nom);
|
---|
| 533 | }
|
---|
[165] | 534 | }
|
---|
| 535 |
|
---|
| 536 | nobj_item no;
|
---|
| 537 | no.obj = obj;
|
---|
[295] | 538 | no.obja = servnobjm->GetAdapter(obj); // L'adaptateur
|
---|
[333] | 539 | no.oid = myNObj;
|
---|
| 540 | no.dirid = did;
|
---|
[331] | 541 | (*myObjs)[nom] = no;
|
---|
[333] | 542 |
|
---|
| 543 | (*itr).second.nobj++;
|
---|
| 544 |
|
---|
[685] | 545 | if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
|
---|
[1321] | 546 | string oln = nobj + " (T= " + no.obja->GetDataObjType() + ")" ;
|
---|
[685] | 547 | (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
|
---|
| 548 | }
|
---|
[449] | 549 | if (verbeux) cout << "NamedObjMgr::AddObj() Object " << nom << " ( "
|
---|
[295] | 550 | << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;
|
---|
[344] | 551 | return(true);
|
---|
[165] | 552 | }
|
---|
| 553 |
|
---|
[1224] | 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 | }
|
---|
[1315] | 561 | AnyDataObj * cloneobj = adap->CloneDataObj(true);
|
---|
[1224] | 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 |
|
---|
[165] | 570 | /* --Methode-- */
|
---|
[344] | 571 | bool NamedObjMgr::RenameObj(string & nom, string& nomnew)
|
---|
[165] | 572 | {
|
---|
[333] | 573 | string n1,r1,n2,r2;
|
---|
[344] | 574 | int dids = ParseObjectName(nom, r1, n1);
|
---|
| 575 | NObjDirList::iterator itr1 = myDirs->find(r1);
|
---|
[333] | 576 | int did = ParseObjectName(nomnew, r2, n2);
|
---|
[344] | 577 | NObjDirList::iterator itr2 = myDirs->find(r2);
|
---|
| 578 |
|
---|
[333] | 579 | if (did == 0) {
|
---|
| 580 | cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
|
---|
[344] | 581 | return(false);
|
---|
[333] | 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;
|
---|
[344] | 588 | return(false);
|
---|
[333] | 589 | }
|
---|
| 590 | NObjList::iterator it2 = myObjs->find(nomnew);
|
---|
| 591 | if (it2 != myObjs->end()) {
|
---|
| 592 | cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl;
|
---|
[344] | 593 | return(false);
|
---|
[333] | 594 | }
|
---|
| 595 |
|
---|
[344] | 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 |
|
---|
[333] | 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++;
|
---|
[685] | 611 |
|
---|
| 612 | if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
|
---|
| 613 | (myImgApp->ObjMgrW())->DelObjList(dids, no.oid);
|
---|
[1321] | 614 | string oln = n2 + " (T= " + no.obja->GetDataObjType() + ")" ;
|
---|
[685] | 615 | (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
|
---|
| 616 | }
|
---|
[449] | 617 | if (verbeux)
|
---|
| 618 | cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
|
---|
[344] | 619 | return(true);
|
---|
[331] | 620 | }
|
---|
| 621 |
|
---|
| 622 | /* --Methode-- */
|
---|
[463] | 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);}
|
---|
[1165] | 632 | AnyDataObj* obnomcp = obnom->CloneDataObj();
|
---|
[463] | 633 | if(obnomcp==NULL) return(false);
|
---|
| 634 | if(! AddObj(obnomcp,nomcp) ) {delete obnomcp; return(false);}
|
---|
| 635 | return true;
|
---|
| 636 | }
|
---|
| 637 |
|
---|
[1164] | 638 |
|
---|
[463] | 639 | /* --Methode-- */
|
---|
[344] | 640 | bool NamedObjMgr::DelObj(string & nom, bool fgd)
|
---|
[331] | 641 | {
|
---|
[333] | 642 | string n1,r1;
|
---|
[685] | 643 | int did = ParseObjectName(nom, r1, n1);
|
---|
[333] | 644 | nom = '/' + r1 + '/' + n1;
|
---|
[165] | 645 | NObjList::iterator it = myObjs->find(nom);
|
---|
[344] | 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 | }
|
---|
[165] | 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 | }
|
---|
[314] | 658 | delete (*it).second.obja; // destruction de l'adaptateur
|
---|
[165] | 659 | if (fgd) delete (*it).second.obj;
|
---|
[333] | 660 |
|
---|
[685] | 661 | if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
|
---|
| 662 | int olid = (*it).second.oid;
|
---|
| 663 | (myImgApp->ObjMgrW())->DelObjList(did, olid);
|
---|
| 664 | }
|
---|
[165] | 665 | myObjs->erase(it);
|
---|
[333] | 666 | (*itr).second.nobj--;
|
---|
| 667 |
|
---|
[685] | 668 |
|
---|
[449] | 669 | if (!verbeux) return(true);
|
---|
[165] | 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;
|
---|
[344] | 672 | return(true);
|
---|
[165] | 673 | }
|
---|
| 674 |
|
---|
| 675 | /* --Methode-- */
|
---|
[344] | 676 | bool NamedObjMgr::DelObj_Id(int oid)
|
---|
[165] | 677 | {
|
---|
[333] | 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 | }
|
---|
[344] | 686 | if (of) return(DelObj(nom, true));
|
---|
| 687 | else return(false);
|
---|
[331] | 688 | }
|
---|
| 689 |
|
---|
| 690 | /* --Methode-- */
|
---|
| 691 | void NamedObjMgr::DelObjects(string & patt, bool fgd)
|
---|
| 692 | {
|
---|
[333] | 693 | string n1,r1;
|
---|
| 694 | ParseObjectName(patt, r1, n1);
|
---|
| 695 | patt = '/' + r1 + '/' + n1;
|
---|
[165] | 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-- */
|
---|
[331] | 708 | AnyDataObj* NamedObjMgr::GetObj(string & nom)
|
---|
[165] | 709 | {
|
---|
[333] | 710 | string n1,r1;
|
---|
| 711 | ParseObjectName(nom, r1, n1);
|
---|
| 712 | nom = '/' + r1 + '/' + n1;
|
---|
[165] | 713 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 714 | if (it == myObjs->end()) return(NULL);
|
---|
| 715 | return((*it).second.obj);
|
---|
| 716 | }
|
---|
| 717 |
|
---|
| 718 | /* --Methode-- */
|
---|
[331] | 719 | NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
|
---|
[295] | 720 | {
|
---|
[333] | 721 | string n1,r1;
|
---|
| 722 | ParseObjectName(nom, r1, n1);
|
---|
| 723 | nom = '/' + r1 + '/' + n1;
|
---|
[295] | 724 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 725 | if (it == myObjs->end()) return(NULL);
|
---|
| 726 | return((*it).second.obja);
|
---|
| 727 | }
|
---|
| 728 |
|
---|
| 729 | /* --Methode-- */
|
---|
[331] | 730 | void NamedObjMgr::ListObjs(string & patt)
|
---|
[165] | 731 | {
|
---|
[331] | 732 | int k;
|
---|
| 733 | AnyDataObj* obj=NULL;
|
---|
| 734 | string ctyp;
|
---|
| 735 | char strg[256];
|
---|
| 736 |
|
---|
[333] | 737 | string n1,r1;
|
---|
| 738 | ParseObjectName(patt, r1, n1);
|
---|
| 739 | patt = '/' + r1 + '/' + n1;
|
---|
| 740 | cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
|
---|
[331] | 741 | NObjList::iterator it; k = 0;
|
---|
[333] | 742 | string cn;
|
---|
[331] | 743 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
[333] | 744 | cn = (*it).first;
|
---|
| 745 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
[331] | 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;
|
---|
[165] | 754 | return;
|
---|
| 755 | }
|
---|
| 756 |
|
---|
| 757 | /* --Methode-- */
|
---|
[333] | 758 | void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
|
---|
[165] | 759 | {
|
---|
[333] | 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 | }
|
---|
[165] | 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-- */
|
---|
[331] | 793 | void NamedObjMgr::ReadObj(string const & flnm, string & nobj)
|
---|
[165] | 794 | {
|
---|
[495] | 795 | PPersist* ppobj=NULL;
|
---|
[165] | 796 | bool ok = true;
|
---|
[495] | 797 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 798 | TRY{
|
---|
| 799 | PInPersist pis(flnm);
|
---|
[495] | 800 | ppobj = PPersistMgr::ReadObject(pis);
|
---|
| 801 | if (ppobj == NULL) ok = false;
|
---|
[165] | 802 | } CATCH(merr)
|
---|
| 803 | { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n",
|
---|
| 804 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
[495] | 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
|
---|
[165] | 815 | if (!ok) return;
|
---|
| 816 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
---|
[495] | 817 | AddObj(ppobj->DataObj(), nobj, true);
|
---|
[685] | 818 | cout << "NamedObjMgr::ReadObj(...) object " << nobj << " read from file " << endl;
|
---|
[165] | 819 | return;
|
---|
| 820 | }
|
---|
| 821 |
|
---|
| 822 | /* --Methode-- */
|
---|
| 823 | void NamedObjMgr::ReadObj(PInPersist& s, int num)
|
---|
| 824 | {
|
---|
[2180] | 825 | int_4 i; // $CHECK$ int -> int_4 a cause de TagKey
|
---|
| 826 | #ifdef SANS_EVOLPLANCK
|
---|
| 827 | int_4 cid, key, ln; // $CHECK$ int -> int_4 a cause de TagKey
|
---|
| 828 | #endif
|
---|
[165] | 829 | int n0, n1;
|
---|
| 830 | bool ok = true;
|
---|
| 831 | PPersist* obj=NULL;
|
---|
| 832 | string nom;
|
---|
| 833 |
|
---|
[449] | 834 | int nread = 0;
|
---|
[165] | 835 | if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
|
---|
| 836 | if (num >= 0) {
|
---|
[495] | 837 | cerr << "NamedObjMgr::ReadObj(PInPersist, " << num << " Error! NbTags ="
|
---|
| 838 | << s.NbTags() << endl;
|
---|
[165] | 839 | return;
|
---|
| 840 | }
|
---|
[495] | 841 |
|
---|
| 842 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 843 | TRY {
|
---|
| 844 | obj = PPersistMgr::ReadObject(s);
|
---|
| 845 | if (obj == NULL) ok = false;
|
---|
| 846 | } CATCH(merr) {
|
---|
| 847 | printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 848 | ok = false;
|
---|
| 849 | } ENDTRY;
|
---|
[495] | 850 | #else
|
---|
| 851 | try {
|
---|
| 852 | obj = s.ReadObject();
|
---|
| 853 | }
|
---|
| 854 | catch (IOExc iox) {
|
---|
| 855 | cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 856 | ok = false;
|
---|
| 857 | }
|
---|
| 858 | #endif
|
---|
| 859 |
|
---|
[165] | 860 | if (!ok) return;
|
---|
| 861 | nom = "";
|
---|
[295] | 862 | AddObj(obj->DataObj(), nom);
|
---|
[449] | 863 | nread++;
|
---|
[165] | 864 | }
|
---|
| 865 |
|
---|
| 866 | if (num < 0) { n0 = 0; n1 = s.NbTags(); }
|
---|
| 867 | else { n0 = num; n1 = num+1; }
|
---|
| 868 | for(i=n0; i<n1; i++) {
|
---|
[495] | 869 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 870 | key = s.TagKey(i, cid, ln);
|
---|
| 871 | if (ln <= 0) nom = "";
|
---|
| 872 | else nom = s.TagName(i);
|
---|
| 873 | s.GotoTag(i);
|
---|
| 874 | TRY {
|
---|
| 875 | obj = PPersistMgr::ReadObject(s);
|
---|
| 876 | if (obj == NULL) ok = false;
|
---|
| 877 | } CATCH(merr) {
|
---|
| 878 | printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 879 | ok = false;
|
---|
| 880 | } ENDTRY;
|
---|
[495] | 881 | #else
|
---|
| 882 | s.GotoTagNum(i);
|
---|
[584] | 883 | nom = s.GetTagName(i);
|
---|
[495] | 884 | try {
|
---|
| 885 | obj = s.ReadObject();
|
---|
| 886 | }
|
---|
| 887 | catch (IOExc iox) {
|
---|
| 888 | cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 889 | ok = false;
|
---|
| 890 | }
|
---|
| 891 | #endif
|
---|
[449] | 892 | if (ok) { AddObj(obj->DataObj(), nom, true); nread++; }
|
---|
[165] | 893 | }
|
---|
| 894 |
|
---|
[449] | 895 | cout << "NamedObjMgr::ReadObj(...) " << nread << " Objects read " << endl;
|
---|
[165] | 896 | return;
|
---|
| 897 | }
|
---|
| 898 | /* --Methode-- */
|
---|
| 899 | void NamedObjMgr::ReadAll(string const & flnm)
|
---|
| 900 | {
|
---|
| 901 | bool ok = true;
|
---|
| 902 | PPersist* obj=NULL;
|
---|
| 903 |
|
---|
[2180] | 904 | PInPersist* ppin=NULL;
|
---|
[495] | 905 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 906 | TRY{
|
---|
| 907 | ppin = new PInPersist(flnm);
|
---|
| 908 | if (ppin->NbTags() < 1) obj = PPersistMgr::ReadObject((*ppin));
|
---|
| 909 | else obj = NULL;
|
---|
| 910 | } CATCH(merr)
|
---|
| 911 | { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n",
|
---|
| 912 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
[495] | 913 | #else
|
---|
| 914 | try {
|
---|
| 915 | ppin = new PInPersist(flnm);
|
---|
| 916 | if (ppin->NbTags() < 1) obj = ppin->ReadObject();
|
---|
| 917 | else obj = NULL;
|
---|
| 918 | }
|
---|
| 919 | catch (IOExc iox) {
|
---|
| 920 | cerr << "NamedObjMgr::ReadAll()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 921 | ok = false;
|
---|
| 922 | }
|
---|
| 923 | #endif
|
---|
[165] | 924 | if (!ok) return;
|
---|
| 925 | if (obj) {
|
---|
| 926 | string nom = servnobjm->FileName2Name(flnm);
|
---|
[295] | 927 | AddObj(obj->DataObj(), nom);
|
---|
[165] | 928 | }
|
---|
| 929 | else ReadObj((*ppin), -1);
|
---|
| 930 | delete ppin;
|
---|
| 931 | return;
|
---|
| 932 | }
|
---|
| 933 |
|
---|
| 934 | /* --Methode-- */
|
---|
[331] | 935 | void NamedObjMgr::ReadFits(string const & flnm, string & nobj)
|
---|
[165] | 936 | {
|
---|
| 937 |
|
---|
[293] | 938 | #ifdef SANS_EVOLPLANCK
|
---|
[2180] | 939 | bool ok = false;
|
---|
[709] | 940 | RzImage* obj=NULL;
|
---|
[495] | 941 | TRY{
|
---|
[165] | 942 | obj = RzReadFits((char*)flnm.c_str());
|
---|
| 943 | if (obj == NULL) ok = false;
|
---|
[709] | 944 | else ok = true;
|
---|
[165] | 945 | } CATCH(merr) {
|
---|
| 946 | printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 947 | ok = false;
|
---|
| 948 | } ENDTRY;
|
---|
[709] | 949 |
|
---|
| 950 | if (ok && (obj != NULL)) {
|
---|
[165] | 951 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
---|
[295] | 952 | AddObj((AnyDataObj*)obj, nobj);
|
---|
[165] | 953 | }
|
---|
[1105] | 954 | #else
|
---|
[1321] | 955 | try {
|
---|
| 956 | FITS_AutoReader fiar(flnm);
|
---|
[1335] | 957 | char bun[16];
|
---|
| 958 | int nhdu = fiar.NbBlocks();
|
---|
[1321] | 959 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
---|
| 960 | string name;
|
---|
| 961 | AnyDataObj* obj;
|
---|
[1513] | 962 | int kon = 1;
|
---|
[1321] | 963 | for(int k=1; k<=nhdu; k++) {
|
---|
| 964 | obj = fiar.ReadObject(k);
|
---|
[1330] | 965 | if (obj) {
|
---|
[1321] | 966 | cout << " NamedObjMgr::ReadFits() " << (string)typeid(*obj).name()
|
---|
| 967 | << " read From HDU " << k << endl;
|
---|
[1513] | 968 | if (typeid(*obj) == typeid(DVList)) {
|
---|
| 969 | delete obj;
|
---|
| 970 | continue;
|
---|
| 971 | }
|
---|
| 972 | if (kon > 1) {
|
---|
| 973 | sprintf(bun, "%d", kon);
|
---|
[1330] | 974 | name = nobj + bun;
|
---|
| 975 | }
|
---|
| 976 | else name = nobj;
|
---|
| 977 | AddObj(obj, name);
|
---|
[1513] | 978 | kon++;
|
---|
[1330] | 979 | }
|
---|
[1321] | 980 | else cerr << " NamedObjMgr::ReadFits() NULL pointer from FITS_AutoReader" << endl;
|
---|
| 981 | }
|
---|
| 982 | }
|
---|
| 983 | catch(PThrowable & exc) {
|
---|
| 984 | cerr << " NamedObjMgr::ReadFits() / Error - Catched Exception \n "
|
---|
| 985 | << " Type= " << (string)typeid(exc).name()
|
---|
| 986 | << " - Msg= " << exc.Msg() << endl;
|
---|
| 987 |
|
---|
| 988 | }
|
---|
[1105] | 989 | #endif
|
---|
| 990 |
|
---|
[165] | 991 | return;
|
---|
| 992 | }
|
---|
| 993 |
|
---|
| 994 |
|
---|
| 995 | static int key_for_write = 5000;
|
---|
| 996 | /* --Methode-- */
|
---|
[333] | 997 | void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
|
---|
[165] | 998 | {
|
---|
[333] | 999 | if (nom.length() < 1) return;
|
---|
| 1000 | string nob,rep;
|
---|
| 1001 | ParseObjectName(nom, rep, nob);
|
---|
| 1002 | nom = '/' + rep + '/' + nob;
|
---|
[295] | 1003 | NObjMgrAdapter* obja=NULL;
|
---|
[333] | 1004 | string nomf = (keeppath) ? nom : nob;
|
---|
[295] | 1005 | obja = GetObjAdapter(nom);
|
---|
| 1006 | if (obja == NULL) return;
|
---|
[165] | 1007 | printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
|
---|
[295] | 1008 | nom.c_str(), typeid(*(obja->GetDataObj())).name());
|
---|
[333] | 1009 | obja->SavePPF(s, nomf);
|
---|
[165] | 1010 | return;
|
---|
| 1011 | }
|
---|
| 1012 |
|
---|
| 1013 | /* --Methode-- */
|
---|
[333] | 1014 | void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
|
---|
| 1015 | {
|
---|
| 1016 | string n1,r1;
|
---|
| 1017 | if (patt.length() < 1) return;
|
---|
| 1018 | bool keeppath = (patt[0] == '/') ? true : false;
|
---|
| 1019 | ParseObjectName(patt, r1, n1);
|
---|
| 1020 | patt = '/' + r1 + '/' + n1;
|
---|
| 1021 |
|
---|
| 1022 | bool ok = true;
|
---|
[2180] | 1023 | POutPersist* pout=NULL;
|
---|
[495] | 1024 | #ifdef SANS_EVOLPLANCK
|
---|
[333] | 1025 | TRY{
|
---|
| 1026 | pout = new POutPersist(flnm);
|
---|
| 1027 | } CATCH(merr)
|
---|
| 1028 | { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n",
|
---|
| 1029 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
[495] | 1030 | #else
|
---|
| 1031 | try {
|
---|
| 1032 | pout = new POutPersist(flnm);
|
---|
| 1033 | }
|
---|
| 1034 | catch (IOExc iox) {
|
---|
| 1035 | cerr << "NamedObjMgr::SaveObjects()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 1036 | ok = false;
|
---|
| 1037 | }
|
---|
| 1038 | #endif
|
---|
[333] | 1039 | if (!ok) return;
|
---|
| 1040 | NObjList::iterator it;
|
---|
| 1041 | string cn;
|
---|
| 1042 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 1043 | cn = (*it).first;
|
---|
| 1044 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 1045 | SaveObj(cn, (*pout), keeppath);
|
---|
| 1046 | }
|
---|
| 1047 | delete pout;
|
---|
| 1048 | return;
|
---|
| 1049 | }
|
---|
| 1050 |
|
---|
| 1051 | /* --Methode-- */
|
---|
[165] | 1052 | void NamedObjMgr::SaveAll(string const& flnm)
|
---|
| 1053 | {
|
---|
| 1054 | bool ok = true;
|
---|
| 1055 |
|
---|
[2180] | 1056 | POutPersist* pout=NULL;
|
---|
[495] | 1057 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 1058 | TRY{
|
---|
| 1059 | pout = new POutPersist(flnm);
|
---|
| 1060 | } CATCH(merr)
|
---|
| 1061 | { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n",
|
---|
| 1062 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
[495] | 1063 | #else
|
---|
| 1064 | try {
|
---|
| 1065 | pout = new POutPersist(flnm);
|
---|
| 1066 | }
|
---|
| 1067 | catch (IOExc iox) {
|
---|
| 1068 | cerr << "NamedObjMgr::SaveAll()/Error Exception - Msg= " << iox.Msg() << endl;
|
---|
| 1069 | ok = false;
|
---|
| 1070 | }
|
---|
| 1071 | #endif
|
---|
[165] | 1072 | if (!ok) return;
|
---|
[332] | 1073 | NObjList::iterator it;
|
---|
| 1074 | string no;
|
---|
| 1075 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 1076 | no = (*it).first;
|
---|
[333] | 1077 | SaveObj(no, (*pout), true);
|
---|
[332] | 1078 | }
|
---|
[165] | 1079 | delete pout;
|
---|
| 1080 | return;
|
---|
| 1081 | }
|
---|
| 1082 |
|
---|
| 1083 | /* --Methode-- */
|
---|
[331] | 1084 | void NamedObjMgr::SaveFits(string& nom, string const & flnm)
|
---|
[165] | 1085 | {
|
---|
[295] | 1086 | NObjMgrAdapter* obja=NULL;
|
---|
| 1087 | obja = GetObjAdapter(nom);
|
---|
| 1088 | if (obja == NULL) return;
|
---|
| 1089 | obja->SaveFits(flnm);
|
---|
[293] | 1090 | return;
|
---|
[165] | 1091 | }
|
---|
| 1092 |
|
---|
| 1093 |
|
---|
| 1094 |
|
---|
| 1095 | /* --Methode-- */
|
---|
[331] | 1096 | void NamedObjMgr::PrintObj(string& nom)
|
---|
[165] | 1097 | {
|
---|
[295] | 1098 | NObjMgrAdapter* obja=NULL;
|
---|
| 1099 | obja = GetObjAdapter(nom);
|
---|
| 1100 | if (obja == NULL) return;
|
---|
[594] | 1101 | AnyDataObj* ob = obja->GetDataObj();
|
---|
| 1102 | if (ob == NULL) {
|
---|
| 1103 | cerr << "NamedObjMgr::PrintObj() / Error - NULL object ! in " << nom << endl;
|
---|
| 1104 | return;
|
---|
| 1105 | }
|
---|
| 1106 | string ctyp = typeid(*ob).name();
|
---|
[295] | 1107 | cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
|
---|
| 1108 | obja->Print(cout);
|
---|
[165] | 1109 |
|
---|
| 1110 | return;
|
---|
| 1111 | }
|
---|
| 1112 |
|
---|
| 1113 | /* --Methode-- */
|
---|
[331] | 1114 | void NamedObjMgr::DisplayObj(string& nom, string dopt)
|
---|
[165] | 1115 | {
|
---|
[295] | 1116 | NObjMgrAdapter* obja=NULL;
|
---|
| 1117 | obja = GetObjAdapter(nom);
|
---|
| 1118 | if (obja == NULL) {
|
---|
[594] | 1119 | cout << "NamedObjMgr::DisplayObj() Error , No object with name " << nom << endl;
|
---|
[165] | 1120 | return;
|
---|
| 1121 | }
|
---|
[594] | 1122 | if (obja->GetDataObj() == NULL) {
|
---|
| 1123 | cerr << "NamedObjMgr::DisplayObj() / Error - NULL object ! in " << nom << endl;
|
---|
| 1124 | return;
|
---|
| 1125 | }
|
---|
[165] | 1126 | if (!myImgApp) return;
|
---|
| 1127 |
|
---|
[295] | 1128 | PIDrawer * dr = NULL;
|
---|
| 1129 | P2DArrayAdapter* arr = NULL;
|
---|
| 1130 | dr = obja->GetDrawer(dopt);
|
---|
| 1131 | if (!dr) arr = obja->Get2DArray(dopt);
|
---|
[165] | 1132 |
|
---|
[295] | 1133 | if (!dr && !arr) {
|
---|
| 1134 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
[594] | 1135 | cout << "NamedObjMgr::DisplayObj() Error , No display for " << ctyp << endl;
|
---|
[295] | 1136 | return;
|
---|
| 1137 | }
|
---|
| 1138 |
|
---|
[165] | 1139 | int wrsid = 0;
|
---|
| 1140 |
|
---|
[344] | 1141 | string n1,r1;
|
---|
| 1142 | ParseObjectName(nom, r1, n1);
|
---|
| 1143 |
|
---|
[295] | 1144 | if (dr) {
|
---|
| 1145 | PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
|
---|
[1971] | 1146 | if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n1, dopt);
|
---|
| 1147 | else wrsid = myImgApp->DispScDrawer( dr, n1, dopt);
|
---|
[295] | 1148 | }
|
---|
[1971] | 1149 | else if (arr) wrsid = myImgApp->DispImage(arr, n1, dopt);
|
---|
[165] | 1150 |
|
---|
[295] | 1151 | if(wrsid != 0) {
|
---|
| 1152 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1153 | if (it == myObjs->end()) return;
|
---|
| 1154 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1155 | }
|
---|
[1971] | 1156 |
|
---|
[295] | 1157 | return;
|
---|
| 1158 | }
|
---|
[165] | 1159 |
|
---|
[295] | 1160 | /* --Methode-- */
|
---|
[331] | 1161 | void NamedObjMgr::DisplayImage(string& nom, string dopt)
|
---|
[295] | 1162 | {
|
---|
| 1163 | NObjMgrAdapter* obja=NULL;
|
---|
| 1164 | obja = GetObjAdapter(nom);
|
---|
| 1165 | if (obja == NULL) {
|
---|
[449] | 1166 | cout << "NamedObjMgr::DisplayImage() Error , No such object " << nom << endl;
|
---|
[295] | 1167 | return;
|
---|
| 1168 | }
|
---|
[594] | 1169 | if (obja->GetDataObj() == NULL) {
|
---|
| 1170 | cerr << "NamedObjMgr::DisplayImage() / Error - NULL object ! in " << nom << endl;
|
---|
| 1171 | return;
|
---|
| 1172 | }
|
---|
[295] | 1173 | if (!myImgApp) return;
|
---|
| 1174 |
|
---|
| 1175 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
---|
[165] | 1176 |
|
---|
[295] | 1177 | if (!arr) {
|
---|
| 1178 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
[449] | 1179 | cout << "NamedObjMgr::DisplayImage() Error , Not supported for " << ctyp << endl;
|
---|
[295] | 1180 | return;
|
---|
| 1181 | }
|
---|
[165] | 1182 |
|
---|
[344] | 1183 | string n1,r1;
|
---|
| 1184 | ParseObjectName(nom, r1, n1);
|
---|
| 1185 |
|
---|
[295] | 1186 | int wrsid = 0;
|
---|
[1971] | 1187 | wrsid = myImgApp->DispImage(arr, n1, dopt);
|
---|
[165] | 1188 |
|
---|
[295] | 1189 | if(wrsid != 0) {
|
---|
| 1190 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1191 | if (it == myObjs->end()) return;
|
---|
| 1192 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1193 | }
|
---|
| 1194 | return;
|
---|
| 1195 | }
|
---|
| 1196 | /* --Methode-- */
|
---|
[331] | 1197 | void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
|
---|
[295] | 1198 | {
|
---|
| 1199 | NObjMgrAdapter* obja=NULL;
|
---|
| 1200 | obja = GetObjAdapter(nom);
|
---|
| 1201 | if (obja == NULL) {
|
---|
[449] | 1202 | cout << "NamedObjMgr::DisplaySurf3D() Error , No such object " << nom << endl;
|
---|
[295] | 1203 | return;
|
---|
| 1204 | }
|
---|
[594] | 1205 | if (obja->GetDataObj() == NULL) {
|
---|
| 1206 | cerr << "NamedObjMgr::DisplaySurf3D() / Error - NULL object ! in " << nom << endl;
|
---|
| 1207 | return;
|
---|
| 1208 | }
|
---|
[295] | 1209 | if (!myImgApp) return;
|
---|
| 1210 |
|
---|
| 1211 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
---|
[165] | 1212 |
|
---|
[295] | 1213 | if (!arr) {
|
---|
| 1214 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
[449] | 1215 | cout << "NamedObjMgr::DisplaySurf3D() Error , Not supported " << ctyp << endl;
|
---|
[295] | 1216 | return;
|
---|
| 1217 | }
|
---|
[165] | 1218 |
|
---|
[295] | 1219 | if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
|
---|
| 1220 | cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
|
---|
[449] | 1221 | << "x" << arr->YSize() << ") too big (max=250x250)" << endl;
|
---|
[295] | 1222 | delete arr;
|
---|
| 1223 | return;
|
---|
[165] | 1224 | }
|
---|
| 1225 |
|
---|
[344] | 1226 | string n1,r1;
|
---|
| 1227 | ParseObjectName(nom, r1, n1);
|
---|
| 1228 |
|
---|
[295] | 1229 | int wrsid = 0;
|
---|
| 1230 | PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
|
---|
[1971] | 1231 | wrsid = myImgApp->Disp3DDrawer(sdr, n1, dopt);
|
---|
[295] | 1232 | if(wrsid >= 0) {
|
---|
[165] | 1233 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1234 | if (it == myObjs->end()) return;
|
---|
| 1235 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1236 | }
|
---|
[295] | 1237 |
|
---|
| 1238 | return;
|
---|
[165] | 1239 | }
|
---|
| 1240 |
|
---|
| 1241 | /* --Methode-- */
|
---|
[331] | 1242 | void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
|
---|
[486] | 1243 | string& erx, string& ery, string& erz, string& wt,
|
---|
| 1244 | string& label, string dopt, bool fg3d)
|
---|
[165] | 1245 | {
|
---|
[295] | 1246 | AnyDataObj* obj=GetObj(nom);
|
---|
[165] | 1247 | if (obj == NULL) {
|
---|
[449] | 1248 | cout << "NamedObjMgr::DisplayNT() Error , No such object " << nom << endl;
|
---|
[165] | 1249 | return;
|
---|
| 1250 | }
|
---|
| 1251 | if (!myImgApp) return;
|
---|
| 1252 |
|
---|
[326] | 1253 | NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
|
---|
| 1254 | if (nt == NULL) {
|
---|
| 1255 | // if (typeid(*obj) != typeid(NTupleInterface)) {
|
---|
[295] | 1256 | string ctyp = typeid(*obj).name();
|
---|
[449] | 1257 | cout << "NamedObjMgr::DisplayNT() Error , Object not an NTuple " << ctyp << endl;
|
---|
[165] | 1258 | return;
|
---|
| 1259 | }
|
---|
| 1260 |
|
---|
| 1261 | int wrsid = 0;
|
---|
[1971] | 1262 | dopt = "defline " + dopt;
|
---|
[165] | 1263 |
|
---|
[344] | 1264 | string n1,r1;
|
---|
| 1265 | ParseObjectName(nom, r1, n1);
|
---|
| 1266 |
|
---|
[333] | 1267 | if ( fg3d && (nmz.length()>0) ) { // Display 3D
|
---|
[326] | 1268 | PINTuple3D* pin = new PINTuple3D(nt, false);
|
---|
[165] | 1269 | pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
|
---|
[486] | 1270 | pin->SelectWt(wt.c_str());
|
---|
| 1271 | pin->SelectLabel(label.c_str());
|
---|
[165] | 1272 | pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
|
---|
| 1273 | string titre = nmz + "%" + nmy + "%" + nmz;
|
---|
[1971] | 1274 | wrsid = myImgApp->Disp3DDrawer(pin, n1, dopt, titre);
|
---|
[165] | 1275 | }
|
---|
| 1276 | else {
|
---|
[326] | 1277 | PINTuple* pin = new PINTuple(nt, false);
|
---|
[165] | 1278 | pin->SelectXY(nmx.c_str(), nmy.c_str());
|
---|
[486] | 1279 | pin->SelectWt(wt.c_str());
|
---|
| 1280 | pin->SelectLabel(label.c_str());
|
---|
[165] | 1281 | pin->SelectErrBar(erx.c_str(), ery.c_str());
|
---|
[333] | 1282 | string titre = nmy + "%" + nmx;
|
---|
[1971] | 1283 | wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, dopt, titre);
|
---|
[165] | 1284 | }
|
---|
| 1285 |
|
---|
| 1286 | if(wrsid >= 0) {
|
---|
| 1287 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1288 | if (it == myObjs->end()) return;
|
---|
| 1289 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1290 | }
|
---|
| 1291 |
|
---|
| 1292 | return;
|
---|
| 1293 | }
|
---|
| 1294 |
|
---|
[339] | 1295 | /* --Methode-- cmv 13/10/98 : Obsolete mais ne pas virer SVP */
|
---|
[331] | 1296 | void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
|
---|
[165] | 1297 | // Pour le display 2D ou 3D d'un ``GeneralFitData''.
|
---|
| 1298 | //| nom = nom de l'objet GeneralFitData a representer.
|
---|
| 1299 | //| numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
|
---|
| 1300 | //| numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
|
---|
| 1301 | //| Pour le display 2D, numvary="" string vide.
|
---|
| 1302 | //| err = qu'elles erreurs faut il representer ?
|
---|
| 1303 | //| - 2D : x y xy (display y=f(x))
|
---|
| 1304 | //| - 3D : x y z xy xz yz xzy (display z=f(x,y))
|
---|
| 1305 | //| Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
|
---|
| 1306 | //| les barres d'erreurs sont representees.
|
---|
| 1307 | //| opt = options generales pour le display.
|
---|
| 1308 | {
|
---|
[295] | 1309 | AnyDataObj* obj=GetObj(nom);
|
---|
[165] | 1310 | if(obj == NULL)
|
---|
[449] | 1311 | {cout << "NamedObjMgr::DisplayGFD() Error , No such object " << nom << endl;
|
---|
[165] | 1312 | return;}
|
---|
| 1313 | if(!myImgApp) return;
|
---|
[295] | 1314 | if(typeid(*obj) != typeid(GeneralFitData))
|
---|
| 1315 | {string ctyp = typeid(*obj).name();
|
---|
[449] | 1316 | cout<<"NamedObjMgr::DisplayGFD() Error , Object not a GeneralFitData "<<ctyp<<endl;
|
---|
[165] | 1317 | return;}
|
---|
| 1318 |
|
---|
| 1319 | // Decodage des erreurs a representer
|
---|
| 1320 | bool errx=false, erry=false, errz=false;
|
---|
| 1321 | if(err.length()>0) {
|
---|
[2180] | 1322 | for(int i=0;i<(int_4)err.length();i++)
|
---|
[165] | 1323 | if (err[i]=='x' || err[i]=='X') errx = true;
|
---|
| 1324 | else if(err[i]=='y' || err[i]=='Y') erry = true;
|
---|
| 1325 | else if(err[i]=='z' || err[i]=='Z') errz = true;
|
---|
| 1326 | }
|
---|
| 1327 | // Decodage des numeros de variables en abscisse
|
---|
[339] | 1328 | int numvx=-1, numvy=-1;
|
---|
| 1329 | if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
|
---|
| 1330 | if(numvary.length()>0) numvy = atoi(numvary.c_str());
|
---|
| 1331 |
|
---|
[344] | 1332 | string n1,r1;
|
---|
| 1333 | ParseObjectName(nom, r1, n1);
|
---|
| 1334 |
|
---|
[339] | 1335 | int wrsid = 0;
|
---|
| 1336 | if(numvy>=0) { // display 3D
|
---|
[165] | 1337 | PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
|
---|
| 1338 | pigfd->SelectXY(numvx,numvy);
|
---|
| 1339 | pigfd->SelectErrBar(errx,erry,errz);
|
---|
[1971] | 1340 | wrsid = myImgApp->Disp3DDrawer(pigfd,n1,dopt);
|
---|
[339] | 1341 | } else { // display 2D
|
---|
[165] | 1342 | PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
|
---|
| 1343 | pigfd->SelectX(numvx);
|
---|
| 1344 | pigfd->SelectErrBar(errx,erry);
|
---|
[1971] | 1345 | wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,dopt);
|
---|
[165] | 1346 | }
|
---|
| 1347 |
|
---|
| 1348 | if(wrsid >= 0) {
|
---|
| 1349 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1350 | if (it == myObjs->end()) return;
|
---|
| 1351 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 1352 | }
|
---|
[1971] | 1353 |
|
---|
[165] | 1354 | return;
|
---|
| 1355 | }
|
---|
| 1356 |
|
---|
[1525] | 1357 | /* --Methode-- */
|
---|
| 1358 | void NamedObjMgr::DisplayVector(string & nomvx, string& nomvy, string dopt)
|
---|
| 1359 | // Pour l'affichage 2-D de points avec coordonnees definies par deux vecteurs
|
---|
| 1360 | // nomvx et nomvy
|
---|
| 1361 | {
|
---|
| 1362 | #ifdef SANS_EVOLPLANCK
|
---|
| 1363 | cerr << " NamedObjMgr::DisplayVector() Error: Not implemented with PEIDA " << endl;
|
---|
| 1364 | #else
|
---|
| 1365 |
|
---|
| 1366 | if(!myImgApp) return;
|
---|
| 1367 |
|
---|
| 1368 | AnyDataObj* obj;
|
---|
| 1369 | obj = GetObj(nomvx);
|
---|
| 1370 | if(obj == NULL) {
|
---|
| 1371 | cout << "NamedObjMgr::DisplayVector() Error , No such object " << nomvx << endl;
|
---|
| 1372 | return;
|
---|
| 1373 | }
|
---|
| 1374 | Vector * vx = dynamic_cast<Vector *>(obj);
|
---|
| 1375 | if (vx == NULL) {
|
---|
| 1376 | cout << "NamedObjMgr::DisplayVector() Error " << nomvx << " not a Vector ! " << endl;
|
---|
| 1377 | return;
|
---|
| 1378 | }
|
---|
| 1379 |
|
---|
| 1380 | obj = GetObj(nomvy);
|
---|
| 1381 | if(obj == NULL) {
|
---|
| 1382 | cout << "NamedObjMgr::DisplayVector() Error , No such object " << nomvy << endl;
|
---|
| 1383 | return;
|
---|
| 1384 | }
|
---|
| 1385 | Vector * vy = dynamic_cast<Vector *>(obj);
|
---|
| 1386 | if (vy == NULL) {
|
---|
| 1387 | cout << "NamedObjMgr::DisplayVector() Error " << nomvy << " not a Vector ! " << endl;
|
---|
| 1388 | return;
|
---|
| 1389 | }
|
---|
| 1390 |
|
---|
| 1391 |
|
---|
| 1392 | Vector * cvx, * cvy;
|
---|
| 1393 |
|
---|
| 1394 | if (vx->Size() != vy->Size()) {
|
---|
| 1395 | cout << "NamedObjMgr::DisplayVector() Warning / Vx.Size() != Vy.Size() " << endl;
|
---|
| 1396 | if (vx->Size() < vy->Size()) {
|
---|
| 1397 | cvx = new Vector(*vx);
|
---|
| 1398 | cvy = new Vector(vy->SubVector(Range(0, 0, vx->Size()-1)));
|
---|
| 1399 | }
|
---|
| 1400 | else {
|
---|
| 1401 | cvx = new Vector(vx->SubVector(Range(0, 0, vy->Size()-1)));
|
---|
| 1402 | cvy = new Vector(*vy);
|
---|
| 1403 | }
|
---|
| 1404 | }
|
---|
| 1405 | else {
|
---|
| 1406 | cvx = new Vector(*vx);
|
---|
| 1407 | cvy = new Vector(*vy);
|
---|
| 1408 | }
|
---|
| 1409 |
|
---|
| 1410 | POVectorAdapter * avx = new POVectorAdapter(cvx, true);
|
---|
| 1411 | POVectorAdapter * avy = new POVectorAdapter(cvy, true);
|
---|
| 1412 | PIYfXDrawer * vxydrw = new PIYfXDrawer(avx, avy, true);
|
---|
| 1413 |
|
---|
| 1414 | string nx,rx;
|
---|
| 1415 | ParseObjectName(nomvx, rx, nx);
|
---|
| 1416 | string ny,ry;
|
---|
| 1417 | ParseObjectName(nomvy, ry, ny);
|
---|
| 1418 |
|
---|
| 1419 | string title = ny + " (Y) vs. " + nx + " (X)";
|
---|
| 1420 | // display 2D
|
---|
[2180] | 1421 | myImgApp->DispScDrawer(vxydrw, title, dopt);
|
---|
[1525] | 1422 |
|
---|
| 1423 | return;
|
---|
| 1424 |
|
---|
| 1425 | #endif
|
---|
| 1426 | }
|
---|
| 1427 |
|
---|
[165] | 1428 | /* --Methode--
|
---|
[331] | 1429 | void NamedObjMgr::DisplayImage(string& nom, string dopt)
|
---|
[165] | 1430 | {
|
---|
| 1431 | cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
|
---|
| 1432 | }
|
---|
| 1433 | */
|
---|
| 1434 |
|
---|
| 1435 |
|
---|
| 1436 |
|
---|
| 1437 |
|
---|
[1971] | 1438 | /* --Methode--
|
---|
[165] | 1439 | void NamedObjMgr::SetGraphicAttributes(string gratt)
|
---|
| 1440 | {
|
---|
| 1441 | bool fg = false;
|
---|
| 1442 | servnobjm->DecodeDispOption(gratt, fg);
|
---|
[546] | 1443 | Services2NObjMgr::SetDefaultStatsOption(Services2NObjMgr::GetStatsOption(gratt));
|
---|
[165] | 1444 | }
|
---|
[333] | 1445 |
|
---|
[165] | 1446 | void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
|
---|
| 1447 | {
|
---|
| 1448 | if (!myImgApp) return;
|
---|
| 1449 | if (fcr) myImgApp->CreateGraphWin(nzx, nzy);
|
---|
| 1450 | else myImgApp->SetZone(nzx, nzy);
|
---|
| 1451 | }
|
---|
[1971] | 1452 | */
|
---|
[165] | 1453 |
|
---|
| 1454 | /* --Methode-- */
|
---|
[333] | 1455 | void NamedObjMgr::AddWRsId(string & nom, int wrsid)
|
---|
[165] | 1456 | {
|
---|
[333] | 1457 | if(wrsid != 0) {
|
---|
| 1458 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1459 | if (it == myObjs->end()) return;
|
---|
| 1460 | (*it).second.wrsid.push_back(wrsid);
|
---|
[295] | 1461 | }
|
---|
[165] | 1462 | return;
|
---|
| 1463 | }
|
---|
| 1464 |
|
---|
| 1465 | /* --Methode-- */
|
---|
[333] | 1466 | void NamedObjMgr::UpdateObjMgrWindow(int did)
|
---|
[165] | 1467 | {
|
---|
[333] | 1468 | if (!myImgApp) return;
|
---|
[685] | 1469 | (myImgApp->ObjMgrW())->ClearObjList();
|
---|
[165] | 1470 |
|
---|
[333] | 1471 | NObjList::iterator it;
|
---|
| 1472 | string cn;
|
---|
| 1473 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 1474 | if ((*it).second.dirid != did) continue;
|
---|
| 1475 | cn = (*it).first.substr(1);
|
---|
[1321] | 1476 | // cn = cn.substr(cn.find('/')+1) + " (T= " + typeid(*((*it).second.obj)).name() + ")" ;
|
---|
| 1477 | cn = cn.substr(cn.find('/')+1) + " (T= " + (*it).second.obja->GetDataObjType() + ")" ;
|
---|
[685] | 1478 | (myImgApp->ObjMgrW())->AddObj(cn.c_str(), (*it).second.oid);
|
---|
[165] | 1479 | }
|
---|
[333] | 1480 | }
|
---|
[165] | 1481 |
|
---|
| 1482 |
|
---|
[333] | 1483 | /* Nouvelle-Fonction */
|
---|
[1207] | 1484 | void NamedObjMgr::RemoveSpacesFromName(string & nom)
|
---|
[165] | 1485 | {
|
---|
[333] | 1486 | // on supprime les blancs de debut et de fin
|
---|
| 1487 | size_t p = nom.find_first_not_of(" ");
|
---|
| 1488 | if(p>nom.length()) { nom = ""; return; }
|
---|
| 1489 | nom = nom.substr(p);
|
---|
| 1490 | p = nom.find(' ');
|
---|
| 1491 | if(p>nom.length()) p=nom.length();
|
---|
| 1492 | nom = nom.substr(0, p);
|
---|
[165] | 1493 | }
|
---|
| 1494 |
|
---|
[333] | 1495 | /* Nouvelle-Fonction */
|
---|
[1207] | 1496 | bool NamedObjMgr::CheckDirName(string & nom)
|
---|
[165] | 1497 | {
|
---|
[333] | 1498 | RemoveSpacesFromName(nom);
|
---|
| 1499 | if (nom.length() < 1) return(false);
|
---|
| 1500 | if (nom[0] == '/') nom = nom.substr(1) ;
|
---|
| 1501 | size_t p = nom.find('/');
|
---|
| 1502 | if (p < nom.length()) nom = nom.substr(0,p);
|
---|
| 1503 | if (nom.length() < 1) return(false);
|
---|
| 1504 | return(true);
|
---|
[165] | 1505 | }
|
---|
| 1506 |
|
---|
[333] | 1507 | /* Nouvelle-Fonction */
|
---|
[1207] | 1508 | int NamedObjMgr::ParseObjectName(string & nom, string & nomrep, string & nomobj)
|
---|
[165] | 1509 | {
|
---|
[333] | 1510 | RemoveSpacesFromName(nom);
|
---|
| 1511 | // Si le nom ne commence pas par un slash, c'est le repertoire courant
|
---|
| 1512 | if (nom[0] != '/') { nomrep = *currDir; nomobj = nom; }
|
---|
[165] | 1513 | else {
|
---|
[333] | 1514 | string xx = nom.substr(1);
|
---|
| 1515 | size_t p = xx.find('/');
|
---|
| 1516 | if (p < xx.length()) {
|
---|
| 1517 | nomrep = xx.substr(0,p);
|
---|
| 1518 | nomobj = xx.substr(p+1);
|
---|
[165] | 1519 | }
|
---|
[333] | 1520 | else {
|
---|
| 1521 | nomrep = xx;
|
---|
| 1522 | nomobj = "";
|
---|
[165] | 1523 | }
|
---|
| 1524 | }
|
---|
[333] | 1525 | int rc = 0;
|
---|
| 1526 | NObjDirList::iterator it = myDirs->find(nomrep);
|
---|
| 1527 | if (it != myDirs->end()) rc = (*it).second.id;
|
---|
| 1528 | return(rc);
|
---|
[165] | 1529 | }
|
---|
| 1530 |
|
---|