本文整理汇总了C++中QPolygonF::front方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygonF::front方法的具体用法?C++ QPolygonF::front怎么用?C++ QPolygonF::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygonF
的用法示例。
在下文中一共展示了QPolygonF::front方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getScaledPosition
/**
* Draw the arrow triangle.
*
* @param[in] painter Painter that must be used.
* @param[in] plot Plot where arrow must be plotted.
*/
void Arrow2D::drawArrow(QPainter &painter, Plot2D *plot){
painter.setPen(m_arrowLinePen);
painter.setBrush(m_arrowBrush);
const auto initialPoint = getScaledPosition(m_pivot, plot);
const auto finalPoint = getScaledPosition(m_finalPoint, plot);
const double angle = atan2(finalPoint.y() - initialPoint.y(), finalPoint.x() - initialPoint.x());
const double arrowLength = getScaledDimensionX(m_arrowLength, plot);
const double arrowWidth = getScaledDimensionX(m_arrowWidth, plot);
const QPointF p1(-m_arrowLength + finalPoint.x(), -m_arrowWidth * 0.5 + finalPoint.y());
const QPointF p2(-m_arrowLength + finalPoint.x(), m_arrowWidth * 0.5 + finalPoint.y());
QPolygonF arrow;
arrow << finalPoint << p1 << p2;
QTransform transform;
transform.rotateRadians(angle);
const QPolygonF rotatedArrow = transform.map(arrow);
const auto deltaPosition = arrow.front() - rotatedArrow.front();
QTransform translateTransform;
translateTransform.translate(deltaPosition.x(), deltaPosition.y());
const QPolygonF rotoTranslatedArros = translateTransform.map(rotatedArrow);
painter.drawPolygon(rotoTranslatedArros);
}
示例2: _drawPolygon
void _drawPolygon(QPainter *p, const QPolygonF &polygon) //画QPolygonF
{
//temp
p->drawPolygon(polygon);
QPointF A=polygon.operator [](polygon.size()-2);
QPointF B=polygon.operator [](polygon.size()-1);
_drawArrow(p,A,B);
//下面是强调起点的标志
QPen pen(Qt::darkYellow);
pen.setWidth(4);
p->setPen(pen);
p->drawPoint(polygon.front());
}