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

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

MAJ Makefile - Reza 30/8/2000

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