[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 | #if defined(__KCC__)
|
---|
| 11 | using std::string ;
|
---|
| 12 | #include <list.h>
|
---|
| 13 | #include <map.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include "strutil.h"
|
---|
| 17 | #include "datatypes.h"
|
---|
| 18 |
|
---|
| 19 | #include "nobjmgr.h"
|
---|
| 20 | #include "servnobjm.h"
|
---|
[330] | 21 | #include "nomgadapter.h"
|
---|
[165] | 22 | #include "pistdimgapp.h"
|
---|
| 23 |
|
---|
| 24 |
|
---|
[293] | 25 | // EVOL-PLANCK
|
---|
| 26 | #ifdef SANS_EVOLPLANCK
|
---|
| 27 | #include "fitsimage.h"
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
[295] | 30 | #include "pisurfdr.h"
|
---|
[165] | 31 | #include "pipodrw.h"
|
---|
[333] | 32 |
|
---|
[165] | 33 | #include "pintuple.h"
|
---|
| 34 | #include "pintup3d.h"
|
---|
| 35 | #include "pigfd1.h"
|
---|
| 36 | #include "pigfd2.h"
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | //++
|
---|
| 40 | // Class NamedObjMgr
|
---|
| 41 | // Lib PI
|
---|
| 42 | // include nobjmgr.h
|
---|
| 43 | //
|
---|
| 44 | // Cette classe fournit les services nécéssaire àla gestion des objets
|
---|
| 45 | // (l'ensemble des objets PPersist de PEIDA++) au sein du programme
|
---|
| 46 | // d'analyse interactive *piapp* . Elle constitue en outre l'interface
|
---|
| 47 | // entre les fonctions utilisateur et l'application graphique.
|
---|
| 48 | //--
|
---|
| 49 | //++
|
---|
| 50 | // Links Voir aussi
|
---|
| 51 | // PIStdImgApp
|
---|
| 52 | // Services2NObjMgr
|
---|
| 53 | // PIACmd
|
---|
| 54 | //--
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | // ..................................................................
|
---|
| 58 | // ...... Gestion des objets nommes, variables globales ............
|
---|
[331] | 59 | struct nobj_diritem {
|
---|
| 60 | int id;
|
---|
| 61 | int nobj;
|
---|
| 62 | };
|
---|
| 63 |
|
---|
| 64 | typedef map<string, nobj_diritem, less<string> > NObjDirList;
|
---|
| 65 |
|
---|
[165] | 66 | struct nobj_item {
|
---|
[295] | 67 | AnyDataObj* obj;
|
---|
| 68 | NObjMgrAdapter* obja;
|
---|
[333] | 69 | int oid;
|
---|
[331] | 70 | int dirid;
|
---|
[165] | 71 | list<int> wrsid;
|
---|
| 72 | bool operator==(nobj_item const& b) const
|
---|
| 73 | { return (this->obj == b.obj); }
|
---|
| 74 | };
|
---|
| 75 |
|
---|
| 76 | typedef map<string, nobj_item, less<string> > NObjList;
|
---|
| 77 |
|
---|
[331] | 78 | static NObjDirList* myDirs = NULL;
|
---|
| 79 | static NObjList* myObjs = NULL;
|
---|
[165] | 80 | static int fgOInit = 0;
|
---|
| 81 | static int myNObj = 0;
|
---|
[331] | 82 | static int myDirId = 0;
|
---|
| 83 | static string* currDir;
|
---|
[165] | 84 |
|
---|
| 85 | static PIStdImgApp* myImgApp=NULL;
|
---|
| 86 | static Services2NObjMgr* servnobjm=NULL;
|
---|
| 87 |
|
---|
| 88 | static string* TmpDir; // Repertoire pour les compilations / link dynamique
|
---|
| 89 |
|
---|
[333] | 90 | // Pour completer le nom de l'objet avec le nom du repertoire
|
---|
| 91 | static void RemoveSpacesFromName(string & nom);
|
---|
| 92 | static bool CheckDirName(string & nom);
|
---|
| 93 | static int ParseObjectName(string & nom, string & nomrep, string & nomobj);
|
---|
| 94 | // ..................................................................
|
---|
| 95 |
|
---|
[165] | 96 | //++
|
---|
| 97 | // Titre Constructeurs
|
---|
| 98 | //--
|
---|
| 99 | //++
|
---|
| 100 | // NamedObjMgr()
|
---|
| 101 | // Constructeur. Les différents instantiation de la classe "NamedObjMgr"
|
---|
| 102 | // dans une même application créent des objets qui travaillent sur la même
|
---|
| 103 | // liste d'objets. Les objets de cette classe ne possedent en effet pas
|
---|
| 104 | // de variables membres.
|
---|
| 105 | //--
|
---|
| 106 |
|
---|
| 107 | /* --Methode-- */
|
---|
| 108 | NamedObjMgr::NamedObjMgr()
|
---|
| 109 | {
|
---|
| 110 | if (fgOInit == 0) {
|
---|
[333] | 111 | myNObj = 0;
|
---|
| 112 | myDirId = 0;
|
---|
[331] | 113 | myDirs = new NObjDirList;
|
---|
[165] | 114 | myObjs = new NObjList;
|
---|
[331] | 115 | currDir = new string("home");
|
---|
[333] | 116 | string dirn = "home";
|
---|
| 117 | CreateDir(dirn);
|
---|
| 118 | dirn = "tmp";
|
---|
| 119 | CreateDir(dirn);
|
---|
| 120 | dirn = "old";
|
---|
| 121 | CreateDir(dirn);
|
---|
| 122 | dirn = "home";
|
---|
| 123 | SetCurrentDir(dirn);
|
---|
| 124 | myDirId = 50;
|
---|
[165] | 125 | char* varenv;
|
---|
| 126 | TmpDir = new string("");
|
---|
| 127 | if ( (varenv=getenv("PEIDA_TMP")) != NULL ) (*TmpDir) = varenv;
|
---|
| 128 | else if ( (varenv=getenv("TMPDIR")) != NULL ) (*TmpDir) = varenv;
|
---|
| 129 | int l = (*TmpDir).length();
|
---|
| 130 | if ( (l>0) && ((*TmpDir)[l-1] != '/') ) (*TmpDir) += '/';
|
---|
[333] | 131 | servnobjm = new Services2NObjMgr(this, (*TmpDir));
|
---|
[165] | 132 | }
|
---|
| 133 | fgOInit++;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | /* --Methode-- */
|
---|
| 138 | NamedObjMgr::~NamedObjMgr()
|
---|
| 139 | {
|
---|
| 140 | fgOInit--;
|
---|
| 141 | if (fgOInit == 0) delete myObjs;
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | //++
|
---|
| 145 | // Titre Méthodes
|
---|
| 146 | //--
|
---|
| 147 | //++
|
---|
| 148 | // void SetImgApp(PIStdImgApp* app)
|
---|
| 149 | // Spécifie l'objet "PIStdImgApp" associé.
|
---|
| 150 | // PIStdImgApp* GetImgApp()
|
---|
| 151 | // Accès à l'objet "PIStdImgApp" associé.
|
---|
| 152 | //--
|
---|
| 153 |
|
---|
| 154 | /* --Methode-- */
|
---|
| 155 | void NamedObjMgr::SetImgApp(PIStdImgApp* app)
|
---|
| 156 | {
|
---|
| 157 | myImgApp = app;
|
---|
| 158 | servnobjm->SetImgApp(app);
|
---|
[333] | 159 |
|
---|
| 160 | NObjDirList::iterator it;
|
---|
| 161 | string cn;
|
---|
| 162 | for(it= myDirs->begin(); it != myDirs->end(); it++) {
|
---|
| 163 | cn = '/' + (*it).first;
|
---|
| 164 | (myImgApp->ObjMgrW())->AddDirectory(cn.c_str(), (*it).second.id);
|
---|
| 165 | }
|
---|
[165] | 166 | }
|
---|
| 167 |
|
---|
| 168 | /* --Methode-- */
|
---|
| 169 | PIStdImgApp* NamedObjMgr::GetImgApp()
|
---|
| 170 | {
|
---|
| 171 | return(myImgApp);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | /* --Methode-- */
|
---|
| 175 | Services2NObjMgr* NamedObjMgr::GetServiceObj()
|
---|
| 176 | {
|
---|
| 177 | return(servnobjm);
|
---|
| 178 | }
|
---|
| 179 |
|
---|
[331] | 180 | /* --Methode-- */
|
---|
[333] | 181 | void NamedObjMgr::CreateDir(string & dirname)
|
---|
[331] | 182 | {
|
---|
[333] | 183 | if ( !CheckDirName(dirname) ) {
|
---|
| 184 | cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
| 185 | return;
|
---|
| 186 | }
|
---|
| 187 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 188 | if (it != myDirs->end()) {
|
---|
| 189 | cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
|
---|
| 190 | return;
|
---|
| 191 | }
|
---|
| 192 | myDirId++;
|
---|
| 193 | nobj_diritem di;
|
---|
| 194 | di.id = myDirId;
|
---|
| 195 | di.nobj = 0;
|
---|
| 196 | (*myDirs)[dirname] = di;
|
---|
| 197 | if (myImgApp) {
|
---|
| 198 | string str = '/' + dirname;
|
---|
| 199 | (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
|
---|
| 200 | }
|
---|
| 201 | cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
|
---|
[331] | 202 | }
|
---|
| 203 |
|
---|
| 204 | /* --Methode-- */
|
---|
[333] | 205 | void NamedObjMgr::DeleteDir(string & dirname)
|
---|
[331] | 206 | {
|
---|
[333] | 207 | if ( !CheckDirName(dirname) ) {
|
---|
| 208 | cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
| 209 | return;
|
---|
| 210 | }
|
---|
| 211 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 212 | if (it == myDirs->end()) {
|
---|
| 213 | cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
|
---|
| 214 | return;
|
---|
| 215 | }
|
---|
| 216 | if ((*it).second.nobj > 0) {
|
---|
| 217 | cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
|
---|
| 218 | return;
|
---|
| 219 | }
|
---|
| 220 | if ((*it).second.id < 50) {
|
---|
| 221 | cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
|
---|
| 222 | return;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | if (myImgApp)
|
---|
| 226 | (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
|
---|
| 227 | myDirs->erase(it);
|
---|
| 228 | cout << "amedObjMgr::DeleteDir() " << dirname << " deleted " << endl;
|
---|
[331] | 229 | }
|
---|
| 230 |
|
---|
| 231 | /* --Methode-- */
|
---|
[333] | 232 | void NamedObjMgr::SetCurrentDir(string & dirname)
|
---|
[331] | 233 | {
|
---|
[333] | 234 | if ( !CheckDirName(dirname) ) {
|
---|
| 235 | cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
|
---|
| 236 | return;
|
---|
| 237 | }
|
---|
| 238 | NObjDirList::iterator it = myDirs->find(dirname);
|
---|
| 239 | if (it == myDirs->end()) {
|
---|
| 240 | cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
|
---|
| 241 | return;
|
---|
| 242 | }
|
---|
| 243 | *currDir = dirname;
|
---|
| 244 | cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
|
---|
[331] | 245 | }
|
---|
| 246 |
|
---|
| 247 | /* --Methode-- */
|
---|
[333] | 248 | void NamedObjMgr::GetCurrentDir(string & dirname)
|
---|
| 249 | {
|
---|
| 250 | dirname = *currDir;
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | /* --Methode-- */
|
---|
| 254 | void NamedObjMgr::ListDirs(string & patt)
|
---|
| 255 | {
|
---|
| 256 | NObjDirList::iterator it;
|
---|
| 257 | string cn;
|
---|
| 258 | cout << "NamedObjMgr::ListDirs( " << patt << " ) " << endl;
|
---|
| 259 | int k = 0;
|
---|
| 260 | for(it= myDirs->begin(); it != myDirs->end(); it++) {
|
---|
| 261 | cn = (*it).first;
|
---|
| 262 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 263 | k++;
|
---|
| 264 | cout << k << "- " << (*it).first << " (NbObj= " << (*it).second.nobj << ")" << endl;
|
---|
| 265 | }
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | /* --Methode-- */
|
---|
| 269 | void NamedObjMgr::GetDirList(string & patt, vector<string>& lstd)
|
---|
| 270 | {
|
---|
| 271 | NObjDirList::iterator it;
|
---|
| 272 | string cn;
|
---|
| 273 | for(it= myDirs->begin(); it != myDirs->end(); it++) {
|
---|
| 274 | cn = (*it).first;
|
---|
| 275 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 276 | lstd.push_back(cn);
|
---|
| 277 | }
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 | /* --Methode-- */
|
---|
[331] | 281 | void NamedObjMgr::CleanTmpDir()
|
---|
| 282 | {
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | /* --Methode-- */
|
---|
| 286 | void NamedObjMgr::CleanOldDir()
|
---|
| 287 | {
|
---|
| 288 | }
|
---|
| 289 |
|
---|
[333] | 290 |
|
---|
[165] | 291 | //++
|
---|
| 292 | // Titre Gestion de la liste des objets
|
---|
| 293 | //--
|
---|
| 294 | //++
|
---|
[295] | 295 | // void AddObj(AnyDataObj* obj, string& nom)
|
---|
[165] | 296 | // Ajoute l'objet "obj" à la liste, identifié par "nom".
|
---|
| 297 | // Si un objet de même nom existe, l'ancien objet est renommé en concaténant
|
---|
| 298 | // un numéro à son nom.
|
---|
| 299 | // void DelObj(string const& nom, bool fgd=true)
|
---|
| 300 | // Supprime l'objet "nom" de la liste. L'objet est détruit si "fgd==true" ("delete obj")
|
---|
| 301 | // void DelObjects(string const& patt, bool fgd=true)
|
---|
| 302 | // Supprime l'ensemble des objets dont le nom correspond au patron "patt".
|
---|
| 303 | // Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
|
---|
[295] | 304 | // AnyDataObj* GetObj(string const& nom)
|
---|
[165] | 305 | // Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est
|
---|
| 306 | // pas dans la liste.
|
---|
| 307 | // void RenameObj(string const& nom, string& nomnew)
|
---|
| 308 | // Change le nom d'un objet dans la liste.
|
---|
| 309 | //--
|
---|
| 310 |
|
---|
| 311 |
|
---|
| 312 | /* --Methode-- */
|
---|
[333] | 313 | void NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
|
---|
[165] | 314 | {
|
---|
| 315 |
|
---|
| 316 | if (obj == NULL) return;
|
---|
[333] | 317 | // On verifie si l'objet est deja dans la liste
|
---|
| 318 | NObjList::iterator it;
|
---|
| 319 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 320 | if ((*it).second.obj == obj) {
|
---|
| 321 | cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl;
|
---|
| 322 | return;
|
---|
| 323 | }
|
---|
| 324 | }
|
---|
| 325 | string nobj;
|
---|
| 326 | string nrep;
|
---|
| 327 | char buff[32];
|
---|
| 328 | int did = ParseObjectName(nom, nrep, nobj);
|
---|
| 329 | if (did == 0) {
|
---|
| 330 | if (!crd) {
|
---|
| 331 | cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl;
|
---|
| 332 | return;
|
---|
| 333 | }
|
---|
| 334 | else { CreateDir(nrep); did = myDirId; }
|
---|
| 335 | }
|
---|
[165] | 336 |
|
---|
| 337 | myNObj++;
|
---|
[333] | 338 | if (nobj.length() < 1) {
|
---|
| 339 | sprintf(buff,"O%d", myNObj);
|
---|
| 340 | nobj = buff;
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | nom = '/' + nrep + '/' + nobj;
|
---|
| 344 | it = myObjs->find(nom);
|
---|
[165] | 345 | if (it != myObjs->end()) { // l'objet existe deja
|
---|
[333] | 346 | if (nrep == "tmp") { // Les objets de /tmp sont jetes
|
---|
| 347 | cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
|
---|
| 348 | DelObj(nom);
|
---|
| 349 | }
|
---|
| 350 | else { // On met l'ancien objet dans /old
|
---|
| 351 | string on,od;
|
---|
[335] | 352 | // ParseObjectName((*it).first, od, on);
|
---|
[333] | 353 | sprintf(buff, "%d", (*it).second.oid);
|
---|
[335] | 354 | string nomnew = "/old/" + nobj + buff;
|
---|
[333] | 355 | RenameObj(nom, nomnew);
|
---|
| 356 | }
|
---|
[165] | 357 | }
|
---|
| 358 |
|
---|
| 359 | nobj_item no;
|
---|
| 360 | no.obj = obj;
|
---|
[295] | 361 | no.obja = servnobjm->GetAdapter(obj); // L'adaptateur
|
---|
[333] | 362 | no.oid = myNObj;
|
---|
| 363 | no.dirid = did;
|
---|
[331] | 364 | (*myObjs)[nom] = no;
|
---|
[333] | 365 |
|
---|
| 366 | NObjDirList::iterator itr = myDirs->find(nrep);
|
---|
| 367 | (*itr).second.nobj++;
|
---|
| 368 |
|
---|
[331] | 369 | cout << "NamedObjMgr::AddObj() Object " << nom << " ( "
|
---|
[295] | 370 | << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;
|
---|
[165] | 371 | return;
|
---|
| 372 | }
|
---|
| 373 |
|
---|
| 374 | /* --Methode-- */
|
---|
[331] | 375 | void NamedObjMgr::RenameObj(string & nom, string& nomnew)
|
---|
[165] | 376 | {
|
---|
[333] | 377 | string n1,r1,n2,r2;
|
---|
| 378 | ParseObjectName(nom, r1, n1);
|
---|
| 379 | int did = ParseObjectName(nomnew, r2, n2);
|
---|
| 380 | if (did == 0) {
|
---|
| 381 | cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
|
---|
| 382 | return;
|
---|
| 383 | }
|
---|
| 384 | nom = '/' + r1 + '/' + n1;
|
---|
| 385 | nomnew = '/' + r2 + '/' + n2;
|
---|
| 386 | NObjList::iterator it1 = myObjs->find(nom);
|
---|
| 387 | if (it1 == myObjs->end()) {
|
---|
| 388 | cout << "NamedObjMgr::RenameObj() Error - No " << nom << " object !" << endl;
|
---|
| 389 | return;
|
---|
| 390 | }
|
---|
| 391 | NObjList::iterator it2 = myObjs->find(nomnew);
|
---|
| 392 | if (it2 != myObjs->end()) {
|
---|
| 393 | cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl;
|
---|
| 394 | return;
|
---|
| 395 | }
|
---|
| 396 |
|
---|
| 397 | nobj_item no = (*it1).second;
|
---|
| 398 | no.dirid = did;
|
---|
| 399 | myObjs->erase(it1);
|
---|
| 400 | NObjDirList::iterator itr = myDirs->find(r1);
|
---|
| 401 | (*itr).second.nobj--;
|
---|
| 402 | (*myObjs)[nomnew] = no;
|
---|
| 403 | itr = myDirs->find(r2);
|
---|
| 404 | (*itr).second.nobj++;
|
---|
| 405 | cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
|
---|
[331] | 406 | return;
|
---|
| 407 | }
|
---|
| 408 |
|
---|
| 409 | /* --Methode-- */
|
---|
| 410 | void NamedObjMgr::DelObj(string & nom, bool fgd)
|
---|
| 411 | {
|
---|
[333] | 412 | string n1,r1;
|
---|
| 413 | ParseObjectName(nom, r1, n1);
|
---|
| 414 | nom = '/' + r1 + '/' + n1;
|
---|
[165] | 415 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 416 | if (it == myObjs->end()) return;
|
---|
| 417 | list<int>::iterator ii;
|
---|
| 418 | if (myImgApp) {
|
---|
| 419 | //DBG cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl;
|
---|
| 420 | for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++)
|
---|
| 421 | myImgApp->DelWRsId((*ii));
|
---|
| 422 | }
|
---|
[314] | 423 | delete (*it).second.obja; // destruction de l'adaptateur
|
---|
[165] | 424 | if (fgd) delete (*it).second.obj;
|
---|
[333] | 425 |
|
---|
[165] | 426 | myObjs->erase(it);
|
---|
[333] | 427 | NObjDirList::iterator itr = myDirs->find(r1);
|
---|
| 428 | (*itr).second.nobj--;
|
---|
| 429 |
|
---|
[165] | 430 | if (fgd) cout << "NamedObjMgr::DelObj() Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
|
---|
| 431 | else cout << "NamedObjMgr::DelObj() Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
|
---|
| 432 | return;
|
---|
| 433 | }
|
---|
| 434 |
|
---|
| 435 | /* --Methode-- */
|
---|
[331] | 436 | void NamedObjMgr::DelObj_Id(int oid)
|
---|
[165] | 437 | {
|
---|
[333] | 438 | NObjList::iterator it;
|
---|
| 439 | string nom;
|
---|
| 440 | bool of = false;
|
---|
| 441 | for(it = myObjs->begin(); it != myObjs->end(); it++)
|
---|
| 442 | if ( (*it).second.oid == oid ) {
|
---|
| 443 | of = true; nom = (*it).first;
|
---|
| 444 | break;
|
---|
| 445 | }
|
---|
| 446 | if (of) DelObj(nom, true);
|
---|
[331] | 447 | }
|
---|
| 448 |
|
---|
| 449 | /* --Methode-- */
|
---|
| 450 | void NamedObjMgr::DelObjects(string & patt, bool fgd)
|
---|
| 451 | {
|
---|
[333] | 452 | string n1,r1;
|
---|
| 453 | ParseObjectName(patt, r1, n1);
|
---|
| 454 | patt = '/' + r1 + '/' + n1;
|
---|
[165] | 455 | NObjList::iterator it;
|
---|
| 456 | list<string> odel;
|
---|
| 457 | string cn;
|
---|
| 458 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 459 | cn = (*it).first;
|
---|
| 460 | if (csh_parse(cn.c_str(), patt.c_str()) != 0) odel.push_back(cn);
|
---|
| 461 | }
|
---|
| 462 | list<string>::iterator ii;
|
---|
| 463 | for(ii=odel.begin(); ii != odel.end(); ii++) DelObj(*ii, fgd);
|
---|
| 464 | }
|
---|
| 465 |
|
---|
| 466 | /* --Methode-- */
|
---|
[331] | 467 | AnyDataObj* NamedObjMgr::GetObj(string & nom)
|
---|
[165] | 468 | {
|
---|
[333] | 469 | string n1,r1;
|
---|
| 470 | ParseObjectName(nom, r1, n1);
|
---|
| 471 | nom = '/' + r1 + '/' + n1;
|
---|
[165] | 472 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 473 | if (it == myObjs->end()) return(NULL);
|
---|
| 474 | return((*it).second.obj);
|
---|
| 475 | }
|
---|
| 476 |
|
---|
| 477 | /* --Methode-- */
|
---|
[331] | 478 | NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
|
---|
[295] | 479 | {
|
---|
[333] | 480 | string n1,r1;
|
---|
| 481 | ParseObjectName(nom, r1, n1);
|
---|
| 482 | nom = '/' + r1 + '/' + n1;
|
---|
[295] | 483 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 484 | if (it == myObjs->end()) return(NULL);
|
---|
| 485 | return((*it).second.obja);
|
---|
| 486 | }
|
---|
| 487 |
|
---|
| 488 | /* --Methode-- */
|
---|
[331] | 489 | void NamedObjMgr::ListObjs(string & patt)
|
---|
[165] | 490 | {
|
---|
[331] | 491 | int k;
|
---|
| 492 | AnyDataObj* obj=NULL;
|
---|
| 493 | string ctyp;
|
---|
| 494 | char strg[256];
|
---|
| 495 |
|
---|
[333] | 496 | string n1,r1;
|
---|
| 497 | ParseObjectName(patt, r1, n1);
|
---|
| 498 | patt = '/' + r1 + '/' + n1;
|
---|
| 499 | cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
|
---|
[331] | 500 | NObjList::iterator it; k = 0;
|
---|
[333] | 501 | string cn;
|
---|
[331] | 502 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
[333] | 503 | cn = (*it).first;
|
---|
| 504 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
[331] | 505 | obj = (*it).second.obj;
|
---|
| 506 | ctyp = typeid(*obj).name();
|
---|
| 507 | sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str());
|
---|
| 508 | ctyp = strg;
|
---|
| 509 | cout << ctyp << "\n" ;
|
---|
| 510 | k++;
|
---|
| 511 | }
|
---|
| 512 | cout << endl;
|
---|
[165] | 513 | return;
|
---|
| 514 | }
|
---|
| 515 |
|
---|
| 516 | /* --Methode-- */
|
---|
[333] | 517 | void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
|
---|
[165] | 518 | {
|
---|
[333] | 519 | string n1,r1;
|
---|
| 520 | if (patt.length() < 1) return;
|
---|
| 521 | bool fgr = (patt[0] == '/') ? true : false;
|
---|
| 522 | ParseObjectName(patt, r1, n1);
|
---|
| 523 | patt = '/' + r1 + '/' + n1;
|
---|
| 524 | NObjList::iterator it;
|
---|
| 525 | string cn;
|
---|
| 526 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 527 | cn = (*it).first;
|
---|
| 528 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 529 | if (fgr) lst.push_back(cn);
|
---|
| 530 | else {
|
---|
| 531 | ParseObjectName(cn, r1, n1);
|
---|
| 532 | lst.push_back(n1);
|
---|
| 533 | }
|
---|
| 534 | }
|
---|
[165] | 535 | }
|
---|
| 536 |
|
---|
| 537 | //++
|
---|
| 538 | // Titre Entrées-Sorties (I/O) sur les objets
|
---|
| 539 | //--
|
---|
| 540 | //++
|
---|
| 541 | // void ReadObj(PInPersist& s, int num=-1)
|
---|
| 542 | // Lit l'objet à partir avec le tag numéro "num" dans le flot "PInPersist s"
|
---|
| 543 | // et l'ajoute à la liste. Si "num" est négatif, tous les objets présents
|
---|
| 544 | // sur le flot "s" sont créés et ajoutés à la liste.
|
---|
| 545 | // void ReadObj(string const & nomppf, string nobj="")
|
---|
| 546 | // Lit le premier objet à partir du fichier PPF "nomppf". L'objet est ajouté
|
---|
| 547 | // à la liste avec le nom "nobj". Si "nobj" est une chaîne vide, un nom est
|
---|
| 548 | // composé à partir du nom de fichier.
|
---|
| 549 | //--
|
---|
| 550 |
|
---|
| 551 | /* --Methode-- */
|
---|
[331] | 552 | void NamedObjMgr::ReadObj(string const & flnm, string & nobj)
|
---|
[165] | 553 | {
|
---|
| 554 | PPersist* obj=NULL;
|
---|
| 555 | bool ok = true;
|
---|
| 556 |
|
---|
| 557 | TRY{
|
---|
| 558 | PInPersist pis(flnm);
|
---|
| 559 | obj = PPersistMgr::ReadObject(pis);
|
---|
| 560 | if (obj == NULL) ok = false;
|
---|
| 561 | } CATCH(merr)
|
---|
| 562 | { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n",
|
---|
| 563 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
| 564 |
|
---|
| 565 | if (!ok) return;
|
---|
| 566 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
---|
[333] | 567 | AddObj(obj->DataObj(), nobj, true);
|
---|
[165] | 568 | return;
|
---|
| 569 | }
|
---|
| 570 |
|
---|
| 571 | /* --Methode-- */
|
---|
| 572 | void NamedObjMgr::ReadObj(PInPersist& s, int num)
|
---|
| 573 | {
|
---|
| 574 | int i, cid, key, ln;
|
---|
| 575 | int n0, n1;
|
---|
| 576 | bool ok = true;
|
---|
| 577 | PPersist* obj=NULL;
|
---|
| 578 | string nom;
|
---|
| 579 |
|
---|
| 580 | if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
|
---|
| 581 | if (num >= 0) {
|
---|
| 582 | printf("NamedObjMgr::ReadObj(PInPersist, %d) Error! NbTags = %d \n", num, s.NbTags());
|
---|
| 583 | return;
|
---|
| 584 | }
|
---|
| 585 | TRY {
|
---|
| 586 | obj = PPersistMgr::ReadObject(s);
|
---|
| 587 | if (obj == NULL) ok = false;
|
---|
| 588 | } CATCH(merr) {
|
---|
| 589 | printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 590 | ok = false;
|
---|
| 591 | } ENDTRY;
|
---|
| 592 | if (!ok) return;
|
---|
| 593 | nom = "";
|
---|
[295] | 594 | AddObj(obj->DataObj(), nom);
|
---|
[165] | 595 | }
|
---|
| 596 |
|
---|
| 597 | if (num < 0) { n0 = 0; n1 = s.NbTags(); }
|
---|
| 598 | else { n0 = num; n1 = num+1; }
|
---|
| 599 | for(i=n0; i<n1; i++) {
|
---|
| 600 | key = s.TagKey(i, cid, ln);
|
---|
| 601 | if (ln <= 0) nom = "";
|
---|
| 602 | else nom = s.TagName(i);
|
---|
| 603 | s.GotoTag(i);
|
---|
| 604 | TRY {
|
---|
| 605 | obj = PPersistMgr::ReadObject(s);
|
---|
| 606 | if (obj == NULL) ok = false;
|
---|
| 607 | } CATCH(merr) {
|
---|
| 608 | printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 609 | ok = false;
|
---|
| 610 | } ENDTRY;
|
---|
[333] | 611 | if (ok) AddObj(obj->DataObj(), nom, true);
|
---|
[165] | 612 | }
|
---|
| 613 |
|
---|
| 614 | return;
|
---|
| 615 | }
|
---|
| 616 | /* --Methode-- */
|
---|
| 617 | void NamedObjMgr::ReadAll(string const & flnm)
|
---|
| 618 | {
|
---|
| 619 | bool ok = true;
|
---|
| 620 | PPersist* obj=NULL;
|
---|
| 621 |
|
---|
| 622 | PInPersist* ppin;
|
---|
| 623 | TRY{
|
---|
| 624 | ppin = new PInPersist(flnm);
|
---|
| 625 | if (ppin->NbTags() < 1) obj = PPersistMgr::ReadObject((*ppin));
|
---|
| 626 | else obj = NULL;
|
---|
| 627 | } CATCH(merr)
|
---|
| 628 | { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n",
|
---|
| 629 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
| 630 |
|
---|
| 631 | if (!ok) return;
|
---|
| 632 | if (obj) {
|
---|
| 633 | string nom = servnobjm->FileName2Name(flnm);
|
---|
[295] | 634 | AddObj(obj->DataObj(), nom);
|
---|
[165] | 635 | }
|
---|
| 636 | else ReadObj((*ppin), -1);
|
---|
| 637 | delete ppin;
|
---|
| 638 | return;
|
---|
| 639 | }
|
---|
| 640 |
|
---|
| 641 | /* --Methode-- */
|
---|
[331] | 642 | void NamedObjMgr::ReadFits(string const & flnm, string & nobj)
|
---|
[165] | 643 | {
|
---|
| 644 | bool ok = true;
|
---|
| 645 | RzImage* obj;
|
---|
| 646 |
|
---|
| 647 | TRY{
|
---|
| 648 | // obj = RzReadFits((char*)flnm.c_str(), ImgOffX, ImgOffY, ImgSizX, ImgSizY, ImgBitSgn);
|
---|
[293] | 649 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 650 | obj = RzReadFits((char*)flnm.c_str());
|
---|
[293] | 651 | #else
|
---|
| 652 | printf("NamedObjMgr::ReadFITS( NON-Disponible EVOL-PLANCK) \n");
|
---|
| 653 | obj = NULL;
|
---|
| 654 | #endif
|
---|
[165] | 655 | if (obj == NULL) ok = false;
|
---|
| 656 | } CATCH(merr) {
|
---|
| 657 | printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 658 | ok = false;
|
---|
| 659 | } ENDTRY;
|
---|
| 660 | if (ok) {
|
---|
| 661 | if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
|
---|
[295] | 662 | AddObj((AnyDataObj*)obj, nobj);
|
---|
[165] | 663 | }
|
---|
| 664 | return;
|
---|
| 665 | }
|
---|
| 666 |
|
---|
| 667 |
|
---|
| 668 | static int key_for_write = 5000;
|
---|
| 669 | /* --Methode-- */
|
---|
[333] | 670 | void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
|
---|
[165] | 671 | {
|
---|
[333] | 672 | if (nom.length() < 1) return;
|
---|
| 673 | string nob,rep;
|
---|
| 674 | ParseObjectName(nom, rep, nob);
|
---|
| 675 | nom = '/' + rep + '/' + nob;
|
---|
[295] | 676 | NObjMgrAdapter* obja=NULL;
|
---|
[333] | 677 | string nomf = (keeppath) ? nom : nob;
|
---|
[295] | 678 | obja = GetObjAdapter(nom);
|
---|
| 679 | if (obja == NULL) return;
|
---|
[165] | 680 | printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
|
---|
[295] | 681 | nom.c_str(), typeid(*(obja->GetDataObj())).name());
|
---|
[333] | 682 | obja->SavePPF(s, nomf);
|
---|
[165] | 683 | return;
|
---|
| 684 | }
|
---|
| 685 |
|
---|
| 686 | /* --Methode-- */
|
---|
[333] | 687 | void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
|
---|
| 688 | {
|
---|
| 689 | string n1,r1;
|
---|
| 690 | if (patt.length() < 1) return;
|
---|
| 691 | bool keeppath = (patt[0] == '/') ? true : false;
|
---|
| 692 | ParseObjectName(patt, r1, n1);
|
---|
| 693 | patt = '/' + r1 + '/' + n1;
|
---|
| 694 |
|
---|
| 695 | bool ok = true;
|
---|
| 696 | POutPersist* pout;
|
---|
| 697 | TRY{
|
---|
| 698 | pout = new POutPersist(flnm);
|
---|
| 699 | } CATCH(merr)
|
---|
| 700 | { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n",
|
---|
| 701 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
| 702 | if (!ok) return;
|
---|
| 703 | NObjList::iterator it;
|
---|
| 704 | string cn;
|
---|
| 705 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 706 | cn = (*it).first;
|
---|
| 707 | if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
|
---|
| 708 | SaveObj(cn, (*pout), keeppath);
|
---|
| 709 | }
|
---|
| 710 | delete pout;
|
---|
| 711 | return;
|
---|
| 712 | }
|
---|
| 713 |
|
---|
| 714 | /* --Methode-- */
|
---|
[165] | 715 | void NamedObjMgr::SaveAll(string const& flnm)
|
---|
| 716 | {
|
---|
| 717 | bool ok = true;
|
---|
| 718 |
|
---|
| 719 | POutPersist* pout;
|
---|
| 720 | TRY{
|
---|
| 721 | pout = new POutPersist(flnm);
|
---|
| 722 | } CATCH(merr)
|
---|
| 723 | { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n",
|
---|
| 724 | (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
|
---|
| 725 | if (!ok) return;
|
---|
[332] | 726 | NObjList::iterator it;
|
---|
| 727 | string no;
|
---|
| 728 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 729 | no = (*it).first;
|
---|
[333] | 730 | SaveObj(no, (*pout), true);
|
---|
[332] | 731 | }
|
---|
[165] | 732 | delete pout;
|
---|
| 733 | return;
|
---|
| 734 | }
|
---|
| 735 |
|
---|
| 736 | /* --Methode-- */
|
---|
[331] | 737 | void NamedObjMgr::SaveFits(string& nom, string const & flnm)
|
---|
[165] | 738 | {
|
---|
[295] | 739 | NObjMgrAdapter* obja=NULL;
|
---|
| 740 | obja = GetObjAdapter(nom);
|
---|
| 741 | if (obja == NULL) return;
|
---|
| 742 | obja->SaveFits(flnm);
|
---|
[293] | 743 | return;
|
---|
[165] | 744 | }
|
---|
| 745 |
|
---|
| 746 |
|
---|
| 747 |
|
---|
| 748 | /* --Methode-- */
|
---|
[331] | 749 | void NamedObjMgr::PrintObj(string& nom)
|
---|
[165] | 750 | {
|
---|
[295] | 751 | NObjMgrAdapter* obja=NULL;
|
---|
| 752 | obja = GetObjAdapter(nom);
|
---|
| 753 | if (obja == NULL) return;
|
---|
[165] | 754 |
|
---|
[295] | 755 | string ctyp = typeid(*obja->GetDataObj()).name();
|
---|
| 756 | cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
|
---|
| 757 | obja->Print(cout);
|
---|
[165] | 758 |
|
---|
| 759 | return;
|
---|
| 760 | }
|
---|
| 761 |
|
---|
| 762 | /* --Methode-- */
|
---|
[331] | 763 | void NamedObjMgr::DisplayObj(string& nom, string dopt)
|
---|
[165] | 764 | {
|
---|
[295] | 765 | NObjMgrAdapter* obja=NULL;
|
---|
| 766 | obja = GetObjAdapter(nom);
|
---|
| 767 | if (obja == NULL) {
|
---|
[165] | 768 | cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 769 | return;
|
---|
| 770 | }
|
---|
| 771 | if (!myImgApp) return;
|
---|
| 772 |
|
---|
[295] | 773 | PIDrawer * dr = NULL;
|
---|
| 774 | P2DArrayAdapter* arr = NULL;
|
---|
| 775 | dr = obja->GetDrawer(dopt);
|
---|
| 776 | if (!dr) arr = obja->Get2DArray(dopt);
|
---|
[165] | 777 |
|
---|
[295] | 778 | if (!dr && !arr) {
|
---|
| 779 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
| 780 | cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl;
|
---|
| 781 | return;
|
---|
| 782 | }
|
---|
| 783 |
|
---|
[165] | 784 | int wrsid = 0;
|
---|
| 785 | bool fgsr = true;
|
---|
| 786 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 787 |
|
---|
[295] | 788 | if (dr) {
|
---|
| 789 | PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
|
---|
| 790 | if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, nom, opt);
|
---|
| 791 | else wrsid = myImgApp->DispScDrawer( dr, nom, opt);
|
---|
| 792 | }
|
---|
| 793 | else if (arr) wrsid = myImgApp->DispImage(arr, nom, opt);
|
---|
[165] | 794 |
|
---|
[295] | 795 | if(wrsid != 0) {
|
---|
| 796 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 797 | if (it == myObjs->end()) return;
|
---|
| 798 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 799 | }
|
---|
| 800 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 801 | return;
|
---|
| 802 | }
|
---|
[165] | 803 |
|
---|
[295] | 804 | /* --Methode-- */
|
---|
[331] | 805 | void NamedObjMgr::DisplayImage(string& nom, string dopt)
|
---|
[295] | 806 | {
|
---|
| 807 | NObjMgrAdapter* obja=NULL;
|
---|
| 808 | obja = GetObjAdapter(nom);
|
---|
| 809 | if (obja == NULL) {
|
---|
| 810 | cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 811 | return;
|
---|
| 812 | }
|
---|
| 813 | if (!myImgApp) return;
|
---|
| 814 |
|
---|
| 815 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
---|
[165] | 816 |
|
---|
[295] | 817 | if (!arr) {
|
---|
| 818 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
| 819 | cout << "NamedObjMgr::DisplayImage() Error , Non supporte pour " << ctyp << endl;
|
---|
| 820 | return;
|
---|
| 821 | }
|
---|
[165] | 822 |
|
---|
[295] | 823 | int wrsid = 0;
|
---|
| 824 | bool fgsr = true;
|
---|
| 825 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 826 | wrsid = myImgApp->DispImage(arr, nom, opt);
|
---|
[165] | 827 |
|
---|
[295] | 828 | if(wrsid != 0) {
|
---|
| 829 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 830 | if (it == myObjs->end()) return;
|
---|
| 831 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 832 | }
|
---|
| 833 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 834 | return;
|
---|
| 835 | }
|
---|
| 836 | /* --Methode-- */
|
---|
[331] | 837 | void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
|
---|
[295] | 838 | {
|
---|
| 839 | NObjMgrAdapter* obja=NULL;
|
---|
| 840 | obja = GetObjAdapter(nom);
|
---|
| 841 | if (obja == NULL) {
|
---|
| 842 | cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 843 | return;
|
---|
| 844 | }
|
---|
| 845 | if (!myImgApp) return;
|
---|
| 846 |
|
---|
| 847 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
---|
[165] | 848 |
|
---|
[295] | 849 | if (!arr) {
|
---|
| 850 | string ctyp = typeid(*(obja->GetDataObj())).name();
|
---|
| 851 | cout << "NamedObjMgr::DisplaySurf3D() Error , Non supporte pour " << ctyp << endl;
|
---|
| 852 | return;
|
---|
| 853 | }
|
---|
[165] | 854 |
|
---|
[295] | 855 | if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
|
---|
| 856 | cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
|
---|
| 857 | << "x" << arr->YSize() << ") trop grand (max=250x250)" << endl;
|
---|
| 858 | delete arr;
|
---|
| 859 | return;
|
---|
[165] | 860 | }
|
---|
| 861 |
|
---|
[295] | 862 | int wrsid = 0;
|
---|
| 863 | bool fgsr = true;
|
---|
| 864 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 865 | PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
|
---|
| 866 | wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt);
|
---|
| 867 | if(wrsid >= 0) {
|
---|
[165] | 868 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 869 | if (it == myObjs->end()) return;
|
---|
| 870 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 871 | }
|
---|
[295] | 872 |
|
---|
| 873 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 874 | return;
|
---|
[165] | 875 | }
|
---|
| 876 |
|
---|
| 877 | /* --Methode-- */
|
---|
[331] | 878 | void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
|
---|
[333] | 879 | string& erx, string& ery, string& erz, string dopt, bool fg3d)
|
---|
[165] | 880 | {
|
---|
[295] | 881 | AnyDataObj* obj=GetObj(nom);
|
---|
[165] | 882 | if (obj == NULL) {
|
---|
| 883 | cout << "NamedObjMgr::DisplayNT() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 884 | return;
|
---|
| 885 | }
|
---|
| 886 | if (!myImgApp) return;
|
---|
| 887 |
|
---|
[326] | 888 | NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
|
---|
| 889 | if (nt == NULL) {
|
---|
| 890 | // if (typeid(*obj) != typeid(NTupleInterface)) {
|
---|
[295] | 891 | string ctyp = typeid(*obj).name();
|
---|
[165] | 892 | cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl;
|
---|
| 893 | return;
|
---|
| 894 | }
|
---|
| 895 |
|
---|
| 896 | int wrsid = 0;
|
---|
| 897 | bool fgsr = true;
|
---|
[326] | 898 | dopt = "defline," + dopt;
|
---|
[165] | 899 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 900 |
|
---|
[333] | 901 | if ( fg3d && (nmz.length()>0) ) { // Display 3D
|
---|
[326] | 902 | PINTuple3D* pin = new PINTuple3D(nt, false);
|
---|
[165] | 903 | pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
|
---|
| 904 | pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
|
---|
| 905 | string titre = nmz + "%" + nmy + "%" + nmz;
|
---|
| 906 | wrsid = myImgApp->Disp3DDrawer(pin, nom, opt, titre);
|
---|
| 907 | }
|
---|
| 908 | else {
|
---|
[326] | 909 | PINTuple* pin = new PINTuple(nt, false);
|
---|
[165] | 910 | pin->SelectXY(nmx.c_str(), nmy.c_str());
|
---|
| 911 | pin->SelectErrBar(erx.c_str(), ery.c_str());
|
---|
[333] | 912 | if ( nmz.length()>0 ) pin->SelectWt(nmz.c_str());
|
---|
| 913 | string titre = nmy + "%" + nmx;
|
---|
[165] | 914 | wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, nom, opt, titre);
|
---|
| 915 | }
|
---|
| 916 |
|
---|
| 917 | if(wrsid >= 0) {
|
---|
| 918 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 919 | if (it == myObjs->end()) return;
|
---|
| 920 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 921 | }
|
---|
| 922 |
|
---|
| 923 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 924 | return;
|
---|
| 925 | }
|
---|
| 926 |
|
---|
| 927 | /* --Methode-- cmv 13/10/98 */
|
---|
[331] | 928 | void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
|
---|
[165] | 929 | // Pour le display 2D ou 3D d'un ``GeneralFitData''.
|
---|
| 930 | //| nom = nom de l'objet GeneralFitData a representer.
|
---|
| 931 | //| numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
|
---|
| 932 | //| numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
|
---|
| 933 | //| Pour le display 2D, numvary="" string vide.
|
---|
| 934 | //| err = qu'elles erreurs faut il representer ?
|
---|
| 935 | //| - 2D : x y xy (display y=f(x))
|
---|
| 936 | //| - 3D : x y z xy xz yz xzy (display z=f(x,y))
|
---|
| 937 | //| Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
|
---|
| 938 | //| les barres d'erreurs sont representees.
|
---|
| 939 | //| opt = options generales pour le display.
|
---|
| 940 | {
|
---|
[295] | 941 | AnyDataObj* obj=GetObj(nom);
|
---|
[165] | 942 | if(obj == NULL)
|
---|
| 943 | {cout << "NamedObjMgr::DisplayGFD() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 944 | return;}
|
---|
| 945 | if(!myImgApp) return;
|
---|
[295] | 946 | if(typeid(*obj) != typeid(GeneralFitData))
|
---|
| 947 | {string ctyp = typeid(*obj).name();
|
---|
[165] | 948 | cout<<"NamedObjMgr::DisplayGFD() Error , Objet n'est pas un GeneralFitData "<<ctyp<<endl;
|
---|
| 949 | return;}
|
---|
| 950 |
|
---|
| 951 | // Decodage des options classiques
|
---|
| 952 | bool fgsr = true;
|
---|
| 953 | int opt = servnobjm->DecodeDispOption(dopt, fgsr);
|
---|
| 954 | // Decodage des erreurs a representer
|
---|
| 955 | bool errx=false, erry=false, errz=false;
|
---|
| 956 | if(err.length()>0) {
|
---|
| 957 | for(int i=0;i<err.length();i++)
|
---|
| 958 | if (err[i]=='x' || err[i]=='X') errx = true;
|
---|
| 959 | else if(err[i]=='y' || err[i]=='Y') erry = true;
|
---|
| 960 | else if(err[i]=='z' || err[i]=='Z') errz = true;
|
---|
| 961 | }
|
---|
| 962 | // Decodage des numeros de variables en abscisse
|
---|
| 963 | int numvx=-1, numvy=-1;
|
---|
| 964 | if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
|
---|
| 965 | if(numvary.length()>0) numvy = atoi(numvary.c_str());
|
---|
| 966 |
|
---|
| 967 | int wrsid = 0;
|
---|
| 968 | if(numvy>=0) { // Display 3D
|
---|
| 969 | PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
|
---|
| 970 | pigfd->SelectXY(numvx,numvy);
|
---|
| 971 | pigfd->SelectErrBar(errx,erry,errz);
|
---|
| 972 | wrsid = myImgApp->Disp3DDrawer(pigfd,nom,opt);
|
---|
| 973 | } else { // Display 2D
|
---|
| 974 | PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
|
---|
| 975 | pigfd->SelectX(numvx);
|
---|
| 976 | pigfd->SelectErrBar(errx,erry);
|
---|
| 977 | wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,opt);
|
---|
| 978 | }
|
---|
| 979 |
|
---|
| 980 | if(wrsid >= 0) {
|
---|
| 981 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 982 | if (it == myObjs->end()) return;
|
---|
| 983 | (*it).second.wrsid.push_back(wrsid);
|
---|
| 984 | }
|
---|
| 985 | if (fgsr) myImgApp->RestoreGraphicAtt();
|
---|
| 986 | return;
|
---|
| 987 | }
|
---|
| 988 |
|
---|
| 989 | /* --Methode--
|
---|
[331] | 990 | void NamedObjMgr::DisplayImage(string& nom, string dopt)
|
---|
[165] | 991 | {
|
---|
| 992 | cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
|
---|
| 993 | }
|
---|
| 994 | */
|
---|
| 995 |
|
---|
| 996 |
|
---|
| 997 |
|
---|
| 998 |
|
---|
| 999 | /* --Methode-- */
|
---|
| 1000 | void NamedObjMgr::SetGraphicAttributes(string gratt)
|
---|
| 1001 | {
|
---|
| 1002 | bool fg = false;
|
---|
| 1003 | servnobjm->DecodeDispOption(gratt, fg);
|
---|
| 1004 | }
|
---|
[333] | 1005 |
|
---|
[165] | 1006 | /* --Methode-- */
|
---|
| 1007 | void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
|
---|
| 1008 | {
|
---|
| 1009 | if (!myImgApp) return;
|
---|
| 1010 | if (fcr) myImgApp->CreateGraphWin(nzx, nzy);
|
---|
| 1011 | else myImgApp->SetZone(nzx, nzy);
|
---|
| 1012 | }
|
---|
| 1013 |
|
---|
| 1014 | /* --Methode-- */
|
---|
[333] | 1015 | void NamedObjMgr::AddWRsId(string & nom, int wrsid)
|
---|
[165] | 1016 | {
|
---|
[333] | 1017 | if(wrsid != 0) {
|
---|
| 1018 | NObjList::iterator it = myObjs->find(nom);
|
---|
| 1019 | if (it == myObjs->end()) return;
|
---|
| 1020 | (*it).second.wrsid.push_back(wrsid);
|
---|
[295] | 1021 | }
|
---|
[165] | 1022 | return;
|
---|
| 1023 | }
|
---|
| 1024 |
|
---|
| 1025 | /* --Methode-- */
|
---|
[333] | 1026 | void NamedObjMgr::UpdateObjMgrWindow(int did)
|
---|
[165] | 1027 | {
|
---|
[333] | 1028 | if (!myImgApp) return;
|
---|
| 1029 | (myImgApp->ObjMgrW())->ClearHelpList();
|
---|
[165] | 1030 |
|
---|
[333] | 1031 | NObjList::iterator it;
|
---|
| 1032 | string cn;
|
---|
| 1033 | for(it = myObjs->begin(); it != myObjs->end(); it++) {
|
---|
| 1034 | if ((*it).second.dirid != did) continue;
|
---|
| 1035 | cn = (*it).first.substr(1);
|
---|
| 1036 | cn = cn.substr(cn.find('/')+1) + " (T= " + typeid(*((*it).second.obj)).name() + ")" ;
|
---|
| 1037 | (myImgApp->ObjMgrW())->AddObj(cn.c_str());
|
---|
[165] | 1038 | }
|
---|
[333] | 1039 | }
|
---|
[165] | 1040 |
|
---|
| 1041 |
|
---|
[333] | 1042 | /* Nouvelle-Fonction */
|
---|
| 1043 | void RemoveSpacesFromName(string & nom)
|
---|
[165] | 1044 | {
|
---|
[333] | 1045 | // on supprime les blancs de debut et de fin
|
---|
| 1046 | size_t p = nom.find_first_not_of(" ");
|
---|
| 1047 | if(p>nom.length()) { nom = ""; return; }
|
---|
| 1048 | nom = nom.substr(p);
|
---|
| 1049 | p = nom.find(' ');
|
---|
| 1050 | if(p>nom.length()) p=nom.length();
|
---|
| 1051 | nom = nom.substr(0, p);
|
---|
[165] | 1052 | }
|
---|
| 1053 |
|
---|
[333] | 1054 | /* Nouvelle-Fonction */
|
---|
| 1055 | bool CheckDirName(string & nom)
|
---|
[165] | 1056 | {
|
---|
[333] | 1057 | RemoveSpacesFromName(nom);
|
---|
| 1058 | if (nom.length() < 1) return(false);
|
---|
| 1059 | if (nom[0] == '/') nom = nom.substr(1) ;
|
---|
| 1060 | size_t p = nom.find('/');
|
---|
| 1061 | if (p < nom.length()) nom = nom.substr(0,p);
|
---|
| 1062 | if (nom.length() < 1) return(false);
|
---|
| 1063 | return(true);
|
---|
[165] | 1064 | }
|
---|
| 1065 |
|
---|
[333] | 1066 | /* Nouvelle-Fonction */
|
---|
| 1067 | int ParseObjectName(string & nom, string & nomrep, string & nomobj)
|
---|
[165] | 1068 | {
|
---|
[333] | 1069 | RemoveSpacesFromName(nom);
|
---|
| 1070 | // Si le nom ne commence pas par un slash, c'est le repertoire courant
|
---|
| 1071 | if (nom[0] != '/') { nomrep = *currDir; nomobj = nom; }
|
---|
[165] | 1072 | else {
|
---|
[333] | 1073 | string xx = nom.substr(1);
|
---|
| 1074 | size_t p = xx.find('/');
|
---|
| 1075 | if (p < xx.length()) {
|
---|
| 1076 | nomrep = xx.substr(0,p);
|
---|
| 1077 | nomobj = xx.substr(p+1);
|
---|
[165] | 1078 | }
|
---|
[333] | 1079 | else {
|
---|
| 1080 | nomrep = xx;
|
---|
| 1081 | nomobj = "";
|
---|
[165] | 1082 | }
|
---|
| 1083 | }
|
---|
[333] | 1084 | int rc = 0;
|
---|
| 1085 | NObjDirList::iterator it = myDirs->find(nomrep);
|
---|
| 1086 | if (it != myDirs->end()) rc = (*it).second.id;
|
---|
| 1087 | return(rc);
|
---|
[165] | 1088 | }
|
---|
| 1089 |
|
---|