void ResizableRectMarker
::paintArc1(int x,
int y,
int width,
int height,
QPainter* painter
) {
double radius = sqrt(pow(0.5*width,2)+pow(0.5*height,2));
double step = sqrt(pow(radius,2)-pow(0.5*width,2));
QPointF bottomRight
(x
+width,y
+height
);
QRectF rect
(topLeft, bottomRight
);
int startAngle = atan2(0.5*width,step)* 180 / M_PI * 16;
int spanAngle = 2*startAngle;
qDebug() << "start angle:" << startAngle << "|" << "spanAngle:" << spanAngle;
painter->drawArc(rect, startAngle, spanAngle);
}
void ResizableRectMarker::paintArc1(int x, int y, int width, int height, QPainter* painter)
{
double radius = sqrt(pow(0.5*width,2)+pow(0.5*height,2));
double step = sqrt(pow(radius,2)-pow(0.5*width,2));
QPointF topLeft(x,y);
QPointF bottomRight(x+width,y+height);
QRectF rect(topLeft, bottomRight);
int startAngle = atan2(0.5*width,step)* 180 / M_PI * 16;
int spanAngle = 2*startAngle;
qDebug() << "start angle:" << startAngle << "|" << "spanAngle:" << spanAngle;
painter->drawArc(rect, startAngle, spanAngle);
}
To copy to clipboard, switch view to plain text mode
the problem is the the arc drawn is not in the center, and also if the rectangle is not a square, the arc is wired.
Bookmarks