Changeset 2164 in Sophya for trunk/SophyaPI/PI/pi3ddrw.cc


Ignore:
Timestamp:
Aug 7, 2002, 4:59:52 PM (23 years ago)
Author:
ansari
Message:
  • Creation d'une classe gestionnaire de trace d'elements a etre utilise

ds la classe PIElDrawer (Traceur d'elements, d'axes 2D et titres, etc ...)

  • Ajout d'une nouvelle classe PIElDrawer3D , remplissant les memes

fonctions pour les objets 3D

  • Ajout de trace de label d'axes ds PIAxes
  • Ajout methode Set3DBox ds PIDrawer3D - Preparation en vue du

transfert du trace de boite/axes 3D a l'objet PIElDrawer3D

Reza 7/8/2002

File:
1 edited

Legend:

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

    r2138 r2164  
    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)
     49//      Définition de la boite 3D.
     50//
    4851// void Draw3DBoxe(PIGraphic3D* g3, double xx1, double xx2, double yy1, double yy2,  -
    4952//                 double zz1, double zz2, double xl1, double xl2, -
     
    6265  lCO = 10.;  dlCO = 3.; 
    6366  v3D_obs = false;
    64   x3Min = y3Min = z3Min = -1.; 
    65   x3Max = y3Max = z3Max = 1.;
     67  Set3DBox(-1., 1., -1., 1., -1., 1.);
    6668}
    6769
     
    103105  co = lCO;     dco = dlCO;
    104106  return(v3D_obs);
     107}
     108/* --Methode-- */
     109void PIDrawer3D::Set3DBox(double xmin, double xmax, double ymin, double ymax,
     110                          double zmin, double zmax)
     111{
     112  x3Min = xmin;  x3Max = xmax;
     113  y3Min = ymin;  y3Max = ymax;
     114  z3Min = zmin;  z3Max = zmax;
    105115}
    106116
     
    221231}
    222232
     233/*  --------------------------------------------------------------  */
     234/*  ------------------- Classe PIElDrawer3D ------------------------  */
     235/*  --------------------------------------------------------------  */
     236
     237//++
     238// Class        PIElDrawer3D
     239// Lib          PI
     240// include      p3ddrw.h
     241//
     242//      Classe de traceur ("Drawer") capable de gérer et de
     243//      tracer une liste d'éléments simples. Cette classe
     244//      est utilisé pour le tracé des axes et des éléments de
     245//      texte ds les "PIScDrawWdg", "PIDraw3DWdg" et "PIImage".
     246//--
     247//++
     248// Links        Parents
     249// PIDrawer3D
     250//--
     251//++
     252// Links        Voir aussi
     253// PIElDrawer
     254// PIElDrwMgr
     255//--
     256
     257//++
     258// Titre        Constructeurs et méthodes
     259//--
     260
     261//++
     262// PIElDrawer3D()
     263//      Constructeur
     264//--
     265
     266/* --Methode-- */
     267PIElDrawer3D::PIElDrawer3D()
     268{
     269  ShowTitles();
     270}
     271
     272/* --Methode-- */
     273PIElDrawer3D::~PIElDrawer3D()
     274{
     275}
     276
     277
     278//++
     279//  void  SetTitles(string tt, string tb)
     280//  void  SetTitles(string tt, string tb, PIGraphicAtt const& att)
     281//      Ajout de titres haut ("tt") et bas ("tb")
     282//--
     283
     284
     285/* --Methode-- */
     286int PIElDrawer3D::DecodeOptionString(vector<string> & opt, bool rmdecopt)
     287{
     288  int nopt0 = opt.size();
     289  if (nopt0 < 1)  return(0); 
     290  int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
     291  if ((nopt0 - ndec1) < 1) return(ndec1);  // si tout a ete decode
     292  vector<string> udopt;
     293  unsigned int k = 0;
     294  int ndec = opt.size();
     295  for( k=0; k<opt.size(); k++ ) {
     296    string opts = opt[k];
     297    if (opts == "title") ShowTitles(true);
     298    else if (opts == "notitle") ShowTitles(false);
     299
     300    else {
     301      ndec--;
     302      if (rmdecopt)  udopt.push_back(opts);
     303    }
     304  } 
     305
     306  if (rmdecopt)  opt = udopt;
     307  return(ndec+ndec1);
     308}
     309
     310
     311/* --Methode-- */
     312void  PIElDrawer3D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
     313{
     314SelGraAtt(g);   // DrawAxes change certains attributs graphiques
     315DrawAxes(g);   // Trace des axes
     316g->SelFont(PI_NormalSizeFont);
     317SelGraAtt(g);   // DrawAxes change certains attributs graphiques
     318
     319// Trace des titres
     320if ( showTitles && ((titleT.length() > 0) || (titleB.length() > 0)) ) {
     321  PIGraphicAtt grs = GetGraphicAtt();
     322  UpdateGraphicAtt(titleAtt);
     323  SelGraAtt(g);
     324
     325  aXdir = false;  // Vrai si Axe X de Droite vers Gauche
     326  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
     327  double fx, fy, fh;
     328//  fh = g->GetFontHeightUC(gas, gds);
     329  fh = 0.075*(YMax()-YMin());
     330  if ( titleT.length() > 0) {
     331      if (g->isAxeYDirUpDown()) fy = g->DeltaUCY(YMin(), -fh);
     332      else fy = g->DeltaUCY(YMax(), fh);
     333      g->DrawString((XMax()+XMin())*0.5, fy, titleT.c_str(), PI_HorizontalCenter | PI_VerticalBottom);
     334//      printf(" PIElDrawer3D::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
     335    }
     336  if ( titleB.length() > 0) {
     337      fx = g->CalcStringWidth(titleB.c_str());
     338      if(aXdir) fx = g->DeltaUCX(XMax(), -(XMax()-XMin()-fx)/2.);
     339      else fx = g->DeltaUCX(XMin(), (XMax()-XMin()-fx)/2.);
     340      if (g->isAxeYDirUpDown()) fy =  g->DeltaUCY(YMax(), fh*1.5);
     341      else fy = g->DeltaUCY(YMin(), -fh*1.5);
     342      g->DrawString((XMax()+XMin())*0.5, fy, titleB.c_str(), PI_HorizontalCenter | PI_VerticalBottom);
     343//      printf(" PIElDrawer3D::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
     344    }
     345  SetGraphicAtt(grs);
     346  }
     347
     348 SelGraAtt(g);
     349// Trace des elements
     350 ElDrwMgr().DrawElements(g, xmin, ymin, xmax, ymax);
     351
     352}
     353
Note: See TracChangeset for help on using the changeset viewer.