Changeset 2546 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Jun 2, 2004, 3:22:07 PM (21 years ago)
Author:
ansari
Message:

Suite (et presque fin) codage de traitement des options de limites d'axes et d'auto/rescaling ds les Drawers3D et le PIWdg3D - Reza 2 Juin 2004

Location:
trunk/SophyaPI/PI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pi3ddrw.cc

    r2544 r2546  
    262262}
    263263
     264/* --Methode-- */
     265int PIDrawer3D::DecodeOptionString(vector<string> & opt, bool rmdecopt)
     266{
     267  int optsz1 = opt.size();
     268  if(optsz1<1)  return(0); 
     269  // On appelle d'abord le decodage de la classe PIDrawer de laquelle
     270  // on herite. (Pas obligatoire) on decode donc ici les attributs de
     271  // couleur, fontes ...
     272  int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
     273  if(optsz1-ndec1<1) return(ndec1);  // si tout a ete decode
     274
     275  vector<string> udopt;  // On gardera ici les options non decodees
     276  unsigned int k = 0;
     277  int ndec = opt.size();
     278  for( k=0; k<opt.size(); k++ ) {
     279    string opts = opt[k];
     280    if ( (opts == "rescale") || (opts == "autoscale") ) aScxy = aScz = true;
     281    else if ( (opts == "norescale") || (opts == "noautoscale") ) aScxy = aScz = false;
     282    else if ( (opts == "rescalexy") || (opts == "autoscalexy") )  aScxy = true;
     283    else if ( (opts == "norescalexy") || (opts == "noautoscalexy") )  aScxy = false;
     284    else if ( (opts == "rescalez") || (opts == "autoscalez") )  aScz = true;
     285    else if ( (opts == "norescalez") || (opts == "noautoscalez") )  aScz = false;
     286    else {
     287      // Si option non decode
     288      ndec--;
     289      // S'il faut supprimer les options decodees
     290      if (rmdecopt)  udopt.push_back(opts);
     291    }
     292  } 
     293  // S'il faut supprimer les options decodees, on remplace l'argument opt
     294  // par le vecteur des options non decodees.
     295  if (rmdecopt)  opt = udopt;
     296  return(ndec+ndec1); 
     297}
     298
     299/* --Methode-- */
     300int PIDrawer3D::OptionToString(vector<string> & opt) const
     301{
     302 PIDrawer::OptionToString(opt);
     303 if ( aScxy || aScz ) opt.push_back("autoscale");
     304 else if (!aScxy && !aScz ) opt.push_back("noautoscale");
     305 else {
     306   if(aScxy) opt.push_back("autoscalexy"); else opt.push_back("noautoscalexy");
     307   if(aScz) opt.push_back("autoscalez"); else opt.push_back("noautoscalez");
     308 }
     309 return 1;
     310}
     311
     312/* --Methode-- */
     313void PIDrawer3D::GetOptionsHelpInfo(string& info)
     314{
     315info += " ---- PIDrawer3D options help info : \n" ;
     316info += "  X/Y,Z axis rescaling option (-> cubic 3D box)  \n";
     317info += "  rescale=autoscale/ norescale=noautoscale : X/Y and Z axis \n";
     318info += "  rescalexy=autoscalexy / norescalexy=noautoscalexy : X/Y  axis \n";
     319info += "  rescalexy=autoscalexy / norescalexy=noautoscalexy : Z axis \n";
     320info += " --- + Usual color/line/marker/... attribute decoding  \n";
     321// On recupere ensuite la chaine info de la classe de base
     322PIDrawer::GetOptionsHelpInfo(info);
     323return;
     324}
     325
    264326/*  --------------------------------------------------------------  */
    265327/*  ------------------- Classe PIElDrawer3D ------------------------  */
     
    319381  int nopt0 = opt.size();
    320382  if (nopt0 < 1)  return(0); 
    321   int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
     383  int ndec1 = PIDrawer3D::DecodeOptionString(opt, rmdecopt);
    322384  if ((nopt0 - ndec1) < 1) return(ndec1);  // si tout a ete decode
    323385  vector<string> udopt;
  • trunk/SophyaPI/PI/pi3ddrw.h

    r2544 r2546  
    5151                                                    double zz1, double zz2, double xl1, double xl2,
    5252                                                    double yl1, double yl2, double zl1, double zl2);
     53//   Methode de decodage des options
     54  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     55  virtual int        OptionToString(vector<string> & opt) const;
     56//   Texte d'aide des options disponibles
     57  virtual void       GetOptionsHelpInfo(string& info);
    5358
    5459  // Cordonnees du cube 3D
  • trunk/SophyaPI/PI/pi3dwdg.cc

    r2544 r2546  
    4141//      * <Alt>E : Supprime le dernier élément graphique ajouté.
    4242//      * <Alt>A : Active/desactive l'affichage des axes
    43 //      * <Alt>R : Reinitialise la vue 3D (vue par défaut) et rafraichit le dessin.
     43//      * <Alt>U : Reinitialise la vue 3D (vue par défaut) et rafraichit le dessin.
     44//      * <Alt>R : Rafraichit le dessin du widget.
    4445//      * <Alt>S : Active/desactive le mode de rotation d'objet sans Shift
    4546//
     
    169170  double D = xmax-xmin;
    170171  if (D < (ymax-ymin))  D = ymax-ymin;
     172  if (D < (zmax-zmin))  D = zmax-zmin;
    171173  D *= 1.4;
    172174  Set3DView((xmin+xmax)/2., (ymin+ymax)/2, zmin+(zmax-zmin)*0.40,
     
    181183#if defined(CC_HAS_RTTI_SUPPORT)
    182184  while ( (it != m3DrIl.end()) &&
    183           (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)) != mBDrw) ) it++;
     185          (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)) == mBDrw) ) it++;
    184186  if (it == m3DrIl.end())  return;
    185187  PIDrawer3D* dr3 = dynamic_cast<PIDrawer3D*>(GetDrawerId(*it));
    186188#else
    187189  while ( (it != m3DrIl.end()) &&
    188           ( (PIDrawer3D*)(GetDrawerId(*it)) != mBDrw) ) it++;
     190          ( (PIDrawer3D*)(GetDrawerId(*it)) == mBDrw) ) it++;
    189191  PIDrawer3D* dr3 = (PIDrawer3D*)(GetDrawerId(*it));
    190192#endif
     
    210212int PIDraw3DWdg::DecodeOptionString(vector<string> & opt, bool rmdecopt)
    211213{
    212   // AFAIRE - Reza 01/03/2002
    213   return(0);
     214  if (opt.size() == 0)  return(0); 
     215
     216  vector<string> udopt;
     217  unsigned int k = 0;
     218  int ndec = opt.size();
     219  bool fg3db = false;
     220
     221  double xmin = mBDrw->ScaleX( mBDrw->XMin3() );
     222  double xmax = mBDrw->ScaleX( mBDrw->XMax3() );
     223  double ymin = mBDrw->ScaleY( mBDrw->YMin3() );
     224  double ymax = mBDrw->ScaleY( mBDrw->YMax3() );
     225  double zmin = mBDrw->ScaleY( mBDrw->ZMin3() );
     226  double zmax = mBDrw->ScaleY( mBDrw->ZMax3() );
     227  bool asxy = mBDrw->isAutoScaleXY();
     228  bool asz = mBDrw->isAutoScaleZ();
     229
     230  for( k=0; k<opt.size(); k++ ) {
     231    string opts = opt[k];
     232    // Limites en x,y
     233    if (opts.substr(0,10) == "xyzlimits=") {
     234      sscanf(opts.substr(10).c_str(),"%lg,%lg,%lg,%lg,%lg,%lg",
     235             &xmin, &xmax, &ymin, &ymax, &zmin, &zmax);
     236      fg3db = true;
     237      continue;
     238    }
     239    if (opts.substr(0,9) == "lim3dbox=") {
     240      sscanf(opts.substr(9).c_str(),"%lg,%lg,%lg,%lg,%lg,%lg",
     241             &xmin, &xmax, &ymin, &ymax, &zmin, &zmax);
     242      fg3db = true;
     243      continue;
     244    }
     245    if (opts == "autoscale3dbox") {
     246      asxy = asz = true;
     247      fg3db = true;
     248      continue;
     249    }
     250    if (opts == "noautoscale3dbox") {
     251      asxy = asz = false;
     252      fg3db = true;
     253      continue;
     254    }
     255    if (opts == "autoscalexy3dbox") {
     256      asxy = true;
     257      fg3db = true;
     258      continue;
     259    }
     260    if (opts == "noautoscalexy3dbox") {
     261      asxy = false;
     262      fg3db = true;
     263      continue;
     264    }
     265    if (opts == "autoscalez3dbox") {
     266      asz = true;
     267      fg3db = true;
     268      continue;
     269    }
     270    if (opts == "noautoscalez3dbox") {
     271      asz = false;
     272      fg3db = true;
     273      continue;
     274    }
     275    // Option non decode
     276    ndec--;
     277    if (rmdecopt) udopt.push_back(opts);   
     278  }
     279
     280  if (fg3db)  Set3DViewBox(xmin,xmax,ymin,ymax,zmin,zmax,asxy,asz);
     281 
     282  if (rmdecopt)  opt = udopt;
     283  return(ndec);
    214284}
    215285
     
    313383  else if (key == 'S' || key == 's')  skcfg = !skcfg; 
    314384  else if (key == 'R' || key == 'r')  Refresh();
    315   else if (key == 'B' || key == 'b')  Update3DView();
     385  else if (key == 'U' || key == 'u')  Update3DView();
    316386  }
    317387}
  • trunk/SophyaPI/PI/pisurfdr.cc

    r2544 r2546  
    160160
    161161  double dx,dy;   // taille du bin
    162   dx = (mXmax-mXmin)*mScx/xsz;
    163   dy = (mYmax-mYmin)*mScy/ysz;
     162  dx = ScaleX(mXmax-mXmin)/xsz;
     163  dy = ScaleY(mYmax-mYmin)/ysz;
    164164 
    165165  int i1,j1;
     
    172172      ijzp[k].ij = j*xsz+i;
    173173      mArr->XYfromxy(i,j,x,y);
    174       x *= mScx; x += dx/2.;
    175       y *= mScy; y += dy/2.;
     174      x = ScaleX(x); x += dx/2.;
     175      y = ScaleY(y); y += dy/2.;
    176176      ijzp[k].zh = mArr->Value(i,j);
    177       z = ijzp[k].zh * mScz;
     177      z = ScaleZ(ijzp[k].zh);
    178178      g3->C3DC2ObsCS(x,y,z,xp,yp,zp);
    179179      ijzp[k].dp = zp;
     
    185185      j1 = (j>0) ? j-1 : 0;
    186186      z = mArr->Value(i,j) + mArr->Value(i1,j) + mArr->Value(i1,j1) +  mArr->Value(i,j1);
    187       z = z/4.*mScz;       
     187      z = ScaleZ(z/4.);       
    188188//      g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);
    189189      xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;    zw[j*(xsz+1)+i] = z;   
     
    193193  for(i=0; i<xsz; i++) {
    194194     mArr->XYfromxy(i,j-1,x,y);
    195      x *= mScx;
    196      y *= mScy; y += dy;
     195     x = ScaleX(x);
     196     y = ScaleY(y); y += dy;
    197197     i1 = (i>0) ? i-1 : 0;
    198198     j1 = j-1;
    199199     z = mArr->Value(i,j-1) + mArr->Value(i1,j-1) + mArr->Value(i1,j1) +  mArr->Value(i,j1);
    200      z = z/4.*mScz;
     200     z = ScaleZ(z/4.);
    201201//     g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
    202202     xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;   zw[j*(xsz+1)+i] = z;   
     
    205205  for(j=0; j<ysz; j++) {
    206206     mArr->XYfromxy(i-1,j,x,y);
    207      x *= mScx; x += dx;
    208      y *= mScy;
     207     x = ScaleX(x); x += dx;
     208     y = ScaleY(y);
    209209     i1 = i-1;
    210210     j1 = (j>0) ? j-1 : 0;
    211211     z = mArr->Value(i-1,j) + mArr->Value(i1,j) + mArr->Value(i1,j1) +  mArr->Value(i-1,j1);
    212      z = z/4.*mScz;
     212     z = ScaleZ(z/4.);
    213213//     g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
    214214     xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;   zw[j*(xsz+1)+i] = z;   
     
    217217  mArr->XYfromxy(i-1,j-1,x,y);
    218218  i1 = i-1;   j1 = j-1;
    219   x *= mScx; x += dx;
    220   y *= mScy; y += dy;
     219  x = ScaleX(x); x += dx;
     220  y = ScaleY(y); y += dy;
    221221  z = mArr->Value(i-1,j-1) + mArr->Value(i1,j-1) + mArr->Value(i1,j1) +  mArr->Value(i-1,j1);
    222   z = z/4.*mScz;
     222  z = ScaleZ(z/4.);
    223223//  g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
    224224  xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;    zw[j*(xsz+1)+i] = z;   
     
    291291}
    292292
    293 /* --Methode-- */
    294 int PISurfaceDrawer::DecodeOptionString(vector<string> & opt, bool rmdecopt)
    295 {
    296   int optsz1 = opt.size();
    297   if(optsz1<1)  return(0); 
    298   // On appelle d'abord le decodage de la classe PIDrawer de laquelle
    299   // on herite. (Pas obligatoire) on decode donc ici les attributs de
    300   // couleur, fontes ...
    301   int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
    302   if(optsz1-ndec1<1) return(ndec1);  // si tout a ete decode
    303 
    304   vector<string> udopt;  // On gardera ici les options non decodees
    305   unsigned int k = 0;
    306   int ndec = opt.size();
    307   for( k=0; k<opt.size(); k++ ) {
    308     string opts = opt[k];
    309     if (opts == "rescalexy") aScxy = true;
    310     else if (opts == "norescalexy") aScxy = false;
    311     else if (opts == "rescalez") aScz = true;
    312     else if (opts == "norescalez") aScz = false;
    313     else {
    314       // Si option non decode
    315       ndec--;
    316       // S'il faut supprimer les options decodees
    317       if (rmdecopt)  udopt.push_back(opts);
    318     }
    319   } 
    320   // S'il faut supprimer les options decodees, on remplace l'argument opt
    321   // par le vecteur des options non decodees.
    322   if (rmdecopt)  opt = udopt;
    323   return(ndec+ndec1); 
    324 }
    325 
    326 /* --Methode-- */
    327 int PISurfaceDrawer::OptionToString(vector<string> & opt) const
    328 {
    329  PIDrawer::OptionToString(opt);
    330 
    331  if(aScxy) opt.push_back("rescalexy"); else opt.push_back("norescalexy");
    332  if(aScz) opt.push_back("rescalez"); else opt.push_back("norescalez");
    333 
    334  return 1;
    335 }
    336 
    337 /* --Methode-- */
    338 void PISurfaceDrawer::GetOptionsHelpInfo(string& info)
    339 {
    340 info += " ---- PISurfaceDrawer options help info : \n" ;
    341 info += "  rescalexy / norescalexy   rescalez / norescalez \n";
    342 info += "  and usual color/line/marker/... attribute decoding  \n";
    343 // On recupere ensuite la chaine info de la classe de base
    344 PIDrawer::GetOptionsHelpInfo(info);
    345 return;
    346 }
  • trunk/SophyaPI/PI/pisurfdr.h

    r2544 r2546  
    1818
    1919  virtual void          Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
     20
     21/* --- Juin 2004 : decodage des options mis ds PIDrawer3D
    2022//   Methode de decodage des options
    2123  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     
    2325//   Texte d'aide des options disponibles
    2426  virtual void       GetOptionsHelpInfo(string& info);
     27  ---------     */
    2528
    2629protected :
Note: See TracChangeset for help on using the changeset viewer.