19 #include <QGraphicsScene>
20 #include <QGraphicsSceneContextMenuEvent>
28 if (
const auto* maskItem =
dynamic_cast<const MaskItem*
>(item))
29 return maskItem->maskValue();
37 , m_block_on_property_change(false)
65 Qt::UniqueConnection);
75 painter->setRenderHints(QPainter::Antialiasing);
81 static const QSet<MaskEditorHelper::EViewTypes> relevantMaskTypes = {
85 QPainterPath resultingShape = mapToScene(shape());
86 for (
auto* item : scene()->items()) {
87 auto*
const maskItem =
dynamic_cast<IShape2DView*
>(item);
92 const bool isMaskingItem = itemMaskValue(maskItem->parameterizedItem());
93 const bool isOnTop = maskItem->zValue() > zValue();
94 if (isMaskingItem || !isOnTop)
97 const auto maskItemShape = maskItem->mapToScene(maskItem->shape());
98 if (!maskItemShape.intersects(resultingShape))
103 resultingShape = resultingShape.subtracted(maskItemShape);
106 return mapFromScene(resultingShape);
131 if (!childItems().contains(childView))
132 childView->setParentItem(
this);
158 bool schedule_update =
false;
160 schedule_update =
true;
162 bool visible =
false;
164 visible = maskItem->isVisibleValue();
165 this->setVisible(visible);
166 schedule_update =
true;
Defines interface class ISceneAdaptor.
Defines interface IShape2DView.
Defines MaskItems classes.
Interface to adapt MaskItems coordinates (expressed in units of IntensityDataItem) to/from scene coor...
virtual qreal fromSceneX(qreal) const =0
convert scene x-coordinate to native mask coordinate
virtual qreal toSceneY(qreal) const =0
convert native mask y-coordinate to scene coordinate
virtual qreal fromSceneY(qreal) const =0
convert scene y-coordinate to native mask coordinate
virtual qreal toSceneX(qreal) const =0
convert native mask x-coordinate to scene coordinate
Main interface class for views representing MaskItems, Projections on graphics scene.
virtual void onPropertyChange()
virtual void addView(IShape2DView *childView, int row=0)
virtual SessionItem * parameterizedItem() const =0
virtual void onItemDestroyed()=0
virtual void onChangedX()
virtual void update_view()=0
update visual appearance of view (triggered by ISceneAdaptor)
const ISceneAdaptor * m_adaptor
qreal toSceneX(qreal value) const
QRectF boundingRect() const override
qreal fromSceneY(qreal value) const
void setBlockOnProperty(bool value)
void disconnectFromItem(SessionItem *item)
QPainterPath maskedShape() const
Returns the shape with all masking already applied.
bool blockOnProperty() const
void onItemPropertyChange(const QString &propertyName)
qreal fromSceneX(qreal value) const
convert scene coordinates to ColorMap plot coordinates
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
void setSceneAdaptor(const ISceneAdaptor *adaptor)
virtual void onChangedY()
qreal toSceneY(qreal value) const
bool m_block_on_property_change
IShape2DView(SessionItem *item)
static QBrush getMaskBrush(bool mask_value)
static QPen getMaskPen(bool mask_value)
A base class for all mask items.
static bool isIsVisiblePropertyName(const QString &name)
static bool isMaskValuePropertyName(const QString &name)
void unsubscribe(const void *caller)
Cancels all subscriptions of given caller.
void setOnItemDestroy(std::function< void(SessionItem *)> f, const void *caller=nullptr)
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=nullptr)
Base class for a GUI data item.
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
QString const & name(EShape k)