Changeset 295 in Sophya for trunk/SophyaPI/PIext/nobjmgr.cc


Ignore:
Timestamp:
May 13, 1999, 12:12:51 PM (26 years ago)
Author:
ercodmgr
Message:

Mise aux "normes" version DPC/Planck - Gestion des objets a travers

un adaptateur/interface NTuple par NamedObjMgr.
Enregistrement d'objets et de l'adaptateur (I/O PPersist, display, ...)
par ServNobjMgr .... Reza 13/05/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/nobjmgr.cc

    r293 r295  
    33#include <ctype.h>
    44
     5#include <typeinfo>
    56#include <iostream.h>
    67#include <string>
     
    2021#include "pistdimgapp.h"
    2122
    22 #include "pclassids.h"
    23 #include "poly.h"
    24 #include "dvlist.h"
    2523#include "matrix.h"
    2624#include "cvector.h"
     
    2927#ifdef SANS_EVOLPLANCK
    3028#include "fitsimage.h" 
    31 #include "zfidu.h" 
    3229#endif
    3330
     
    3532#include "fct2dfit.h"
    3633
    37 #include "pimgadapter.h"
     34#include "pisurfdr.h"
    3835#include "pipodrw.h"
    39 
    4036#include "pihisto.h"
    4137#include "hisprof.h"
    4238#include "pihisto2d.h"
    4339#include "pintuple.h"
    44 #include "pisurfdr.h" 
    4540#include "pintup3d.h"
    4641#include "pigfd1.h"
    4742#include "pigfd2.h"
    4843
    49 //  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
    50 #ifdef SANS_EVOLPLANCK
    51 #include "pistlist.h"
    52 #include "transfo.h"
    53 #endif
    5444
    5545//++
     
    7464// ......  Gestion des objets nommes, variables globales ............
    7565struct nobj_item {
    76   PPersist* obj;
     66  AnyDataObj* obj;
     67  NObjMgrAdapter* obja;
    7768  int num;
    7869  list<int> wrsid;
     
    162153//--
    163154//++
    164 // void AddObj(PPersist* obj, string& nom)
     155// void AddObj(AnyDataObj* obj, string& nom)
    165156//      Ajoute l'objet "obj" à la liste, identifié par "nom".
    166157//      Si un objet de même nom existe, l'ancien objet est renommé en concaténant
     
    171162//      Supprime l'ensemble des objets dont le nom correspond au patron "patt".
    172163//      Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
    173 // PPersist*  GetObj(string const& nom)
     164// AnyDataObj*  GetObj(string const& nom)
    174165//      Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est
    175166//      pas dans la liste.
     
    182173
    183174/* --Methode-- */
    184 void NamedObjMgr::AddObj(PPersist* obj, string& nom)
     175void NamedObjMgr::AddObj(AnyDataObj* obj, string& nom, bool)
    185176{
    186177
     
    198189
    199190myNObj++;
    200 if (nom.length() < 1) nom = servnobjm->PClassIdToShortClassName(obj->ClassId());
     191if (nom.length() < 1) nom = typeid(*obj).name();
    201192NObjList::iterator it = myObjs->find(nom);
    202193if (it != myObjs->end()) { // l'objet existe deja
     
    210201nobj_item no;
    211202no.obj = obj;
     203no.obja = servnobjm->GetAdapter(obj);  // L'adaptateur
    212204no.num =  myNObj;
    213205(*myObjs)[(*lastobj)] = no;
    214206if (myImgApp)  {
    215   string str = (*lastobj) + "    (T= " + servnobjm->PClassIdToClassName(obj->ClassId()) + ")" ;
     207  string str = (*lastobj) + "    (T= " + typeid(*obj).name() + ")" ;
    216208  (myImgApp->ObjMgrW())->AddObj(str.c_str(), myNObj+1000);
    217209}
    218210 
    219211cout << "NamedObjMgr::AddObj()  Object " << (*lastobj) << " ( " 
    220      << servnobjm->PClassIdToClassName(obj->ClassId()) << " ) added (Total= " << myObjs->size() << ")" << endl; 
     212     << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl; 
    221213return;
    222214}
     
    234226  (myImgApp->ObjMgrW())->DelObj((*it).second.num+1000);
    235227}
     228delete (*it).second.obj;  // destruction de l'adaptateur
    236229if (fgd) delete (*it).second.obj;
    237230myObjs->erase(it);
     
    256249
    257250/* --Methode-- */
    258 PPersist* NamedObjMgr::GetObj(string const& nom)
     251AnyDataObj* NamedObjMgr::GetObj(string const& nom)
    259252{
    260253NObjList::iterator it = myObjs->find(nom);
     
    264257
    265258/* --Methode-- */
     259NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string const& nom)
     260{
     261NObjList::iterator it = myObjs->find(nom);
     262if (it == myObjs->end()) return(NULL);
     263return((*it).second.obja);
     264}
     265
     266/* --Methode-- */
    266267void NamedObjMgr::RenameObj(string const& nom, string& nomnew)
    267268{
    268 PPersist* obj = GetObj(nom);
     269AnyDataObj* obj = GetObj(nom);
    269270if (obj == NULL) return;
    270271DelObj(nom, false);
     
    309310if (!ok)  return;
    310311if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
    311 AddObj(obj, nobj);
     312AddObj(obj->DataObj(), nobj);
    312313return;
    313314}
     
    336337  if (!ok)  return;
    337338  nom = "";
    338   AddObj(obj, nom);
     339  AddObj(obj->DataObj(), nom);
    339340}
    340341 
     
    353354    ok = false;
    354355  } ENDTRY;
    355   if (ok)  AddObj(obj, nom); 
     356  if (ok)  AddObj(obj->DataObj(), nom); 
    356357}
    357358
     
    376377if (obj) {
    377378  string nom = servnobjm->FileName2Name(flnm);
    378   AddObj(obj, nom);
     379  AddObj(obj->DataObj(), nom);
    379380  }
    380381else ReadObj((*ppin), -1);
     
    404405if (ok) {
    405406  if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
    406   AddObj((PPersist*)obj, nobj);
     407  AddObj((AnyDataObj*)obj, nobj);
    407408}
    408409return;
     
    414415void NamedObjMgr::SaveObj(string const& nom, POutPersist& s)
    415416{
    416 PPersist* obj=NULL;
    417 obj = GetObj(nom);
    418 if (obj == NULL)  return;
     417NObjMgrAdapter* obja=NULL;
     418obja = GetObjAdapter(nom);
     419if (obja == NULL)  return;
    419420printf("NamedObjMgr::SaveObj(%s, )  (Type=%s) \n", 
    420        nom.c_str(), servnobjm->PClassIdToClassName(obj->ClassId()));
    421 string nm = nom;  // A cause de const
    422 obj->Write(s,  key_for_write, nm);
    423 key_for_write++;
     421       nom.c_str(), typeid(*(obja->GetDataObj())).name());
     422obja->SavePPF(s, nom);
    424423return;
    425424}
     
    446445void NamedObjMgr::SaveFits(string const& nom, string const & flnm)
    447446{
    448 
    449 #ifndef SANS_EVOLPLANCK
    450 printf("NamedObjMgr::SaveFITS( NON-Disponible EVOL-PLANCK) \n");
    451 return;
    452 
    453 #else
    454 
    455 PPersist* obj=NULL;
    456 obj = GetObj(nom);
    457 if (obj == NULL)  return;
    458 int cid = obj->ClassId();
    459 if ( (cid < ClassId_Image) && ( cid > ClassId_Image+kr_8) ) {
    460   printf("NamedObjMgr::SaveFits(%s, ) Error - Object is NOT an image (type=%s) \n",
    461          nom.c_str(), servnobjm->PClassIdToClassName(obj->ClassId()) );
    462   return;
    463 }
    464 
    465 RzImage* pim = (RzImage*)obj;
    466 TRY {
    467   switch (pim->PixelType()) {
    468     case kuint_2:
    469       {
    470       FitsImageU2 imgfits(*pim);
    471       imgfits.Save(flnm);
    472       }
    473     break;
    474     case kint_2:
    475       {
    476       FitsImageI2 imgfits(*pim);
    477       imgfits.Save(flnm);
    478       }
    479       break;
    480     case kint_4:
    481       {
    482       FitsImageI4 imgfits(*pim);
    483       imgfits.Save(flnm);
    484       }
    485       break;
    486     case kr_4:
    487       {
    488       FitsImageR4 imgfits(*pim);
    489       imgfits.Save(flnm);
    490       }
    491       break;
    492     default :
    493       printf("NamedObjMgr::SaveObj()/Error Type d'image (%d) NON supporte en FITS \n",
    494              (int)pim->PixelType());
    495       break;
    496   }
    497 }  CATCH(merr) {
    498   printf("NamedObjMgr::SaveObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
    499 } ENDTRY;
    500 
    501 #endif
    502 
     447NObjMgrAdapter* obja=NULL;
     448obja = GetObjAdapter(nom);
     449if (obja == NULL)  return;
     450obja->SaveFits(flnm);
    503451return;
    504452}
     
    509457{
    510458int k;
    511 PPersist* obj=NULL;
     459AnyDataObj* obj=NULL;
    512460string ctyp;
    513461char strg[256];
    514 int cid;
    515462
    516463cout << "NamedObjMgr::ListObjs() NObjs= " << myObjs->size() << "\n" ;
     
    519466  obj = (*it).second.obj;
    520467
    521   cid = obj->ClassId();
    522   ctyp = servnobjm->PClassIdToClassName(cid);
    523   sprintf(strg, "%2d/ %16s : %s", k, servnobjm->PClassIdToClassName(obj->ClassId()), ((*it).first).c_str());
     468  ctyp = typeid(*obj).name();
     469  sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str());
    524470  ctyp = strg;
    525471  cout << ctyp << "\n" ;
     
    533479void NamedObjMgr::PrintObj(string const& nom)
    534480{
    535 PPersist* obj=GetObj(nom);
    536 if (obj == NULL) {
    537   cout << "NamedObjMgr::PrintObj() Error , Pas d'objet de nom " << nom << endl;
    538   return;
    539 }
    540 
    541 int cid = obj->ClassId();
    542 string ctyp = servnobjm->PClassIdToClassName(cid);
    543 
    544 cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp
    545      << "Cid= " << cid << ")" << endl;
    546 
    547 int i4dum;
    548 switch (cid) {
    549   case ClassId_Poly1 :
    550     ((Poly*)obj)->Print(cout);
    551     break;
    552   case ClassId_Poly2 :
    553     ((Poly2*)obj)->Print(cout);
    554     break;
    555   case ClassId_Matrix :
    556   case ClassId_Vector :
    557     cout << *((Matrix*)obj);
    558     break;
    559 
    560   case ClassId_DVList :
    561     ((DVList*)obj)->Print();
    562     break;
    563 
    564   case ClassId_Histo1D :
    565     ((Histo*)obj)->Print(60);
    566     break;
    567   case ClassId_Histo2D :
    568     ((Histo2D*)obj)->Print();
    569     break;
    570   case ClassId_HProf :
    571     ((HProf*)obj)->Print(60);
    572     break;
    573   case ClassId_NTuple :
    574     cout << ((NTuple*)obj)->Info();
    575     cout << *((NTuple*)obj);
    576     break;
    577   case ClassId_GeneralFitData :
    578     ((GeneralFitData*)obj)->PrintStatus();
    579     i4dum = ((GeneralFitData*)obj)->NData();
    580     if(i4dum>0) {
    581       ((GeneralFitData*)obj)->PrintData(0);
    582       ((GeneralFitData*)obj)->PrintData(i4dum-1);
    583     }
    584     break;
    585 
    586   case ClassId_Image :
    587   case ClassId_Image + kuint_1 :
    588   case ClassId_Image + kint_1 :
    589   case ClassId_Image + kuint_2 :
    590   case ClassId_Image + kint_2 :
    591   case ClassId_Image + kuint_4 :
    592   case ClassId_Image + kint_4 :
    593   case ClassId_Image + kr_4 :
    594   case ClassId_Image + kr_8 :
    595     ((RzImage*)obj)->Print();
    596     break;
    597 
    598 #ifdef SANS_EVOLPLANCK
    599   case ClassId_ZFidu :
    600     ((ZFidu*)obj)->Print();
    601     break;
    602 
    603   case ClassId_StarList :
    604     ((StarList*)obj)->Print(10, 1, 50);
    605     break;
    606   case ClassId_Transfo :
    607     ((Transfo*)obj)->Print(cout);
    608     break;
    609   case ClassId_PSF :
    610     break;
    611 
    612   case ClassId_Star + BStar_Type :
    613   case ClassId_Star + RzStar_Type :
    614   case ClassId_Star + PSFStar_Type :
    615   case ClassId_Star + MCStar_Type :
    616   case ClassId_Star + CircRFixStar_Type :
    617   case ClassId_Star + PSFDHStar_Type :
    618   case ClassId_Star + PSFSEStar_Type :
    619   case ClassId_Star + MCDHStar_Type :
    620     ((BStar*)obj)->Print(1);
    621     break;
    622 #endif
    623 
    624 // - Ajout objet PPF
    625   default:
    626     break;
    627   }
    628 cout << endl;
     481NObjMgrAdapter* obja=NULL;
     482obja = GetObjAdapter(nom);
     483if (obja == NULL)  return;
     484
     485string ctyp = typeid(*obja->GetDataObj()).name();
     486cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
     487obja->Print(cout);
     488
    629489return;
    630490}
     
    633493void NamedObjMgr::DisplayObj(string const& nom, string dopt)
    634494{
    635 PPersist* obj=GetObj(nom);
    636 if (obj == NULL) {
     495NObjMgrAdapter* obja=NULL;
     496obja = GetObjAdapter(nom);
     497if (obja == NULL) {
    637498  cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl;
    638499  return;
     
    640501if (!myImgApp)  return;
    641502 
    642 int cid = obj->ClassId();
    643 string ctyp = servnobjm->PClassIdToClassName(cid);
     503PIDrawer * dr = NULL;
     504P2DArrayAdapter* arr = NULL;
     505dr = obja->GetDrawer(dopt);
     506if (!dr) arr = obja->Get2DArray(dopt);
     507
     508if (!dr && !arr) {
     509  string ctyp = typeid(*(obja->GetDataObj())).name();
     510  cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl;
     511  return;
     512  }
    644513
    645514int wrsid = 0;
    646515bool fgsr = true;
    647 // On veut tracer une ligne pour vecteur et histo1D par defaut
    648 if ( (cid == ClassId_Vector) || (cid == ClassId_Histo1D) )  dopt = "thinline," + dopt;
    649 else if(cid == ClassId_HProf)  dopt = "fcirclemarker5," + dopt;
    650516int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    651517
    652 switch (cid) {
    653   case ClassId_Poly1 :
    654   case ClassId_Poly2 :
    655   case ClassId_DVList :
    656     cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl;
    657     break;
    658 
    659   case ClassId_Matrix :
    660     {
    661     wrsid = myImgApp->DispImage(new POMatrixAdapter((Matrix*)obj, false), nom, opt);
    662     break;
    663     }
    664   case ClassId_Vector :
    665     {
    666     PIYfXDrawer* dr = new   PIYfXDrawer( new POVectorAdapter((Vector*)obj, false), NULL, true);
    667     wrsid = myImgApp->DispScDrawer( (PIDrawer*)dr, nom, opt);   
    668     break;
    669     }
    670   case ClassId_Histo1D :
    671     {
    672     PIHisto* pih = new PIHisto(((Histo*)obj), false);
    673     wrsid = myImgApp->DispScDrawer( (PIDrawer*)pih, nom, opt);
    674     break;
    675     }
    676   case ClassId_Histo2D :
    677     {
    678     PIHisto2D* pih2 = new PIHisto2D(((Histo2D*)obj), false);
    679     wrsid = myImgApp->DispScDrawer( (PIDrawer*)pih2, nom, opt, nom, true);
    680     break;
    681     }
    682   case ClassId_HProf :
    683     {
    684     PIHisto* pihp = new PIHisto(((Histo*)obj), false);
    685     wrsid = myImgApp->DispScDrawer( (PIDrawer*)pihp, nom, opt);
    686     break;
    687     }
    688   case ClassId_GeneralFitData :
    689     {
    690     GeneralFitData* gfd = (GeneralFitData*)obj;
    691     if(gfd->NVar()==1) {
    692       PIGenFitDat* pigfd = new PIGenFitDat(gfd,false);
    693       wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,opt);
    694     } else if(gfd->NVar()==2) {
    695       PIGenFitDat3D* pigfd = new PIGenFitDat3D(gfd,false);
    696       wrsid = myImgApp->Disp3DDrawer(pigfd,nom,opt);
    697     } else {
    698       cout<<"NamedObjMgr::DisplayObj() Error , Utilisez DisplayGFD pour GeneralFitData "
    699           <<ctyp<<"\n de "<<gfd->NVar()<<" variables (!=1,2)"<<endl;
    700     }
    701     break;
    702     }
    703 
    704   case ClassId_NTuple :
    705     cout << "NamedObjMgr::DisplayObj() Error , Utilisez DisplayNt pour NTuple " << ctyp << endl;
    706     break;
    707 
    708   case ClassId_Image :
    709   case ClassId_Image + kuint_1 :
    710   case ClassId_Image + kint_1 :
    711   case ClassId_Image + kr_8 :
    712   case ClassId_Image + kuint_4 :
    713     wrsid = myImgApp->DispImage(new RzImageAdapter((RzImage*)obj, false), nom, opt);
    714     break;
    715   case ClassId_Image + kuint_2 :
    716     wrsid = myImgApp->DispImage(new ImageAdapter<uint_2>((ImageU2*)obj, false), nom, opt);
    717     break;
    718   case ClassId_Image + kint_2 :
    719     wrsid = myImgApp->DispImage(new ImageAdapter<int_2>((ImageI2*)obj, false), nom, opt);
    720     break;
    721   case ClassId_Image + kint_4 :
    722     wrsid = myImgApp->DispImage(new ImageAdapter<int_4>((ImageI4*)obj, false), nom, opt);
    723     break;
    724   case ClassId_Image + kr_4 :
    725     wrsid = myImgApp->DispImage(new ImageAdapter<r_4>((ImageR4*)obj, false), nom, opt);
    726     break;
    727 
    728 #ifdef SANS_EVOLPLANCK
    729   case ClassId_ZFidu :
    730     {
    731     int nx = ((ZFidu*)obj)->XMax() -  ((ZFidu*)obj)->XMin();
    732     int ny = ((ZFidu*)obj)->YMax() -  ((ZFidu*)obj)->YMin();
    733     if (nx > 1024)  nx = 1024;
    734     if (ny > 1024)  ny = 1024;
    735     if (nx < 128)  nx = 128;
    736     if (ny < 128)  nx = 128;
    737     ImageU2* msk = ((ZFidu*)obj)->MakeBadZoneMask(nx, ny);
    738     myImgApp->DispImage(new ImageAdapter<uint_2>((ImageU2*)msk, true), nom, opt);
    739     break;
    740     }
    741 
    742   case ClassId_StarList :
    743     {
    744     PIStarList* pist = new PIStarList(((StarList*)obj), false);
    745     wrsid = myImgApp->DispScDrawer( (PIDrawer*)pist, nom, opt);
    746     break;
    747     }
    748 
    749   case ClassId_Transfo :
    750   case ClassId_PSF :
    751   case ClassId_Star + BStar_Type :
    752   case ClassId_Star + RzStar_Type :
    753   case ClassId_Star + PSFStar_Type :
    754   case ClassId_Star + MCStar_Type :
    755   case ClassId_Star + CircRFixStar_Type :
    756   case ClassId_Star + PSFDHStar_Type :
    757   case ClassId_Star + PSFSEStar_Type :
    758   case ClassId_Star + MCDHStar_Type :
    759     cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl;
    760     break;
    761 #endif
    762 
    763 // - Ajout objet PPF
    764   default:
    765     break;
    766   }
     518if (dr) {
     519  PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
     520  if(dr3)  wrsid = myImgApp->Disp3DDrawer(dr3, nom, opt);
     521  else wrsid = myImgApp->DispScDrawer( dr, nom, opt);
     522  }
     523else if (arr) wrsid = myImgApp->DispImage(arr, nom, opt);
    767524
    768525if(wrsid != 0) {
     
    775532}
    776533
     534/* --Methode-- */
     535void NamedObjMgr::DisplayImage(string const& nom, string dopt)
     536{
     537NObjMgrAdapter* obja=NULL;
     538obja = GetObjAdapter(nom);
     539if (obja == NULL) {
     540  cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl;
     541  return;
     542}
     543if (!myImgApp)  return;
     544 
     545P2DArrayAdapter* arr = obja->Get2DArray(dopt);
     546
     547if (!arr) {
     548  string ctyp = typeid(*(obja->GetDataObj())).name();
     549  cout << "NamedObjMgr::DisplayImage() Error , Non supporte pour " << ctyp << endl;
     550  return;
     551  }
     552
     553int wrsid = 0;
     554bool fgsr = true;
     555int opt = servnobjm->DecodeDispOption(dopt, fgsr);
     556wrsid = myImgApp->DispImage(arr, nom, opt);
     557
     558if(wrsid != 0) {
     559  NObjList::iterator it = myObjs->find(nom);
     560  if (it == myObjs->end()) return;
     561  (*it).second.wrsid.push_back(wrsid);
     562  }
     563if (fgsr) myImgApp->RestoreGraphicAtt();
     564return;
     565}
     566/* --Methode-- */
     567void NamedObjMgr::DisplaySurf3D(string const& nom, string dopt)
     568{
     569NObjMgrAdapter* obja=NULL;
     570obja = GetObjAdapter(nom);
     571if (obja == NULL) {
     572  cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl;
     573  return;
     574}
     575if (!myImgApp)  return;
     576 
     577P2DArrayAdapter* arr = obja->Get2DArray(dopt);
     578
     579if (!arr) {
     580  string ctyp = typeid(*(obja->GetDataObj())).name();
     581  cout << "NamedObjMgr::DisplaySurf3D() Error , Non supporte pour " << ctyp << endl;
     582  return;
     583  }
     584
     585if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
     586  cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" <<  arr->XSize()
     587       << "x" << arr->YSize() << ") trop grand (max=250x250)" << endl;
     588  delete arr;
     589  return;
     590  }
     591
     592int wrsid = 0;
     593bool fgsr = true;
     594int opt = servnobjm->DecodeDispOption(dopt, fgsr);
     595PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
     596wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt);
     597if(wrsid >= 0) {
     598  NObjList::iterator it = myObjs->find(nom);
     599  if (it == myObjs->end()) return;
     600  (*it).second.wrsid.push_back(wrsid);
     601  }
     602
     603if (fgsr) myImgApp->RestoreGraphicAtt(); 
     604return;
     605}
    777606
    778607/* --Methode-- */
     
    780609                            string& erx, string& ery, string& erz, string dopt)
    781610{
    782 PPersist* obj=GetObj(nom);
     611AnyDataObj* obj=GetObj(nom);
    783612if (obj == NULL) {
    784613  cout << "NamedObjMgr::DisplayNT() Error , Pas d'objet de nom " << nom << endl;
     
    787616if (!myImgApp)  return;
    788617
    789 int cid = obj->ClassId();
    790 if (cid != ClassId_NTuple) {
    791   string ctyp = servnobjm->PClassIdToClassName(cid);
     618if (typeid(*obj) != typeid(NTuple)) {
     619  string ctyp = typeid(*obj).name();
    792620  cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl;
    793621  return;
     
    837665//|  opt = options generales pour le display.
    838666{
    839 PPersist* obj=GetObj(nom);
     667AnyDataObj* obj=GetObj(nom);
    840668if(obj == NULL)
    841669  {cout << "NamedObjMgr::DisplayGFD() Error , Pas d'objet de nom " << nom << endl;
    842670   return;}
    843671if(!myImgApp) return;
    844 int cid = obj->ClassId();
    845 if(cid != ClassId_GeneralFitData)
    846   {string ctyp = servnobjm->PClassIdToClassName(cid);
     672if(typeid(*obj) != typeid(GeneralFitData))
     673  {string ctyp = typeid(*obj).name();
    847674   cout<<"NamedObjMgr::DisplayGFD() Error , Objet n'est pas un GeneralFitData "<<ctyp<<endl;
    848675   return;}
     
    894721
    895722
    896 /* --Methode-- */
    897 void NamedObjMgr::DisplaySurf3D(string const& nom, string dopt)
    898 {
    899 PPersist* obj=GetObj(nom);
    900 if (obj == NULL) {
    901   cout << "NamedObjMgr::DisplaySurf3D() Error , Pas d'objet de nom " << nom << endl;
    902   return;
    903 }
    904 if (!myImgApp)  return;
    905 
    906 int cid = obj->ClassId();
    907 
    908 
    909 P2DArrayAdapter* arr=NULL;
    910 switch (cid) {
    911   case ClassId_Matrix :
    912     arr = new POMatrixAdapter((Matrix*)obj, false);
    913     break;
    914   case ClassId_Histo2D :
    915     arr = new POH2DAdapter((Histo2D*)obj, false);
    916     break;
    917   case ClassId_Image :
    918   case ClassId_Image + kuint_1 :
    919   case ClassId_Image + kint_1 :
    920   case ClassId_Image + kr_8 :
    921   case ClassId_Image + kuint_4 :
    922     arr = new RzImageAdapter((RzImage*)obj, false);
    923     break;
    924   case ClassId_Image + kuint_2 :
    925     arr = new ImageAdapter<uint_2>((ImageU2*)obj, false);
    926     break;
    927   case ClassId_Image + kint_2 :
    928     arr = new ImageAdapter<int_2>((ImageI2*)obj, false);
    929     break;
    930   case ClassId_Image + kint_4 :
    931     arr = new ImageAdapter<int_4>((ImageI4*)obj, false);
    932     break;
    933   case ClassId_Image + kr_4 :
    934     arr = new ImageAdapter<r_4>((ImageR4*)obj, false);
    935     break;
    936 
    937   default :
    938     cout << "NamedObjMgr::DisplaySurf3D() Error , Pas de display pour " << servnobjm->PClassIdToClassName(cid) << endl;
    939     return;
    940   }
    941 
    942 if (!arr) return;
    943 if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
    944   cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" <<  arr->XSize()
    945        << "x" << arr->YSize() << ") trop grand (max=250x250)" << endl;
    946   delete arr;
    947   return;
    948   }
    949 
    950 int wrsid = 0;
    951 bool fgsr = true;
    952 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    953 if (cid == ClassId_Histo2D)  arr->DefineXYCoordinates(0., 0., 1., 1.);
    954 PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
    955 wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt);
    956 if(wrsid >= 0) {
    957   NObjList::iterator it = myObjs->find(nom);
    958   if (it == myObjs->end()) return;
    959   (*it).second.wrsid.push_back(wrsid);
    960   }
    961 
    962 if (fgsr) myImgApp->RestoreGraphicAtt(); 
    963 return;
    964 }
    965723
    966724
     
    984742                                  string& expcut, string dopt)
    985743{
    986 PPersist* obj=GetObj(nom);
    987 if (obj == NULL) {
     744NObjMgrAdapter* obja=NULL;
     745obja = GetObjAdapter(nom);
     746if (obja == NULL) {
    988747  cout << "NamedObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl;
    989748  return;
    990 }
     749  }
    991750if (!myImgApp)  return;
    992751
     
    999758else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
    1000759
    1001 servnobjm->Nobj_ComputeExpressions(obj, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
     760servnobjm->Nobj_ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
    1002761
    1003762if (nt->NEntry() < 1) {
     
    1025784                                  string& expcut, string dopt)
    1026785{
    1027 PPersist* obj=GetObj(nom);
    1028 if (obj == NULL) {
     786NObjMgrAdapter* obja=NULL;
     787obja = GetObjAdapter(nom);
     788if (obja == NULL) {
    1029789  cout << "NamedObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl;
    1030790  return;
     
    1036796
    1037797string expwt = "1.";
    1038 servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
     798servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
    1039799
    1040800if (nt->NEntry() < 1) {
     
    1064824void NamedObjMgr::ProjectH1(string const& nom, string& expx, string& expwt, string& expcut, string& nomh1, string dopt)
    1065825{
    1066 PPersist* obj=GetObj(nom);
    1067 
    1068 if (obj == NULL) {
     826NObjMgrAdapter* obja=NULL;
     827obja = GetObjAdapter(nom);
     828if (obja == NULL) {
    1069829  cout << "NamedObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl;
    1070830  return;
     
    1074834Histo* h1 = NULL;
    1075835NTuple* nt = NULL;
    1076 PPersist* oh = NULL;
     836AnyDataObj* oh = NULL;
    1077837if (nomh1.length() > 0) oh=GetObj(nomh1);
    1078838else nomh1 = "H1Proj";
    1079 if ( (oh != NULL) && (oh->ClassId() == ClassId_Histo1D) )  h1 = (Histo*)oh;  // Pas de remise a zero ! h1->Zero();
     839if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) )  h1 = (Histo*)oh;  // Pas de remise a zero ! h1->Zero();
    1080840else {
    1081841  char* ntn[2]= {"hxval", "hwt"};
     
    1083843  }
    1084844string expz = "0.";   
    1085 servnobjm->Nobj_ComputeExpressions(obj, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
     845servnobjm->Nobj_ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
    1086846
    1087847if ((!h1) && (!nt)) return;
     
    1113873                            string& nomh2, string dopt)
    1114874{
    1115 PPersist* obj=GetObj(nom);
    1116 
    1117 if (obj == NULL) {
     875NObjMgrAdapter* obja=NULL;
     876obja = GetObjAdapter(nom);
     877if (obja == NULL) {
    1118878  cout << "NamedObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl;
    1119879  return;
     
    1123883Histo2D* h2 = NULL;
    1124884NTuple* nt = NULL;
    1125 PPersist* oh = NULL;
     885AnyDataObj* oh = NULL;
    1126886if (nomh2.length() > 0)  oh=GetObj(nomh2);
    1127887else nomh2 = "H2Proj";
    1128 if ( (oh != NULL) && (oh->ClassId() == ClassId_Histo2D) )  h2 = (Histo2D*)oh;  // Pas de remise a zero ! h2->Zero();
     888if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) )  h2 = (Histo2D*)oh;  // Pas de remise a zero ! h2->Zero();
    1129889else {
    1130890  char* ntn[3]= {"hxval", "hyval", "hwt"};
     
    1132892  }
    1133893string expz = "0.";   
    1134 servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
     894servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
    1135895
    1136896if ((!h2) && (!nt)) return;
     
    1174934//| opt = options generales pour le display.
    1175935{
    1176 PPersist* obj=GetObj(nom);
    1177 
    1178 if (obj == NULL) {
     936NObjMgrAdapter* obja=NULL;
     937obja = GetObjAdapter(nom);
     938if (obja == NULL) {
    1179939  cout << "NamedObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl;
    1180940  return;
     
    1184944HProf* hprof = NULL;
    1185945NTuple* nt = NULL;
    1186 PPersist* oh = NULL;
     946AnyDataObj* oh = NULL;
    1187947if (nomprof.length() > 0)  oh=GetObj(nomprof);
    1188948else nomprof = "ProfProj";
    1189 if( (oh!=NULL) && (oh->ClassId()== ClassId_HProf) )  hprof = (HProf*)oh;
     949if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) )  hprof = (HProf*)oh;
    1190950else {
    1191951  char* ntn[3]= {"hxval", "hyval", "hwt"};
     
    1193953}
    1194954string expz = "0.";
    1195 servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
     955servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
    1196956
    1197957if((!hprof) && (!nt)) return;
     
    1223983void NamedObjMgr::FillVect(string const& nom, string& expx, string& expcut, string& nomvec, string dopt)
    1224984{
    1225 PPersist* obj=GetObj(nom);
    1226 
    1227 if (obj == NULL) {
     985NObjMgrAdapter* obja=NULL;
     986obja = GetObjAdapter(nom);
     987if (obja == NULL) {
    1228988  cout << "NamedObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl;
    1229989  return;
     
    1239999string expwt = "1.";
    12401000string expz = "0.";   
    1241 servnobjm->Nobj_ComputeExpressions(obj, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
     1001servnobjm->Nobj_ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
    12421002
    12431003if (!nt) return;
     
    12651025                         string& expcut, string& nomnt)
    12661026{
    1267 PPersist* obj=GetObj(nom);
    1268 
    1269 if (obj == NULL) {
     1027NObjMgrAdapter* obja=NULL;
     1028obja = GetObjAdapter(nom);
     1029if (obja == NULL) {
    12701030  cout << "NamedObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl;
    12711031  return;
     
    12751035bool fgnnt = false;
    12761036NTuple* nt = NULL;
    1277 PPersist* oh = NULL;
     1037AnyDataObj* oh = NULL;
    12781038if (nomnt.length() > 0)  oh=GetObj(nomnt);
    12791039else nomnt = "NTFill";
    1280 if ( (oh != NULL) && (oh->ClassId() == ClassId_NTuple) )  {
     1040if ( (oh != NULL) && (typeid(*oh) == typeid(HProf)) )  {
    12811041  nt = (NTuple*)oh;
    12821042  if (nt->NVar() > 10) {
     
    12911051  }
    12921052
    1293 servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, expt, expcut, nt, NULL, NULL);
     1053servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
    12941054
    12951055if (fgnnt) AddObj(nt, nomnt);
     
    13111071//| nomgfd = nom du GeneralFitData engendre (optionnel)
    13121072{
    1313 PPersist* obj=GetObj(nom);
    1314 if(obj == NULL)
    1315   {cout<<"NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
    1316    return;}
     1073NObjMgrAdapter* obja=NULL;
     1074obja = GetObjAdapter(nom);
     1075if (obja == NULL) {
     1076  cout << "NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
     1077  return;
     1078  }
    13171079if(!myImgApp)  return;
    13181080
     
    13211083if(expy.length()<=0) {nvar = 1; expy = "0.";}
    13221084
    1323 // Que faut-il copier dans GeneralFitData
    1324 int ndata=0;
    1325 int cid = obj->ClassId();
    1326 switch (cid) {
    1327   case ClassId_Vector :
    1328     ndata=((Vector*)obj)->NElts();
    1329     break;
    1330   case ClassId_Matrix :
    1331     ndata=((Matrix*)obj)->NCol()*((Matrix*)obj)->NRows();
    1332     break;
    1333   case ClassId_Histo1D :
    1334   case ClassId_HProf :
    1335     ndata=((Histo*)obj)->NBins();
    1336     break;
    1337   case ClassId_Histo2D :
    1338     ndata=((Histo2D*)obj)->NBinX()*((Histo2D*)obj)->NBinY();
    1339     break;
    1340   case ClassId_Image :
    1341   case ClassId_Image + kuint_1 :
    1342   case ClassId_Image + kint_1 :
    1343   case ClassId_Image + kr_8 :
    1344   case ClassId_Image + kuint_4 :
    1345   case ClassId_Image + kuint_2 :
    1346   case ClassId_Image + kint_2 :
    1347   case ClassId_Image + kint_4 :
    1348   case ClassId_Image + kr_4 :
    1349     ndata=((RzImage*)obj)->XSize()*((RzImage*)obj)->YSize();
    1350     break;
    1351 #ifdef SANS_EVOLPLANCK
    1352   case ClassId_StarList :
    1353     ndata=((StarList*)obj)->NbStars();
    1354     break;
    1355 #endif
    1356   case ClassId_NTuple :
    1357     ndata=((NTuple*)obj)->NEntry();
    1358     break;
    1359   case ClassId_GeneralFitData :
    1360     ndata=((GeneralFitData*)obj)->NData();
    1361     break;
    1362   default :
    1363     cout<<"FillGFD Erreur: N/A to  "<<servnobjm->PClassIdToClassName(cid)<<endl;
    1364     return;
    1365 }
    1366 
    1367 // Nom du GeneralFitData cree.
    1368 if (nomgfd.length() <= 0) nomgfd = "GFDFill";
    1369 // Consistence ndata.
    1370 if(ndata<=0)
    1371   {cout<<"NamedObjMgr::FillGFD() Warning   ndata="<<ndata<<endl;
    1372    return;}
     1085// $CHECK$ - cmv calculait le nombre d'entree ndata
     1086// en fonction de chaque objet - Je l'ai vire Reza 11/05/99
    13731087
    13741088// Creation NTuple Buffer
     
    13771091
    13781092// Remplissage NTuple buffer
    1379 servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, experr, expcut, nt, NULL, NULL);
     1093servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
    13801094if(nt->NEntry() < 1)
    13811095  {cout<<"NamedObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl;
     
    13831097
    13841098//Remplissage de la structure GeneraFitData
    1385 GeneralFitData* gfd = new GeneralFitData(nvar,ndata,0);
     1099if (nt->NEntry() <= 0) {
     1100  cout<<"NamedObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
     1101  delete nt;
     1102  return;
     1103  }
     1104
     1105GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
    13861106int k;
    13871107float* xn;
     
    17241444//|2D     yaa.b et y = idem "xaa.b et x" mais pour y
    17251445{
    1726 PPersist* obj=GetObj(nom);
     1446AnyDataObj* obj=GetObj(nom);
    17271447if (obj == NULL) {
    17281448  cout<<"NamedObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
     
    17331453  {cout<<"NamedObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
    17341454   return;}
    1735 int cid = obj->ClassId();
    1736 string ctyp = servnobjm->PClassIdToClassName(cid);
     1455string ctyp = typeid(*obj).name();
    17371456
    17381457int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
     
    17401459Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
    17411460GeneralFitData* g = NULL;
    1742 switch (cid) {
     1461
    17431462  // 1D
    1744   case ClassId_Vector :
    1745     ndim = 1;
    1746     v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
    1747     break;
    1748   case ClassId_HProf :
    1749   case ClassId_Histo1D :
    1750     ndim = 1;
    1751     h = (Histo*)  obj; nbinx = h->NBins(); nbiny = 1;
    1752     break;
    1753   // 2D
    1754   case ClassId_Matrix :
    1755     ndim = 2;
    1756     m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
    1757     break;
    1758   case ClassId_Histo2D :
    1759     ndim = 2;
    1760     h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
    1761     break;
    1762   // 1D ou 2D selon
    1763   case ClassId_GeneralFitData :
    1764     g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
    1765     if(     g->NVar()==1) ndim = 1;
    1766     else if(g->NVar()==2) ndim = 2;
    1767     else {
    1768       cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
    1769           <<((GeneralFitData*) obj)->NVar()<<endl; return;}
    1770     break;
    1771   case ClassId_Image :
    1772   case ClassId_Image + kuint_1 :
    1773   case ClassId_Image + kuint_2 :
    1774   case ClassId_Image + kint_2 :
    1775   case ClassId_Image + kint_4 :
    1776   case ClassId_Image + kr_4 :
    1777   case ClassId_Image + kr_8 :
    1778     ndim = 2;
    1779     im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
    1780     break;
    1781   default:
    1782     cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un "
    1783         <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
    1784     return;
    1785     break;
    1786 }
     1463if (typeid(*obj) == typeid(Vector)) {
     1464  ndim = 1;
     1465  v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
     1466  }
     1467else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) {
     1468  ndim = 1;
     1469  h = (Histo*)  obj; nbinx = h->NBins(); nbiny = 1;
     1470  }
     1471else if (typeid(*obj) == typeid(Matrix)) {
     1472  ndim = 2;
     1473  m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
     1474  }
     1475else if (typeid(*obj) == typeid(Histo2D)) {
     1476  ndim = 2;
     1477  h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
     1478  }
     1479else if (typeid(*obj) == typeid(GeneralFitData)) {
     1480  g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
     1481  if(     g->NVar()==1) ndim = 1;
     1482  else if(g->NVar()==2) ndim = 2;
     1483  else {
     1484     cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
     1485         <<((GeneralFitData*) obj)->NVar()<<endl; return; }
     1486  }
     1487else if (dynamic_cast<RzImage*>(obj)) {
     1488  ndim = 2;
     1489  im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
     1490  }
     1491else  {
     1492  cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un "
     1493      <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
     1494  return;
     1495  }
     1496
    17871497ndata = nbinx*nbiny;
    17881498if(ndata<=0)
Note: See TracChangeset for help on using the changeset viewer.