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