Changeset 344 in Sophya


Ignore:
Timestamp:
Aug 2, 1999, 6:52:49 PM (26 years ago)
Author:
ercodmgr
Message:

1/ Extension de fonctionalites de gestion de repertoires (Lock, ...)
2/ Plus de NTupIntf_Adapter quand les objets heritent de NTupleInterface
3/ Support pour affichage info texte, ds PINtuple et PIStarList

Location:
trunk/SophyaPI/PIext
Files:
22 edited

Legend:

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

    r339 r344  
    155155// Gestion des repertoires
    156156else if (kw == "mkdir" ) {
    157   if (tokens.size() < 1) { cout << "Usage: mkdir dirname " << endl; return(0); }
    158   mObjMgr->CreateDir(tokens[0]); 
     157  if (tokens.size() < 1) { cout << "Usage: mkdir dirname [true]" << endl; return(0); }
     158  bool crd = mObjMgr->CreateDir(tokens[0]); 
     159  if ( crd && (tokens.size() > 1) && (tokens[1] == "true") )
     160    mObjMgr->SetKeepOldDirAtt(tokens[0], true);
    159161  }
    160162else if (kw == "rmdir" ) {
     
    460462else if (kw == "ntloop" ) {
    461463  if (tokens.size() < 3) {
    462     cout << "Usage: ntloop nameobj fname funcname [ntname]" << endl;
     464    cout << "Usage: ntloop nameobj fname funcname [ntname [N1 N2] ]" << endl;
    463465    return(0);
    464466    }
    465467  if (tokens.size() < 4)  tokens.push_back("");
    466   srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3]);
     468  if (tokens[3] == "!") tokens[3] = "";
     469  int nl1 = -1;
     470  int nl2 = -1;
     471  if (tokens.size() > 5) {
     472    nl1 = atoi(tokens[4].c_str());
     473    nl2 = atoi(tokens[5].c_str());
     474    }
     475  srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], nl1, nl2);
    467476  }
    468477
     
    626635kw = "mkdir";
    627636usage = "Create a directory";
    628 usage += "\n Usage: mkdir dirname";
     637usage += "\n Usage: mkdir dirname [true]";
     638usage += "\n if second argument==true, the directory's KeepOld attribute is set to true";
    629639mpiac->RegisterCommand(kw, usage, this, "Object Managment");
    630640kw = "rmdir";
     
    796806usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
    797807usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
    798 usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName]";
     808usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName [N1 N2] ]";
     809usage += "\n Or:    ntloop nameobj CFileName FuncName ! N1 N2 ";
    799810usage += "\n  Related commands: ntexpcfile fillnt";
    800811mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
  • trunk/SophyaPI/PIext/nobjmgr.cc

    r339 r344  
    4242// include      nobjmgr.h
    4343//
    44 //      Cette classe fournit les services nécéssaire àla gestion des objets
     44//      Cette classe fournit les services nécéssaires à la gestion des objets
    4545//      (l'ensemble des objets PPersist de PEIDA++) au sein du programme
    4646//      d'analyse interactive *piapp* . Elle constitue en outre l'interface
     
    5858// ......  Gestion des objets nommes, variables globales ............
    5959struct nobj_diritem {
    60   int id;
    61   int nobj;
     60  int id;                 // Directory Id
     61  int nobj;               // Number of objects in directory
     62  bool lock;              // True -> directory locked, No Add, del or rename
     63  bool keepold;           // True -> When duplicate object name, old object moved to /old
    6264};
    6365
     
    6567
    6668struct nobj_item {
    67   AnyDataObj* obj;
    68   NObjMgrAdapter* obja;
    69   int oid;
    70   int dirid;
    71   list<int> wrsid;
     69  AnyDataObj* obj;             // Object pointer
     70  NObjMgrAdapter* obja;        // Object adapter pointer
     71  int oid;                     // object Id
     72  int dirid;                   // Directory Id
     73  list<int> wrsid;             // List of Window Resource Id (Drawer, PIBaseWdg, ...)
     74                               // (for PIStdImgApp)
    7275  bool operator==(nobj_item const& b) const
    7376    { return (this->obj ==  b.obj); }
     
    116119  string dirn = "home";
    117120  CreateDir(dirn);
     121  SetKeepOldDirAtt(dirn, true);
    118122  dirn = "tmp";
    119123  CreateDir(dirn);
     124  SetKeepOldDirAtt(dirn, false);
    120125  dirn = "old";
    121126  CreateDir(dirn);
     127  SetKeepOldDirAtt(dirn, false);
    122128  dirn = "home";
    123129  SetCurrentDir(dirn);
     
    179185
    180186/* --Methode-- */
    181 void NamedObjMgr::CreateDir(string & dirname)
     187bool NamedObjMgr::CreateDir(string & dirname)
    182188{
    183189if ( !CheckDirName(dirname) ) {
    184190  cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
    185   return;
     191  return(false);
    186192  }
    187193NObjDirList::iterator it = myDirs->find(dirname);
    188194if (it != myDirs->end()) {
    189195  cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
    190   return;
     196  return(false);
    191197  }
    192198myDirId++;
     
    194200di.id = myDirId;
    195201di.nobj = 0;
     202di.lock = false;
     203di.keepold = false;
    196204(*myDirs)[dirname] = di;
    197205if (myImgApp)  {
     
    200208  }
    201209cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
    202 }
    203 
    204 /* --Methode-- */
    205 void NamedObjMgr::DeleteDir(string & dirname)
     210return(true);
     211}
     212
     213/* --Methode-- */
     214bool NamedObjMgr::DeleteDir(string & dirname)
    206215{
    207216if ( !CheckDirName(dirname) ) {
    208217  cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
    209   return;
     218  return(false);
    210219  }
    211220NObjDirList::iterator it = myDirs->find(dirname);
    212221if (it == myDirs->end()) {
    213222  cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
    214   return;
     223  return(false);
    215224  }
    216225if ((*it).second.nobj > 0) {
    217226  cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
    218   return;
     227  return(false);
     228  }
     229if ((*it).second.lock ) {
     230  cout << "NamedObjMgr::DeleteDir() " << dirname << " locked ! " << endl;
     231  return(false);
    219232  }
    220233if ((*it).second.id < 50) {
    221234  cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
    222   return;
     235  return(false);
    223236  }
    224237
     
    227240myDirs->erase(it);
    228241cout << "amedObjMgr::DeleteDir() " << dirname << " deleted " << endl; 
    229 }
    230 
    231 /* --Methode-- */
    232 void NamedObjMgr::SetCurrentDir(string & dirname)
     242return(true);
     243}
     244
     245/* --Methode-- */
     246void NamedObjMgr::LockDir(string & dirname)
     247{
     248if ( !CheckDirName(dirname) ) return;
     249NObjDirList::iterator it = myDirs->find(dirname);
     250if (it == myDirs->end()) return;
     251(*it).second.lock = true;
     252cout << "NamedObjMgr::LockDir() " << dirname << " Locked " << endl;
     253return;
     254}
     255
     256/* --Methode-- */
     257void NamedObjMgr::UnlockDir(string & dirname)
     258{
     259if ( !CheckDirName(dirname) ) return;
     260NObjDirList::iterator it = myDirs->find(dirname);
     261if (it == myDirs->end()) return;
     262(*it).second.lock = true;
     263cout << "NamedObjMgr::UnlockDir() " << dirname << " Unlocked " << endl;
     264return;
     265}
     266
     267/* --Methode-- */
     268void NamedObjMgr::SetKeepOldDirAtt(string & dirname, bool keepold)
     269{
     270if ( !CheckDirName(dirname) ) return;
     271NObjDirList::iterator it = myDirs->find(dirname);
     272if (it == myDirs->end()) return;
     273(*it).second.keepold = keepold;
     274cout << "NamedObjMgr::SetKeepOldDirAtt() " << dirname << "  ->  ";
     275if ( keepold ) cout << " True " << endl;
     276else cout << " False " << endl;
     277return;
     278}
     279
     280
     281/* --Methode-- */
     282bool NamedObjMgr::SetCurrentDir(string & dirname)
    233283{
    234284if ( !CheckDirName(dirname) ) {
    235285  cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
    236   return;
     286  return(false);
    237287  }
    238288NObjDirList::iterator it = myDirs->find(dirname);
    239289if (it == myDirs->end()) {
    240290  cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
    241   return;
     291  return(false);
    242292  }
    243293*currDir = dirname;
    244294cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
     295return(true);
    245296}
    246297
     
    262313  if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
    263314  k++;
    264   cout << k << "- " << (*it).first << "  (NbObj= " << (*it).second.nobj << ")" << endl;
     315  cout << k << "- " << (*it).first;
     316  if ( (*it).second.lock )  cout << "  Locked " ;
     317  if ( (*it).second.keepold )   cout << "  KeepOld " ;
     318  cout << "  (Id= " << (*it).second.id << " NbObj= " << (*it).second.nobj << ")" << endl;
     319   
    265320  }
    266321}
     
    311366
    312367/* --Methode-- */
    313 void NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
    314 {
    315 
    316 if (obj == NULL)  return;
     368bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
     369{
     370
     371if (obj == NULL)  return(false);
    317372// On verifie si l'objet est deja dans la liste
    318373NObjList::iterator it;
     
    320375  if ((*it).second.obj == obj) {
    321376    cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl;
    322     return;
     377    return(false);
    323378    }
    324379  }
     
    330385  if (!crd) {
    331386    cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl;
    332     return;
     387    return(false);
    333388    }
    334389  else { CreateDir(nrep);  did =  myDirId; }
     
    342397
    343398nom = '/' + nrep + '/' + nobj; 
     399NObjDirList::iterator itr = myDirs->find(nrep);
     400if ((*itr).second.lock) {
     401  cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl;
     402  return(false);
     403  }
    344404it = myObjs->find(nom);
    345405if (it != myObjs->end()) { // l'objet existe deja
    346   if (nrep == "tmp") {  // Les objets de /tmp sont jetes
    347     cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
    348     DelObj(nom);
    349     }
    350   else {  // On met l'ancien objet dans /old
     406  if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
    351407    string on,od;
    352408//    ParseObjectName((*it).first, od, on);
     
    355411    RenameObj(nom, nomnew);
    356412    }
     413  else {  // Sinon, on remplace l'objet
     414    cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
     415    DelObj(nom);
     416    }
    357417  }
    358418
     
    364424(*myObjs)[nom] = no;
    365425
    366 NObjDirList::iterator itr = myDirs->find(nrep);
    367426(*itr).second.nobj++;
    368427
    369428cout << "NamedObjMgr::AddObj()  Object " << nom << " ( " 
    370429     << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl; 
    371 return;
    372 }
    373 
    374 /* --Methode-- */
    375 void NamedObjMgr::RenameObj(string & nom, string& nomnew)
     430return(true);
     431}
     432
     433/* --Methode-- */
     434bool NamedObjMgr::RenameObj(string & nom, string& nomnew)
    376435{
    377436string n1,r1,n2,r2;
    378 ParseObjectName(nom, r1, n1);
     437int dids = ParseObjectName(nom, r1, n1);
     438NObjDirList::iterator itr1 = myDirs->find(r1);
    379439int did = ParseObjectName(nomnew, r2, n2);
     440NObjDirList::iterator itr2 = myDirs->find(r2);
     441
    380442if (did == 0) {
    381443  cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
    382   return;
     444  return(false);
    383445  }
    384446nom = '/' + r1 + '/' + n1;
     
    387449if (it1 == myObjs->end()) {
    388450  cout << "NamedObjMgr::RenameObj() Error -  No " << nom << " object !" << endl;
    389   return;
     451  return(false);
    390452  }
    391453NObjList::iterator it2 = myObjs->find(nomnew);
    392454if (it2 != myObjs->end()) {
    393455  cout << "NamedObjMgr::RenameObj() Error -  Object " << nomnew << " exist !" << endl;
    394   return;
    395   }
     456  return(false);
     457  }
     458
     459if ( (*itr1).second.lock || (*itr2).second.lock ) {
     460  cout << "NamedObjMgr::RenameObj() Error - Source or destination directory locked !"
     461       << endl;
     462  return(false); 
     463  }
     464
    396465
    397466nobj_item no = (*it1).second;
     
    404473(*itr).second.nobj++;
    405474cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
    406 return;
    407 }
    408 
    409 /* --Methode-- */
    410 void NamedObjMgr::DelObj(string & nom, bool fgd)
     475return(true);
     476}
     477
     478/* --Methode-- */
     479bool NamedObjMgr::DelObj(string & nom, bool fgd)
    411480{
    412481string n1,r1;
     
    414483nom = '/' + r1 + '/' + n1;
    415484NObjList::iterator it = myObjs->find(nom);
    416 if (it == myObjs->end()) return;
     485if (it == myObjs->end()) return(false);
     486NObjDirList::iterator itr = myDirs->find(r1);
     487if ( (*itr).second.lock  ) {
     488  cout << "NamedObjMgr::DelObj() Error - Locked directory " << r1 << endl;
     489  return(false);
     490  }
    417491list<int>::iterator ii;
    418492if (myImgApp) {
     
    425499
    426500myObjs->erase(it);
    427 NObjDirList::iterator itr = myDirs->find(r1);
    428501(*itr).second.nobj--;
    429502
    430503if (fgd) cout << "NamedObjMgr::DelObj()  Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
    431504else  cout << "NamedObjMgr::DelObj()  Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
    432 return
    433 }
    434 
    435 /* --Methode-- */
    436 void NamedObjMgr::DelObj_Id(int oid)
     505return(true)
     506}
     507
     508/* --Methode-- */
     509bool NamedObjMgr::DelObj_Id(int oid)
    437510{
    438511NObjList::iterator it;
     
    444517    break;
    445518  }
    446 if (of) DelObj(nom, true);
     519if (of) return(DelObj(nom, true));
     520else return(false);
    447521}
    448522
     
    786860int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    787861
     862string n1,r1;
     863ParseObjectName(nom, r1, n1);
     864
    788865if (dr) {
    789866  PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
    790   if(dr3)  wrsid = myImgApp->Disp3DDrawer(dr3, nom, opt);
    791   else wrsid = myImgApp->DispScDrawer( dr, nom, opt);
    792   }
    793 else if (arr) wrsid = myImgApp->DispImage(arr, nom, opt);
     867  if(dr3)  wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt);
     868  else wrsid = myImgApp->DispScDrawer( dr, n1, opt);
     869  }
     870else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt);
    794871
    795872if(wrsid != 0) {
     
    821898  }
    822899
     900string n1,r1;
     901ParseObjectName(nom, r1, n1);
     902
    823903int wrsid = 0;
    824904bool fgsr = true;
    825905int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    826 wrsid = myImgApp->DispImage(arr, nom, opt);
     906wrsid = myImgApp->DispImage(arr, n1, opt);
    827907
    828908if(wrsid != 0) {
     
    860940  }
    861941
     942string n1,r1;
     943ParseObjectName(nom, r1, n1);
     944
    862945int wrsid = 0;
    863946bool fgsr = true;
    864947int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    865948PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
    866 wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt);
     949wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt);
    867950if(wrsid >= 0) {
    868951  NObjList::iterator it = myObjs->find(nom);
     
    899982int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    900983
     984string n1,r1;
     985ParseObjectName(nom, r1, n1);
     986
    901987if ( fg3d && (nmz.length()>0) )  { // Display 3D
    902988  PINTuple3D* pin = new PINTuple3D(nt, false);
     
    904990  pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
    905991  string titre = nmz + "%" + nmy + "%" + nmz;
    906   wrsid = myImgApp->Disp3DDrawer(pin, nom, opt, titre); 
     992  wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre); 
    907993}
    908994else {
     
    912998  if ( nmz.length()>0 ) pin->SelectWt(nmz.c_str());
    913999  string titre = nmy + "%" + nmx;
    914   wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, nom, opt, titre);
     1000  wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre);
    9151001  }
    9161002
     
    9651051 if(numvary.length()>0) numvy = atoi(numvary.c_str());
    9661052 
     1053 string n1,r1;
     1054 ParseObjectName(nom, r1, n1);
     1055
    9671056 int wrsid = 0;
    9681057 if(numvy>=0) {              // display 3D
     
    9701059  pigfd->SelectXY(numvx,numvy);
    9711060  pigfd->SelectErrBar(errx,erry,errz);
    972   wrsid = myImgApp->Disp3DDrawer(pigfd,nom,opt); 
     1061  wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt); 
    9731062} else {                   // display 2D
    9741063  PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
    9751064  pigfd->SelectX(numvx);
    9761065  pigfd->SelectErrBar(errx,erry);
    977   wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,opt);
     1066  wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt);
    9781067}
    9791068
  • trunk/SophyaPI/PIext/nobjmgr.h

    r333 r344  
    3232
    3333// Gestion des repertoires
    34   virtual void          CreateDir(string & dirname);
    35   virtual void          DeleteDir(string & dirname);
    36   virtual void          SetCurrentDir(string & dirname);
     34  virtual bool          CreateDir(string & dirname);
     35  virtual bool          DeleteDir(string & dirname);
     36  virtual void          LockDir(string & dirname);
     37  virtual void          UnlockDir(string & dirname);
     38  virtual void          SetKeepOldDirAtt(string & dirname, bool keepold=false);
     39  virtual bool          SetCurrentDir(string & dirname);
    3740  virtual void          GetCurrentDir(string & dirname);
    3841  virtual void          ListDirs(string & patt);
     
    4245
    4346//  Pour ajouter, supprimer et acceder aux objets
    44   virtual void          AddObj(AnyDataObj* obj, string & nom, bool crd=false);
    45   virtual void          RenameObj(string & nom, string& nomnew);
    46   virtual void          DelObj(string & nom, bool fgd=true);
     47  virtual bool          AddObj(AnyDataObj* obj, string & nom, bool crd=false);
     48  virtual bool          RenameObj(string & nom, string& nomnew);
     49  virtual bool          DelObj(string & nom, bool fgd=true);
    4750  virtual void          DelObjects(string & patt, bool fgd=true);
    48   virtual void          DelObj_Id(int oid);
     51  virtual bool          DelObj_Id(int oid);
    4952  virtual AnyDataObj*   GetObj(string & nom);
    5053  virtual void          ListObjs(string & patt);               
  • trunk/SophyaPI/PIext/nomgadapter.cc

    r295 r344  
    7070
    7171/* --Methode-- */
    72 NTupleInterface* NObjMgrAdapter::GetNTupleInterface()
     72NTupleInterface* NObjMgrAdapter::GetNTupleInterface(bool& adel)
    7373{
    7474string s = typeid(*mObj).name();
    7575cout << "NObjMgrAdapter::GetNTupleInterface() - Error : Not supported for " << s << endl;
     76adel = false;
    7677return(NULL);
    7778}
  • trunk/SophyaPI/PIext/nomgadapter.h

    r295 r344  
    3434  virtual PIDrawer*             GetDrawer(string& dopt);
    3535  virtual P2DArrayAdapter*      Get2DArray(string& dopt);
    36   virtual NTupleInterface*      GetNTupleInterface();
     36
     37// NTupleInterface* nti = GetNTupleInterface(adel)
     38// Retourne un objet de type NTupleInterface (nti), ainsi que adel
     39// si adel == true, le programme appelant doit faire delete de nti
     40  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    3741protected:
    3842  AnyDataObj* mObj;
  • trunk/SophyaPI/PIext/nomgfdadapter.cc

    r339 r344  
    5252
    5353/* --Methode-- */
    54 NTupleInterface* NOMAdapter_GeneralFitData::GetNTupleInterface()
     54NTupleInterface* NOMAdapter_GeneralFitData::GetNTupleInterface(bool& adel)
    5555{
    56 return( new NTupInt_GeneralFitData(mG) );
     56adel = false;
     57return(mG);
    5758}
    5859
    59 // -------------------------------------------------------------
    60 
    61 /* --Methode-- */
    62 NTupInt_GeneralFitData::NTupInt_GeneralFitData(GeneralFitData* g)
    63 {
    64 mG = g;
    65 }
    66 
    67 /* --Methode-- */
    68 NTupInt_GeneralFitData::~NTupInt_GeneralFitData()
    69 {
    70 }
    71 
    72 /* --Methode-- */
    73 uint_4 NTupInt_GeneralFitData::NbLines() const
    74 {
    75 return(mG->NbLines());
    76 }
    77 
    78 /* --Methode-- */
    79 uint_4 NTupInt_GeneralFitData::NbColumns() const
    80 {
    81 return(mG->NbColumns());
    82 }
    83 
    84 /* --Methode-- */
    85 r_8* NTupInt_GeneralFitData::GetLineD(int n) const
    86 {
    87 return(mG->GetLineD(n));
    88 }
    89 
    90 /* --Methode-- */
    91 string NTupInt_GeneralFitData::VarList_C(const char* nx) const
    92 {
    93 return(mG->VarList_C(nx));
    94 }
  • trunk/SophyaPI/PIext/nomgfdadapter.h

    r339 r344  
    2424
    2525  virtual void             Print(ostream& os);
    26   virtual NTupleInterface* GetNTupleInterface();
     26  virtual NTupleInterface* GetNTupleInterface(bool& adel);
    2727
    2828protected:
     
    3030};
    3131
    32 // Class Interface GeneralFitData pour GeneralFitData
    33 class NTupInt_GeneralFitData : public NTupleInterface {
    34 public:
    35                   NTupInt_GeneralFitData(GeneralFitData* g);
    36   virtual         ~NTupInt_GeneralFitData();
    37   virtual uint_4  NbLines() const ;
    38   virtual uint_4  NbColumns() const ;
    39   virtual r_8 *   GetLineD(int n) const ;
    40   virtual string  VarList_C(const char* nomx=NULL) const ;
    41 protected:
    42   GeneralFitData* mG;
    43 };
    4432
    4533#endif
  • trunk/SophyaPI/PIext/nomhistadapter.cc

    r326 r344  
    6363
    6464/* --Methode-- */
    65 NTupleInterface* NOMAdapter_Histo::GetNTupleInterface()
    66 {
     65NTupleInterface* NOMAdapter_Histo::GetNTupleInterface(bool& adel)
     66{
     67adel = true;
    6768return( new NTupInt_Histo(mHis) );
    6869}
     
    178179
    179180/* --Methode-- */
    180 NTupleInterface* NOMAdapter_Histo2D::GetNTupleInterface()
    181 {
     181NTupleInterface* NOMAdapter_Histo2D::GetNTupleInterface(bool& adel)
     182{
     183adel = true;
    182184return( new NTupInt_Histo2D(mHis) );
    183185}
     
    289291
    290292/* --Methode-- */
    291 NTupleInterface* NOMAdapter_NTuple::GetNTupleInterface()
    292 {
    293 return( new NTupInt_NTuple(mNt) );
    294 }
    295 
    296 
    297 // -------------------------------------------------------------
    298 
    299 /* --Methode-- */
    300 NTupInt_NTuple::NTupInt_NTuple(NTuple* nt)
    301 {
    302 mNt = nt;
    303 }
    304 
    305 /* --Methode-- */
    306 NTupInt_NTuple::~NTupInt_NTuple()
    307 {
    308 }
    309 
    310 /* --Methode-- */
    311 uint_4 NTupInt_NTuple::NbLines() const
    312 {
    313 return(mNt->NEntry());
    314 }
    315 
    316 /* --Methode-- */
    317 uint_4 NTupInt_NTuple::NbColumns() const
    318 {
    319 return(mNt->NVar());
    320 }
    321 
    322 /* --Methode-- */
    323 r_8* NTupInt_NTuple::GetLineD(int n) const
    324 {
    325 return(mNt->GetVecD(n));
    326 }
    327 
    328 /* --Methode-- */
    329 string NTupInt_NTuple::VarList_C(const char* nx) const
    330 {
    331 return(mNt->VarList_C(nx));
    332 }
     293NTupleInterface* NOMAdapter_NTuple::GetNTupleInterface(bool& adel)
     294{
     295adel = false;
     296return(mNt);
     297// return( new NTupInt_NTuple(mNt) );
     298}
     299
     300
  • trunk/SophyaPI/PIext/nomhistadapter.h

    r326 r344  
    3030  virtual void                  Print(ostream& os);
    3131  virtual PIDrawer*             GetDrawer(string& dopt);
    32   virtual NTupleInterface*      GetNTupleInterface();
     32  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    3333
    3434protected:
     
    6868  virtual PIDrawer*             GetDrawer(string& dopt);
    6969  virtual P2DArrayAdapter*      Get2DArray(string& dopt);
    70   virtual NTupleInterface*      GetNTupleInterface();
     70  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    7171
    7272protected:
     
    105105
    106106  virtual void                  Print(ostream& os);
    107   virtual NTupleInterface*      GetNTupleInterface();
     107  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    108108
    109109protected:
     
    111111};
    112112
    113 // Class Interface NTuple pour NTuple
    114 class NTupInt_NTuple : public NTupleInterface {
    115 public:
    116                         NTupInt_NTuple(NTuple* nt);
    117   virtual               ~NTupInt_NTuple();
    118   virtual uint_4        NbLines() const ;
    119   virtual uint_4        NbColumns() const ;
    120   virtual r_8 *         GetLineD(int n) const ;
    121   virtual string        VarList_C(const char* nomx=NULL) const ;
    122 protected:
    123   NTuple* mNt;
    124 };
    125113
    126114
  • trunk/SophyaPI/PIext/nomimagadapter.cc

    r326 r344  
    6969void NOMAdapter_Image<T>::Print(ostream& os)
    7070{
    71 os << (*mImg);
     71mImg->Print(os);
    7272}
    7373
     
    8282/* --Methode-- */
    8383template <class T>
    84 NTupleInterface* NOMAdapter_Image<T>::GetNTupleInterface()
     84NTupleInterface* NOMAdapter_Image<T>::GetNTupleInterface(bool& adel)
    8585{
     86adel = true;
    8687return( new NTupInt_Image<T>(mImg) );
    8788}
  • trunk/SophyaPI/PIext/nomimagadapter.h

    r326 r344  
    3030  virtual void                  Print(ostream& os);
    3131  virtual P2DArrayAdapter*      Get2DArray(string& dopt);
    32   virtual NTupleInterface*      GetNTupleInterface();
     32  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    3333
    3434protected:
  • trunk/SophyaPI/PIext/nommatvecadapter.cc

    r326 r344  
    6161
    6262/* --Methode-- */
    63 NTupleInterface* NOMAdapter_Vector::GetNTupleInterface()
    64 {
     63NTupleInterface* NOMAdapter_Vector::GetNTupleInterface(bool& adel)
     64{
     65adel = true;
    6566return( new NTupInt_Vector(mVec) );
    6667}
     
    169170
    170171/* --Methode-- */
    171 NTupleInterface* NOMAdapter_Matrix::GetNTupleInterface()
    172 {
     172NTupleInterface* NOMAdapter_Matrix::GetNTupleInterface(bool& adel)
     173{
     174adel = true;
    173175return( new NTupInt_Matrix(mMtx) );
    174176}
  • trunk/SophyaPI/PIext/nommatvecadapter.h

    r326 r344  
    2828  virtual void                  Print(ostream& os);
    2929  virtual PIDrawer*             GetDrawer(string& dopt);
    30   virtual NTupleInterface*      GetNTupleInterface();
     30  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    3131
    3232protected:
     
    6767  virtual void                  Print(ostream& os);
    6868  virtual P2DArrayAdapter*      Get2DArray(string& dopt);
    69   virtual NTupleInterface*      GetNTupleInterface();
     69  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    7070
    7171protected:
  • trunk/SophyaPI/PIext/nomstladapter.cc

    r326 r344  
    6464
    6565/* --Methode-- */
    66 NTupleInterface* NOMAdapter_StarList::GetNTupleInterface()
     66NTupleInterface* NOMAdapter_StarList::GetNTupleInterface(bool& adel)
    6767{
     68adel = true;
    6869return( new NTupInt_StarList(mStl) );
    6970}
  • trunk/SophyaPI/PIext/nomstladapter.h

    r326 r344  
    2828  virtual void                  Print(ostream& os);
    2929  virtual PIDrawer*             GetDrawer(string& dopt);
    30   virtual NTupleInterface*      GetNTupleInterface();
     30  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    3131
    3232protected:
  • trunk/SophyaPI/PIext/pintuple.cc

    r336 r344  
    9797msz = mMSz;
    9898if (msz < 1) msz = 1;
    99 g->SelMarker(sz, mrk);
     99g->SelMarker(msz, mrk);
    100100
    101101nok = 0; 
     
    136136}
    137137
     138/* --Methode-- */
     139void PINTuple::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
     140{
     141if (!mNT) return;
     142if ( (xK < 0) || (yK < 0) )  return;
     143
     144int ncnt = 0;
     145double xp,yp;
     146char buff[128];
     147sprintf(buff,"PINTuple: NLines= %d  NCol= %d \n", mNT->NbLines(),  mNT->NbColumns());
     148info += buff;
     149info += mNT->LineHeaderToString();
     150for (int i=0; i<mNT->NbLines(); i++) {
     151  xp = mNT->GetCell(i, xK);
     152  yp = mNT->GetCell(i, yK);
     153  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
     154  ncnt++;
     155  if (ncnt > 101) continue;
     156  info += mNT->LineToString(i);
     157  }
     158if (ncnt >= 101) info += " .... \n";
     159sprintf(buff," %d points inside selected region \n", ncnt);
     160info += buff;
     161// printf("PINTuple::AppendTextInfo()-DBG %g %g %g %g - %d\n", xmin, ymin, xmax, ymax, ncnt);
     162return;
     163}
  • trunk/SophyaPI/PIext/pintuple.h

    r333 r344  
     1// This may look like C code, but it is really -*- C++ -*-
     2// Module PI : Peida Interactive  PINTuple et PINTupleWdg
     3// Traceur d objet de type NTupleInterface
     4
    15#ifndef PINTUPLE_H
    26#define PINTUPLE_H
     
    1317  virtual void       UpdateLimits();
    1418 
    15           void       SelectXY(const char* px, const char* py);
    16           void       SelectWt(const char* pw=NULL, int nbins=10);
    17           void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL);
     19  virtual void       SelectXY(const char* px, const char* py);
     20  virtual void       SelectWt(const char* pw=NULL, int nbins=10);
     21  virtual void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL);
    1822
     23  virtual void       AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
    1924       
    2025protected:
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r338 r344  
    655655if (w == NULL)  return;
    656656w->Hide();
     657bool ownwindow=false;  // To Check if this is one of our windows
    657658WindMList::iterator it;
    658659for(it = mWList.begin(); it != mWList.end(); it++)
    659   if ((*it).second == w)  { mWList.erase(it);  break; }
     660  if ((*it).second == w)  { mWList.erase(it);  ownwindow = true; break; }
    660661if (w == mGrW) { mGrW = NULL;  mGrIdx = -1; }
    661662if (w == mStW) { mStW = NULL;  mStIdx = -1; m[2]->SetSensitivity("StackTools", false); }
    662663if (w == mCurWin) mCurWin = NULL;
     664
     665if (!ownwindow) return; // We do nothing if this is not a window we have created ...
     666
    663667int k;
    664668PIWdg* cwd;
  • trunk/SophyaPI/PIext/pistlist.cc

    r205 r344  
    101101}
    102102
     103/* --Methode-- */
     104void PIStarList::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
     105{
     106BStar *sti;
     107double xp,yp;
     108double flx,fnd;
     109char buff[128];
     110int ncnt = 0;
     111sprintf(buff,"PIStarList: NStars \n", mStL->NbStars() );
     112info += buff;
     113info += "  Num:   XPos       YPos     Flux      Fond \n";
     114for (int i=0; i<mStL->NbStars(); i++) {
     115  sti = mStL->Star(i);
     116  if ( !(sti->Nice(BStar::flagOK)) )  continue;
     117  flx = sti->Flux();
     118  if ( (flx < mFmin) || (flx > mFmax) )  continue;
     119  xp = sti->PosX();   yp = sti->PosY();
     120  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
     121  ncnt++;
     122  if (ncnt > 101) continue;
     123  fnd = sti->Fond();
     124  sprintf(buff,"%6d: %8.3g %8.3g %8.3g %8.3g \n", i, xp, yp, flx, fnd);
     125  info += buff;
     126  }
     127if (ncnt >= 101) info += " .... \n";
     128sprintf(buff," %d stars inside selected region \n", ncnt);
     129info += buff;
     130return;
     131}
  • trunk/SophyaPI/PIext/pistlist.h

    r205 r344  
    1313  virtual void       UpdateLimits();
    1414 
     15  virtual void       AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
     16
    1517  void               SetFluxLimits(float min=1., float max=-1., int nl=5, bool dispflx=false, bool refr=false);
    1618
  • trunk/SophyaPI/PIext/servnobjm.cc

    r341 r344  
    200200
    201201if (vpy) {
    202   string titre = (nom.length() < 1) ? "Function f(x)" : nom;
    203   P1DArrayAdapter* vya = new POVectorAdapter(vpy, true);
     202  string titre;
     203  if (nom.length() < 1) {
     204     titre = "Function f(x)";
     205     nom = "/tmp/func";
     206    }
     207  else titre = nom;
     208 
     209  P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);
    204210  vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
    205211  PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ;
     
    256262
    257263if (mtx) {
    258   string titre = (nom.length() < 1) ? "Function f(x,y)" : nom; 
     264  string titre;
     265  if (nom.length() < 1) {
     266     titre = "Function f(x,y)";
     267     nom = "/tmp/func2d";
     268    }
     269  else titre = nom;
    259270  bool fgsr = true;
    260271  int opt = DecodeDispOption(dopt, fgsr);
    261   P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true);
     272  P2DArrayAdapter* arr = new POMatrixAdapter(mtx, false);
    262273  arr->DefineXYCoordinates(xmin, ymin, dx, dy);
    263274  PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
     
    636647/* --Methode-- */
    637648void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname,
    638                                      string const & funcname, string & nomnt)
     649                                     string const & funcname, string & nomnt,
     650                                     int nl1, int nl2)
    639651{
    640652if (!mImgapp)  return;
     
    646658  return;
    647659  }
    648 NTupleInterface* objnt = obja->GetNTupleInterface();
     660bool adel = true;
     661NTupleInterface* objnt = obja->GetNTupleInterface(adel);
    649662if (objnt == NULL)  {
    650663  cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No NTupleInterface !" <<endl;
     
    655668if (!f) {
    656669  cerr << "Services2NObjMgr::FillNTFrCFile Error Creation  NTLoopExprFunc" <<  endl;
     670  if (adel) delete objnt;   // Delete de l'objet NTupleInterface si necessaire
    657671  return;
    658672  }
     
    691705TRY  {
    692706  double* xn;
    693   int kmax = objnt->NbLines();
    694   for(k=0; k<kmax; k++)    {
     707  if (nl1 < 0) nl1 = 0;
     708  if (nl2 < 0) nl2 = objnt->NbLines();
     709  if (nl2 > objnt->NbLines()) nl2 = objnt->NbLines();
     710  int kmax = nl2;
     711  for(k=nl1; k<kmax; k++)    {
    695712    xn = objnt->GetLineD(k);
    696713    if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
     
    709726  cerr << "Services2NObjMgr::FillNTFrCFile()  Exception :" << merr << es;
    710727  } ENDTRY;
    711  
     728
     729if (adel) delete objnt;   // Delete de l'objet NTupleInterface si necessaire
    712730CloseDLL();
    713731
     
    729747  return;
    730748  }
    731 NTupleInterface* objnt = obja->GetNTupleInterface();
     749bool adel = true;
     750NTupleInterface* objnt = obja->GetNTupleInterface(adel);
    732751if (objnt == NULL)  {
    733752  cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom
     
    740759if ((fip = fopen(fname.c_str(), "w")) == NULL)   {
    741760  cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl;
     761  if (adel) delete objnt;   // Delete de l'objet NTupleInterface si necessaire
    742762  return;
    743763  }
     764
    744765// constitution du fichier des decalarations des variables de l'interface NTuple
    745766fputs("#include <stdlib.h> \n", fip);
    746767fputs("#include <stdio.h> \n", fip);
    747768fputs("#include <math.h> \n\n", fip);
     769
     770fputs("/* ------ Some random number generators --------- */ \n", fip);
     771fputs("#define frand01() ( (float) drand48() ) \n", fip);
     772fputs("#define drand01() drand48()  \n", fip);
     773fputs("#define rand01()  drand48()  \n", fip);
     774fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
     775fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
     776fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
     777fputs("double NorRand(void) \n", fip);
     778fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
     779fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
     780fputs(" x = sqrt(-2.*log(A))*cos(M_2PI*B); \n", fip);
     781fputs(" return(x); \n } \n", fip);
     782fputs("#define GauRand() NorRand() \n", fip);
     783fputs("#define gaurand() NorRand() \n\n", fip);
     784
    748785fputs("/* NTupleInterface Variable declaration - Generated by piapp  \n", fip);
    749786fputs("      -- Services2NObjMgr::PrepareNTExpressionCFile()  --     */ \n\n", fip);
     
    759796
    760797fclose(fip);
     798
     799if (adel) delete objnt;   // Delete de l'objet NTupleInterface si necessaire
    761800return;
    762801}
     
    13041343{
    13051344if (obja == NULL) return;
    1306 NTupleInterface* objnt = obja->GetNTupleInterface();
     1345bool adel = true;
     1346NTupleInterface* objnt = obja->GetNTupleInterface(adel);
    13071347if (objnt == NULL)  return;
    13081348string  vardec = objnt->VarList_C("_zz6qi_");
     
    13111351if (!f) {
    13121352  cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " <<  endl;
     1353  if (adel) delete objnt;  // Delete de l'objet NTupleInterface si necessaire
    13131354  return;
    13141355  }
     
    13441385 
    13451386
     1387if (adel) delete objnt;  // Delete de l'objet NTupleInterface si necessaire
    13461388// Fermeture du fichier .so
    13471389CloseDLL();
     
    13721414fputs("#include <stdlib.h> \n", fip);
    13731415fputs("#include <math.h> \n", fip);
     1416
     1417fputs("/* ------ Some random number generators --------- */ \n", fip);
     1418fputs("#define frand01() ( (float) drand48() ) \n", fip);
     1419fputs("#define drand01() drand48()  \n", fip);
     1420fputs("#define rand01()  drand48()  \n", fip);
     1421fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
     1422fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
     1423fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
     1424fputs("double NorRand(void) \n", fip);
     1425fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
     1426fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
     1427fputs(" x = sqrt(-2.*log(A))*cos(M_2PI*B); \n", fip);
     1428fputs(" return(x); \n } \n", fip);
     1429fputs("#define GauRand() NorRand() \n", fip);
     1430fputs("#define gaurand() NorRand() \n\n", fip);
     1431
    13741432fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
    13751433fprintf(fip,"%s \n", vardec.c_str());
  • trunk/SophyaPI/PIext/servnobjm.h

    r333 r344  
    7979                               string& experr, string& expcut, string& nomgfd);
    8080  virtual void          FillNTFrCFile(string & nom, string const & fname,
    81                                       string const & funcname, string & nomnt);
     81                                      string const & funcname, string & nomnt,
     82                                      int nl1=-1, int nl2=-1);
    8283  virtual void          PrepareNTExpressionCFile(string & nomobj, string const & fname,
    8384                                                 string const & funcname);
Note: See TracChangeset for help on using the changeset viewer.