Changeset 2242 in Sophya


Ignore:
Timestamp:
Nov 3, 2002, 10:49:34 PM (23 years ago)
Author:
ansari
Message:

Ajout trace d'arc 3 pts - non termine et amelioration de PIElDrawer , Reza 3/11/2002

Location:
trunk/SophyaPI/PI
Files:
11 edited

Legend:

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

    r2166 r2242  
    8484          break;
    8585        case PIDEL_Text :
    86           g->DrawString((*it).ex, (*it).ey, (char*) ((*it).es.c_str()) );
     86          g->DrawString((*it).ex, (*it).ey, ((*it).es->txt.c_str()), (*it).es->txtpd );
    8787          break;
    8888        case PIDEL_Rect :
     
    9797        case PIDEL_FCirc :
    9898          g->DrawFCircle((*it).ex, (*it).ey, (*it).edx );
     99          break;
     100        case PIDEL_Arc :
     101          g->Draw3PtArc((*it).xpol[0], (*it).ypol[0], (*it).xpol[1],
     102                        (*it).ypol[1], (*it).xpol[2], (*it).ypol[2] );
     103          break;
     104        case PIDEL_FArc :
     105          g->Draw3PtFArc((*it).xpol[0], (*it).ypol[0], (*it).xpol[1],
     106                         (*it).ypol[1], (*it).xpol[2], (*it).ypol[2] );
    99107          break;
    100108        case PIDEL_Poly :
     
    145153//      Renvoie le numéro identificateur de l'élément.
    146154//
     155// int  ElAddArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2 \
     156//               PIGrCoord x3, PIGrCoord y3)
     157// int  ElAddArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2 \
     158//               PIGrCoord x3, PIGrCoord y3, PIGraphicAtt gatt)
     159//      Ajout d'un élément de type arc défini par trois points
     160//      (possibilité de spécification d'un attribut graphique).
     161//      Renvoie le numéro identificateur de l'élément.
     162//
     163// int  ElAddFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2 \
     164//                PIGrCoord x3, PIGrCoord y3)
     165// int  ElAddFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2 \
     166//                PIGrCoord x3, PIGrCoord y3, PIGraphicAtt gatt)
     167//      Ajout d'un élément de type arc plein défini par trois points
     168//      (possibilité de spécification d'un attribut graphique).
     169//      Renvoie le numéro identificateur de l'élément.
     170//
    147171// int  ElAddPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y)
    148172// int  ElAddPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y, PIGraphicAtt gatt)
     
    162186//--
    163187
     188
    164189/* --Methode-- */
    165190int PIElDrwMgr::ElAdd(int typ, PIGrCoord x, PIGrCoord  y, PIGrCoord dx, PIGrCoord dy,
    166                       const char* s, PIGraphicAtt const& att)
     191                      const char* s, PIGraphicAtt const& att, unsigned long tpd)
    167192{
    168193  DrwEl dre;
     
    172197  dre.edx = dx;  dre.edy = dy;
    173198  dre.gatt = att;
    174   if (s)  dre.es = s;
     199  if (s)  {
     200    dre.es = new TxtEl;
     201    dre.es->txt = s;
     202    dre.es->txtpd = tpd;
     203  }
     204  else dre.es = NULL;
    175205  dre.xpol = dre.ypol = NULL;
    176206  dre.npol = 0;
     
    188218  dre.edx = dre.edy = 0;
    189219  dre.gatt = att;
     220  dre.es = NULL;
    190221  dre.xpol = dre.ypol = NULL;
    191222  dre.npol = (y.size() < x.size()) ? y.size() : x.size();
     
    203234
    204235/* --Methode-- */
     236int PIElDrwMgr::ElAdd(int typ, PIGrCoord* x, PIGrCoord* y, int n,
     237                      PIGraphicAtt const & att)
     238{
     239  vector<PIGrCoord> vx, vy;
     240  for(int k=0; k<n; k++) {
     241    vx.push_back(x[k]);
     242    vy.push_back(y[k]);
     243  }
     244  return ( ElAdd(typ, vx, vy, att) );
     245}
     246
     247
     248/* --Methode-- */
    205249void  PIElDrwMgr::ElDel(int id)
    206250{
     
    208252  for (it = mElist.begin(); it != mElist.end(); it++) {
    209253    if ( (*it).eid == id) {
     254      if ( (*it).es ) delete (*it).es;
    210255      if ( (*it).xpol ) delete[] (*it).xpol;
    211256      if ( (*it).ypol ) delete[] (*it).ypol;
     
    222267  DrwElList::iterator it;
    223268  for (it = mElist.begin(); it != mElist.end(); it++) {
     269    if ( (*it).es ) delete (*it).es;
    224270    if ( (*it).xpol ) delete[] (*it).xpol;
    225271    if ( (*it).ypol ) delete[] (*it).ypol;
     
    311357    else if (opts == "finecenteredaxesgrid")
    312358      SetAxesFlags(kStdAxes | kMajTicks | kMinTicks | kLabels | kGridOn);
     359    else if (opts == "axesnone")
     360      SetAxesFlags(kAxesNone);
    313361    else if (opts == "autofontsize")
    314362      SetAxesAutoFontSize(true);
     
    331379void  PIElDrawer::DrawAxes(PIGraphicUC* g)
    332380{
     381  if (axesFlags == kAxesNone) return;
    333382  g->NoClip();
    334383  g->SaveGraphicAtt();
  • trunk/SophyaPI/PI/pieldrw.h

    r2164 r2242  
    1616         PIDEL_Rect = 3, PIDEL_FRect = 4,
    1717         PIDEL_Circ = 5, PIDEL_FCirc = 6,
    18          PIDEL_Poly = 7, PIDEL_FPoly = 8,
    19          PIDEL_Mark = 9, PIDEL_Arrow = 10 } ;
     18         PIDEL_Arc = 7,  PIDEL_FArc = 8,
     19         PIDEL_Poly = 9, PIDEL_FPoly = 10,
     20         PIDEL_Mark = 11, PIDEL_Arrow = 12,
     21         PIDEL_CText = 13  } ;
    2022
    2123                PIElDrwMgr();
     
    2426  virtual void  DrawElements(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
    2527
     28  // ---- Ajout de lignes
    2629  inline int    ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
    2730    { PIGraphicAtt gatt; return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, gatt) ); } 
     
    3033    { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, gatt) ); } 
    3134
     35  // ---- Ajout de fleches
    3236  inline int    ElAddArrow(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
    3337    { PIGraphicAtt gatt; return( ElAdd(PIDEL_Arrow, x1, y1, x2, y2, NULL, gatt) ); } 
     
    3640    { return( ElAdd(PIDEL_Arrow, x1, y1, x2, y2, NULL, gatt) ); } 
    3741
     42  // ---- Ajout de marker
    3843  inline int    ElAddMarker(PIGrCoord x, PIGrCoord y)
    3944    { PIGraphicAtt gatt; return( ElAdd(PIDEL_Circ, x, y, 0, 0, NULL, gatt) ); } 
     
    4146    { return( ElAdd(PIDEL_Mark, x, y, 0, 0, NULL, gatt) ); } 
    4247
     48  // ---- Ajout de texte
    4349  inline int    ElAddText(PIGrCoord x, PIGrCoord y, const char* s)
    4450    { PIGraphicAtt gatt; return( ElAdd(PIDEL_Text, x, y, 0, 0, s, gatt) ); } 
    45   inline int    ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIGraphicAtt const & gatt)
    46     { return( ElAdd(PIDEL_Text, x, y, 0, 0, s, gatt) ); } 
     51  inline int    ElAddText(PIGrCoord x, PIGrCoord y, const char* s,
     52                          PIGraphicAtt const & gatt, unsigned long tpd)
     53    { return( ElAdd(PIDEL_Text, x, y, 0, 0, s, gatt, tpd) ); } 
    4754  inline int    ElAddText(PIGrCoord x, PIGrCoord y, string const & s)
    4855    { PIGraphicAtt gatt; return( ElAdd(PIDEL_Text, x, y, 0, 0, s.c_str(), gatt) ); } 
    49   inline int    ElAddText(PIGrCoord x, PIGrCoord y, string const & s, PIGraphicAtt const & gatt)
    50     { return( ElAdd(PIDEL_Text, x, y, 0, 0, s.c_str(), gatt) ); } 
    51 
     56  inline int    ElAddText(PIGrCoord x, PIGrCoord y, string const & s,
     57                          PIGraphicAtt const & gatt, unsigned long tpd)
     58    { return( ElAdd(PIDEL_Text, x, y, 0, 0, s.c_str(), gatt, tpd) ); } 
     59
     60  // ---- Ajout de rectangles
    5261  inline int    ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy)
    5362    { PIGraphicAtt gatt; return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL, gatt) ); } 
     
    6271    { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL, gatt) ); } 
    6372
     73  // ---- Ajout de cercles
    6474  inline int    ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r)
    6575    { PIGraphicAtt gatt; return( ElAdd(PIDEL_Circ, x, y, r, r, NULL, gatt) ); } 
     
    7282    { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL, gatt) ); } 
    7383
     84  // ---- Ajout d' arcs
     85  inline int    ElAddArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     86                         PIGrCoord x3, PIGrCoord y3)
     87    { PIGraphicAtt gatt; PIGrCoord x[3], y[3];
     88      x[0] = x1; x[1] = x2; x[2] = x3;
     89      y[0] = y1; y[1] = y2; y[2] = y3;
     90      return( ElAdd(PIDEL_Arc, x, y, 3, gatt) ); } 
     91
     92  inline int    ElAddArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     93                         PIGrCoord x3, PIGrCoord y3, PIGraphicAtt const & gatt)
     94    { PIGrCoord x[3], y[3];
     95      x[0] = x1; x[1] = x2; x[2] = x3;
     96      y[0] = y1; y[1] = y2; y[2] = y3;
     97      return( ElAdd(PIDEL_Arc, x, y, 3, gatt) ); } 
     98
     99  inline int    ElAddFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     100                          PIGrCoord x3, PIGrCoord y3)
     101    { PIGraphicAtt gatt; PIGrCoord x[3], y[3];
     102      x[0] = x1; x[1] = x2; x[2] = x3;
     103      y[0] = y1; y[1] = y2; y[2] = y3;
     104      return( ElAdd(PIDEL_FArc, x, y, 3, gatt) ); } 
     105
     106  inline int    ElAddFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     107                          PIGrCoord x3, PIGrCoord y3, PIGraphicAtt const & gatt)
     108    { PIGrCoord x[3], y[3];
     109      x[0] = x1; x[1] = x2; x[2] = x3;
     110      y[0] = y1; y[1] = y2; y[2] = y3;
     111      return( ElAdd(PIDEL_FArc, x, y, 3, gatt) ); } 
     112
     113  // ---- Ajout de polygones
    74114  inline int    ElAddPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y)
    75115    { PIGraphicAtt gatt; return( ElAdd(PIDEL_Poly, x, y, gatt) ); } 
     
    80120    { PIGraphicAtt gatt; return( ElAdd(PIDEL_FPoly, x, y, gatt) ); } 
    81121  inline int    ElAddFPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y, PIGraphicAtt const & gatt)
     122
    82123    { return( ElAdd(PIDEL_FPoly, x, y, gatt) ); } 
    83124
     
    87128protected:
    88129  int                ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
    89                            const char* s, PIGraphicAtt const & att);
     130                           const char* s, PIGraphicAtt const & att,
     131                           unsigned long txtposdir=0);
    90132  int                ElAdd(int typ, vector<PIGrCoord>& x, vector<PIGrCoord>& y,
    91133                           PIGraphicAtt const & att);
     134  int                ElAdd(int typ, PIGrCoord* x, PIGrCoord* y, int n,
     135                           PIGraphicAtt const & att);
     136
     137  struct TxtEl {
     138    string txt;
     139    unsigned long txtpd;
     140  };
    92141
    93142  struct DrwEl{
     
    95144    PIGrCoord ex,ey;
    96145    PIGrCoord edx,edy;
    97     string es;
    98146    PIGraphicAtt gatt;
     147    TxtEl* es;
    99148    PIGrCoord* xpol;
    100149    PIGrCoord* ypol;
  • trunk/SophyaPI/PI/pigraphgen.cc

    r2138 r2242  
    77#include "pigraphgen.h"
    88#include <math.h>
    9 
     9#include "ucckprot.h"
    1010
    1111//++
     
    266266//      Tracé d'un arc plein, inclu dans le "(x0,y0)" , "dx,dy"
    267267//      entre les angles (en degré) "degdeb" - "degfin"
     268//
     269// Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, \
     270//            PIGrCoord x3, PIGrCoord y3)
     271//      Tracé d'un arc spécifié par trois points "(x1,y1)", "(x2,y2)" et "(x3,y3)"
     272// Draw3PtFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, \
     273//             PIGrCoord x3, PIGrCoord y3)
     274//      Tracé d'un arc plein spécifié par trois points "(x1,y1)", "(x2,y2)" et "(x3,y3)"
    268275//--
    269276
     
    278285//      Tracé de "n" signes aux points "(x[i],y[i])"
    279286//--
     287
     288/* --Methode-- */
     289void PIGraphicGen::Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     290                              PIGrCoord x3, PIGrCoord y3)
     291  // Trace d'un arc de cercle passant par 3 points
     292{
     293  double x0, y0;
     294  double dx, dy;
     295  double degdeb, degfin;
     296  int rc;
     297  rc = ComputeArcFrom3Pt(x1, y1, x2, y2, x3, y3, x0, y0, dx, dy, degdeb, degfin);
     298  if (rc != 0) return;
     299  DrawArc(x0, y0, dx, dy, degdeb, degfin);
     300}
     301
     302/* --Methode-- */
     303void PIGraphicGen::Draw3PtFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     304                               PIGrCoord x3, PIGrCoord y3)
     305  // Trace d'un arc de cercle passant par 3 points
     306{
     307  double x0, y0;
     308  double dx, dy;
     309  double degdeb, degfin;
     310  int rc;
     311  rc = ComputeArcFrom3Pt(x1, y1, x2, y2, x3, y3, x0, y0, dx, dy, degdeb, degfin);
     312  if (rc != 0) return;
     313  DrawFArc(x0, y0, dx, dy, degdeb, degfin);
     314}
     315
     316/* --Methode-- */
     317int PIGraphicGen::ComputeArcFrom3Pt(double x1, double y1, double x2, double y2,
     318                                    double x3, double y3, double& x0, double& y0,
     319                                    double& dx, double& dy, double& degdeb, double& degfin)
     320{
     321  x0 = y0 = dx = dy = 0.;
     322  degdeb = degfin = 0.;
     323  double px[2], py[2];
     324  cout << "DBG - Arc3Pt" << x1 << "," << y1 << " - "
     325       << x2 << "," << y2 << " - "
     326       << x3 << "," << y3 << endl;
     327  // Milieu de M1-M2
     328  px[0] = (x1+x2)*0.5;
     329  py[0] = (y1+y2)*0.5;
     330  // Milieu de M2-M3
     331  px[1] = (x2+x3)*0.5;
     332  py[1] = (y2+y3)*0.5;
     333  double delx, dely;
     334  double a[2], b[2];
     335  bool xcst[2];
     336  for(int i=0; i<2; i++) {
     337    if (i == 0) {
     338      delx = x2-x1;
     339      dely = y2-y1;
     340    }
     341    else {
     342      delx = x3-x2;
     343      dely = y3-y2;
     344    }
     345    if ((fabs(delx) > PETIT_DBLE) && (fabs(dely) > PETIT_DBLE)) {
     346      // Direction perpendiculaire a M1-M2 , M2-M3
     347      double alpha = atan2( dely, delx) + M_PI/2.;
     348      a[i] = tan(alpha);
     349      b[i] = py[i]-a[i]*px[i];
     350      xcst[i] = false;
     351    }
     352    else if (fabs(delx) > PETIT_DBLE) {
     353      a[i] = b[i] = px[i];
     354      xcst[i] = true;
     355    }
     356    else if (fabs(dely) > PETIT_DBLE) {
     357      a[i] = 0.; b[i] = py[i];
     358      xcst[i] = false;
     359    }
     360    else {
     361      cerr << " PIGraphicGen::ComputeArcFrom3Pt()/Error - delx=" << delx
     362           << " dely=" << dely << " (=0) for i=" << i << endl;
     363      return(1);
     364    }
     365  }
     366  if (xcst[0] && xcst[1]) {
     367    cerr << " PIGraphicGen::ComputeArcFrom3Pt()/Error - xcst[0]&&xcst[1]" << endl;
     368    return(2);
     369  }
     370  double xc,yc;
     371  double dela = a[1]-a[0];
     372  if (xcst[0] || xcst[1]) {
     373    if (xcst[0]) {
     374      xc = px[0];  yc = a[1]*xc+b[1];
     375    }
     376    else {
     377      xc = px[1];  yc = a[0]*xc+b[0];
     378    }
     379  }
     380  else {
     381    if (fabs(dela) < PETIT_DBLE) {
     382      cerr << " PIGraphicGen::ComputeArcFrom3Pt()/Error - a[1]-a[0]=" << dela << endl;
     383      return(3);   
     384    }
     385    xc = (b[0]-b[1])/dela;  yc = a[0]*xc+b[0];
     386  }
     387  delx = x1-xc;
     388  dely = y1-yc;
     389  double r = sqrt(delx*delx+dely*dely);
     390  double ang1 = atan2(dely, delx);
     391  delx = x3-xc;
     392  dely = y3-yc;
     393  double ang2 = atan2(dely, delx);
     394  x0 = (xc-r);
     395  y0 = (yc-r);
     396  dx = dy = 2.*r;
     397  degdeb = -ang1*180./M_PI;
     398  degfin = -ang2*180./M_PI;
     399  cout << "DBG - Arc3Pt-2  " << xc << "," << yc << " R=" << r << " deg= "
     400       << degdeb << " :: " << degfin << endl;
     401  return(0);
     402}
    280403
    281404/* --Methode-- */
  • trunk/SophyaPI/PI/pigraphgen.h

    r2138 r2242  
    104104                              double degdeb, double degfin)                            = 0;
    105105
     106  virtual void       Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     107                                PIGrCoord x3, PIGrCoord y3);
     108  virtual void       Draw3PtFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     109                                 PIGrCoord x3, PIGrCoord y3);
     110  static  int        ComputeArcFrom3Pt(double x1, double y1, double x2, double y2,
     111                                       double x3, double y3, double& x0, double& y0,
     112                                       double& dx, double& dy, double& degdeb, double& degfin);
     113 
     114
    106115  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0)                            = 0;
    107116  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)                    = 0;
  • trunk/SophyaPI/PI/pigraphuc.cc

    r2166 r2242  
    653653
    654654/* --Methode-- */
     655void PIGraphicUC::Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     656                             PIGrCoord x3, PIGrCoord y3)
     657  // Trace d'un arc de cercle passant par 3 points
     658{
     659  if (!mGrC) return;
     660  double xf1, xf2, xf3;
     661  double yf1, yf2, yf3;
     662  UC2GrC(x1, y1, xf1, yf1);
     663  UC2GrC(x2, y2, xf2, yf2);
     664  UC2GrC(x3, y3, xf3, yf3);
     665  mGrC->Draw3PtArc(xf1, yf1, xf2, yf2, xf3, yf3);
     666}
     667
     668/* --Methode-- */
     669void PIGraphicUC::Draw3PtFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     670                              PIGrCoord x3, PIGrCoord y3)
     671  // Trace d'un arc de cercle passant par 3 points
     672{
     673  if (!mGrC) return;
     674  double xf1, xf2, xf3;
     675  double yf1, yf2, yf3;
     676  UC2GrC(x1, y1, xf1, yf1);
     677  UC2GrC(x2, y2, xf2, yf2);
     678  UC2GrC(x3, y3, xf3, yf3);
     679  mGrC->Draw3PtFArc(xf1, yf1, xf2, yf2, xf3, yf3);
     680}
     681
     682
     683/* --Methode-- */
    655684void PIGraphicUC::DrawMarker(PIGrCoord x0, PIGrCoord y0)
    656685{
  • trunk/SophyaPI/PI/pigraphuc.h

    r1935 r2242  
    6868  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    6969                              double degdeb, double degfin);
     70  virtual void       Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     71                                PIGrCoord x3, PIGrCoord y3);
     72  virtual void       Draw3PtFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     73                                 PIGrCoord x3, PIGrCoord y3);
     74  static  int        ComputeArcFrom3Pt(PIGrCoord& x1, PIGrCoord& y1,
     75                                       PIGrCoord& x2, PIGrCoord& y2,
     76                                       PIGrCoord& x2, PIGrCoord& y2,
     77                                       PIGrCoord& x0, PIGrCoord& y0,
     78                                       PIGrCoord& dx, PIGrCoord& dy,
     79                                       double& degdeb, double& degfin);
    7080 
    7181  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
     
    138148
    139149protected:
    140 
     150 
    141151  PIGraphicGen* mGrC;
    142152
  • trunk/SophyaPI/PI/pigratt.cc

    r2138 r2242  
    7777// int  DecodeAttStrings(vector<string> & att, bool rmdecatt=true)
    7878//      Décode les attributs  à partir du vecteur de string "att".
    79 //      Si Si "rmdecatt == true", les attributs décodés sont supprimés du
     79//      Si "rmdecatt == true", les attributs décodés sont supprimés du
    8080//      vecteur de départ.
     81// unsigned long DecodeTextPosDirAtt(vector<string> & att, bool rmdecatt=true)
     82//      Décode les attributs de direction et de positionnement de tracé de texte
     83//      à partir du vecteur de string "att" (méthode statique).
     84//      Si "rmdecatt == true", les attributs décodés sont supprimés du
     85//      vecteur de départ.
     86//      Retourne le flag de positionnement.
    8187//--
    8288
     
    499505  return(ndec);
    500506}
     507
     508int PIGraphicAtt::DecodeTextPosDirAtt(vector<string> & att, unsigned long& tdirpos,
     509                                   bool rmdecatt)
     510{
     511  if (att.size() == 0)  return(0); 
     512  tdirpos = PI_HorizontalLeft | PI_VerticalBottom | PI_TextDirectionHorizontal;
     513  int ndec = att.size();
     514  vector<string> udopt;
     515  int k;
     516  for( k=0; k<att.size(); k++ ) {
     517    string& opts = att[k];
     518    if (opts == "horizleft")  {
     519      tdirpos &= (! PI_HorizontalPosition);
     520      tdirpos |= PI_HorizontalLeft;
     521    }
     522    else if (opts == "horizcenter") {
     523      tdirpos &= (! PI_HorizontalPosition);
     524      tdirpos |= PI_HorizontalCenter;
     525    }
     526    else if (opts == "horizright") {
     527      tdirpos &= (! PI_HorizontalPosition);
     528      tdirpos |= PI_HorizontalRight;
     529    }
     530    else if (opts == "vertbottom") {
     531      tdirpos &= (! PI_VerticalPosition);
     532      tdirpos |= PI_VerticalBottom;
     533    }
     534    else if (opts == "vertcenter") {
     535      tdirpos &= (! PI_VerticalPosition);
     536      tdirpos |= PI_VerticalCenter;
     537    }
     538    else if (opts == "verttop") {
     539      tdirpos &= (! PI_VerticalPosition);
     540      tdirpos |= PI_VerticalTop;
     541    }
     542    else if (opts == "textdirhoriz") {
     543      tdirpos &= (! PI_TextDirection);
     544    }
     545    else if (opts == "textdirvertup") {
     546      tdirpos &= (! PI_TextDirection);
     547      tdirpos |= PI_TextDirectionVerticalUp;
     548    }
     549    else if (opts == "textdirvertdown") {
     550      tdirpos &= (! PI_TextDirection);
     551      tdirpos |= PI_TextDirectionVerticalDown;
     552    }
     553    else {
     554      ndec--;
     555      if (rmdecatt)  udopt.push_back(opts);   
     556    }
     557  }
     558  if (rmdecatt)  att = udopt;
     559  return(ndec);
     560 
     561}
  • trunk/SophyaPI/PI/pigratt.h

    r1970 r2242  
    3333  virtual void   UpdateFrom(PIGraphicAtt const & att);
    3434  virtual int    DecodeAttStrings(vector<string> & att, bool rmdecatt=true);
    35 
     35  // decodage des attributs de positions et direction de trace de texte
     36  static  int    DecodeTextPosDirAtt(vector<string> & att, unsigned long& tdirpos,
     37                                     bool rmdecatt=true);
    3638// Changement des attributs graphiques
    3739  inline void    SetColAtt(PIColors fg=PI_NotDefColor,
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r2119 r2242  
    244244      continue;
    245245    }
     246    if (opts.substr(0,10) == "defdrrect=") {
     247      double x1 = 0.1;
     248      double y1 = 0.1;
     249      double x2 = 0.9;
     250      double y2 = 0.9;
     251      sscanf(opts.substr(10).c_str(),"%lg,%lg,%lg,%lg",&x1, &x2,&y1,&y2);
     252      SetDefaultDrawRectangle(x1, y1, x2, y2, true);
     253      continue;
     254    }
    246255    if (opts == "linx") {
    247256      fglinlog = true;  fglogx = false;
  • trunk/SophyaPI/PI/piversion.h

    r2230 r2242  
    22#define PIVERSION_H_SEEN
    33
    4 #define PI_VERSIONNUMBER  3.83
     4#define PI_VERSIONNUMBER  3.85
    55
    66#endif
  • trunk/SophyaPI/PI/piyfxdrw.cc

    r2115 r2242  
    188188PIFuncDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
    189189{
     190  if (mFunc == NULL) return;
     191
    190192  PIGrCoord x1, x2, y1, y2;
    191193  g->GetGrSpace(x1, x2, y1, y2);
Note: See TracChangeset for help on using the changeset viewer.