23 const double bbox_margins = 5;
29 , m_block_on_point_update(false)
30 , m_close_polygon_request(false)
32 setFlag(QGraphicsItem::ItemIsSelectable);
33 setFlag(QGraphicsItem::ItemIsMovable);
34 setFlag(QGraphicsItem::ItemSendsGeometryChanges);
51 if (childItems().contains(childView))
56 pointView->setParentItem(
this);
61 childItems()[0]->setAcceptHoverEvents(
true);
63 pointView->setVisible(
true);
74 return !childItems().empty() ? childItems().back()->scenePos() : QPointF();
90 for (QGraphicsItem* childItem : childItems()) {
91 childItem->setFlag(QGraphicsItem::ItemIsMovable);
92 childItem->setFlag(QGraphicsItem::ItemSendsGeometryChanges);
93 childItem->setAcceptHoverEvents(
false);
94 childItem->setCursor(Qt::SizeAllCursor);
119 painter->setRenderHints(QPainter::Antialiasing);
121 painter->drawPolyline(
m_polygon.toPolygon());
127 if (change == QGraphicsItem::ItemSelectedHasChanged)
135 IShape2DView::mouseMoveEvent(event);
161 const QRectF scene_rect =
m_polygon.boundingRect().marginsAdded(
162 QMarginsF(bbox_margins, bbox_margins, bbox_margins, bbox_margins));
164 m_bounding_rect = QRectF(0.0, 0.0, scene_rect.width(), scene_rect.height());
166 setPos(scene_rect.x(), scene_rect.y());
172 for (
auto* childView : childItems())
175 setPos(scene_rect.x(), scene_rect.y());
187 for (QGraphicsItem* childItem : childItems()) {
189 QPointF pos = view->scenePos();
191 view->updateParameterizedItem(pos);
198 for (QGraphicsItem* childItem : childItems())
199 childItem->setVisible(value);
Defines MaskItems classes.
Defines PolygonPointView class.
Defines PolygonView class.
Main interface class for views representing MaskItems, Projections on graphics scene.
qreal toSceneX(qreal value) const
void disconnectFromItem(SessionItem *item)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
qreal toSceneY(qreal value) const
static QPen getMaskPen(bool mask_value)
void setIsClosed(bool closed)
QVector< PolygonPointItem * > points() const
This is a View of polygon point for PolygonMaskItem.
void closePolygonRequest(bool)
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
void onClosePolygonRequest(bool value)
bool closePolygonIfNecessary()
Returns true if there was a request to close polygon (emitted by its start point),...
void onItemDestroyed() override
PolygonView(PolygonItem *item)
bool m_close_polygon_request
QPointF lastAddedPoint() const
Returns last added poligon point in scene coordinates.
void addView(IShape2DView *childView, int row) override
void update_view() override
void update_polygon()
Runs through all PolygonPointItem and calculate bounding rectangle. Determines position of the rectan...
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
QPainterPath shape() const override
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
SessionItem * parameterizedItem() const override
void update_points()
When polygon moves as a whole thing across the scene, given method updates coordinates of PolygonPoin...
bool m_block_on_point_update
void setChildrenVisible(bool value)
Base class for a GUI data item.