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

Last change on this file since 2089 was 1971, checked in by ansari, 23 years ago

1/ Basculement de decodage des options de display aux methodes
PIDrawer/PIWdg::DecodeOptionString()
2/ Possibilite de Show/Hide de la partie Zoom/ColorMap/Stat du MainWindow

Reza 30/4/2002

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