Polygon
::Polygon(QList<QPointF>
*polygonPointList, qreal minX, qreal maxX, qreal minY, qreal maxY,
QColor color
){
_pen->setColor(color);
_rectWidth = maxX-minX;
_rectHeight = maxY-minY;
_rectX = -(_rectWidth)/2.0;
_rectY = -(_rectHeight)/2.0;
_polygonPath->moveTo(polygonPointList->takeAt(0));
while(!polygonPointList->isEmpty()){
_polygonPath->lineTo(polygonPointList->takeAt(0));
}
}
QRectF Polygon
::boundingRect() const {
qreal adjustment = 2.000;
return QRectF(_rectX
-adjustment,_rectY
-adjustment,_rectWidth
+2*adjustment,_rectHeight
+2*adjustment
);
}
{
painter->setPen(*_pen);
painter->drawPath(*_polygonPath);
return;
}
Polygon::Polygon(QList<QPointF> *polygonPointList, qreal minX, qreal maxX, qreal minY, qreal maxY, QColor color)
{
_pen = new QPen();
_pen->setColor(color);
_rectWidth = maxX-minX;
_rectHeight = maxY-minY;
_rectX = -(_rectWidth)/2.0;
_rectY = -(_rectHeight)/2.0;
_polygonPath = new QPainterPath();
_polygonPath->moveTo(polygonPointList->takeAt(0));
while(!polygonPointList->isEmpty()){
_polygonPath->lineTo(polygonPointList->takeAt(0));
}
}
QRectF Polygon::boundingRect() const
{
qreal adjustment = 2.000;
return QRectF(_rectX-adjustment,_rectY-adjustment,_rectWidth+2*adjustment,_rectHeight+2*adjustment);
}
void Polygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->setPen(*_pen);
painter->drawPath(*_polygonPath);
return;
}
To copy to clipboard, switch view to plain text mode
Bookmarks