traceType Arc2D::arcLength() const { validate(); LOG_DEBUG("Startpoint x,y: " << m_firstPoint.x << ", " << m_firstPoint.y); LOG_DEBUG("Endpoint x,y: " << m_secondPoint.x << ", " << m_secondPoint.y); LOG_DEBUG("is clockwise : " << m_isClockwise); LOG_DEBUG("Magnitude is: " << radius()); traceType angle = spanAngle(); return angle * radius(); }
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { painter->setPen(pen()); painter->setBrush(brush()); painter->drawArc(rect(), startAngle(), spanAngle()); // fix me, need to adjust the rect size so that it's only as big as the arc // if (option->state & QStyle::State_Selected) // qt_graphicsItem_highlightSelected(this, painter, option); }
bool Arc2D::isPointOnArcWithDifferentQuadrant(const Quadrant2D& firstQuadrant, const Quadrant2D& secondQuadrant, const Quadrant2D& requestedQuadrant) const{ bool shouldIncrement(PI/2 < spanAngle()); Quadrant2D quadrant = firstQuadrant; while (shouldIncrement || (quadrant!= secondQuadrant)) { shouldIncrement = false; if (quadrant == requestedQuadrant) { return true; } quadrant.increment(m_isClockwise); } return false; }
bool Arc2D::isPointOnArcWithEqualQuadrant(const Point2D& firstPoint, const Point2D& requestedPoint, const bool& i_isClockwise) const { // it is in the same quadrant so we can do traceType firstPointAlpha(firstPoint.getAlpha()); traceType requestedPointAlpha(requestedPoint.getAlpha()); traceType spannedAngle(spanAngle()); if (!i_isClockwise) { if (firstPointAlpha < requestedPointAlpha) { if ((firstPointAlpha + spannedAngle) > requestedPointAlpha) { return true; } } } else { // clockwise if (firstPointAlpha > requestedPointAlpha) { if ((firstPointAlpha - spannedAngle) < requestedPointAlpha) { return true; } } } return false; }
int QElipseItem::GetSpanAngle() //获得跨度角度值 { int nspanAngle=spanAngle(); return nspanAngle/16; }