Changeset 295 in Sophya for trunk/SophyaPI/PIext/nobjmgr.cc
- Timestamp:
- May 13, 1999, 12:12:51 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/nobjmgr.cc
r293 r295 3 3 #include <ctype.h> 4 4 5 #include <typeinfo> 5 6 #include <iostream.h> 6 7 #include <string> … … 20 21 #include "pistdimgapp.h" 21 22 22 #include "pclassids.h"23 #include "poly.h"24 #include "dvlist.h"25 23 #include "matrix.h" 26 24 #include "cvector.h" … … 29 27 #ifdef SANS_EVOLPLANCK 30 28 #include "fitsimage.h" 31 #include "zfidu.h"32 29 #endif 33 30 … … 35 32 #include "fct2dfit.h" 36 33 37 #include "pi mgadapter.h"34 #include "pisurfdr.h" 38 35 #include "pipodrw.h" 39 40 36 #include "pihisto.h" 41 37 #include "hisprof.h" 42 38 #include "pihisto2d.h" 43 39 #include "pintuple.h" 44 #include "pisurfdr.h"45 40 #include "pintup3d.h" 46 41 #include "pigfd1.h" 47 42 #include "pigfd2.h" 48 43 49 // Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...50 #ifdef SANS_EVOLPLANCK51 #include "pistlist.h"52 #include "transfo.h"53 #endif54 44 55 45 //++ … … 74 64 // ...... Gestion des objets nommes, variables globales ............ 75 65 struct nobj_item { 76 PPersist* obj; 66 AnyDataObj* obj; 67 NObjMgrAdapter* obja; 77 68 int num; 78 69 list<int> wrsid; … … 162 153 //-- 163 154 //++ 164 // void AddObj( PPersist* obj, string& nom)155 // void AddObj(AnyDataObj* obj, string& nom) 165 156 // Ajoute l'objet "obj" à la liste, identifié par "nom". 166 157 // Si un objet de même nom existe, l'ancien objet est renommé en concaténant … … 171 162 // Supprime l'ensemble des objets dont le nom correspond au patron "patt". 172 163 // 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) 174 165 // Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est 175 166 // pas dans la liste. … … 182 173 183 174 /* --Methode-- */ 184 void NamedObjMgr::AddObj( PPersist* obj, string& nom)175 void NamedObjMgr::AddObj(AnyDataObj* obj, string& nom, bool) 185 176 { 186 177 … … 198 189 199 190 myNObj++; 200 if (nom.length() < 1) nom = servnobjm->PClassIdToShortClassName(obj->ClassId());191 if (nom.length() < 1) nom = typeid(*obj).name(); 201 192 NObjList::iterator it = myObjs->find(nom); 202 193 if (it != myObjs->end()) { // l'objet existe deja … … 210 201 nobj_item no; 211 202 no.obj = obj; 203 no.obja = servnobjm->GetAdapter(obj); // L'adaptateur 212 204 no.num = myNObj; 213 205 (*myObjs)[(*lastobj)] = no; 214 206 if (myImgApp) { 215 string str = (*lastobj) + " (T= " + servnobjm->PClassIdToClassName(obj->ClassId()) + ")" ;207 string str = (*lastobj) + " (T= " + typeid(*obj).name() + ")" ; 216 208 (myImgApp->ObjMgrW())->AddObj(str.c_str(), myNObj+1000); 217 209 } 218 210 219 211 cout << "NamedObjMgr::AddObj() Object " << (*lastobj) << " ( " 220 << servnobjm->PClassIdToClassName(obj->ClassId()) << " ) added (Total= " << myObjs->size() << ")" << endl;212 << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl; 221 213 return; 222 214 } … … 234 226 (myImgApp->ObjMgrW())->DelObj((*it).second.num+1000); 235 227 } 228 delete (*it).second.obj; // destruction de l'adaptateur 236 229 if (fgd) delete (*it).second.obj; 237 230 myObjs->erase(it); … … 256 249 257 250 /* --Methode-- */ 258 PPersist* NamedObjMgr::GetObj(string const& nom)251 AnyDataObj* NamedObjMgr::GetObj(string const& nom) 259 252 { 260 253 NObjList::iterator it = myObjs->find(nom); … … 264 257 265 258 /* --Methode-- */ 259 NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string const& nom) 260 { 261 NObjList::iterator it = myObjs->find(nom); 262 if (it == myObjs->end()) return(NULL); 263 return((*it).second.obja); 264 } 265 266 /* --Methode-- */ 266 267 void NamedObjMgr::RenameObj(string const& nom, string& nomnew) 267 268 { 268 PPersist* obj = GetObj(nom);269 AnyDataObj* obj = GetObj(nom); 269 270 if (obj == NULL) return; 270 271 DelObj(nom, false); … … 309 310 if (!ok) return; 310 311 if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm); 311 AddObj(obj , nobj);312 AddObj(obj->DataObj(), nobj); 312 313 return; 313 314 } … … 336 337 if (!ok) return; 337 338 nom = ""; 338 AddObj(obj , nom);339 AddObj(obj->DataObj(), nom); 339 340 } 340 341 … … 353 354 ok = false; 354 355 } ENDTRY; 355 if (ok) AddObj(obj , nom);356 if (ok) AddObj(obj->DataObj(), nom); 356 357 } 357 358 … … 376 377 if (obj) { 377 378 string nom = servnobjm->FileName2Name(flnm); 378 AddObj(obj , nom);379 AddObj(obj->DataObj(), nom); 379 380 } 380 381 else ReadObj((*ppin), -1); … … 404 405 if (ok) { 405 406 if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm); 406 AddObj(( PPersist*)obj, nobj);407 AddObj((AnyDataObj*)obj, nobj); 407 408 } 408 409 return; … … 414 415 void NamedObjMgr::SaveObj(string const& nom, POutPersist& s) 415 416 { 416 PPersist* obj=NULL;417 obj = GetObj(nom);418 if (obj == NULL) return;417 NObjMgrAdapter* obja=NULL; 418 obja = GetObjAdapter(nom); 419 if (obja == NULL) return; 419 420 printf("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()); 422 obja->SavePPF(s, nom); 424 423 return; 425 424 } … … 446 445 void NamedObjMgr::SaveFits(string const& nom, string const & flnm) 447 446 { 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 447 NObjMgrAdapter* obja=NULL; 448 obja = GetObjAdapter(nom); 449 if (obja == NULL) return; 450 obja->SaveFits(flnm); 503 451 return; 504 452 } … … 509 457 { 510 458 int k; 511 PPersist* obj=NULL;459 AnyDataObj* obj=NULL; 512 460 string ctyp; 513 461 char strg[256]; 514 int cid;515 462 516 463 cout << "NamedObjMgr::ListObjs() NObjs= " << myObjs->size() << "\n" ; … … 519 466 obj = (*it).second.obj; 520 467 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()); 524 470 ctyp = strg; 525 471 cout << ctyp << "\n" ; … … 533 479 void NamedObjMgr::PrintObj(string const& nom) 534 480 { 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; 481 NObjMgrAdapter* obja=NULL; 482 obja = GetObjAdapter(nom); 483 if (obja == NULL) return; 484 485 string ctyp = typeid(*obja->GetDataObj()).name(); 486 cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl; 487 obja->Print(cout); 488 629 489 return; 630 490 } … … 633 493 void NamedObjMgr::DisplayObj(string const& nom, string dopt) 634 494 { 635 PPersist* obj=GetObj(nom); 636 if (obj == NULL) { 495 NObjMgrAdapter* obja=NULL; 496 obja = GetObjAdapter(nom); 497 if (obja == NULL) { 637 498 cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl; 638 499 return; … … 640 501 if (!myImgApp) return; 641 502 642 int cid = obj->ClassId(); 643 string ctyp = servnobjm->PClassIdToClassName(cid); 503 PIDrawer * dr = NULL; 504 P2DArrayAdapter* arr = NULL; 505 dr = obja->GetDrawer(dopt); 506 if (!dr) arr = obja->Get2DArray(dopt); 507 508 if (!dr && !arr) { 509 string ctyp = typeid(*(obja->GetDataObj())).name(); 510 cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 511 return; 512 } 644 513 645 514 int wrsid = 0; 646 515 bool fgsr = true; 647 // On veut tracer une ligne pour vecteur et histo1D par defaut648 if ( (cid == ClassId_Vector) || (cid == ClassId_Histo1D) ) dopt = "thinline," + dopt;649 else if(cid == ClassId_HProf) dopt = "fcirclemarker5," + dopt;650 516 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 651 517 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 } 518 if (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 } 523 else if (arr) wrsid = myImgApp->DispImage(arr, nom, opt); 767 524 768 525 if(wrsid != 0) { … … 775 532 } 776 533 534 /* --Methode-- */ 535 void NamedObjMgr::DisplayImage(string const& nom, string dopt) 536 { 537 NObjMgrAdapter* obja=NULL; 538 obja = GetObjAdapter(nom); 539 if (obja == NULL) { 540 cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl; 541 return; 542 } 543 if (!myImgApp) return; 544 545 P2DArrayAdapter* arr = obja->Get2DArray(dopt); 546 547 if (!arr) { 548 string ctyp = typeid(*(obja->GetDataObj())).name(); 549 cout << "NamedObjMgr::DisplayImage() Error , Non supporte pour " << ctyp << endl; 550 return; 551 } 552 553 int wrsid = 0; 554 bool fgsr = true; 555 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 556 wrsid = myImgApp->DispImage(arr, nom, opt); 557 558 if(wrsid != 0) { 559 NObjList::iterator it = myObjs->find(nom); 560 if (it == myObjs->end()) return; 561 (*it).second.wrsid.push_back(wrsid); 562 } 563 if (fgsr) myImgApp->RestoreGraphicAtt(); 564 return; 565 } 566 /* --Methode-- */ 567 void NamedObjMgr::DisplaySurf3D(string const& nom, string dopt) 568 { 569 NObjMgrAdapter* obja=NULL; 570 obja = GetObjAdapter(nom); 571 if (obja == NULL) { 572 cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl; 573 return; 574 } 575 if (!myImgApp) return; 576 577 P2DArrayAdapter* arr = obja->Get2DArray(dopt); 578 579 if (!arr) { 580 string ctyp = typeid(*(obja->GetDataObj())).name(); 581 cout << "NamedObjMgr::DisplaySurf3D() Error , Non supporte pour " << ctyp << endl; 582 return; 583 } 584 585 if ((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 592 int wrsid = 0; 593 bool fgsr = true; 594 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 595 PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true); 596 wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt); 597 if(wrsid >= 0) { 598 NObjList::iterator it = myObjs->find(nom); 599 if (it == myObjs->end()) return; 600 (*it).second.wrsid.push_back(wrsid); 601 } 602 603 if (fgsr) myImgApp->RestoreGraphicAtt(); 604 return; 605 } 777 606 778 607 /* --Methode-- */ … … 780 609 string& erx, string& ery, string& erz, string dopt) 781 610 { 782 PPersist* obj=GetObj(nom);611 AnyDataObj* obj=GetObj(nom); 783 612 if (obj == NULL) { 784 613 cout << "NamedObjMgr::DisplayNT() Error , Pas d'objet de nom " << nom << endl; … … 787 616 if (!myImgApp) return; 788 617 789 int cid = obj->ClassId(); 790 if (cid != ClassId_NTuple) { 791 string ctyp = servnobjm->PClassIdToClassName(cid); 618 if (typeid(*obj) != typeid(NTuple)) { 619 string ctyp = typeid(*obj).name(); 792 620 cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl; 793 621 return; … … 837 665 //| opt = options generales pour le display. 838 666 { 839 PPersist* obj=GetObj(nom);667 AnyDataObj* obj=GetObj(nom); 840 668 if(obj == NULL) 841 669 {cout << "NamedObjMgr::DisplayGFD() Error , Pas d'objet de nom " << nom << endl; 842 670 return;} 843 671 if(!myImgApp) return; 844 int cid = obj->ClassId(); 845 if(cid != ClassId_GeneralFitData) 846 {string ctyp = servnobjm->PClassIdToClassName(cid); 672 if(typeid(*obj) != typeid(GeneralFitData)) 673 {string ctyp = typeid(*obj).name(); 847 674 cout<<"NamedObjMgr::DisplayGFD() Error , Objet n'est pas un GeneralFitData "<<ctyp<<endl; 848 675 return;} … … 894 721 895 722 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 }965 723 966 724 … … 984 742 string& expcut, string dopt) 985 743 { 986 PPersist* obj=GetObj(nom); 987 if (obj == NULL) { 744 NObjMgrAdapter* obja=NULL; 745 obja = GetObjAdapter(nom); 746 if (obja == NULL) { 988 747 cout << "NamedObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl; 989 748 return; 990 }749 } 991 750 if (!myImgApp) return; 992 751 … … 999 758 else { haserr = false; experrx = experry = "0."; nt = new NTuple(2, ntn); } 1000 759 1001 servnobjm->Nobj_ComputeExpressions(obj , expx, expy, experrx, experry, expcut, nt, NULL, NULL);760 servnobjm->Nobj_ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL); 1002 761 1003 762 if (nt->NEntry() < 1) { … … 1025 784 string& expcut, string dopt) 1026 785 { 1027 PPersist* obj=GetObj(nom); 1028 if (obj == NULL) { 786 NObjMgrAdapter* obja=NULL; 787 obja = GetObjAdapter(nom); 788 if (obja == NULL) { 1029 789 cout << "NamedObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl; 1030 790 return; … … 1036 796 1037 797 string expwt = "1."; 1038 servnobjm->Nobj_ComputeExpressions(obj , expx, expy, expz, expwt, expcut, nt, NULL, NULL);798 servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL); 1039 799 1040 800 if (nt->NEntry() < 1) { … … 1064 824 void NamedObjMgr::ProjectH1(string const& nom, string& expx, string& expwt, string& expcut, string& nomh1, string dopt) 1065 825 { 1066 PPersist* obj=GetObj(nom);1067 1068 if (obj == NULL) {826 NObjMgrAdapter* obja=NULL; 827 obja = GetObjAdapter(nom); 828 if (obja == NULL) { 1069 829 cout << "NamedObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl; 1070 830 return; … … 1074 834 Histo* h1 = NULL; 1075 835 NTuple* nt = NULL; 1076 PPersist* oh = NULL;836 AnyDataObj* oh = NULL; 1077 837 if (nomh1.length() > 0) oh=GetObj(nomh1); 1078 838 else nomh1 = "H1Proj"; 1079 if ( (oh != NULL) && ( oh->ClassId() == ClassId_Histo1D) ) h1 = (Histo*)oh; // Pas de remise a zero ! h1->Zero();839 if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) ) h1 = (Histo*)oh; // Pas de remise a zero ! h1->Zero(); 1080 840 else { 1081 841 char* ntn[2]= {"hxval", "hwt"}; … … 1083 843 } 1084 844 string expz = "0."; 1085 servnobjm->Nobj_ComputeExpressions(obj , expx, expwt, expz, expwt, expcut, nt, h1, NULL);845 servnobjm->Nobj_ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL); 1086 846 1087 847 if ((!h1) && (!nt)) return; … … 1113 873 string& nomh2, string dopt) 1114 874 { 1115 PPersist* obj=GetObj(nom);1116 1117 if (obj == NULL) {875 NObjMgrAdapter* obja=NULL; 876 obja = GetObjAdapter(nom); 877 if (obja == NULL) { 1118 878 cout << "NamedObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl; 1119 879 return; … … 1123 883 Histo2D* h2 = NULL; 1124 884 NTuple* nt = NULL; 1125 PPersist* oh = NULL;885 AnyDataObj* oh = NULL; 1126 886 if (nomh2.length() > 0) oh=GetObj(nomh2); 1127 887 else nomh2 = "H2Proj"; 1128 if ( (oh != NULL) && ( oh->ClassId() == ClassId_Histo2D) ) h2 = (Histo2D*)oh; // Pas de remise a zero ! h2->Zero();888 if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) ) h2 = (Histo2D*)oh; // Pas de remise a zero ! h2->Zero(); 1129 889 else { 1130 890 char* ntn[3]= {"hxval", "hyval", "hwt"}; … … 1132 892 } 1133 893 string expz = "0."; 1134 servnobjm->Nobj_ComputeExpressions(obj , expx, expy, expwt, expwt, expcut, nt, NULL, h2);894 servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2); 1135 895 1136 896 if ((!h2) && (!nt)) return; … … 1174 934 //| opt = options generales pour le display. 1175 935 { 1176 PPersist* obj=GetObj(nom);1177 1178 if (obj == NULL) {936 NObjMgrAdapter* obja=NULL; 937 obja = GetObjAdapter(nom); 938 if (obja == NULL) { 1179 939 cout << "NamedObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl; 1180 940 return; … … 1184 944 HProf* hprof = NULL; 1185 945 NTuple* nt = NULL; 1186 PPersist* oh = NULL;946 AnyDataObj* oh = NULL; 1187 947 if (nomprof.length() > 0) oh=GetObj(nomprof); 1188 948 else nomprof = "ProfProj"; 1189 if( (oh!=NULL) && ( oh->ClassId()== ClassId_HProf) ) hprof = (HProf*)oh;949 if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) ) hprof = (HProf*)oh; 1190 950 else { 1191 951 char* ntn[3]= {"hxval", "hyval", "hwt"}; … … 1193 953 } 1194 954 string expz = "0."; 1195 servnobjm->Nobj_ComputeExpressions(obj , expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);955 servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof); 1196 956 1197 957 if((!hprof) && (!nt)) return; … … 1223 983 void NamedObjMgr::FillVect(string const& nom, string& expx, string& expcut, string& nomvec, string dopt) 1224 984 { 1225 PPersist* obj=GetObj(nom);1226 1227 if (obj == NULL) {985 NObjMgrAdapter* obja=NULL; 986 obja = GetObjAdapter(nom); 987 if (obja == NULL) { 1228 988 cout << "NamedObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl; 1229 989 return; … … 1239 999 string expwt = "1."; 1240 1000 string expz = "0."; 1241 servnobjm->Nobj_ComputeExpressions(obj , expx, expz, expz, expwt, expcut, nt, NULL, NULL);1001 servnobjm->Nobj_ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL); 1242 1002 1243 1003 if (!nt) return; … … 1265 1025 string& expcut, string& nomnt) 1266 1026 { 1267 PPersist* obj=GetObj(nom);1268 1269 if (obj == NULL) {1027 NObjMgrAdapter* obja=NULL; 1028 obja = GetObjAdapter(nom); 1029 if (obja == NULL) { 1270 1030 cout << "NamedObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl; 1271 1031 return; … … 1275 1035 bool fgnnt = false; 1276 1036 NTuple* nt = NULL; 1277 PPersist* oh = NULL;1037 AnyDataObj* oh = NULL; 1278 1038 if (nomnt.length() > 0) oh=GetObj(nomnt); 1279 1039 else nomnt = "NTFill"; 1280 if ( (oh != NULL) && ( oh->ClassId() == ClassId_NTuple) ) {1040 if ( (oh != NULL) && (typeid(*oh) == typeid(HProf)) ) { 1281 1041 nt = (NTuple*)oh; 1282 1042 if (nt->NVar() > 10) { … … 1291 1051 } 1292 1052 1293 servnobjm->Nobj_ComputeExpressions(obj , expx, expy, expz, expt, expcut, nt, NULL, NULL);1053 servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL); 1294 1054 1295 1055 if (fgnnt) AddObj(nt, nomnt); … … 1311 1071 //| nomgfd = nom du GeneralFitData engendre (optionnel) 1312 1072 { 1313 PPersist* obj=GetObj(nom); 1314 if(obj == NULL) 1315 {cout<<"NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl; 1316 return;} 1073 NObjMgrAdapter* obja=NULL; 1074 obja = GetObjAdapter(nom); 1075 if (obja == NULL) { 1076 cout << "NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl; 1077 return; 1078 } 1317 1079 if(!myImgApp) return; 1318 1080 … … 1321 1083 if(expy.length()<=0) {nvar = 1; expy = "0.";} 1322 1084 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 1373 1087 1374 1088 // Creation NTuple Buffer … … 1377 1091 1378 1092 // Remplissage NTuple buffer 1379 servnobjm->Nobj_ComputeExpressions(obj , expx, expy, expz, experr, expcut, nt, NULL, NULL);1093 servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL); 1380 1094 if(nt->NEntry() < 1) 1381 1095 {cout<<"NamedObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl; … … 1383 1097 1384 1098 //Remplissage de la structure GeneraFitData 1385 GeneralFitData* gfd = new GeneralFitData(nvar,ndata,0); 1099 if (nt->NEntry() <= 0) { 1100 cout<<"NamedObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl; 1101 delete nt; 1102 return; 1103 } 1104 1105 GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0); 1386 1106 int k; 1387 1107 float* xn; … … 1724 1444 //|2D yaa.b et y = idem "xaa.b et x" mais pour y 1725 1445 { 1726 PPersist* obj=GetObj(nom);1446 AnyDataObj* obj=GetObj(nom); 1727 1447 if (obj == NULL) { 1728 1448 cout<<"NamedObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl; … … 1733 1453 {cout<<"NamedObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl; 1734 1454 return;} 1735 int cid = obj->ClassId(); 1736 string ctyp = servnobjm->PClassIdToClassName(cid); 1455 string ctyp = typeid(*obj).name(); 1737 1456 1738 1457 int ndim = 0, nbinx=0, nbiny=0, ndata = 0; … … 1740 1459 Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL; 1741 1460 GeneralFitData* g = NULL; 1742 switch (cid) { 1461 1743 1462 // 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 } 1463 if (typeid(*obj) == typeid(Vector)) { 1464 ndim = 1; 1465 v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1; 1466 } 1467 else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) { 1468 ndim = 1; 1469 h = (Histo*) obj; nbinx = h->NBins(); nbiny = 1; 1470 } 1471 else if (typeid(*obj) == typeid(Matrix)) { 1472 ndim = 2; 1473 m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows(); 1474 } 1475 else if (typeid(*obj) == typeid(Histo2D)) { 1476 ndim = 2; 1477 h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY(); 1478 } 1479 else 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 } 1487 else if (dynamic_cast<RzImage*>(obj)) { 1488 ndim = 2; 1489 im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize(); 1490 } 1491 else { 1492 cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un " 1493 <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl; 1494 return; 1495 } 1496 1787 1497 ndata = nbinx*nbiny; 1788 1498 if(ndata<=0)
Note:
See TracChangeset
for help on using the changeset viewer.