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

Last change on this file since 1539 was 1525, checked in by ansari, 24 years ago

Ajout methode NamedObjMgr::DisplayVector() et commande vecplot , Reza 13/6/2001

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