FIXED: JKQTPGeoEllipse is now correctly drawn with a nonzero angle

This commit is contained in:
jkriege2 2023-07-21 19:27:57 +02:00
parent ed1204cea6
commit ed8b23d7cf
2 changed files with 4 additions and 4 deletions

View File

@ -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));

View File

@ -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);