Index: trunk/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- trunk/SophyaPI/PIext/nobjmgr.cc	(revision 293)
+++ trunk/SophyaPI/PIext/nobjmgr.cc	(revision 295)
@@ -3,4 +3,5 @@
 #include <ctype.h>
 
+#include <typeinfo>
 #include <iostream.h>
 #include <string>
@@ -20,7 +21,4 @@
 #include "pistdimgapp.h"
 
-#include "pclassids.h"
-#include "poly.h"
-#include "dvlist.h"
 #include "matrix.h"
 #include "cvector.h"
@@ -29,5 +27,4 @@
 #ifdef SANS_EVOLPLANCK
 #include "fitsimage.h"  
-#include "zfidu.h"  
 #endif
 
@@ -35,21 +32,14 @@
 #include "fct2dfit.h"
 
-#include "pimgadapter.h"
+#include "pisurfdr.h"
 #include "pipodrw.h"
-
 #include "pihisto.h"
 #include "hisprof.h"
 #include "pihisto2d.h"
 #include "pintuple.h"
-#include "pisurfdr.h"  
 #include "pintup3d.h"
 #include "pigfd1.h"
 #include "pigfd2.h"
 
-//  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
-#ifdef SANS_EVOLPLANCK 
-#include "pistlist.h"
-#include "transfo.h"
-#endif
 
 //++
@@ -74,5 +64,6 @@
 // ......  Gestion des objets nommes, variables globales ............
 struct nobj_item {
-  PPersist* obj;
+  AnyDataObj* obj;
+  NObjMgrAdapter* obja;
   int num;
   list<int> wrsid;
@@ -162,5 +153,5 @@
 //--
 //++
-// void AddObj(PPersist* obj, string& nom)
+// void AddObj(AnyDataObj* obj, string& nom)
 //	Ajoute l'objet "obj" à la liste, identifié par "nom".
 //	Si un objet de même nom existe, l'ancien objet est renommé en concaténant 
@@ -171,5 +162,5 @@
 //	Supprime l'ensemble des objets dont le nom correspond au patron "patt".
 //	Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
-// PPersist*  GetObj(string const& nom) 
+// AnyDataObj*  GetObj(string const& nom) 
 //	Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est 
 //	pas dans la liste.
@@ -182,5 +173,5 @@
 
 /* --Methode-- */
-void NamedObjMgr::AddObj(PPersist* obj, string& nom)
+void NamedObjMgr::AddObj(AnyDataObj* obj, string& nom, bool)
 {
 
@@ -198,5 +189,5 @@
 
 myNObj++;
-if (nom.length() < 1) nom = servnobjm->PClassIdToShortClassName(obj->ClassId());
+if (nom.length() < 1) nom = typeid(*obj).name();
 NObjList::iterator it = myObjs->find(nom);
 if (it != myObjs->end()) { // l'objet existe deja
@@ -210,13 +201,14 @@
 nobj_item no;
 no.obj = obj;
+no.obja = servnobjm->GetAdapter(obj);  // L'adaptateur
 no.num =  myNObj;
 (*myObjs)[(*lastobj)] = no;
 if (myImgApp)  { 
-  string str = (*lastobj) + "    (T= " + servnobjm->PClassIdToClassName(obj->ClassId()) + ")" ;
+  string str = (*lastobj) + "    (T= " + typeid(*obj).name() + ")" ;
   (myImgApp->ObjMgrW())->AddObj(str.c_str(), myNObj+1000);
 }
  
 cout << "NamedObjMgr::AddObj()  Object " << (*lastobj) << " ( "  
-     << servnobjm->PClassIdToClassName(obj->ClassId()) << " ) added (Total= " << myObjs->size() << ")" << endl;  
+     << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;  
 return;
 }
@@ -234,4 +226,5 @@
   (myImgApp->ObjMgrW())->DelObj((*it).second.num+1000);
 }
+delete (*it).second.obj;  // destruction de l'adaptateur 
 if (fgd) delete (*it).second.obj;
 myObjs->erase(it);
@@ -256,5 +249,5 @@
 
 /* --Methode-- */
-PPersist* NamedObjMgr::GetObj(string const& nom)
+AnyDataObj* NamedObjMgr::GetObj(string const& nom)
 {
 NObjList::iterator it = myObjs->find(nom);
@@ -264,7 +257,15 @@
 
 /* --Methode-- */
+NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string const& nom)
+{
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return(NULL); 
+return((*it).second.obja);
+}
+
+/* --Methode-- */
 void NamedObjMgr::RenameObj(string const& nom, string& nomnew)
 {
-PPersist* obj = GetObj(nom);
+AnyDataObj* obj = GetObj(nom);
 if (obj == NULL) return;
 DelObj(nom, false);
@@ -309,5 +310,5 @@
 if (!ok)  return;
 if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
-AddObj(obj, nobj);
+AddObj(obj->DataObj(), nobj);
 return;
 }
@@ -336,5 +337,5 @@
   if (!ok)  return;
   nom = "";
-  AddObj(obj, nom);
+  AddObj(obj->DataObj(), nom);
 }
  
@@ -353,5 +354,5 @@
     ok = false; 
   } ENDTRY;
-  if (ok)  AddObj(obj, nom);  
+  if (ok)  AddObj(obj->DataObj(), nom);  
 }
 
@@ -376,5 +377,5 @@
 if (obj) {
   string nom = servnobjm->FileName2Name(flnm);
-  AddObj(obj, nom);
+  AddObj(obj->DataObj(), nom);
   }
 else ReadObj((*ppin), -1);
@@ -404,5 +405,5 @@
 if (ok) { 
   if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
-  AddObj((PPersist*)obj, nobj);
+  AddObj((AnyDataObj*)obj, nobj);
 }
 return;
@@ -414,12 +415,10 @@
 void NamedObjMgr::SaveObj(string const& nom, POutPersist& s)
 {
-PPersist* obj=NULL;
-obj = GetObj(nom);
-if (obj == NULL)  return;
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL)  return;
 printf("NamedObjMgr::SaveObj(%s, )  (Type=%s) \n",  
-       nom.c_str(), servnobjm->PClassIdToClassName(obj->ClassId()));
-string nm = nom;  // A cause de const 
-obj->Write(s,  key_for_write, nm);
-key_for_write++;
+       nom.c_str(), typeid(*(obja->GetDataObj())).name());
+obja->SavePPF(s, nom);
 return; 
 }
@@ -446,59 +445,8 @@
 void NamedObjMgr::SaveFits(string const& nom, string const & flnm)
 {
-
-#ifndef SANS_EVOLPLANCK 
-printf("NamedObjMgr::SaveFITS( NON-Disponible EVOL-PLANCK) \n"); 
-return;
-
-#else
-
-PPersist* obj=NULL;
-obj = GetObj(nom);
-if (obj == NULL)  return;
-int cid = obj->ClassId();
-if ( (cid < ClassId_Image) && ( cid > ClassId_Image+kr_8) ) {
-  printf("NamedObjMgr::SaveFits(%s, ) Error - Object is NOT an image (type=%s) \n",
-         nom.c_str(), servnobjm->PClassIdToClassName(obj->ClassId()) );
-  return;
-}
-
-RzImage* pim = (RzImage*)obj;
-TRY { 
-  switch (pim->PixelType()) {
-    case kuint_2:
-      {
-      FitsImageU2 imgfits(*pim);
-      imgfits.Save(flnm); 
-      }
-    break;
-    case kint_2:
-      {
-      FitsImageI2 imgfits(*pim);
-      imgfits.Save(flnm); 
-      }
-      break;
-    case kint_4:
-      {
-      FitsImageI4 imgfits(*pim);
-      imgfits.Save(flnm); 
-      }
-      break;
-    case kr_4:
-      {
-      FitsImageR4 imgfits(*pim);
-      imgfits.Save(flnm); 
-      }
-      break;
-    default :
-      printf("NamedObjMgr::SaveObj()/Error Type d'image (%d) NON supporte en FITS \n", 
-             (int)pim->PixelType());
-      break;
-  }
-}  CATCH(merr) { 
-  printf("NamedObjMgr::SaveObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
-} ENDTRY;
-
-#endif
-
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL)  return;
+obja->SaveFits(flnm);
 return;
 }
@@ -509,8 +457,7 @@
 {
 int k;
-PPersist* obj=NULL;
+AnyDataObj* obj=NULL;
 string ctyp;
 char strg[256];
-int cid;
 
 cout << "NamedObjMgr::ListObjs() NObjs= " << myObjs->size() << "\n" ;
@@ -519,7 +466,6 @@
   obj = (*it).second.obj;
 
-  cid = obj->ClassId();
-  ctyp = servnobjm->PClassIdToClassName(cid);
-  sprintf(strg, "%2d/ %16s : %s", k, servnobjm->PClassIdToClassName(obj->ClassId()), ((*it).first).c_str()); 
+  ctyp = typeid(*obj).name();
+  sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str()); 
   ctyp = strg;
   cout << ctyp << "\n" ;
@@ -533,98 +479,12 @@
 void NamedObjMgr::PrintObj(string const& nom)
 {
-PPersist* obj=GetObj(nom);
-if (obj == NULL) {
-  cout << "NamedObjMgr::PrintObj() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-}
-
-int cid = obj->ClassId();
-string ctyp = servnobjm->PClassIdToClassName(cid);
-
-cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp 
-     << "Cid= " << cid << ")" << endl;
-
-int i4dum;
-switch (cid) {
-  case ClassId_Poly1 : 
-    ((Poly*)obj)->Print(cout);
-    break;
-  case ClassId_Poly2 : 
-    ((Poly2*)obj)->Print(cout);
-    break;
-  case ClassId_Matrix : 
-  case ClassId_Vector : 
-    cout << *((Matrix*)obj);
-    break;
-
-  case ClassId_DVList : 
-    ((DVList*)obj)->Print();
-    break;
-
-  case ClassId_Histo1D : 
-    ((Histo*)obj)->Print(60);
-    break;
-  case ClassId_Histo2D : 
-    ((Histo2D*)obj)->Print();
-    break;
-  case ClassId_HProf : 
-    ((HProf*)obj)->Print(60);
-    break;
-  case ClassId_NTuple : 
-    cout << ((NTuple*)obj)->Info();
-    cout << *((NTuple*)obj);
-    break;
-  case ClassId_GeneralFitData : 
-    ((GeneralFitData*)obj)->PrintStatus();
-    i4dum = ((GeneralFitData*)obj)->NData();
-    if(i4dum>0) {
-      ((GeneralFitData*)obj)->PrintData(0);
-      ((GeneralFitData*)obj)->PrintData(i4dum-1);
-    }
-    break;
-
-  case ClassId_Image : 
-  case ClassId_Image + kuint_1 : 
-  case ClassId_Image + kint_1 : 
-  case ClassId_Image + kuint_2 : 
-  case ClassId_Image + kint_2 : 
-  case ClassId_Image + kuint_4 : 
-  case ClassId_Image + kint_4 : 
-  case ClassId_Image + kr_4 : 
-  case ClassId_Image + kr_8 : 
-    ((RzImage*)obj)->Print();
-    break;
-
-#ifdef SANS_EVOLPLANCK 
-  case ClassId_ZFidu : 
-    ((ZFidu*)obj)->Print();
-    break;
-
-  case ClassId_StarList : 
-    ((StarList*)obj)->Print(10, 1, 50);
-    break;
-  case ClassId_Transfo : 
-    ((Transfo*)obj)->Print(cout);
-    break;
-  case ClassId_PSF : 
-    break;
-
-  case ClassId_Star + BStar_Type : 
-  case ClassId_Star + RzStar_Type : 
-  case ClassId_Star + PSFStar_Type : 
-  case ClassId_Star + MCStar_Type : 
-  case ClassId_Star + CircRFixStar_Type : 
-  case ClassId_Star + PSFDHStar_Type : 
-  case ClassId_Star + PSFSEStar_Type : 
-  case ClassId_Star + MCDHStar_Type : 
-    ((BStar*)obj)->Print(1);
-    break;
-#endif
-
-// - Ajout objet PPF
-  default:
-    break;
-  }
-cout << endl;
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL)  return;
+
+string ctyp = typeid(*obja->GetDataObj()).name();
+cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
+obja->Print(cout);
+
 return;
 }
@@ -633,6 +493,7 @@
 void NamedObjMgr::DisplayObj(string const& nom, string dopt) 
 {
-PPersist* obj=GetObj(nom);
-if (obj == NULL) {
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
   cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl; 
   return;
@@ -640,129 +501,25 @@
 if (!myImgApp)  return;
  
-int cid = obj->ClassId();
-string ctyp = servnobjm->PClassIdToClassName(cid);
+PIDrawer * dr = NULL;
+P2DArrayAdapter* arr = NULL;
+dr = obja->GetDrawer(dopt);
+if (!dr) arr = obja->Get2DArray(dopt);
+
+if (!dr && !arr) { 
+  string ctyp = typeid(*(obja->GetDataObj())).name();
+  cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 
+  return;
+  }
 
 int wrsid = 0;
 bool fgsr = true;
-// On veut tracer une ligne pour vecteur et histo1D par defaut
-if ( (cid == ClassId_Vector) || (cid == ClassId_Histo1D) )  dopt = "thinline," + dopt;
-else if(cid == ClassId_HProf)  dopt = "fcirclemarker5," + dopt;
 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
 
-switch (cid) {
-  case ClassId_Poly1 : 
-  case ClassId_Poly2 : 
-  case ClassId_DVList : 
-    cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 
-    break;
-
-  case ClassId_Matrix : 
-    {
-    wrsid = myImgApp->DispImage(new POMatrixAdapter((Matrix*)obj, false), nom, opt);
-    break;
-    }
-  case ClassId_Vector : 
-    {
-    PIYfXDrawer* dr = new   PIYfXDrawer( new POVectorAdapter((Vector*)obj, false), NULL, true);
-    wrsid = myImgApp->DispScDrawer( (PIDrawer*)dr, nom, opt);    
-    break;
-    }
-  case ClassId_Histo1D : 
-    {
-    PIHisto* pih = new PIHisto(((Histo*)obj), false);
-    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pih, nom, opt);
-    break;
-    }
-  case ClassId_Histo2D : 
-    {
-    PIHisto2D* pih2 = new PIHisto2D(((Histo2D*)obj), false);
-    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pih2, nom, opt, nom, true);
-    break;
-    }
-  case ClassId_HProf : 
-    {
-    PIHisto* pihp = new PIHisto(((Histo*)obj), false);
-    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pihp, nom, opt);
-    break;
-    }
-  case ClassId_GeneralFitData : 
-    {
-    GeneralFitData* gfd = (GeneralFitData*)obj;
-    if(gfd->NVar()==1) {
-      PIGenFitDat* pigfd = new PIGenFitDat(gfd,false);
-      wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,opt);
-    } else if(gfd->NVar()==2) {
-      PIGenFitDat3D* pigfd = new PIGenFitDat3D(gfd,false);
-      wrsid = myImgApp->Disp3DDrawer(pigfd,nom,opt);
-    } else {
-      cout<<"NamedObjMgr::DisplayObj() Error , Utilisez DisplayGFD pour GeneralFitData "
-          <<ctyp<<"\n de "<<gfd->NVar()<<" variables (!=1,2)"<<endl; 
-    }
-    break;
-    }
-
-  case ClassId_NTuple : 
-    cout << "NamedObjMgr::DisplayObj() Error , Utilisez DisplayNt pour NTuple " << ctyp << endl; 
-    break;
-
-  case ClassId_Image : 
-  case ClassId_Image + kuint_1 : 
-  case ClassId_Image + kint_1 : 
-  case ClassId_Image + kr_8 : 
-  case ClassId_Image + kuint_4 : 
-    wrsid = myImgApp->DispImage(new RzImageAdapter((RzImage*)obj, false), nom, opt);
-    break;
-  case ClassId_Image + kuint_2 : 
-    wrsid = myImgApp->DispImage(new ImageAdapter<uint_2>((ImageU2*)obj, false), nom, opt);
-    break;
-  case ClassId_Image + kint_2 : 
-    wrsid = myImgApp->DispImage(new ImageAdapter<int_2>((ImageI2*)obj, false), nom, opt);
-    break;
-  case ClassId_Image + kint_4 : 
-    wrsid = myImgApp->DispImage(new ImageAdapter<int_4>((ImageI4*)obj, false), nom, opt);
-    break;
-  case ClassId_Image + kr_4 : 
-    wrsid = myImgApp->DispImage(new ImageAdapter<r_4>((ImageR4*)obj, false), nom, opt);
-    break;
-
-#ifdef SANS_EVOLPLANCK 
-  case ClassId_ZFidu : 
-    {
-    int nx = ((ZFidu*)obj)->XMax() -  ((ZFidu*)obj)->XMin();
-    int ny = ((ZFidu*)obj)->YMax() -  ((ZFidu*)obj)->YMin();
-    if (nx > 1024)  nx = 1024;
-    if (ny > 1024)  ny = 1024;
-    if (nx < 128)  nx = 128;
-    if (ny < 128)  nx = 128;
-    ImageU2* msk = ((ZFidu*)obj)->MakeBadZoneMask(nx, ny);
-    myImgApp->DispImage(new ImageAdapter<uint_2>((ImageU2*)msk, true), nom, opt);
-    break;
-    }
-
-  case ClassId_StarList : 
-    {
-    PIStarList* pist = new PIStarList(((StarList*)obj), false);
-    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pist, nom, opt);
-    break;
-    }
-
-  case ClassId_Transfo : 
-  case ClassId_PSF : 
-  case ClassId_Star + BStar_Type : 
-  case ClassId_Star + RzStar_Type : 
-  case ClassId_Star + PSFStar_Type : 
-  case ClassId_Star + MCStar_Type : 
-  case ClassId_Star + CircRFixStar_Type : 
-  case ClassId_Star + PSFDHStar_Type : 
-  case ClassId_Star + PSFSEStar_Type : 
-  case ClassId_Star + MCDHStar_Type : 
-    cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 
-    break;
-#endif
-
-// - Ajout objet PPF
-  default:
-    break;
-  }
+if (dr) { 
+  PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
+  if(dr3)  wrsid = myImgApp->Disp3DDrawer(dr3, nom, opt);
+  else wrsid = myImgApp->DispScDrawer( dr, nom, opt); 
+  }
+else if (arr) wrsid = myImgApp->DispImage(arr, nom, opt);
 
 if(wrsid != 0) {
@@ -775,4 +532,76 @@
 }
 
+/* --Methode-- */
+void NamedObjMgr::DisplayImage(string const& nom, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return;
+ 
+P2DArrayAdapter* arr = obja->Get2DArray(dopt);
+
+if (!arr) { 
+  string ctyp = typeid(*(obja->GetDataObj())).name();
+  cout << "NamedObjMgr::DisplayImage() Error , Non supporte pour " << ctyp << endl; 
+  return;
+  }
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+wrsid = myImgApp->DispImage(arr, nom, opt);
+
+if(wrsid != 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+return;
+}
+/* --Methode-- */
+void NamedObjMgr::DisplaySurf3D(string const& nom, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return;
+ 
+P2DArrayAdapter* arr = obja->Get2DArray(dopt);
+
+if (!arr) { 
+  string ctyp = typeid(*(obja->GetDataObj())).name();
+  cout << "NamedObjMgr::DisplaySurf3D() Error , Non supporte pour " << ctyp << endl; 
+  return;
+  }
+
+if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
+  cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" <<  arr->XSize() 
+       << "x" << arr->YSize() << ") trop grand (max=250x250)" << endl; 
+  delete arr;
+  return;
+  }
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
+wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt);
+if(wrsid >= 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+
+if (fgsr) myImgApp->RestoreGraphicAtt();  
+return; 
+}
 
 /* --Methode-- */
@@ -780,5 +609,5 @@
                             string& erx, string& ery, string& erz, string dopt)
 {
-PPersist* obj=GetObj(nom);
+AnyDataObj* obj=GetObj(nom);
 if (obj == NULL) {
   cout << "NamedObjMgr::DisplayNT() Error , Pas d'objet de nom " << nom << endl; 
@@ -787,7 +616,6 @@
 if (!myImgApp)  return; 
 
-int cid = obj->ClassId();
-if (cid != ClassId_NTuple) { 
-  string ctyp = servnobjm->PClassIdToClassName(cid);
+if (typeid(*obj) != typeid(NTuple)) { 
+  string ctyp = typeid(*obj).name();
   cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl; 
   return;
@@ -837,12 +665,11 @@
 //|  opt = options generales pour le display.
 {
-PPersist* obj=GetObj(nom);
+AnyDataObj* obj=GetObj(nom);
 if(obj == NULL)
   {cout << "NamedObjMgr::DisplayGFD() Error , Pas d'objet de nom " << nom << endl; 
    return;}
 if(!myImgApp) return; 
-int cid = obj->ClassId();
-if(cid != ClassId_GeneralFitData)
-  {string ctyp = servnobjm->PClassIdToClassName(cid);
+if(typeid(*obj) != typeid(GeneralFitData))
+  {string ctyp = typeid(*obj).name();
    cout<<"NamedObjMgr::DisplayGFD() Error , Objet n'est pas un GeneralFitData "<<ctyp<<endl; 
    return;}
@@ -894,73 +721,4 @@
 
 
-/* --Methode-- */
-void NamedObjMgr::DisplaySurf3D(string const& nom, string dopt)
-{
-PPersist* obj=GetObj(nom);
-if (obj == NULL) {
-  cout << "NamedObjMgr::DisplaySurf3D() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-}
-if (!myImgApp)  return; 
-
-int cid = obj->ClassId();
-
-
-P2DArrayAdapter* arr=NULL;
-switch (cid) {
-  case ClassId_Matrix : 
-    arr = new POMatrixAdapter((Matrix*)obj, false);
-    break;
-  case ClassId_Histo2D : 
-    arr = new POH2DAdapter((Histo2D*)obj, false);
-    break;
-  case ClassId_Image : 
-  case ClassId_Image + kuint_1 : 
-  case ClassId_Image + kint_1 : 
-  case ClassId_Image + kr_8 : 
-  case ClassId_Image + kuint_4 : 
-    arr = new RzImageAdapter((RzImage*)obj, false);
-    break;
-  case ClassId_Image + kuint_2 : 
-    arr = new ImageAdapter<uint_2>((ImageU2*)obj, false);
-    break;
-  case ClassId_Image + kint_2 : 
-    arr = new ImageAdapter<int_2>((ImageI2*)obj, false);
-    break;
-  case ClassId_Image + kint_4 : 
-    arr = new ImageAdapter<int_4>((ImageI4*)obj, false);
-    break;
-  case ClassId_Image + kr_4 : 
-    arr = new ImageAdapter<r_4>((ImageR4*)obj, false);
-    break;
-
-  default :
-    cout << "NamedObjMgr::DisplaySurf3D() Error , Pas de display pour " << servnobjm->PClassIdToClassName(cid) << endl; 
-    return;
-  }
-
-if (!arr) return;
-if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
-  cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" <<  arr->XSize() 
-       << "x" << arr->YSize() << ") trop grand (max=250x250)" << endl; 
-  delete arr;
-  return;
-  }
-
-int wrsid = 0;
-bool fgsr = true;
-int opt = servnobjm->DecodeDispOption(dopt, fgsr);
-if (cid == ClassId_Histo2D)  arr->DefineXYCoordinates(0., 0., 1., 1.);
-PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
-wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt);
-if(wrsid >= 0) {
-  NObjList::iterator it = myObjs->find(nom);
-  if (it == myObjs->end()) return; 
-  (*it).second.wrsid.push_back(wrsid);
-  }
-
-if (fgsr) myImgApp->RestoreGraphicAtt();  
-return; 
-}
 
 
@@ -984,9 +742,10 @@
                                   string& expcut, string dopt)
 {
-PPersist* obj=GetObj(nom);
-if (obj == NULL) {
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
   cout << "NamedObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl; 
   return;
-}
+  }
 if (!myImgApp)  return; 
 
@@ -999,5 +758,5 @@
 else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
 
-servnobjm->Nobj_ComputeExpressions(obj, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
+servnobjm->Nobj_ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
 
 if (nt->NEntry() < 1) {
@@ -1025,6 +784,7 @@
                                   string& expcut, string dopt)
 {
-PPersist* obj=GetObj(nom);
-if (obj == NULL) {
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
   cout << "NamedObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl; 
   return;
@@ -1036,5 +796,5 @@
 
 string expwt = "1.";
-servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
+servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
 
 if (nt->NEntry() < 1) {
@@ -1064,7 +824,7 @@
 void NamedObjMgr::ProjectH1(string const& nom, string& expx, string& expwt, string& expcut, string& nomh1, string dopt)
 {
-PPersist* obj=GetObj(nom);
-
-if (obj == NULL) {
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
   cout << "NamedObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl; 
   return;
@@ -1074,8 +834,8 @@
 Histo* h1 = NULL;
 NTuple* nt = NULL;
-PPersist* oh = NULL; 
+AnyDataObj* oh = NULL; 
 if (nomh1.length() > 0) oh=GetObj(nomh1);
 else nomh1 = "H1Proj";
-if ( (oh != NULL) && (oh->ClassId() == ClassId_Histo1D) )  h1 = (Histo*)oh;  // Pas de remise a zero ! h1->Zero();
+if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) )  h1 = (Histo*)oh;  // Pas de remise a zero ! h1->Zero();
 else {
   char* ntn[2]= {"hxval", "hwt"};
@@ -1083,5 +843,5 @@
   }
 string expz = "0.";   
-servnobjm->Nobj_ComputeExpressions(obj, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
+servnobjm->Nobj_ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
 
 if ((!h1) && (!nt)) return;
@@ -1113,7 +873,7 @@
                             string& nomh2, string dopt)
 {
-PPersist* obj=GetObj(nom);
-
-if (obj == NULL) {
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
   cout << "NamedObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl; 
   return;
@@ -1123,8 +883,8 @@
 Histo2D* h2 = NULL;
 NTuple* nt = NULL;
-PPersist* oh = NULL;
+AnyDataObj* oh = NULL;
 if (nomh2.length() > 0)  oh=GetObj(nomh2);
 else nomh2 = "H2Proj";
-if ( (oh != NULL) && (oh->ClassId() == ClassId_Histo2D) )  h2 = (Histo2D*)oh;  // Pas de remise a zero ! h2->Zero();
+if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) )  h2 = (Histo2D*)oh;  // Pas de remise a zero ! h2->Zero();
 else {
   char* ntn[3]= {"hxval", "hyval", "hwt"};
@@ -1132,5 +892,5 @@
   }
 string expz = "0.";   
-servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
+servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
 
 if ((!h2) && (!nt)) return;
@@ -1174,7 +934,7 @@
 //| opt = options generales pour le display.
 {
-PPersist* obj=GetObj(nom);
-
-if (obj == NULL) {
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
   cout << "NamedObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl; 
   return;
@@ -1184,8 +944,8 @@
 HProf* hprof = NULL;
 NTuple* nt = NULL;
-PPersist* oh = NULL;
+AnyDataObj* oh = NULL;
 if (nomprof.length() > 0)  oh=GetObj(nomprof);
 else nomprof = "ProfProj";
-if( (oh!=NULL) && (oh->ClassId()== ClassId_HProf) )  hprof = (HProf*)oh;
+if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) )  hprof = (HProf*)oh;
 else {
   char* ntn[3]= {"hxval", "hyval", "hwt"};
@@ -1193,5 +953,5 @@
 }
 string expz = "0.";
-servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
+servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
 
 if((!hprof) && (!nt)) return;
@@ -1223,7 +983,7 @@
 void NamedObjMgr::FillVect(string const& nom, string& expx, string& expcut, string& nomvec, string dopt)
 {
-PPersist* obj=GetObj(nom);
-
-if (obj == NULL) {
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
   cout << "NamedObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl; 
   return;
@@ -1239,5 +999,5 @@
 string expwt = "1.";
 string expz = "0.";   
-servnobjm->Nobj_ComputeExpressions(obj, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
+servnobjm->Nobj_ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
 
 if (!nt) return;
@@ -1265,7 +1025,7 @@
                          string& expcut, string& nomnt)
 {
-PPersist* obj=GetObj(nom);
-
-if (obj == NULL) {
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
   cout << "NamedObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl; 
   return;
@@ -1275,8 +1035,8 @@
 bool fgnnt = false;
 NTuple* nt = NULL;
-PPersist* oh = NULL;
+AnyDataObj* oh = NULL;
 if (nomnt.length() > 0)  oh=GetObj(nomnt);
 else nomnt = "NTFill";
-if ( (oh != NULL) && (oh->ClassId() == ClassId_NTuple) )  { 
+if ( (oh != NULL) && (typeid(*oh) == typeid(HProf)) )  { 
   nt = (NTuple*)oh;
   if (nt->NVar() > 10) {
@@ -1291,5 +1051,5 @@
   }
 
-servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, expt, expcut, nt, NULL, NULL);
+servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
 
 if (fgnnt) AddObj(nt, nomnt);
@@ -1311,8 +1071,10 @@
 //| nomgfd = nom du GeneralFitData engendre (optionnel)
 {
-PPersist* obj=GetObj(nom);
-if(obj == NULL)
-  {cout<<"NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
-   return;}
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
+  return;
+  }
 if(!myImgApp)  return;
 
@@ -1321,54 +1083,6 @@
 if(expy.length()<=0) {nvar = 1; expy = "0.";}
 
-// Que faut-il copier dans GeneralFitData
-int ndata=0;
-int cid = obj->ClassId();
-switch (cid) {
-  case ClassId_Vector :
-    ndata=((Vector*)obj)->NElts();
-    break;
-  case ClassId_Matrix :
-    ndata=((Matrix*)obj)->NCol()*((Matrix*)obj)->NRows();
-    break;
-  case ClassId_Histo1D :
-  case ClassId_HProf : 
-    ndata=((Histo*)obj)->NBins();
-    break;
-  case ClassId_Histo2D :
-    ndata=((Histo2D*)obj)->NBinX()*((Histo2D*)obj)->NBinY();
-    break;
-  case ClassId_Image : 
-  case ClassId_Image + kuint_1 :
-  case ClassId_Image + kint_1 :
-  case ClassId_Image + kr_8 :
-  case ClassId_Image + kuint_4 :
-  case ClassId_Image + kuint_2 :
-  case ClassId_Image + kint_2 :
-  case ClassId_Image + kint_4 :
-  case ClassId_Image + kr_4 :
-    ndata=((RzImage*)obj)->XSize()*((RzImage*)obj)->YSize();
-    break;
-#ifdef SANS_EVOLPLANCK 
-  case ClassId_StarList : 
-    ndata=((StarList*)obj)->NbStars();
-    break;
-#endif
-  case ClassId_NTuple :
-    ndata=((NTuple*)obj)->NEntry();
-    break;
-  case ClassId_GeneralFitData :
-    ndata=((GeneralFitData*)obj)->NData();
-    break;
-  default :
-    cout<<"FillGFD Erreur: N/A to  "<<servnobjm->PClassIdToClassName(cid)<<endl; 
-    return;
-}
-
-// Nom du GeneralFitData cree.
-if (nomgfd.length() <= 0) nomgfd = "GFDFill";
-// Consistence ndata.
-if(ndata<=0)
-  {cout<<"NamedObjMgr::FillGFD() Warning   ndata="<<ndata<<endl; 
-   return;}
+// $CHECK$ - cmv calculait le nombre d'entree ndata
+// en fonction de chaque objet - Je l'ai vire Reza 11/05/99
 
 // Creation NTuple Buffer
@@ -1377,5 +1091,5 @@
 
 // Remplissage NTuple buffer
-servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, experr, expcut, nt, NULL, NULL);
+servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
 if(nt->NEntry() < 1)
   {cout<<"NamedObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl; 
@@ -1383,5 +1097,11 @@
 
 //Remplissage de la structure GeneraFitData
-GeneralFitData* gfd = new GeneralFitData(nvar,ndata,0);
+if (nt->NEntry() <= 0) {
+  cout<<"NamedObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
+  delete nt;
+  return;
+  }
+
+GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
 int k;
 float* xn;
@@ -1724,5 +1444,5 @@
 //|2D     yaa.b et y = idem "xaa.b et x" mais pour y
 {
-PPersist* obj=GetObj(nom);
+AnyDataObj* obj=GetObj(nom);
 if (obj == NULL) {
   cout<<"NamedObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
@@ -1733,6 +1453,5 @@
   {cout<<"NamedObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
    return;}
-int cid = obj->ClassId();
-string ctyp = servnobjm->PClassIdToClassName(cid);
+string ctyp = typeid(*obj).name();
 
 int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
@@ -1740,49 +1459,40 @@
 Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
 GeneralFitData* g = NULL;
-switch (cid) {
+
   // 1D
-  case ClassId_Vector :
-    ndim = 1;
-    v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
-    break;
-  case ClassId_HProf :
-  case ClassId_Histo1D :
-    ndim = 1;
-    h = (Histo*)  obj; nbinx = h->NBins(); nbiny = 1;
-    break;
-  // 2D
-  case ClassId_Matrix :
-    ndim = 2;
-    m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
-    break;
-  case ClassId_Histo2D :
-    ndim = 2;
-    h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
-    break;
-  // 1D ou 2D selon
-  case ClassId_GeneralFitData :
-    g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
-    if(     g->NVar()==1) ndim = 1;
-    else if(g->NVar()==2) ndim = 2;
-    else {
-      cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
-          <<((GeneralFitData*) obj)->NVar()<<endl; return;}
-    break;
-  case ClassId_Image : 
-  case ClassId_Image + kuint_1 : 
-  case ClassId_Image + kuint_2 : 
-  case ClassId_Image + kint_2 : 
-  case ClassId_Image + kint_4 : 
-  case ClassId_Image + kr_4 :
-  case ClassId_Image + kr_8 : 
-    ndim = 2;
-    im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
-    break;
-  default:
-    cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un "
-        <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
-    return;
-    break;
-}
+if (typeid(*obj) == typeid(Vector)) {
+  ndim = 1;
+  v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
+  }
+else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) {
+  ndim = 1;
+  h = (Histo*)  obj; nbinx = h->NBins(); nbiny = 1;
+  }
+else if (typeid(*obj) == typeid(Matrix)) {
+  ndim = 2;
+  m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
+  }
+else if (typeid(*obj) == typeid(Histo2D)) {
+  ndim = 2;
+  h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
+  }
+else if (typeid(*obj) == typeid(GeneralFitData)) {
+  g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
+  if(     g->NVar()==1) ndim = 1;
+  else if(g->NVar()==2) ndim = 2;
+  else {
+     cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
+         <<((GeneralFitData*) obj)->NVar()<<endl; return; }
+  }
+else if (dynamic_cast<RzImage*>(obj)) {
+  ndim = 2;
+  im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
+  }
+else  {
+  cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un "
+      <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
+  return; 
+  }
+
 ndata = nbinx*nbiny;
 if(ndata<=0)
