mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 01:51:49 +08:00
FIXED: JKQTPGeoEllipse is now correctly drawn with a nonzero angle
This commit is contained in:
parent
ed1204cea6
commit
ed8b23d7cf
@ -65,7 +65,7 @@ QVector<QPointF> JKQTPSplitEllipseIntoPoints(std::function<QPointF (QPointF)> fT
|
||||
const double sina=sin(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
|
||||
const double cosa=cos(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
|
||||
std::function<QPointF(double)> fell=[&](double t)->QPointF {
|
||||
return QPointF(x+a*cos(t)*cosa-b*sin(t)*sina, y+a*cos(t)*sina+b*sin(t)*cosa);
|
||||
return QPointF(x,y)+QPointF(a*cos(t)*cosa-b*sin(t)*sina, a*cos(t)*sina+b*sin(t)*cosa);
|
||||
};
|
||||
std::function<QPointF(double)> fxy = [&](double t) ->QPointF {
|
||||
return fTransform(fell(t));
|
||||
|
@ -455,16 +455,16 @@ void JKQTPGeoEllipse::drawInternal(JKQTPEnhancedPainter& painter, double angleSt
|
||||
auto fTransform=std::bind([](const JKQTPGeometricPlotElement* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
QPolygonF rect;
|
||||
if(mode==InternalDrawMode::Ellipse) {
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0,0,360);
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0,0,360,angle);
|
||||
} else if (mode==InternalDrawMode::Pie) {
|
||||
QPointF first, last;
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0, angleStart, angleStop, 0, nullptr, nullptr, &first, &last);
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0, angleStart, angleStop, angle, nullptr, nullptr, &first, &last);
|
||||
QPolygonF pie;
|
||||
pie<<last<<QPointF(x,y)<<first;
|
||||
rect.append(JKQTPSimplyfyLineSegemnts(JKQTPSplitPolylineIntoPoints(pie, fTransform)));
|
||||
} else if (mode==InternalDrawMode::Chord) {
|
||||
QPointF first, last;
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0, angleStart, angleStop, 0, nullptr, nullptr, &first, &last);
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0, angleStart, angleStop, angle, nullptr, nullptr, &first, &last);
|
||||
rect.append(JKQTPSimplyfyLineSegemnts(JKQTPSplitLineIntoPoints(QLineF(last, first), fTransform)));
|
||||
}
|
||||
painter.drawPolygon(rect);
|
||||
|
Loading…
Reference in New Issue
Block a user