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

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

compil avec PEIDA pour les modifs de l'interface adapteur - Reza 22/9/2000

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