22 const double bbox_margins = 5;
27 setFlag(QGraphicsItem::ItemIsSelectable);
28 setFlag(QGraphicsItem::ItemIsMovable);
29 setFlag(QGraphicsItem::ItemSendsGeometryChanges);
36 if (childItems().contains(childView))
41 pointView->setParentItem(
this);
46 childItems()[0]->setAcceptHoverEvents(
true);
48 pointView->setVisible(
true);
59 return childItems().size() ? childItems().back()->scenePos() : QPointF();
67 for (QGraphicsItem* childItem : childItems()) {
68 childItem->setFlag(QGraphicsItem::ItemIsMovable);
69 childItem->setFlag(QGraphicsItem::ItemSendsGeometryChanges);
70 childItem->setAcceptHoverEvents(
false);
71 childItem->setCursor(Qt::SizeAllCursor);
92 painter->setRenderHints(QPainter::Antialiasing);
100 painter->drawPolyline(
m_polygon.toPolygon());
103 painter->drawPolygon(
m_polygon.toPolygon());
108 if (change == QGraphicsItem::ItemSelectedHasChanged)
116 IShape2DView::mouseMoveEvent(event);
145 QRectF scene_rect =
m_polygon.boundingRect().marginsAdded(
146 QMarginsF(bbox_margins, bbox_margins, bbox_margins, bbox_margins));
148 m_bounding_rect = QRectF(0.0, 0.0, scene_rect.width(), scene_rect.height());
150 setPos(scene_rect.x(), scene_rect.y());
160 for (
auto childView : childItems())
163 setPos(scene_rect.x(), scene_rect.y());
175 for (QGraphicsItem* childItem : childItems()) {
177 QPointF pos = view->scenePos();
186 for (QGraphicsItem* childItem : childItems())
187 childItem->setVisible(value);
#define ASSERT(condition)
Defines MaskItems classes.
Defines PolygonPointView class.
Defines PolygonView class.
Main interface class for views representing MaskItems, Projections on graphics scene.
qreal toSceneX(const QString &property_name) const
qreal toSceneY(const QString &property_name) const
static QBrush getMaskBrush(bool mask_value)
static QPen getMaskPen(bool mask_value)
static const QString P_MASK_VALUE
static const QString P_ISCLOSED
static const QString P_POSX
static const QString P_POSY
This is a View of polygon point for PolygonMaskItem.
void closePolygonRequest(bool)
void updateParameterizedItem(const QPointF &pos)
void onClosePolygonRequest(bool value)
bool closePolygonIfNecessary()
Returns true if there was a request to close polygon (emitted by its start point),...
void addView(IShape2DView *childView, int row)
bool m_close_polygon_request
QPointF lastAddedPoint() const
returns last added poligon point in scene coordinates
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void update_polygon()
Runs through all PolygonPointItem and calculate bounding rectangle.
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
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)
int numberOfChildren() const
Returns total number of children.
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.
void setItemValue(const QString &tag, const QVariant &variant)
Directly set value of item under given tag.
QVector< SessionItem * > getChildrenOfType(const QString &model_type) const
Returns a vector of all children of the given type.