Changeset 2250 in Sophya for trunk/SophyaPI/PIGcont/pigncont.cc


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.