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

Last change on this file since 1207 was 1207, checked in by ercodmgr, 25 years ago
  • refonte de piaffiting avec les fits adapteurs
  • addapteur de fit pour les objets existants
  • entree des Image<T> dans les fits (retour !!!)

cmv 29/9/00

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