Changeset 2516 in Sophya for trunk/SophyaPI
- Timestamp:
- Mar 17, 2004, 7:04:25 PM (22 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/piaxes.cc
r2349 r2516 111 111 112 112 // Les axes 113 double x0axes = (xMin+xMax)/2.; 114 double y0axes = (yMin+yMax)/2.; 115 // POUR REZA: ici si on a demande de forcer les axes en x0,y0 116 // alors on le fait ici: il faut faire a peu pres ca: 117 // > if(getaxescenter()) getaxescenter(x0axes,y0axes); 118 if(x0axes<xMin || x0axes>xMax) x0axes = (xMin+xMax)/2.; 119 if(y0axes<yMin || y0axes>yMax) y0axes = (yMin+yMax)/2.; 113 120 114 g->DrawLine(xMin, (yMin+yMax)/2., xMax, (yMin+yMax)/2.);115 g->DrawLine( (xMin+xMax)/2., yMin, (xMin+xMax)/2., yMax);121 g->DrawLine(xMin, y0axes, xMax, y0axes); 122 g->DrawLine(x0axes, yMin, x0axes, yMax); 116 123 // PIArrowMarker amk = g->GetArrowMarker(); 117 124 // if (amk == PI_NotDefArrowMarker) … … 120 127 // g->SelArrowMarker(5, g->GetArrowMarker()); 121 128 double xm2 = g->DeltaUCX(xMax, yMajTickLen*2.); 122 g->DrawArrowMarker(xMax, (yMin+yMax)/2., xm2, (yMin+yMax)/2., true);129 g->DrawArrowMarker(xMax, y0axes, xm2, y0axes, true); 123 130 double ym2 = g->DeltaUCY(yMax, xMajTickLen*2.); 124 g->DrawArrowMarker( (xMin+xMax)/2., yMax, (xMin+xMax)/2., ym2, true);131 g->DrawArrowMarker(x0axes, yMax, x0axes, ym2, true); 125 132 // La grille en pointilles 126 133 … … 130 137 131 138 if (flags & kMajTicks) { 132 DrawHTicks(g, (yMin+yMax)/2., xMajTickLen, xMajTickLen, xMajTicks);133 DrawVTicks(g, (xMin+xMax)/2., yMajTickLen, yMajTickLen, yMajTicks);139 DrawHTicks(g, y0axes, xMajTickLen, xMajTickLen, xMajTicks); 140 DrawVTicks(g, x0axes, yMajTickLen, yMajTickLen, yMajTicks); 134 141 } 135 142 … … 137 144 138 145 if (flags & kMinTicks) { 139 DrawHTicks(g, (yMin+yMax)/2., xMinTickLen, xMinTickLen, xMinTicks);140 DrawVTicks(g, (xMin+xMax)/2., yMinTickLen, yMinTickLen, yMinTicks);146 DrawHTicks(g, y0axes, xMinTickLen, xMinTickLen, xMinTicks); 147 DrawVTicks(g, x0axes, yMinTickLen, yMinTickLen, yMinTicks); 141 148 } 142 149 … … 146 153 double declab = 2*xMajTickLen; 147 154 if (!aYdir) 148 DrawHLabels(g, (yMin+yMax)/2.-declab, xMajTicks, PI_VerticalTop);155 DrawHLabels(g, y0axes-declab, xMajTicks, PI_VerticalTop); 149 156 else 150 DrawHLabels(g, (yMin+yMax)/2.+declab, xMajTicks, PI_VerticalTop);157 DrawHLabels(g, y0axes+declab, xMajTicks, PI_VerticalTop); 151 158 152 159 declab = 2.*yMajTickLen; 153 160 if (!aXdir) 154 DrawVLabels(g, (xMin+xMax)/2.-declab, yMajTicks, PI_HorizontalRight);161 DrawVLabels(g, x0axes-declab, yMajTicks, PI_HorizontalRight); 155 162 else 156 DrawVLabels(g, (xMin+xMax)/2.+declab, yMajTicks, PI_HorizontalRight);163 DrawVLabels(g, x0axes+declab, yMajTicks, PI_HorizontalRight); 157 164 } 158 165 -
trunk/SophyaPI/PI/pidrawer.cc
r2503 r2516 65 65 SetAxesFlags(kAxesNone); // Pas de trace d'axes par defaut 66 66 SetAxesAutoFontSize(); 67 SetAxesCenter(); 67 68 68 69 mDndfg = false; // Pour controle de l'appel de Detach() si delete … … 142 143 //| kMajTicks , kMinTicks , kLabels , kGridOn 143 144 //| kAxesDflt , kAxesNone 145 // void SetAxesCenter(bool fset,double x0,double y0) 146 // Force axe center to be at (x0,y0) or let it be in the middle 144 147 // void SetAxesAutoFontSize(bool fg=true) 145 148 // Si "fg==true", la taille de la fonte pour les labels d'axes (chiffres) est … … 488 491 } 489 492 493 void 494 PIDrawer::SetAxesCenter(bool fset,double x0,double y0) 495 { 496 axesCenter = fset; 497 if(!axesCenter) return; 498 axesCentX0 = x0; 499 axesCentY0 = y0; 500 } 490 501 491 502 void -
trunk/SophyaPI/PI/pidrawer.h
r2503 r2516 30 30 31 31 virtual void SetAxesFlags(unsigned int flags=kAxesNone); 32 virtual void SetAxesCenter(bool fset=false,double x0=0.,double y0=0.); 32 33 inline void SetAxesAutoFontSize(bool fg=true) { axesAFSz = fg; } 33 34 … … 63 64 64 65 inline unsigned int GetAxesFlags() { return(axesFlags); } 65 inline bool isAxesAutoFontSize() { return axesAFSz; } 66 inline bool GetAxesCenter() { return(axesCenter); } 67 inline bool GetAxesCenter(double &x0,double& y0) 68 {x0=axesCentX0; y0=axesCentY0; return(axesCenter);} 69 inline bool isAxesAutoFontSize() { return axesAFSz; } 66 70 67 71 inline PIGraphicUC* GetGraphicUC() { return(mGrUC); } … … 128 132 unsigned int axesFlags; 129 133 bool axesAFSz; 134 bool axesCenter; double axesCentX0,axesCentY0; 130 135 PIBaseWdgGen* mBWdg; 131 136 PIGraphicUC* mGrUC; -
trunk/SophyaPI/PI/pieldrw.cc
r2503 r2516 563 563 else if (opts == "nogrid") 564 564 SetAxesFlags(GetAxesFlags() & ~kGridOn); 565 else if (opts.substr(0,11) == "axescenter=") { 566 if(opts == "axescenter=") { 567 SetAxesCenter(); 568 } else { 569 double x0=0., y0=0.; 570 sscanf(opts.substr(11).c_str(),"%lf,%lf",&x0,&y0); 571 SetAxesCenter(true,x0,y0); 572 } 573 } 565 574 566 575 else if (opts.substr(0,13) == "autofontsize=") { -
trunk/SophyaPI/PI/piyfxdrw.cc
r2242 r2516 4 4 5 5 #include "machdefs.h" 6 #include <stdlib.h> 7 #include <iostream> 6 8 #include <math.h> 7 9 #include "piyfxdrw.h" … … 54 56 mAy = ay; 55 57 mName = "YfXDrawer"; 58 NptDraw = 0; 56 59 } 57 60 … … 119 122 } 120 123 if (mSz <= 0) return; 124 NptDraw=0; 121 125 122 126 // Trace des markers … … 128 132 if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue; 129 133 g->DrawMarker(xp, yp); 134 NptDraw++; 130 135 } 131 136 } … … 134 139 135 140 // Trace des lignes 141 NptDraw=0; 136 142 double xp2, yp2; 137 143 if (mAy) { xp2 = mAx->Value(0); yp2 = mAy->Value(0); } … … 144 150 ((xp2 < xmin) || (xp2 > xmax) || (yp2 < ymin) || (yp2 > ymax)) ) continue; 145 151 g->DrawLine(xp, yp, xp2, yp2); 152 NptDraw++; 146 153 } 147 } 154 155 } 156 157 158 /* --Methode-- */ 159 double PIYfXDrawer::GetDistanceToPoint(double x, double y) 160 { 161 if(mSz<=0) return 1.e+9; 162 163 const int nessai = 100; 164 long inc = (NptDraw>nessai) ? (long)(NptDraw/nessai)+1 : 1; 165 166 double dist = -1.e+18; 167 long n = 0; 168 for(long i=0; i<mSz; i++) { 169 double xp,yp; 170 if(mAy) {xp=mAx->Value(i); yp=mAy->Value(i);} 171 else {xp=mAx->X(i); yp=mAx->Value(i);} 172 if(xp<XMin() || xp>XMax()) continue; 173 if(yp<YMin() || yp>YMax()) continue; 174 if(n%inc==0) { 175 xp = (xp-x)/(XMax()-XMin())/0.5; 176 yp = (yp-y)/(YMax()-YMin())/0.5; 177 xp = xp*xp+yp*yp; 178 if(dist<0. || xp<dist) dist = xp; 179 } 180 n++; 181 } 182 dist=sqrt(fabs(dist)); 183 //cout<<"PIYfXDrawer: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax() 184 // <<" mSz="<<mSz<<" inc="<<inc<<endl; 185 //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<" NptDraw="<<NptDraw<<endl; 186 187 return dist; 188 } 189 190 191 148 192 149 193 … … 176 220 /* --Methode-- */ 177 221 PIFuncDrawer::PIFuncDrawer(PIFuncDrawer::FUNC f) 178 : mFunc(f)222 : mFunc(f) 179 223 {} 180 224 … … 209 253 } 210 254 255 256 /* --Methode-- */ 257 double PIFuncDrawer::GetDistanceToPoint(double x, double y) 258 { 259 if(mFunc==NULL) return 1.e+9; 260 261 double xStep = (XMax()-XMin())/50; 262 double dist = -1.e+18; 263 for(double xx=XMin()+xStep; xx<XMax(); xx+=xStep) { 264 double xp = (xx-x)/(XMax()-XMin())/0.5; 265 double yp = (mFunc(xp)-y)/(YMax()-YMin())/0.5; 266 xp = xp*xp+yp*yp; 267 if(dist<0. || xp<dist) dist = xp; 268 } 269 dist=sqrt(fabs(dist)); 270 //cout<<"PIFuncDrawer: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()<<endl; 271 //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<endl; 272 273 return dist; 274 } -
trunk/SophyaPI/PI/piyfxdrw.h
r1904 r2516 25 25 virtual void UpdateLimits(); 26 26 27 27 // Renvoie une distance au point x,y 28 virtual double GetDistanceToPoint(double x, double y); 29 28 30 protected: 29 31 P1DArrayAdapter* mAx; … … 31 33 int mSz; 32 34 bool mAdDO; 35 long NptDraw; // nombre de points effectivement dessines dans la fenetre 33 36 }; 34 37 … … 44 47 45 48 virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 49 50 // Renvoie une distance au point x,y 51 virtual double GetDistanceToPoint(double x, double y); 52 46 53 protected: 47 54 FUNC mFunc;
Note:
See TracChangeset
for help on using the changeset viewer.