Changeset 4070 in Sophya


Ignore:
Timestamp:
May 9, 2012, 11:32:27 PM (13 years ago)
Author:
ansari
Message:

Trace en coordonnees polaires (PINTuple) et trace d'axes polaires (piaxes.h .cc)
et adaptation de PIElDrawer et PIAxesTools (piaxestools.h .cc)

Reza, 9 Mai 2012

Location:
trunk/SophyaPI/PI
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/Makefile

    r4059 r4070  
    7878  pimsghandler.h picolist.h pipixutils.h picmap.h picmapx.h picmapgen.h \
    7979  pifontx.h pifontgen.h pigrcoord.h pilineatt.h pigratt.h pidrawer.h \
    80   pibwdggen.h pigraphx.h pievthandler.h psfile.h
     80  ucckprot.h pibwdggen.h pigraphx.h pievthandler.h psfile.h
    8181        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  piaxes.cc
    8282 
  • trunk/SophyaPI/PI/piaxes.cc

    r4059 r4070  
    1212#include "piaxes.h"
    1313#include "pidrawer.h"
     14#include "ucckprot.h"
    1415
    1516//++
     
    1920//
    2021//      Classe gestionnaire de tracé d'axes. A utiliser dans
    21 //      un objet PIDrawer.
     22//      un objet PIDrawer. Ajout trace d'axes polaires en Mai 2012.
    2223//--
    2324//++
     
    4445  ConfigureAutoFontSize(true, PIDrawer::GetGlDefAutoFontSizeFrac());
    4546  ConfigureAxesCenter();
     47  ConfigurePolar();
    4648  setupDone = false;
    4749}
     
    120122  }
    121123
    122   if (flags & kCentAxes) {
    123 
     124  if (flags & kPolarAxes)  {  // axes polaires
     125    //    g->DrawLine(xMin, 0., xMax, 0.);
     126    //    g->DrawLine(0., yMin, 0., yMax);
     127    double rr=fabs(xMin);
     128    double rmin=0., rmax=rr;
     129    rr=fabs(xMax);  if (rr>rmax) rmax=rr;   
     130    rr=fabs(yMin);  if (rr>rmax) rmax=rr;   
     131    rr=fabs(yMax);  if (rr>rmax) rmax=rr;
     132    UC_CheckMinMaxDiff(rmin,rmax);
     133    if (rmin<0.)  { rmax-=(2.*rmin);  rmin=0.; }
     134    vector<double> lesradius,lesrad2;
     135    PIAxes::BestTicks(rmin,rmax,polNRadius,lesradius,lesrad2);
     136    double delta_r=(rmax-rmin)/(double)polNRadius;
     137    double delta_ang=M_PI/(double)polNAng;
     138    double xa,ya,ang;
     139    char sbuff[64];
     140    for(size_t nn=0; nn<lesradius.size(); nn++) {
     141      rr=lesradius[nn];
     142      if (rr<1.e-3*rmax) continue;
     143      //      cout << " *DBG*PIAxes* rmin,rmax=" << rmin << "," << rmax << " rr[" << nn << "]=" << rr << endl;
     144      g->DrawCircle(0.,0.,rr);
     145      sprintf(sbuff,"%g",rr);
     146      rr+=0.1*delta_r; 
     147      xa=cos(-0.2)*rr;  ya=sin(-0.2)*rr;
     148      g->DrawString(xa,ya,sbuff,PI_HorizontalCenter|PI_VerticalCenter);
     149      xa=cos(M_PI-0.2)*rr;  ya=sin(M_PI-0.2)*rr;
     150      g->DrawString(xa,ya,sbuff,PI_HorizontalCenter|PI_VerticalCenter);
     151    }
     152    for(int nn=0; nn<polNAng; nn++) {
     153      ang=(double)nn*delta_ang;
     154      xa=cos(ang+polThetaOffset)*rmax*1.03;
     155      ya=sin(ang+polThetaOffset)*rmax*1.03;
     156      g->DrawLine(-xa, -ya, xa, ya);
     157      sprintf(sbuff,"%g",ang*180./M_PI);
     158      xa*=1.03;  ya*=1.03;
     159      g->DrawString(xa,ya,sbuff,PI_HorizontalCenter|PI_VerticalCenter);
     160      sprintf(sbuff,"%g",ang*180./M_PI+180.);
     161      g->DrawString(-xa,-ya,sbuff,PI_HorizontalCenter|PI_VerticalCenter);
     162    }
     163   
     164  }  // --- FIN trace d'axes polaires
     165
     166  if (flags & kCentAxes)  {   // axes X-Y centres
    124167    // Les axes
    125168    double x0axes = (xMin+xMax)/2.,  y0axes = (yMin+yMax)/2.;
     
    140183    g->DrawArrowMarker(x0axes, yMax, x0axes, ym2, true);
    141184    // La grille en pointilles
    142 
    143185    if (flags & kGridOn) DrawGrid(g);
    144186 
    145     // Les ticks majeurs
    146  
     187    // Les ticks majeurs 
    147188    if ((flags & kTicks) && (flags & kMajTicks)) {
    148189        DrawHTicks(g, y0axes, xMajTickLen, xMajTickLen, xMajTicks);
    149190        DrawVTicks(g, x0axes, yMajTickLen, yMajTickLen, yMajTicks);
    150191    }
    151    
    152     // Les ticks mineurs
    153  
     192    // Les ticks mineurs 
    154193    if ((flags & kTicks) && (flags & kMinTicks)) {
    155194        DrawHTicks(g, y0axes, xMinTickLen, xMinTickLen, xMinTicks);
    156195        DrawVTicks(g, x0axes, yMinTickLen, yMinTickLen, yMinTicks);
    157     }
    158    
    159     // Les labels
    160    
     196    }   
     197    // Les labels   
    161198    if (flags & kLabelsH) {
    162199      double declab = 2*xMajTickLen;
     
    173210        DrawVLabels(g, x0axes+declab, yMajTicks, PI_HorizontalRight);
    174211    }
    175    
    176   }
     212  }   //--- FIN trace axes X-Y centres
    177213 
    178   if (flags & kBoxAxes) {
    179  
    180     // La boite
    181    
     214  if (flags & kBoxAxes) { 
     215    // La boite   
    182216    g->DrawLine(xMin, yMin, xMax, yMin);
    183217    g->DrawLine(xMax, yMin, xMax, yMax);
    184218    g->DrawLine(xMax, yMax, xMin, yMax);
    185219    g->DrawLine(xMin, yMax, xMin, yMin);
    186 
    187220    // Longueur des ticks
    188221    double extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0;
     
    194227    double extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0;
    195228    double intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0;
    196 
    197229    // La grille en pointilles
    198 
    199230    if (flags & kGridOn) DrawGrid(g);
    200 
    201231    // Les ticks majeurs
    202  
    203232    if ((flags & kTicks) && (flags & kMajTicks)) {
    204233        DrawHTicks(g, yMin, intXMajTickLen, extXMajTickLen, xMajTicks);
     
    207236        DrawVTicks(g, xMax, intYMajTickLen, extYMajTickLen, yMajTicks);
    208237    }
    209    
    210     // Les ticks mineurs
    211  
     238    // Les ticks mineurs 
    212239    if ((flags & kTicks) && (flags & kMinTicks)) {
    213240        DrawHTicks(g, yMin, intXMinTickLen, extXMinTickLen, xMinTicks);
     
    216243        DrawVTicks(g, xMax, intYMinTickLen, extYMinTickLen, yMinTicks);
    217244    }
    218 
    219 
    220     // Les labels
    221    
     245    // Les labels   
    222246    if (flags & kLabelsH) {
    223247      double declab = xMajTickLen;
     
    240264      }
    241265    }
    242   }
    243   g->Clip();
     266  }   // --- FIN trace BoxAxes
     267  //  g->Clip();
    244268 
    245269}
  • trunk/SophyaPI/PI/piaxes.h

    r3562 r4070  
    1414  kCentAxes    = 0x0001,
    1515  kBoxAxes     = 0x0002,
    16   kTicks       = 0x0004,
    17   kGridOn      = 0x0008,
     16  kPolarAxes   = 0x0004,
    1817
    19   kIntTicks    = 0x0010,
    20   kExtTicks    = 0x0020,
    21   kMajTicks    = 0x0040,
    22   kMinTicks    = 0x0080,
     18  kTicks       = 0x0010,
     19  kGridOn      = 0x0020,
     20  kIntTicks    = 0x0100,
     21  kExtTicks    = 0x0200,
     22  kMajTicks    = 0x0400,
     23  kMinTicks    = 0x0800,
    2324
    2425  kLabelsH     = 0x1000,
     
    5253    {   DrawXYAxes(g, gratt, xmin, xmax, ymin, ymax, flags, axesAFSz, fontSz); }
    5354
     55
    5456  virtual void      DrawXCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags,
    5557                                 string const& xLabel);
     
    6062  void  ConfigureTicks(int ntickx=10, int nticky=12,
    6163                       double majtl=0.016, double mintl=0.01);
     64  //  Nb de cercles et nb de droites theta=Cte traces en coordonnees polaires
     65  inline void  ConfigurePolar(int nradius=5, int nang=6, double thetaoffset=0.)
     66    { polNRadius=nradius; polNAng=nang; polThetaOffset=thetaoffset; }
    6267  //  Choix de taille automatique de fontes
    6368  void  ConfigureAutoFontSize(bool afsz=true, double fszf=0.04);
     
    107112  double xMajTickLen,  xMinTickLen;
    108113  double yMajTickLen,  yMinTickLen;
    109   bool axesCenter; double axesCentX0,axesCentY0;
    110 
     114  bool axesCenter;
     115  double axesCentX0,axesCentY0;
     116//--- PolarAxe   
     117  int polNRadius, polNAng; // Nb de cercles et nb de droites theta=Cte
     118  double polThetaOffset;   // Offset de l'angle 0 (en radian) par rapport au systeme de coordonnees x-y
    111119};
    112120
  • trunk/SophyaPI/PI/piaxestools.cc

    r3558 r4070  
    131131cpx = spx+0.25*bsx;
    132132cpy += spycb+bsycb;
    133 mCkb[5] = new PICheckBox(this,"Centerd-Axes", 2005, bsx*1.5, bsycb, cpx, cpy);
     133// mCkb[5] = new PICheckBox(this,"Centerd-Axes", 2005, bsx*1.5, bsycb, cpx, cpy);
     134mCkb[5] = NULL;
     135mOpt[0] = new PIOptMenu(this,"TypeAxes",1.5*bsx,bsycb,cpx,cpy);
     136mOpt[0]->AppendItem("BoxAxes",2021); 
     137mOpt[0]->AppendItem("CenteredAxes",2022); 
     138mOpt[0]->AppendItem("PolarAxes",2023);   
     139
    134140cpx += bsx*1.5+3*spx;
    135141mCkb[2] = new PICheckBox(this,"Grid", 2002, bsx*1.5, bsycb, cpx, cpy);
    136 mCkb[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     142// mCkb[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    137143mCkb[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    138144
     
    170176mBut[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    171177 cpx += spx+0.5*bsx;
    172 mOpt = new PIOptMenu(this,"choix-action",1.5*bsx,bsy,cpx,cpy);
    173 mOpt->AppendItem("Transl X",2850);  // mTypAction=0
    174 mOpt->AppendItem("Transl Y",2851);  // mTypAction=1
    175 mOpt->AppendItem("Zoom X",2852);    // mTypAction=2
    176 mOpt->AppendItem("Zoom Y",2853);    // mTypAction=3
    177 mOpt->AppendItem("Zoom X-Y",2854);  // mTypAction=4
    178 mOpt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    179  string sdum="Transl X"; mOpt->SetValueStr(sdum); mTypAction=0;
     178mOpt[1] = new PIOptMenu(this,"choix-action",1.5*bsx,bsy,cpx,cpy);
     179mOpt[1]->AppendItem("Transl X",2850);  // mTypAction=0
     180mOpt[1]->AppendItem("Transl Y",2851);  // mTypAction=1
     181mOpt[1]->AppendItem("Zoom X",2852);    // mTypAction=2
     182mOpt[1]->AppendItem("Zoom Y",2853);    // mTypAction=3
     183mOpt[1]->AppendItem("Zoom X-Y",2854);  // mTypAction=4
     184mOpt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     185 string sdum="Transl X"; mOpt[1]->SetValueStr(sdum); mTypAction=0;
    180186 cpx += spx+1.5*bsx;
    181187mBut[6] = new PIButton(this,">",2803,0.5*bsx,bsy,cpx,cpy);
     
    196202for(i=0;i<2;i++) delete mText[i];
    197203for(i=0;i<8;i++) delete mBut[i];
    198 for(i=0;i<8;i++) delete mCkb[i];
    199 delete mOpt;
     204for(i=0;i<7;i++)
     205  if (mCkb[i]) delete mCkb[i];
     206for(i=0;i<2;i++) delete mOpt[i];
    200207}
    201208
     
    231238  if (scd->GetAxesFlags() & kGridOn) mCkb[2]->SetState(true);
    232239  else mCkb[2]->SetState(false);
    233   if (scd->GetAxesFlags() & kCentAxes) mCkb[5]->SetState(true);
    234   else mCkb[5]->SetState(false);
     240  //  if (scd->GetAxesFlags() & kCentAxes) mCkb[5]->SetState(true);
     241  //  else mCkb[5]->SetState(false);
     242  if (scd->GetAxesFlags() & kCentAxes) mOpt[0]->SetValue(2022);
     243  else if (scd->GetAxesFlags() & kPolarAxes)  mOpt[0]->SetValue(2023);
     244  else mOpt[0]->SetValue(2021);
    235245  if (scd->GetAxesFlags() & kMinTicks) mCkb[6]->SetState(true);
    236246  else mCkb[6]->SetState(false);
     
    247257  mCkb[3]->SetState(false);
    248258  mCkb[4]->SetState(false);
    249   mCkb[5]->SetState(false);
     259  //  mCkb[5]->SetState(false);
     260  mOpt[0]->SetValue(2021);
    250261  mCkb[6]->SetState(false);
    251262  mCkb[7]->SetState(true);
     
    304315  if (mCkb[2]->GetState()) flags |= kGridOn;
    305316  else  flags &= ~kGridOn;
    306   if (mCkb[5]->GetState()) { flags |= kCentAxes;  flags &= ~kBoxAxes; }
    307   else { flags &= ~kCentAxes;  flags |= kBoxAxes; }
     317  PIMessage typax=mOpt[0]->GetValue();
     318  if (typax==2022)   { flags |= kCentAxes;  flags &= ~(kBoxAxes|kPolarAxes); }
     319  else if (typax==2023)  { flags |= kPolarAxes;  flags &= ~(kBoxAxes|kCentAxes); }
     320  else { flags |= kBoxAxes; flags &= ~(kCentAxes|kPolarAxes);}
    308321  if (mCkb[6]->GetState()) flags |= kMinTicks;
    309322  else  flags &= ~kMinTicks;
  • trunk/SophyaPI/PI/piaxestools.h

    r2184 r4070  
    4141  PIText* mText[2];
    4242  PICheckBox* mCkb[8];
    43   PIOptMenu * mOpt;
     43  PIOptMenu * mOpt[2];
    4444  unsigned short mTypAction;
    4545  double mSclAction;
  • trunk/SophyaPI/PI/pieldrw.cc

    r3665 r4070  
    552552    else if (opts == "finecenteredaxesgrid")
    553553      SetAxesFlags(kCentAxes | kTicks | kMajTicks | kMinTicks | kLabels | kGridOn);
     554    else if (opts == "polaraxes")
     555      SetAxesFlags(kPolarAxes);
     556    else if (opts.substr(0,10) == "polaraxes=") {
     557      SetAxesFlags(kPolarAxes);
     558      int nradius=5,nang=6;
     559      int thetaoffdeg=0;
     560      sscanf(opts.substr(10).c_str(),"%d,%d,%d",&nradius,&nang,&thetaoffdeg);
     561      double thetaoffset=(double)thetaoffdeg*M_PI/180.;
     562      axeDr.ConfigurePolar(nradius,nang,thetaoffset);
     563    }
    554564    else if (opts == "axesnone")
    555565      SetAxesFlags(kAxesNone);
  • trunk/SophyaPI/PI/smakefile

    r4059 r4070  
    7878  pimsghandler.h picolist.h pipixutils.h picmap.h picmapx.h picmapgen.h \
    7979  pifontx.h pifontgen.h pigrcoord.h pilineatt.h pigratt.h pidrawer.h \
    80   pibwdggen.h pigraphx.h pievthandler.h psfile.h
     80  ucckprot.h pibwdggen.h pigraphx.h pievthandler.h psfile.h
    8181        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  piaxes.cc
    8282 
Note: See TracChangeset for help on using the changeset viewer.