Changeset 344 in Sophya
- Timestamp:
- Aug 2, 1999, 6:52:49 PM (26 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/basexecut.cc
r339 r344 155 155 // Gestion des repertoires 156 156 else 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); 159 161 } 160 162 else if (kw == "rmdir" ) { … … 460 462 else if (kw == "ntloop" ) { 461 463 if (tokens.size() < 3) { 462 cout << "Usage: ntloop nameobj fname funcname [ntname ]" << endl;464 cout << "Usage: ntloop nameobj fname funcname [ntname [N1 N2] ]" << endl; 463 465 return(0); 464 466 } 465 467 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); 467 476 } 468 477 … … 626 635 kw = "mkdir"; 627 636 usage = "Create a directory"; 628 usage += "\n Usage: mkdir dirname"; 637 usage += "\n Usage: mkdir dirname [true]"; 638 usage += "\n if second argument==true, the directory's KeepOld attribute is set to true"; 629 639 mpiac->RegisterCommand(kw, usage, this, "Object Managment"); 630 640 kw = "rmdir"; … … 796 806 usage = "Loops over an Object NTupleInterface calling a function from a C-file \n"; 797 807 usage += "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]"; 808 usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName [N1 N2] ]"; 809 usage += "\n Or: ntloop nameobj CFileName FuncName ! N1 N2 "; 799 810 usage += "\n Related commands: ntexpcfile fillnt"; 800 811 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); -
trunk/SophyaPI/PIext/nobjmgr.cc
r339 r344 42 42 // include nobjmgr.h 43 43 // 44 // Cette classe fournit les services nécéssaire àla gestion des objets44 // Cette classe fournit les services nécéssaires à la gestion des objets 45 45 // (l'ensemble des objets PPersist de PEIDA++) au sein du programme 46 46 // d'analyse interactive *piapp* . Elle constitue en outre l'interface … … 58 58 // ...... Gestion des objets nommes, variables globales ............ 59 59 struct 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 62 64 }; 63 65 … … 65 67 66 68 struct 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) 72 75 bool operator==(nobj_item const& b) const 73 76 { return (this->obj == b.obj); } … … 116 119 string dirn = "home"; 117 120 CreateDir(dirn); 121 SetKeepOldDirAtt(dirn, true); 118 122 dirn = "tmp"; 119 123 CreateDir(dirn); 124 SetKeepOldDirAtt(dirn, false); 120 125 dirn = "old"; 121 126 CreateDir(dirn); 127 SetKeepOldDirAtt(dirn, false); 122 128 dirn = "home"; 123 129 SetCurrentDir(dirn); … … 179 185 180 186 /* --Methode-- */ 181 voidNamedObjMgr::CreateDir(string & dirname)187 bool NamedObjMgr::CreateDir(string & dirname) 182 188 { 183 189 if ( !CheckDirName(dirname) ) { 184 190 cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl; 185 return ;191 return(false); 186 192 } 187 193 NObjDirList::iterator it = myDirs->find(dirname); 188 194 if (it != myDirs->end()) { 189 195 cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl; 190 return ;196 return(false); 191 197 } 192 198 myDirId++; … … 194 200 di.id = myDirId; 195 201 di.nobj = 0; 202 di.lock = false; 203 di.keepold = false; 196 204 (*myDirs)[dirname] = di; 197 205 if (myImgApp) { … … 200 208 } 201 209 cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl; 202 } 203 204 /* --Methode-- */ 205 void NamedObjMgr::DeleteDir(string & dirname) 210 return(true); 211 } 212 213 /* --Methode-- */ 214 bool NamedObjMgr::DeleteDir(string & dirname) 206 215 { 207 216 if ( !CheckDirName(dirname) ) { 208 217 cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl; 209 return ;218 return(false); 210 219 } 211 220 NObjDirList::iterator it = myDirs->find(dirname); 212 221 if (it == myDirs->end()) { 213 222 cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl; 214 return ;223 return(false); 215 224 } 216 225 if ((*it).second.nobj > 0) { 217 226 cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl; 218 return; 227 return(false); 228 } 229 if ((*it).second.lock ) { 230 cout << "NamedObjMgr::DeleteDir() " << dirname << " locked ! " << endl; 231 return(false); 219 232 } 220 233 if ((*it).second.id < 50) { 221 234 cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl; 222 return ;235 return(false); 223 236 } 224 237 … … 227 240 myDirs->erase(it); 228 241 cout << "amedObjMgr::DeleteDir() " << dirname << " deleted " << endl; 229 } 230 231 /* --Methode-- */ 232 void NamedObjMgr::SetCurrentDir(string & dirname) 242 return(true); 243 } 244 245 /* --Methode-- */ 246 void NamedObjMgr::LockDir(string & dirname) 247 { 248 if ( !CheckDirName(dirname) ) return; 249 NObjDirList::iterator it = myDirs->find(dirname); 250 if (it == myDirs->end()) return; 251 (*it).second.lock = true; 252 cout << "NamedObjMgr::LockDir() " << dirname << " Locked " << endl; 253 return; 254 } 255 256 /* --Methode-- */ 257 void NamedObjMgr::UnlockDir(string & dirname) 258 { 259 if ( !CheckDirName(dirname) ) return; 260 NObjDirList::iterator it = myDirs->find(dirname); 261 if (it == myDirs->end()) return; 262 (*it).second.lock = true; 263 cout << "NamedObjMgr::UnlockDir() " << dirname << " Unlocked " << endl; 264 return; 265 } 266 267 /* --Methode-- */ 268 void NamedObjMgr::SetKeepOldDirAtt(string & dirname, bool keepold) 269 { 270 if ( !CheckDirName(dirname) ) return; 271 NObjDirList::iterator it = myDirs->find(dirname); 272 if (it == myDirs->end()) return; 273 (*it).second.keepold = keepold; 274 cout << "NamedObjMgr::SetKeepOldDirAtt() " << dirname << " -> "; 275 if ( keepold ) cout << " True " << endl; 276 else cout << " False " << endl; 277 return; 278 } 279 280 281 /* --Methode-- */ 282 bool NamedObjMgr::SetCurrentDir(string & dirname) 233 283 { 234 284 if ( !CheckDirName(dirname) ) { 235 285 cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl; 236 return ;286 return(false); 237 287 } 238 288 NObjDirList::iterator it = myDirs->find(dirname); 239 289 if (it == myDirs->end()) { 240 290 cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl; 241 return ;291 return(false); 242 292 } 243 293 *currDir = dirname; 244 294 cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl; 295 return(true); 245 296 } 246 297 … … 262 313 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue; 263 314 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 265 320 } 266 321 } … … 311 366 312 367 /* --Methode-- */ 313 voidNamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)314 { 315 316 if (obj == NULL) return ;368 bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd) 369 { 370 371 if (obj == NULL) return(false); 317 372 // On verifie si l'objet est deja dans la liste 318 373 NObjList::iterator it; … … 320 375 if ((*it).second.obj == obj) { 321 376 cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl; 322 return ;377 return(false); 323 378 } 324 379 } … … 330 385 if (!crd) { 331 386 cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl; 332 return ;387 return(false); 333 388 } 334 389 else { CreateDir(nrep); did = myDirId; } … … 342 397 343 398 nom = '/' + nrep + '/' + nobj; 399 NObjDirList::iterator itr = myDirs->find(nrep); 400 if ((*itr).second.lock) { 401 cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl; 402 return(false); 403 } 344 404 it = myObjs->find(nom); 345 405 if (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 351 407 string on,od; 352 408 // ParseObjectName((*it).first, od, on); … … 355 411 RenameObj(nom, nomnew); 356 412 } 413 else { // Sinon, on remplace l'objet 414 cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl; 415 DelObj(nom); 416 } 357 417 } 358 418 … … 364 424 (*myObjs)[nom] = no; 365 425 366 NObjDirList::iterator itr = myDirs->find(nrep);367 426 (*itr).second.nobj++; 368 427 369 428 cout << "NamedObjMgr::AddObj() Object " << nom << " ( " 370 429 << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl; 371 return ;372 } 373 374 /* --Methode-- */ 375 voidNamedObjMgr::RenameObj(string & nom, string& nomnew)430 return(true); 431 } 432 433 /* --Methode-- */ 434 bool NamedObjMgr::RenameObj(string & nom, string& nomnew) 376 435 { 377 436 string n1,r1,n2,r2; 378 ParseObjectName(nom, r1, n1); 437 int dids = ParseObjectName(nom, r1, n1); 438 NObjDirList::iterator itr1 = myDirs->find(r1); 379 439 int did = ParseObjectName(nomnew, r2, n2); 440 NObjDirList::iterator itr2 = myDirs->find(r2); 441 380 442 if (did == 0) { 381 443 cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl; 382 return ;444 return(false); 383 445 } 384 446 nom = '/' + r1 + '/' + n1; … … 387 449 if (it1 == myObjs->end()) { 388 450 cout << "NamedObjMgr::RenameObj() Error - No " << nom << " object !" << endl; 389 return ;451 return(false); 390 452 } 391 453 NObjList::iterator it2 = myObjs->find(nomnew); 392 454 if (it2 != myObjs->end()) { 393 455 cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl; 394 return; 395 } 456 return(false); 457 } 458 459 if ( (*itr1).second.lock || (*itr2).second.lock ) { 460 cout << "NamedObjMgr::RenameObj() Error - Source or destination directory locked !" 461 << endl; 462 return(false); 463 } 464 396 465 397 466 nobj_item no = (*it1).second; … … 404 473 (*itr).second.nobj++; 405 474 cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl; 406 return ;407 } 408 409 /* --Methode-- */ 410 voidNamedObjMgr::DelObj(string & nom, bool fgd)475 return(true); 476 } 477 478 /* --Methode-- */ 479 bool NamedObjMgr::DelObj(string & nom, bool fgd) 411 480 { 412 481 string n1,r1; … … 414 483 nom = '/' + r1 + '/' + n1; 415 484 NObjList::iterator it = myObjs->find(nom); 416 if (it == myObjs->end()) return; 485 if (it == myObjs->end()) return(false); 486 NObjDirList::iterator itr = myDirs->find(r1); 487 if ( (*itr).second.lock ) { 488 cout << "NamedObjMgr::DelObj() Error - Locked directory " << r1 << endl; 489 return(false); 490 } 417 491 list<int>::iterator ii; 418 492 if (myImgApp) { … … 425 499 426 500 myObjs->erase(it); 427 NObjDirList::iterator itr = myDirs->find(r1);428 501 (*itr).second.nobj--; 429 502 430 503 if (fgd) cout << "NamedObjMgr::DelObj() Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl; 431 504 else cout << "NamedObjMgr::DelObj() Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl; 432 return ;433 } 434 435 /* --Methode-- */ 436 voidNamedObjMgr::DelObj_Id(int oid)505 return(true); 506 } 507 508 /* --Methode-- */ 509 bool NamedObjMgr::DelObj_Id(int oid) 437 510 { 438 511 NObjList::iterator it; … … 444 517 break; 445 518 } 446 if (of) DelObj(nom, true); 519 if (of) return(DelObj(nom, true)); 520 else return(false); 447 521 } 448 522 … … 786 860 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 787 861 862 string n1,r1; 863 ParseObjectName(nom, r1, n1); 864 788 865 if (dr) { 789 866 PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr); 790 if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n om, opt);791 else wrsid = myImgApp->DispScDrawer( dr, n om, opt);792 } 793 else if (arr) wrsid = myImgApp->DispImage(arr, n om, opt);867 if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt); 868 else wrsid = myImgApp->DispScDrawer( dr, n1, opt); 869 } 870 else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt); 794 871 795 872 if(wrsid != 0) { … … 821 898 } 822 899 900 string n1,r1; 901 ParseObjectName(nom, r1, n1); 902 823 903 int wrsid = 0; 824 904 bool fgsr = true; 825 905 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 826 wrsid = myImgApp->DispImage(arr, n om, opt);906 wrsid = myImgApp->DispImage(arr, n1, opt); 827 907 828 908 if(wrsid != 0) { … … 860 940 } 861 941 942 string n1,r1; 943 ParseObjectName(nom, r1, n1); 944 862 945 int wrsid = 0; 863 946 bool fgsr = true; 864 947 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 865 948 PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true); 866 wrsid = myImgApp->Disp3DDrawer(sdr, n om, opt);949 wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt); 867 950 if(wrsid >= 0) { 868 951 NObjList::iterator it = myObjs->find(nom); … … 899 982 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 900 983 984 string n1,r1; 985 ParseObjectName(nom, r1, n1); 986 901 987 if ( fg3d && (nmz.length()>0) ) { // Display 3D 902 988 PINTuple3D* pin = new PINTuple3D(nt, false); … … 904 990 pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str()); 905 991 string titre = nmz + "%" + nmy + "%" + nmz; 906 wrsid = myImgApp->Disp3DDrawer(pin, n om, opt, titre);992 wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre); 907 993 } 908 994 else { … … 912 998 if ( nmz.length()>0 ) pin->SelectWt(nmz.c_str()); 913 999 string titre = nmy + "%" + nmx; 914 wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n om, opt, titre);1000 wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre); 915 1001 } 916 1002 … … 965 1051 if(numvary.length()>0) numvy = atoi(numvary.c_str()); 966 1052 1053 string n1,r1; 1054 ParseObjectName(nom, r1, n1); 1055 967 1056 int wrsid = 0; 968 1057 if(numvy>=0) { // display 3D … … 970 1059 pigfd->SelectXY(numvx,numvy); 971 1060 pigfd->SelectErrBar(errx,erry,errz); 972 wrsid = myImgApp->Disp3DDrawer(pigfd,n om,opt);1061 wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt); 973 1062 } else { // display 2D 974 1063 PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false); 975 1064 pigfd->SelectX(numvx); 976 1065 pigfd->SelectErrBar(errx,erry); 977 wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n om,opt);1066 wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt); 978 1067 } 979 1068 -
trunk/SophyaPI/PIext/nobjmgr.h
r333 r344 32 32 33 33 // 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); 37 40 virtual void GetCurrentDir(string & dirname); 38 41 virtual void ListDirs(string & patt); … … 42 45 43 46 // Pour ajouter, supprimer et acceder aux objets 44 virtual voidAddObj(AnyDataObj* obj, string & nom, bool crd=false);45 virtual voidRenameObj(string & nom, string& nomnew);46 virtual voidDelObj(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); 47 50 virtual void DelObjects(string & patt, bool fgd=true); 48 virtual voidDelObj_Id(int oid);51 virtual bool DelObj_Id(int oid); 49 52 virtual AnyDataObj* GetObj(string & nom); 50 53 virtual void ListObjs(string & patt); -
trunk/SophyaPI/PIext/nomgadapter.cc
r295 r344 70 70 71 71 /* --Methode-- */ 72 NTupleInterface* NObjMgrAdapter::GetNTupleInterface( )72 NTupleInterface* NObjMgrAdapter::GetNTupleInterface(bool& adel) 73 73 { 74 74 string s = typeid(*mObj).name(); 75 75 cout << "NObjMgrAdapter::GetNTupleInterface() - Error : Not supported for " << s << endl; 76 adel = false; 76 77 return(NULL); 77 78 } -
trunk/SophyaPI/PIext/nomgadapter.h
r295 r344 34 34 virtual PIDrawer* GetDrawer(string& dopt); 35 35 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); 37 41 protected: 38 42 AnyDataObj* mObj; -
trunk/SophyaPI/PIext/nomgfdadapter.cc
r339 r344 52 52 53 53 /* --Methode-- */ 54 NTupleInterface* NOMAdapter_GeneralFitData::GetNTupleInterface( )54 NTupleInterface* NOMAdapter_GeneralFitData::GetNTupleInterface(bool& adel) 55 55 { 56 return( new NTupInt_GeneralFitData(mG) ); 56 adel = false; 57 return(mG); 57 58 } 58 59 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() const74 {75 return(mG->NbLines());76 }77 78 /* --Methode-- */79 uint_4 NTupInt_GeneralFitData::NbColumns() const80 {81 return(mG->NbColumns());82 }83 84 /* --Methode-- */85 r_8* NTupInt_GeneralFitData::GetLineD(int n) const86 {87 return(mG->GetLineD(n));88 }89 90 /* --Methode-- */91 string NTupInt_GeneralFitData::VarList_C(const char* nx) const92 {93 return(mG->VarList_C(nx));94 } -
trunk/SophyaPI/PIext/nomgfdadapter.h
r339 r344 24 24 25 25 virtual void Print(ostream& os); 26 virtual NTupleInterface* GetNTupleInterface( );26 virtual NTupleInterface* GetNTupleInterface(bool& adel); 27 27 28 28 protected: … … 30 30 }; 31 31 32 // Class Interface GeneralFitData pour GeneralFitData33 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 };44 32 45 33 #endif -
trunk/SophyaPI/PIext/nomhistadapter.cc
r326 r344 63 63 64 64 /* --Methode-- */ 65 NTupleInterface* NOMAdapter_Histo::GetNTupleInterface() 66 { 65 NTupleInterface* NOMAdapter_Histo::GetNTupleInterface(bool& adel) 66 { 67 adel = true; 67 68 return( new NTupInt_Histo(mHis) ); 68 69 } … … 178 179 179 180 /* --Methode-- */ 180 NTupleInterface* NOMAdapter_Histo2D::GetNTupleInterface() 181 { 181 NTupleInterface* NOMAdapter_Histo2D::GetNTupleInterface(bool& adel) 182 { 183 adel = true; 182 184 return( new NTupInt_Histo2D(mHis) ); 183 185 } … … 289 291 290 292 /* --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 } 293 NTupleInterface* NOMAdapter_NTuple::GetNTupleInterface(bool& adel) 294 { 295 adel = false; 296 return(mNt); 297 // return( new NTupInt_NTuple(mNt) ); 298 } 299 300 -
trunk/SophyaPI/PIext/nomhistadapter.h
r326 r344 30 30 virtual void Print(ostream& os); 31 31 virtual PIDrawer* GetDrawer(string& dopt); 32 virtual NTupleInterface* GetNTupleInterface( );32 virtual NTupleInterface* GetNTupleInterface(bool& adel); 33 33 34 34 protected: … … 68 68 virtual PIDrawer* GetDrawer(string& dopt); 69 69 virtual P2DArrayAdapter* Get2DArray(string& dopt); 70 virtual NTupleInterface* GetNTupleInterface( );70 virtual NTupleInterface* GetNTupleInterface(bool& adel); 71 71 72 72 protected: … … 105 105 106 106 virtual void Print(ostream& os); 107 virtual NTupleInterface* GetNTupleInterface( );107 virtual NTupleInterface* GetNTupleInterface(bool& adel); 108 108 109 109 protected: … … 111 111 }; 112 112 113 // Class Interface NTuple pour NTuple114 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 };125 113 126 114 -
trunk/SophyaPI/PIext/nomimagadapter.cc
r326 r344 69 69 void NOMAdapter_Image<T>::Print(ostream& os) 70 70 { 71 os << (*mImg);71 mImg->Print(os); 72 72 } 73 73 … … 82 82 /* --Methode-- */ 83 83 template <class T> 84 NTupleInterface* NOMAdapter_Image<T>::GetNTupleInterface( )84 NTupleInterface* NOMAdapter_Image<T>::GetNTupleInterface(bool& adel) 85 85 { 86 adel = true; 86 87 return( new NTupInt_Image<T>(mImg) ); 87 88 } -
trunk/SophyaPI/PIext/nomimagadapter.h
r326 r344 30 30 virtual void Print(ostream& os); 31 31 virtual P2DArrayAdapter* Get2DArray(string& dopt); 32 virtual NTupleInterface* GetNTupleInterface( );32 virtual NTupleInterface* GetNTupleInterface(bool& adel); 33 33 34 34 protected: -
trunk/SophyaPI/PIext/nommatvecadapter.cc
r326 r344 61 61 62 62 /* --Methode-- */ 63 NTupleInterface* NOMAdapter_Vector::GetNTupleInterface() 64 { 63 NTupleInterface* NOMAdapter_Vector::GetNTupleInterface(bool& adel) 64 { 65 adel = true; 65 66 return( new NTupInt_Vector(mVec) ); 66 67 } … … 169 170 170 171 /* --Methode-- */ 171 NTupleInterface* NOMAdapter_Matrix::GetNTupleInterface() 172 { 172 NTupleInterface* NOMAdapter_Matrix::GetNTupleInterface(bool& adel) 173 { 174 adel = true; 173 175 return( new NTupInt_Matrix(mMtx) ); 174 176 } -
trunk/SophyaPI/PIext/nommatvecadapter.h
r326 r344 28 28 virtual void Print(ostream& os); 29 29 virtual PIDrawer* GetDrawer(string& dopt); 30 virtual NTupleInterface* GetNTupleInterface( );30 virtual NTupleInterface* GetNTupleInterface(bool& adel); 31 31 32 32 protected: … … 67 67 virtual void Print(ostream& os); 68 68 virtual P2DArrayAdapter* Get2DArray(string& dopt); 69 virtual NTupleInterface* GetNTupleInterface( );69 virtual NTupleInterface* GetNTupleInterface(bool& adel); 70 70 71 71 protected: -
trunk/SophyaPI/PIext/nomstladapter.cc
r326 r344 64 64 65 65 /* --Methode-- */ 66 NTupleInterface* NOMAdapter_StarList::GetNTupleInterface( )66 NTupleInterface* NOMAdapter_StarList::GetNTupleInterface(bool& adel) 67 67 { 68 adel = true; 68 69 return( new NTupInt_StarList(mStl) ); 69 70 } -
trunk/SophyaPI/PIext/nomstladapter.h
r326 r344 28 28 virtual void Print(ostream& os); 29 29 virtual PIDrawer* GetDrawer(string& dopt); 30 virtual NTupleInterface* GetNTupleInterface( );30 virtual NTupleInterface* GetNTupleInterface(bool& adel); 31 31 32 32 protected: -
trunk/SophyaPI/PIext/pintuple.cc
r336 r344 97 97 msz = mMSz; 98 98 if (msz < 1) msz = 1; 99 g->SelMarker( sz, mrk);99 g->SelMarker(msz, mrk); 100 100 101 101 nok = 0; … … 136 136 } 137 137 138 /* --Methode-- */ 139 void PINTuple::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax) 140 { 141 if (!mNT) return; 142 if ( (xK < 0) || (yK < 0) ) return; 143 144 int ncnt = 0; 145 double xp,yp; 146 char buff[128]; 147 sprintf(buff,"PINTuple: NLines= %d NCol= %d \n", mNT->NbLines(), mNT->NbColumns()); 148 info += buff; 149 info += mNT->LineHeaderToString(); 150 for (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 } 158 if (ncnt >= 101) info += " .... \n"; 159 sprintf(buff," %d points inside selected region \n", ncnt); 160 info += buff; 161 // printf("PINTuple::AppendTextInfo()-DBG %g %g %g %g - %d\n", xmin, ymin, xmax, ymax, ncnt); 162 return; 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 1 5 #ifndef PINTUPLE_H 2 6 #define PINTUPLE_H … … 13 17 virtual void UpdateLimits(); 14 18 15 16 17 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); 18 22 23 virtual void AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax); 19 24 20 25 protected: -
trunk/SophyaPI/PIext/pistdimgapp.cc
r338 r344 655 655 if (w == NULL) return; 656 656 w->Hide(); 657 bool ownwindow=false; // To Check if this is one of our windows 657 658 WindMList::iterator it; 658 659 for(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; } 660 661 if (w == mGrW) { mGrW = NULL; mGrIdx = -1; } 661 662 if (w == mStW) { mStW = NULL; mStIdx = -1; m[2]->SetSensitivity("StackTools", false); } 662 663 if (w == mCurWin) mCurWin = NULL; 664 665 if (!ownwindow) return; // We do nothing if this is not a window we have created ... 666 663 667 int k; 664 668 PIWdg* cwd; -
trunk/SophyaPI/PIext/pistlist.cc
r205 r344 101 101 } 102 102 103 /* --Methode-- */ 104 void PIStarList::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax) 105 { 106 BStar *sti; 107 double xp,yp; 108 double flx,fnd; 109 char buff[128]; 110 int ncnt = 0; 111 sprintf(buff,"PIStarList: NStars \n", mStL->NbStars() ); 112 info += buff; 113 info += " Num: XPos YPos Flux Fond \n"; 114 for (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 } 127 if (ncnt >= 101) info += " .... \n"; 128 sprintf(buff," %d stars inside selected region \n", ncnt); 129 info += buff; 130 return; 131 } -
trunk/SophyaPI/PIext/pistlist.h
r205 r344 13 13 virtual void UpdateLimits(); 14 14 15 virtual void AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax); 16 15 17 void SetFluxLimits(float min=1., float max=-1., int nl=5, bool dispflx=false, bool refr=false); 16 18 -
trunk/SophyaPI/PIext/servnobjm.cc
r341 r344 200 200 201 201 if (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); 204 210 vya->DefineXCoordinate(xmin, (xmax-xmin)/np); 205 211 PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ; … … 256 262 257 263 if (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; 259 270 bool fgsr = true; 260 271 int opt = DecodeDispOption(dopt, fgsr); 261 P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true);272 P2DArrayAdapter* arr = new POMatrixAdapter(mtx, false); 262 273 arr->DefineXYCoordinates(xmin, ymin, dx, dy); 263 274 PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true); … … 636 647 /* --Methode-- */ 637 648 void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname, 638 string const & funcname, string & nomnt) 649 string const & funcname, string & nomnt, 650 int nl1, int nl2) 639 651 { 640 652 if (!mImgapp) return; … … 646 658 return; 647 659 } 648 NTupleInterface* objnt = obja->GetNTupleInterface(); 660 bool adel = true; 661 NTupleInterface* objnt = obja->GetNTupleInterface(adel); 649 662 if (objnt == NULL) { 650 663 cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No NTupleInterface !" <<endl; … … 655 668 if (!f) { 656 669 cerr << "Services2NObjMgr::FillNTFrCFile Error Creation NTLoopExprFunc" << endl; 670 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire 657 671 return; 658 672 } … … 691 705 TRY { 692 706 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++) { 695 712 xn = objnt->GetLineD(k); 696 713 if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) { … … 709 726 cerr << "Services2NObjMgr::FillNTFrCFile() Exception :" << merr << es; 710 727 } ENDTRY; 711 728 729 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire 712 730 CloseDLL(); 713 731 … … 729 747 return; 730 748 } 731 NTupleInterface* objnt = obja->GetNTupleInterface(); 749 bool adel = true; 750 NTupleInterface* objnt = obja->GetNTupleInterface(adel); 732 751 if (objnt == NULL) { 733 752 cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom … … 740 759 if ((fip = fopen(fname.c_str(), "w")) == NULL) { 741 760 cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl; 761 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire 742 762 return; 743 763 } 764 744 765 // constitution du fichier des decalarations des variables de l'interface NTuple 745 766 fputs("#include <stdlib.h> \n", fip); 746 767 fputs("#include <stdio.h> \n", fip); 747 768 fputs("#include <math.h> \n\n", fip); 769 770 fputs("/* ------ Some random number generators --------- */ \n", fip); 771 fputs("#define frand01() ( (float) drand48() ) \n", fip); 772 fputs("#define drand01() drand48() \n", fip); 773 fputs("#define rand01() drand48() \n", fip); 774 fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip); 775 fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip); 776 fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip); 777 fputs("double NorRand(void) \n", fip); 778 fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip); 779 fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip); 780 fputs(" x = sqrt(-2.*log(A))*cos(M_2PI*B); \n", fip); 781 fputs(" return(x); \n } \n", fip); 782 fputs("#define GauRand() NorRand() \n", fip); 783 fputs("#define gaurand() NorRand() \n\n", fip); 784 748 785 fputs("/* NTupleInterface Variable declaration - Generated by piapp \n", fip); 749 786 fputs(" -- Services2NObjMgr::PrepareNTExpressionCFile() -- */ \n\n", fip); … … 759 796 760 797 fclose(fip); 798 799 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire 761 800 return; 762 801 } … … 1304 1343 { 1305 1344 if (obja == NULL) return; 1306 NTupleInterface* objnt = obja->GetNTupleInterface(); 1345 bool adel = true; 1346 NTupleInterface* objnt = obja->GetNTupleInterface(adel); 1307 1347 if (objnt == NULL) return; 1308 1348 string vardec = objnt->VarList_C("_zz6qi_"); … … 1311 1351 if (!f) { 1312 1352 cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " << endl; 1353 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire 1313 1354 return; 1314 1355 } … … 1344 1385 1345 1386 1387 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire 1346 1388 // Fermeture du fichier .so 1347 1389 CloseDLL(); … … 1372 1414 fputs("#include <stdlib.h> \n", fip); 1373 1415 fputs("#include <math.h> \n", fip); 1416 1417 fputs("/* ------ Some random number generators --------- */ \n", fip); 1418 fputs("#define frand01() ( (float) drand48() ) \n", fip); 1419 fputs("#define drand01() drand48() \n", fip); 1420 fputs("#define rand01() drand48() \n", fip); 1421 fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip); 1422 fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip); 1423 fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip); 1424 fputs("double NorRand(void) \n", fip); 1425 fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip); 1426 fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip); 1427 fputs(" x = sqrt(-2.*log(A))*cos(M_2PI*B); \n", fip); 1428 fputs(" return(x); \n } \n", fip); 1429 fputs("#define GauRand() NorRand() \n", fip); 1430 fputs("#define gaurand() NorRand() \n\n", fip); 1431 1374 1432 fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip); 1375 1433 fprintf(fip,"%s \n", vardec.c_str()); -
trunk/SophyaPI/PIext/servnobjm.h
r333 r344 79 79 string& experr, string& expcut, string& nomgfd); 80 80 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); 82 83 virtual void PrepareNTExpressionCFile(string & nomobj, string const & fname, 83 84 string const & funcname);
Note:
See TracChangeset
for help on using the changeset viewer.