Changeset 2399 in Sophya


Ignore:
Timestamp:
Jun 6, 2003, 4:57:47 PM (22 years ago)
Author:
ansari
Message:

Modifs pour la prise en charge du trace d'axes par ls BaseDrawer ds les traces 3D - Reza 6 Juin 2003

Location:
trunk/SophyaPI/PI
Files:
5 edited

Legend:

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

    r2260 r2399  
    4646//                double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
    4747//      Renvoie la définition de la Vue-3D. Retourne "true " si définie par "Set3DView_Obs()"
    48 // void Set3DBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
     48// void Set3DBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, -
     49//               double scx=1., double scy=1., double scz=1.)
    4950//      Définition de la boite 3D.
     51// void ComputeScaleFactor(double xmin, double xmax, double ymin, double ymax,
     52//                         double zmin, double zmax, bool asxy, bool asz,
     53//                         double& scy, double& scz)
     54//      Calcul des facteurs d'echelles scy, scz
     55//      Si asxy == true : Application d'un facteur d'échelle pour égaliser
     56//      le rapport d'aspect des deux axes X et Y
     57//      Si asz == true : Application d'un facteur d'échelle pour égaliser
     58//      le rapport d'aspect de l'axe Z par rapport a XY.
    5059//
    5160// void Draw3DBoxe(PIGraphic3D* g3, double xx1, double xx2, double yy1, double yy2,  -
     
    108117/* --Methode-- */
    109118void PIDrawer3D::Set3DBox(double xmin, double xmax, double ymin, double ymax,
    110                           double zmin, double zmax)
     119                          double zmin, double zmax, double scx, double scy, double scz)
    111120{
    112121  x3Min = xmin;  x3Max = xmax;
    113122  y3Min = ymin;  y3Max = ymax;
    114123  z3Min = zmin;  z3Max = zmax;
     124  mScx = scx;  mScy = scy;  mScz = scz;
     125}
     126
     127/* --Methode-- */
     128void PIDrawer3D::ComputeScaleFactor(double xmin, double xmax, double ymin, double ymax,
     129                                    double zmin, double zmax, bool asxy, bool asz,
     130                                    double& scy, double& scz)
     131{
     132  scy = scz = 1.;
     133  if (!asxy && !asz) return;
     134  double scm=1.;
     135  if ((ymax-ymin) <= 1.e-19)  ymax = ymin + 1.e-19;
     136  if (asxy)  {
     137    scy = (xmax-xmin)/(ymax-ymin);
     138    scm = xmax-xmin;
     139    }
     140  else scm =  ((xmax-xmin) > (ymax-ymin)) ? (xmax-xmin)  : (ymax-ymin);
     141  if ((zmax-zmin) <= 1.e-19)  zmax = zmin + 1.e-19;
     142  if (asz) scz = scm/(zmax-zmin);
     143 
    115144}
    116145
     
    141170#endif
    142171  Draw3DBoxe(g3, XMin3(), XMax3(), YMin3(), YMax3(), ZMin3(), ZMax3(),
    143                  XMin3(), XMax3(), YMin3(), YMax3(), ZMin3(), ZMax3()); 
     172             XMin3()/mScx, XMax3()/mScx, YMin3()/mScy, YMax3()/mScy,
     173             ZMin3()/mScz, ZMax3()/mScz); 
    144174}
    145175
  • trunk/SophyaPI/PI/pi3ddrw.h

    r2262 r2399  
    3030
    3131  virtual void          Set3DBox(double xmin, double xmax, double ymin, double ymax,
    32                                  double zmin, double zmax);
     32                                 double zmin, double zmax,
     33                                 double scx=1., double scy=1., double scz=1.);
     34  inline  void          Copy3DBox(PIDrawer3D& dr3) {
     35    Set3DBox(dr3.XMin3(), dr3.XMax3(), dr3.YMin3(), dr3.YMax3(),
     36             dr3.ZMin3(), dr3.ZMax3(), dr3.ScaleX(), dr3.ScaleY(), dr3.ScaleZ());  }
     37
     38  virtual void          ComputeScaleFactor(double xmin, double xmax, double ymin, double ymax,
     39                                           double zmin, double zmax, bool asxy, bool asz,
     40                                           double& scy, double& scz);
    3341 
    3442  virtual PIGraphicUC*  SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g);
     
    3947                                                    double yl1, double yl2, double zl1, double zl2);
    4048
     49  // Cordonnees du cube 3D
    4150  double XMin3() const {return x3Min;}
    4251  double XMax3() const {return x3Max;}
     
    4554  double ZMin3() const {return z3Min;}
    4655  double ZMax3() const {return z3Max;}
     56  // Facteur d'echelle: Cube3D = Coord.User(3D)*Scale
     57  double ScaleX() const {return mScx;}
     58  double ScaleY() const {return mScy;}
     59  double ScaleZ() const {return mScz;}
    4760
    4861protected :
     
    5669  double y3Min, y3Max;  // Pour delimiter le cube 3D
    5770  double z3Min, z3Max;  // Pour delimiter le cube 3D
     71  double mScx, mScy, mScz;  // Facteur d'echelle entre coord. utilise et cube 3D
     72                            // x/y/z-Cube3D = x/y/z-User * mScx/y/z
    5873};
    5974
  • trunk/SophyaPI/PI/pi3dwdg.cc

    r2262 r2399  
    7070
    7171  vfixed = false;
     72  // On cree l'objet PIGraphic3D pour la gestion des vues 3D
     73  mGr3d = new PIGraphic3D(mWGrC, 0, 0, sx, sy);
     74
    7275//  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
    7376  SetDefaultDrawRectangle(0., 0., 1., 1., true);
    7477  mBDrw = new PIElDrawer3D;
    75   mBDrw->SetLimits(0.12,0.88, 0.12,0.88, kAxeDirLtoR,kAxeDirDownUp);
    76   AddDrawer(mBDrw, 0.12, 0.12, 0.88, 0.88, true, false, false);
     78  //  mBDrw->SetLimits(0.12,0.88, 0.12,0.88, kAxeDirLtoR,kAxeDirDownUp);
     79  //  AddDrawer(mBDrw, 0.12, 0.12, 0.88, 0.88, true, false, false);
     80  mBDrw->SetLimits(0.,1.,0.,1.,kAxeDirLtoR,kAxeDirDownUp);
     81  AddDrawer3D(mBDrw, false);
     82  mBDrw->SetAxesFlags(kStdAxes);
     83  vfixed = false; // Il faut laisser le premier Drawer3D fixer les limites et la vue 3D
     84
    7785  mPx = mPy = 0;
    7886
     
    8896  ActivateButton(1);   
    8997
    90   mGr3d = new PIGraphic3D(mWGrC, 0, 0, sx, sy);
    9198  rOfg = false;
    9299  axfg = true;
     
    143150{
    144151  list<int>::iterator it = m3DrIl.begin();
     152#if defined(CC_HAS_RTTI_SUPPORT)
     153  while ( (it != m3DrIl.end()) &&
     154          (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)) != mBDrw) ) it++;
    145155  if (it == m3DrIl.end())  return;
    146 #if defined(CC_HAS_RTTI_SUPPORT)
    147156  PIDrawer3D* dr3 = dynamic_cast<PIDrawer3D*>(GetDrawerId(*it));
    148157#else
     158  while ( (it != m3DrIl.end()) &&
     159          ( (PIDrawer3D*)(GetDrawerId(*it)) != mBDrw) ) it++;
    149160  PIDrawer3D* dr3 = (PIDrawer3D*)(GetDrawerId(*it));
    150161#endif
     
    156167  if (vobs) Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
    157168  else Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
     169  mBDrw->Copy3DBox(*dr3);
    158170  Refresh();
    159171}
     
    194206int PIDraw3DWdg::AddDrawer3D(PIDrawer3D* dr3, bool ad)
    195207{
    196 if (!vfixed)  {
     208if ((!vfixed) && (dr3 != mBDrw))  {
    197209  dr3->UpdateLimits();
    198210  double xo, yo, zo, xc, yc, zc, teta, phi, psi, dax, day, co, dco;
     
    201213  if (vobs) Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
    202214  else Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
     215  mBDrw->Copy3DBox(*dr3);
    203216  }
    204217else {
     
    209222  }
    210223int id = AddDrawer(dr3, false, false, ad);
    211 if (m3DrIl.size() == 0)  dr3->SetAxesFlags(kStdAxes);
    212 else dr3->SetAxesFlags(kAxesNone);
     224if (dr3 != mBDrw) dr3->SetAxesFlags(kAxesNone);
    213225m3DrIl.push_back(id);
    214226return(id);
     
    248260    axfg = !axfg;
    249261    list<int>::iterator it;
    250     if (axfg)
    251       for(it = m3DrIl.begin(); it != m3DrIl.end(); it++) 
    252          GetDrawerId(*it)->SetAxesFlags(kAxesNone);
    253     else {
    254       it = m3DrIl.begin();
    255       if (it != m3DrIl.end())  GetDrawerId(*it)->SetAxesFlags(kStdAxes);
    256       }
     262    if (!axfg) mBDrw->SetAxesFlags(kAxesNone);
     263    else mBDrw->SetAxesFlags(kStdAxes);
    257264    Refresh();
    258265    }
  • trunk/SophyaPI/PI/pisurfdr.cc

    r2164 r2399  
    4545  arr->XYfromxy(0,0,mXmin, mYmin);
    4646  arr->XYfromxy(arr->XSize(),arr->YSize(),mXmax, mYmax);
    47   double scm=1.;
    48   if (asxy)  {
    49     mScy = (mXmax-mXmin)/(mYmax-mYmin);
    50     scm = mXmax-mXmin;
    51     }
    52   else scm =  ((mXmax-mXmin) > (mYmax-mYmin)) ? (mXmax-mXmin)  : (mYmax-mYmin);
     47
     48  mAutoScaleXY = asxy;
     49  mAutoScaleZ = asz;
     50
    5351  int i,j;   double cv;
    5452  mZmin = mZmax = arr->Value(0,0);
     
    6058    }
    6159  if ((mZmax-mZmin) <= 1.e-19)  mZmax = mZmin + 1.e-19;
    62   if (asz) mScz = scm/(mZmax-mZmin);
    6360//  printf("PISurfaceDrawer::PISurfaceDrawer Min/Max: %g,%g  %g,%g  %g,%g  Sc: %g %g %g \n",
    6461//          mXmin, mXmax, mYmin, mYmax, mZmin, mZmax, mScx, mScy, mScz);
     
    8279{
    8380  if (mArr == NULL)  return;
     81  ComputeScaleFactor(mXmin, mXmax, mYmin, mYmax, mZmin, mZmax,
     82                     mAutoScaleXY, mAutoScaleZ, mScy, mScz);
    8483  double xmin, xmax, ymin, ymax, zmin, zmax;
    8584  xmin = mXmin*mScx;  xmax = mXmax*mScx;
     
    9695            (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25); 
    9796
    98   Set3DBox(xmin, xmax, ymin, ymax, zmin-PERC_GARDE*(zmax-zmin), zmax+PERC_GARDE*(zmax-zmin));
     97  Set3DBox(xmin, xmax, ymin, ymax, zmin-PERC_GARDE*(zmax-zmin),
     98           zmax+PERC_GARDE*(zmax-zmin), mScx, mScy, mScz);
    9999
    100100//  printf("PISurfaceDrawer::UpdateLimits() : %g-%g  %g-%g  %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
     
    119119}
    120120
    121 /* --Methode-- */
     121/* --Methode--
    122122void PISurfaceDrawer::DrawAxes(PIGraphicUC* g)
    123123{
     
    132132            mZmin-PERC_GARDE*(mZmax-mZmin),mZmax+PERC_GARDE*(mZmax-mZmin));
    133133}
     134*/
    134135
    135136/* --Methode-- */
     
    289290  delete[] zw;
    290291}
     292
     293/* --Methode-- */
     294int 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") mAutoScaleXY = true;
     310    else if (opts == "norescalexy") mAutoScaleXY = false;
     311    else if (opts == "rescalez") mAutoScaleZ = true;
     312    else if (opts == "norescalez") mAutoScaleZ = 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-- */
     327void PISurfaceDrawer::GetOptionsHelpInfo(string& info)
     328{
     329info += " ---- PISurfaceDrawer options help info : \n" ;
     330info += "  rescalexy / norescalexy   rescalez / norescalez \n";
     331info += "  and usual color/line/marker/... attribute decoding  \n";
     332// On recupere ensuite la chaine info de la classe de base
     333PIDrawer::GetOptionsHelpInfo(info);
     334return;
     335}
  • trunk/SophyaPI/PI/pisurfdr.h

    r204 r2399  
    1818
    1919  virtual void          Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
    20   virtual void          DrawAxes(PIGraphicUC* g);
     20//   Methode de decodage des options
     21  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     22//   Texte d'aide des options disponibles
     23  virtual void       GetOptionsHelpInfo(string& info);
    2124
    2225protected :
    2326  P2DArrayAdapter* mArr;
    2427  bool mAda;
    25   double mScz, mScx, mScy;
     28  bool mAutoScaleXY, mAutoScaleZ;
    2629  double mXmin, mXmax;
    2730  double mYmin, mYmax;
Note: See TracChangeset for help on using the changeset viewer.