- Timestamp:
- May 9, 2012, 11:32:27 PM (13 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Makefile
r4059 r4070 78 78 pimsghandler.h picolist.h pipixutils.h picmap.h picmapx.h picmapgen.h \ 79 79 pifontx.h pifontgen.h pigrcoord.h pilineatt.h pigratt.h pidrawer.h \ 80 pibwdggen.h pigraphx.h pievthandler.h psfile.h80 ucckprot.h pibwdggen.h pigraphx.h pievthandler.h psfile.h 81 81 $(CXXCOMPILE) $(CXXTEMPFLG) -o $@ piaxes.cc 82 82 -
trunk/SophyaPI/PI/piaxes.cc
r4059 r4070 12 12 #include "piaxes.h" 13 13 #include "pidrawer.h" 14 #include "ucckprot.h" 14 15 15 16 //++ … … 19 20 // 20 21 // 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. 22 23 //-- 23 24 //++ … … 44 45 ConfigureAutoFontSize(true, PIDrawer::GetGlDefAutoFontSizeFrac()); 45 46 ConfigureAxesCenter(); 47 ConfigurePolar(); 46 48 setupDone = false; 47 49 } … … 120 122 } 121 123 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 124 167 // Les axes 125 168 double x0axes = (xMin+xMax)/2., y0axes = (yMin+yMax)/2.; … … 140 183 g->DrawArrowMarker(x0axes, yMax, x0axes, ym2, true); 141 184 // La grille en pointilles 142 143 185 if (flags & kGridOn) DrawGrid(g); 144 186 145 // Les ticks majeurs 146 187 // Les ticks majeurs 147 188 if ((flags & kTicks) && (flags & kMajTicks)) { 148 189 DrawHTicks(g, y0axes, xMajTickLen, xMajTickLen, xMajTicks); 149 190 DrawVTicks(g, x0axes, yMajTickLen, yMajTickLen, yMajTicks); 150 191 } 151 152 // Les ticks mineurs 153 192 // Les ticks mineurs 154 193 if ((flags & kTicks) && (flags & kMinTicks)) { 155 194 DrawHTicks(g, y0axes, xMinTickLen, xMinTickLen, xMinTicks); 156 195 DrawVTicks(g, x0axes, yMinTickLen, yMinTickLen, yMinTicks); 157 } 158 159 // Les labels 160 196 } 197 // Les labels 161 198 if (flags & kLabelsH) { 162 199 double declab = 2*xMajTickLen; … … 173 210 DrawVLabels(g, x0axes+declab, yMajTicks, PI_HorizontalRight); 174 211 } 175 176 } 212 } //--- FIN trace axes X-Y centres 177 213 178 if (flags & kBoxAxes) { 179 180 // La boite 181 214 if (flags & kBoxAxes) { 215 // La boite 182 216 g->DrawLine(xMin, yMin, xMax, yMin); 183 217 g->DrawLine(xMax, yMin, xMax, yMax); 184 218 g->DrawLine(xMax, yMax, xMin, yMax); 185 219 g->DrawLine(xMin, yMax, xMin, yMin); 186 187 220 // Longueur des ticks 188 221 double extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0; … … 194 227 double extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0; 195 228 double intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0; 196 197 229 // La grille en pointilles 198 199 230 if (flags & kGridOn) DrawGrid(g); 200 201 231 // Les ticks majeurs 202 203 232 if ((flags & kTicks) && (flags & kMajTicks)) { 204 233 DrawHTicks(g, yMin, intXMajTickLen, extXMajTickLen, xMajTicks); … … 207 236 DrawVTicks(g, xMax, intYMajTickLen, extYMajTickLen, yMajTicks); 208 237 } 209 210 // Les ticks mineurs 211 238 // Les ticks mineurs 212 239 if ((flags & kTicks) && (flags & kMinTicks)) { 213 240 DrawHTicks(g, yMin, intXMinTickLen, extXMinTickLen, xMinTicks); … … 216 243 DrawVTicks(g, xMax, intYMinTickLen, extYMinTickLen, yMinTicks); 217 244 } 218 219 220 // Les labels 221 245 // Les labels 222 246 if (flags & kLabelsH) { 223 247 double declab = xMajTickLen; … … 240 264 } 241 265 } 242 } 243 g->Clip();266 } // --- FIN trace BoxAxes 267 // g->Clip(); 244 268 245 269 } -
trunk/SophyaPI/PI/piaxes.h
r3562 r4070 14 14 kCentAxes = 0x0001, 15 15 kBoxAxes = 0x0002, 16 kTicks = 0x0004, 17 kGridOn = 0x0008, 16 kPolarAxes = 0x0004, 18 17 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, 23 24 24 25 kLabelsH = 0x1000, … … 52 53 { DrawXYAxes(g, gratt, xmin, xmax, ymin, ymax, flags, axesAFSz, fontSz); } 53 54 55 54 56 virtual void DrawXCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags, 55 57 string const& xLabel); … … 60 62 void ConfigureTicks(int ntickx=10, int nticky=12, 61 63 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; } 62 67 // Choix de taille automatique de fontes 63 68 void ConfigureAutoFontSize(bool afsz=true, double fszf=0.04); … … 107 112 double xMajTickLen, xMinTickLen; 108 113 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 111 119 }; 112 120 -
trunk/SophyaPI/PI/piaxestools.cc
r3558 r4070 131 131 cpx = spx+0.25*bsx; 132 132 cpy += 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); 134 mCkb[5] = NULL; 135 mOpt[0] = new PIOptMenu(this,"TypeAxes",1.5*bsx,bsycb,cpx,cpy); 136 mOpt[0]->AppendItem("BoxAxes",2021); 137 mOpt[0]->AppendItem("CenteredAxes",2022); 138 mOpt[0]->AppendItem("PolarAxes",2023); 139 134 140 cpx += bsx*1.5+3*spx; 135 141 mCkb[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); 137 143 mCkb[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 138 144 … … 170 176 mBut[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 171 177 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=0174 mOpt ->AppendItem("Transl Y",2851); // mTypAction=1175 mOpt ->AppendItem("Zoom X",2852); // mTypAction=2176 mOpt ->AppendItem("Zoom Y",2853); // mTypAction=3177 mOpt ->AppendItem("Zoom X-Y",2854); // mTypAction=4178 mOpt ->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);179 string sdum="Transl X"; mOpt ->SetValueStr(sdum); mTypAction=0;178 mOpt[1] = new PIOptMenu(this,"choix-action",1.5*bsx,bsy,cpx,cpy); 179 mOpt[1]->AppendItem("Transl X",2850); // mTypAction=0 180 mOpt[1]->AppendItem("Transl Y",2851); // mTypAction=1 181 mOpt[1]->AppendItem("Zoom X",2852); // mTypAction=2 182 mOpt[1]->AppendItem("Zoom Y",2853); // mTypAction=3 183 mOpt[1]->AppendItem("Zoom X-Y",2854); // mTypAction=4 184 mOpt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 185 string sdum="Transl X"; mOpt[1]->SetValueStr(sdum); mTypAction=0; 180 186 cpx += spx+1.5*bsx; 181 187 mBut[6] = new PIButton(this,">",2803,0.5*bsx,bsy,cpx,cpy); … … 196 202 for(i=0;i<2;i++) delete mText[i]; 197 203 for(i=0;i<8;i++) delete mBut[i]; 198 for(i=0;i<8;i++) delete mCkb[i]; 199 delete mOpt; 204 for(i=0;i<7;i++) 205 if (mCkb[i]) delete mCkb[i]; 206 for(i=0;i<2;i++) delete mOpt[i]; 200 207 } 201 208 … … 231 238 if (scd->GetAxesFlags() & kGridOn) mCkb[2]->SetState(true); 232 239 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); 235 245 if (scd->GetAxesFlags() & kMinTicks) mCkb[6]->SetState(true); 236 246 else mCkb[6]->SetState(false); … … 247 257 mCkb[3]->SetState(false); 248 258 mCkb[4]->SetState(false); 249 mCkb[5]->SetState(false); 259 // mCkb[5]->SetState(false); 260 mOpt[0]->SetValue(2021); 250 261 mCkb[6]->SetState(false); 251 262 mCkb[7]->SetState(true); … … 304 315 if (mCkb[2]->GetState()) flags |= kGridOn; 305 316 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);} 308 321 if (mCkb[6]->GetState()) flags |= kMinTicks; 309 322 else flags &= ~kMinTicks; -
trunk/SophyaPI/PI/piaxestools.h
r2184 r4070 41 41 PIText* mText[2]; 42 42 PICheckBox* mCkb[8]; 43 PIOptMenu * mOpt ;43 PIOptMenu * mOpt[2]; 44 44 unsigned short mTypAction; 45 45 double mSclAction; -
trunk/SophyaPI/PI/pieldrw.cc
r3665 r4070 552 552 else if (opts == "finecenteredaxesgrid") 553 553 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 } 554 564 else if (opts == "axesnone") 555 565 SetAxesFlags(kAxesNone); -
trunk/SophyaPI/PI/smakefile
r4059 r4070 78 78 pimsghandler.h picolist.h pipixutils.h picmap.h picmapx.h picmapgen.h \ 79 79 pifontx.h pifontgen.h pigrcoord.h pilineatt.h pigratt.h pidrawer.h \ 80 pibwdggen.h pigraphx.h pievthandler.h psfile.h80 ucckprot.h pibwdggen.h pigraphx.h pievthandler.h psfile.h 81 81 $(CXXCOMPILE) $(CXXTEMPFLG) -o $@ piaxes.cc 82 82
Note:
See TracChangeset
for help on using the changeset viewer.