source: Sophya/trunk/SophyaPI/PIext/nobjmgr.cc@ 1134

Last change on this file since 1134 was 1105, checked in by ercodmgr, 25 years ago

Minimum pour compil de PIext suite Heritage classe Image<T> de TMatrix<T> Reza+CMV 27/7/2000

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