Changeset 2250 in Sophya for trunk/SophyaPI/PIGcont


Ignore:
Timestamp:
Nov 7, 2002, 11:12:39 AM (23 years ago)
Author:
perderos
Message:

Modifs pour decoder les options de contour/ntcont passees
en ligne + qqes petites modifs ds la fenetre des tools

O Perdereau LAL-Orsay
07/11/2002

Location:
trunk/SophyaPI/PIGcont
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIGcont/picntools.cc

    r1919 r2250  
    7070}
    7171
     72
    7273/* --Methode-- */
    7374void PICnTools::HidePICnTools()
     
    130131bsy = 0.85*bsy;   spy = 0.85*spy;
    131132
    132 mLab[0] = new PILabel(this, " Couleurs des  contours ", 2*bsx, 1.25*bsy, cpx, cpy);
     133mLab[0] = new PILabel(this, " Couleurs ", 2*bsx, 1.25*bsy, cpx, cpy);
    133134mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    134135
     
    199200
    200201
    201 
    202202cpx = 2*spx; // current position
    203203cpy += spy+bsy;
     
    274274cpx = 2*spx;
    275275cpy += spy+bsy;
    276 mLab[1] = new PILabel(this, " Label des  contours ", 2*bsx, 1.25*bsy, cpx, cpy);
     276mLab[1] = new PILabel(this, " Labels ", 2*bsx, 1.25*bsy, cpx, cpy);
    277277mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    278278cpx += spx+2*bsx;
     
    334334cpx = 2*spx;
    335335cpy += spy+bsyo;
    336 mLab[2] = new PILabel(this, " Options de calcul des contours ", 3*bsx, bsy, cpx, cpy);
     336mLab[2] = new PILabel(this, " params du calcul ", 3*bsx, bsy, cpx, cpy);
    337337mLab[2]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
    338338
     
    357357cpx = 2*spx;
    358358
    359 mLab[3] = new PILabel(this, "# Contours", bsx, bsy, cpx, cpy);
     359mLab[3] = new PILabel(this, "Nombre", bsx, bsy, cpx, cpy);
    360360mLab[3]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
    361361cpx += spx+bsx;
     
    484484mCkb[1]->SetState(mCurCDrw->IsMarkOn());
    485485mCkb[2]->SetState(mCurCDrw->IsLabelOn());
    486 
     486if(mCkb[2]->GetState()==false){
     487  mOpt[4]->SetUnSensitive();
     488  mOpt[6]->SetUnSensitive();
     489  mOpt[7]->SetUnSensitive();
     490}else {
     491  mOpt[4]->SetSensitive();
     492  mOpt[6]->SetSensitive();
     493  mOpt[7]->SetSensitive();
     494}
     495
     496
     497if(mCkb[1]->GetState()==false) {
     498  mOpt[3]->SetUnSensitive();
     499  mOpt[2]->SetUnSensitive();
     500}else{
     501  mOpt[3]->SetSensitive();
     502  mOpt[2]->SetSensitive();
     503}
     504
     505
     506if(mCkb[0]->GetState()==false)
     507  mOpt[5]->SetUnSensitive();
     508else
     509  mOpt[5]->SetSensitive();
    487510
    488511int ii,jj,kk;
    489512PIColors fc = dr->GetGraphicAtt().GetFgColor();
    490513for(kk=0; kk<MYNMXCOLORS; kk++)
    491   if (fc == cols[kk])  { mOpt[0]->SetValue(100+kk);  break; }   
     514  if (fc == cols[kk]) 
     515    { mOpt[0]->SetValue(100+kk);  break; }   
     516
     517
    492518CMapId cmi = dr->GetGraphicAtt().GetColMapId();
    493 if (cmi == CMAP_OTHER)  mOpt[1]->SetValue(200);
    494 else for(kk=0; kk<PIColorMap::NumberStandardColorMaps(); kk++)
    495   if (cmi == PIColorMap::GetStandardColorMapId(kk)) { mOpt[1]->SetValue(201+kk);  break; } 
     519double zmin=0;
     520double zmax=1.;
     521if(mCurCDrw!=NULL){
     522   zmin = mCurCDrw->Zmin();
     523    zmax = mCurCDrw->Zmax();
     524}
     525
     526if (cmi == CMAP_OTHER)  {
     527  mOpt[1]->SetValue(200);
     528  mCurCDrw->GetGraphicAtt().SetColMapId(CMAP_OTHER);
     529  cmapv->SetColMapId(CMAP_OTHER,false, zmin , zmax,true);
     530}else for(kk=0; kk<PIColorMap::NumberStandardColorMaps(); kk++)
     531  if (cmi == PIColorMap::GetStandardColorMapId(kk)) {
     532    mOpt[1]->SetValue(201+kk);
     533    cmapv->SetColMapId(PIColorMap::GetStandardColorMapId(kk),false, zmin , zmax,true);
     534    break;
     535  }
     536 
    496537PIMarker mk = dr->GetGraphicAtt().GetMarker();   
    497538for(kk=0; kk<12; kk++)
     
    682723  if (k == 0){
    683724    mCurCDrw->GetGraphicAtt().SetColMapId(CMAP_OTHER);
    684    
     725    cmapv->SetColMapId(CMAP_OTHER,false, zmin , zmax,true);
     726
    685727  }else{
    686728    mCurCDrw->GetGraphicAtt().SetColMapId(PIColorMap::GetStandardColorMapId(k-1));
     
    729771    if (k == 0){
    730772      cmapv->SetColMapId(CMAP_OTHER,false, zmin , zmax,true);
     773     
    731774    }else{
     775     
    732776      cmapv->SetColMapId(PIColorMap::GetStandardColorMapId(k-1),false , zmin , zmax,true);
    733777    }
     
    738782      if(mCkb[0]->GetState()==false)
    739783        mOpt[5]->SetUnSensitive();
    740       else
     784      else 
    741785        mOpt[5]->SetSensitive();
    742786
  • trunk/SophyaPI/PIGcont/pigncont.cc

    r1919 r2250  
    565565  for(int i=0 ; i<k ; i++)My_Levels[i] = ptr[i];
    566566}
     567//++
     568// void SetMyLevels(vector<double>vec)
     569//      Setting du tableau des niveaux des contours
     570//Inputs     
     571//|
     572//| vector <double> vec  : vecteur des niveaux
     573//--
     574void
     575GNUPlotContour::SetMyLevels(vector <double> vec){
     576 
     577  if(My_Levels!=NULL) delete My_Levels;
     578  int sz = vec.size();
     579  assert (sz>0);
     580
     581  My_Levels = new double[sz];
     582  for(int i=0 ; i<sz ; i++)
     583    My_Levels[i] = vec[i];
     584}
    567585
    568586//++
     
    639657    if(_nti!=NULL){delete _nti ; _nti=NULL;}
    640658  }
     659  DeactivateControlWindow(NULL);
    641660  //if (mColorMap!=NULL){delete  mColorMap;  mColorMap=NULL;}
    642661}
     
    762781}
    763782
     783//++
     784void PIContourDrawer::DeactivateControlWindow(PIBaseWdgGen* wdg)
     785//
     786//      Desactivation de la fenetre de controle specialisee
     787//--
     788{
     789  // si wdg != NULL, c'est un Detach (Drawer detache du PIBaseWdg
     790  // si wdg == NULL, c'est un delete du PIHisto2D (du PIDrawer)
     791 
     792  PICnTools::SetCurrentBaseWdg(NULL);
     793  PICnTools::SetCurrentCnDrw(NULL);
     794  PICnTools::HidePICnTools();
     795
     796  return;
     797}
     798
    764799
    765800/* --Methode-- */
     
    793828  mLabelOn = false;
    794829}
    795  
    796 
    797 
     830
     831int PIContourDrawer::DecodeOptionString(vector<string> & opt, bool rmdecopt)
     832{
     833  // inspire de int PINTuple::DecodeOptionString
     834  // OP 11/2002 LAL Orsay
     835 
     836  int ndec = opt.size();
     837  if (ndec < 1)  return(0); 
     838
     839
     840  cout << " PIDrawer::DecodeOptionString  : ndec = "<< ndec <<endl;
     841  // On appelle d'abord le decodage de la classe PIDrawer de laquelle
     842  // on herite. (Pas obligatoire) on decode donc ici les attributs de
     843  // couleur, fontes ...
     844  int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
     845  cout << " PIDrawer::DecodeOptionString apres PIDrawer::DecodeOptionString : ndec = "
     846       << ndec1 <<"<>" << ndec <<endl;
     847  if( ndec - ndec1 < 1 ) return(ndec1);  // si tout a ete decode
     848
     849  vector<string> udopt;  // On gardera ici les options non decodees
     850  int iopt  = 0;
     851  ndec = opt.size();
     852  int recalc = 0;
     853  for (iopt = 0 ; iopt<ndec ; iopt++){
     854
     855    string sopt = opt[iopt];
     856    if( sopt.find_first_of("=") != string::npos ){
     857      // options avec =
     858      string deb = sopt.substr(0,sopt.find_first_of("="));
     859      cout << " option avec =  : "<<deb<<" "<<sopt<<endl;
     860      if( (deb =="ncont") || (deb =="nc") ){ // # de contours
     861        string fin =  sopt.substr(sopt.find_first_of("=")+1 , string::npos);
     862        cout <<" fin "<<fin<<endl;
     863        int nlev = atoi(fin.c_str());
     864        this->SetNLevel(nlev);
     865        this->SetCntLevelKind(LEVELS_NUM);
     866        recalc =1;
     867      }else if(deb=="niv"||deb=="lev"){ // hauteur des niveaux
     868        string fin =  sopt.substr(sopt.find_first_of("=")+1 , string::npos);
     869        char * buff = strdup(fin.c_str());
     870        char *tmp;
     871        tmp = strtok(buff,",");
     872       
     873        if(tmp==NULL){
     874           cerr<< " PICOntourDrawer::DecodeOptionString ERREUR decodage des niveaux impossible " << buff <<endl;
     875         
     876        }else {
     877       
     878          vector <double> ztmp;
     879          while(tmp!=NULL){
     880            ztmp.push_back(atof(tmp));
     881            tmp = strtok(NULL,",");
     882          }
     883          int nlev = ztmp.size();
     884          cout << "  PICOntourDrawer::DecodeOptionString "<<nlev<<" niveaux decodes "<<endl;
     885          this->SetCntLevelKind(LEVELS_DISCRETE);
     886          this->SetNLevel(nlev);
     887          this->SetMyLevels(ztmp);
     888          recalc =1;
     889        }
     890      }else if(deb=="lstep" ){ // niveaux incrementaux : args = nombre,depart,pas
     891        string fin =  sopt.substr(sopt.find_first_of("=")+1 , string::npos);
     892        char * buff = strdup(fin.c_str());
     893        char *tmp;
     894        tmp = strtok(buff,",");
     895       
     896        if(tmp==NULL){
     897          cerr<< " PICOntourDrawer::DecodeOptionString ERREUR decodage nvx/incr. impossible " << buff <<endl;
     898        }else{
     899         
     900          vector <double> ztmp;
     901          while(tmp!=NULL){
     902            ztmp.push_back(atof(tmp));
     903            tmp = strtok(NULL,",");
     904          }
     905          if(ztmp.size() !=2) {
     906            cerr<< " PICOntourDrawer::DecodeOptionString ERREUR nb params incorrect(incr) " << buff <<endl;
     907          }else{
     908            vector <double> zlev;
     909            zlev.push_back(ztmp[1]);
     910            zlev.push_back(ztmp[2]);
     911            this->SetCntLevelKind(LEVELS_INCREMENTAL);
     912            this->SetNLevel( (int) ztmp[0]);
     913            this->SetMyLevels(zlev);
     914            recalc=1;
     915          }
     916        }
     917
     918      }else{
     919        cout<<"PICOntourDrawer::DecodeOptionString ERREUR  option "<<sopt<<" non reconnue "<<endl;
     920        ndec--;
     921        if (rmdecopt)  udopt.push_back( sopt );
     922      }
     923    }else{ //options sans "="
     924      if( sopt == "labon" )
     925        this->SetLabelOn();
     926      else if (sopt == "bspline" ){
     927        this->SetCntKind(CONTOUR_KIND_BSPLINE);
     928        recalc = 1;
     929      }else if (sopt == "3spl" ){
     930        this->SetCntKind(CONTOUR_KIND_CUBIC_SPL);
     931        recalc = 1;
     932      }
     933      else{
     934        cout<<"PICOntourDrawer::DecodeOptionString ERREUR  option "<<sopt<<" non reconnue "<<endl;
     935        ndec--;
     936        if (rmdecopt)  udopt.push_back(sopt);
     937      }
     938    }
     939   
     940  }// FIN DE LA BOUCLE SUR LES OPTIONS
     941
     942  if(recalc==1){
     943    // il faut (re)calculer les contours
     944    cout << " PICOntourDrawer::DecodeOptionString(re)calcul des contours "<<endl;
     945    this->CalcContour();
     946  }
     947  this->Refresh();
     948
     949 
     950  //
     951
     952  // S'il faut supprimer les options decodees, on remplace l'argument opt
     953  // par le vecteur des options non decodees.
     954  if (rmdecopt)  opt = udopt;
     955
     956  return(ndec+ndec1); 
     957 
     958}
     959
     960
     961 
  • trunk/SophyaPI/PIGcont/pigncont.h

    r1919 r2250  
    2828  const double *Levels(){return My_Levels;};
    2929  void SetMyLevels(double *ptr,int k);
     30  void SetMyLevels(vector <double> vec);
    3031  int NLevels(){return Contour_Levels;};
    3132  void SetNLevel(int n){Contour_Levels=n;};
     
    3536  void SetCntKind(t_contour_kind kind){Contour_kind = kind;};
    3637  t_contour_kind GetCntKind(){return Contour_kind ;};
     38
    3739
    3840  NTuple * & MyIso(){return  _myiso;};
     
    7678  virtual bool      IsMarkOn(); 
    7779  virtual bool      IsLabelOn();
    78   virtual void      SetLineOn(bool );
    79   virtual void      SetMarkOn(bool);
    80   virtual void      SetLabelOn(bool);
     80  virtual void      SetLineOn(bool b=true);
     81  virtual void      SetMarkOn(bool b=true);
     82  virtual void      SetLabelOn(bool b=true);
    8183
    8284  //Init  attributs graphiques
     
    8789//  Methode permettant l'affichage d'une fenetre de controle specialisee
    8890  virtual void      ShowControlWindow(PIBaseWdgGen* wdg);
     91  //  Desactivation de la fenetre de controle specialisee
     92  virtual void DeactivateControlWindow(PIBaseWdgGen* wdg);
     93//   Methode permettant de decoder des options a partir de chaines
     94  int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
    8995
    9096
Note: See TracChangeset for help on using the changeset viewer.