15 #ifndef BORNAGAIN_GUI_VIEW_MASK_MASKGRAPHICSSCENE_H
16 #define BORNAGAIN_GUI_VIEW_MASK_MASKGRAPHICSSCENE_H
20 #include <QGraphicsScene>
22 #include <QModelIndex>
23 #include <QSharedPointer>
30 class QItemSelectionModel;
33 class MaskEditorAction;
35 class QGraphicsSceneMouseEvent;
70 const QItemSelection& );
77 void drawForeground(QPainter* painter,
const QRectF& rect)
override;
Defines class MaskDrawingContext.
Defines class MaskEditorHelper.
The ColorMap class presents 2D intensity data from IntensityDataItem as color map.
Interface to adapt MaskItems coordinates (expressed in units of IntensityDataItem) to/from scene coor...
Main interface class for views representing MaskItems, Projections on graphics scene.
Helper class for MaskGraphicsScene to hold drawing conditions.
Graphics proxy to place QWidget inside QGraphicsScene, used by MaskEditorCanvas.
Graphics scene for MaskEditorCanvas to draw masks on top of intensity data widgets.
PolygonView * currentPolygon() const
Returns polygon which is currently under the drawing.
bool isAreaContains(QGraphicsSceneMouseEvent *event, MaskEditorHelper::EViewTypes viewType)
Return true if area beneath the mouse contains views of given type.
bool isValidMouseClick(QGraphicsSceneMouseEvent *event)
Returns true if left mouse bottom click was inside ColorMap viewport rectangle.
void setSelectionModel(QItemSelectionModel *model)
QPointF m_currentMousePosition
void updateScene()
Main method to update scene on various changes in the model.
void processLineItem(QGraphicsSceneMouseEvent *event)
void processVerticalLineItem(const QPointF &pos)
SessionModel * m_maskModel
void setZValues()
Update Z-values of all IMaskView to reflect stacking order in SessionModel. Item with irow=0 is the t...
void setDrawingInProgress(bool value)
void processPolygonItem(QGraphicsSceneMouseEvent *event)
void processMaskAllItem(QGraphicsSceneMouseEvent *event)
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
void setInPanAndZoomMode(bool value)
Sets the state of all views in pan&zoom mode. In pan&zoom mode, the selection is removed,...
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Finalizes item drawing or pass events to other items.
QItemSelectionModel * m_selectionModel
void processHorizontalLineItem(const QPointF &pos)
void onMaskValueChanged(MaskEditorFlags::MaskValue value)
IntensityDataItem * m_intensityItem
void processRectangleShapeItem(QGraphicsSceneMouseEvent *event)
Processes RectangleItem and EllipseItem drawing If the mouse move distance with left button down is l...
bool isDrawingInProgress() const
void removeItemViewFromScene(SessionItem *item)
Removes single view from scene.
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
void itemContextMenuRequest(const QPoint &point)
MaskGraphicsProxy * m_proxy
void setMaskContext(SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
void cancelCurrentDrawing()
void onSceneSelectionChanged()
Propagates selection from scene to model.
IShape2DView * addViewForItem(SessionItem *item)
Creates a view for given item.
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override
Creates item context menu if there is IMaskView beneath the mouse right click.
void deleteViews(const QModelIndex &parentIndex)
Recursive delete of all views corresponding to given index.
bool isValidForMaskAllDrawing(QGraphicsSceneMouseEvent *event)
Returns true if MaskAllItem can be drawn. Only one item of such type is allowed.
void updateViews(const QModelIndex &parentIndex={}, IShape2DView *parentView=nullptr)
Recutsively runs through the model and creates corresponding views.
bool isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent *event)
Returns true if mouse click is valid for rectangular/elliptic/ROI shapes.
void onRowsInserted(const QModelIndex &, int, int)
bool isValidForPolygonDrawing(QGraphicsSceneMouseEvent *event)
Returns true if mouse click is in context suitable for polygon drawing.
void setItemName(SessionItem *itemToChange)
Sets item name depending on alreay existent items. If there is already "Rectangle1",...
MaskDrawingContext m_context
QModelIndex m_maskContainerIndex
bool isValidForLineDrawing(QGraphicsSceneMouseEvent *event)
Returns true if mouse click is in context suitable for line drawing.
QMap< SessionItem *, IShape2DView * > m_ItemToView
void onRowsRemoved(const QModelIndex &, int, int)
void drawForeground(QPainter *painter, const QRectF &rect) override
Draws dashed line to the current mouse position in the case of ungoing line or polygon drawing.
void makeViewAtMousePosSelected(QGraphicsSceneMouseEvent *event)
MaskGraphicsScene(QObject *parent=nullptr)
void updateProxyWidget()
Updates proxy widget for intensity data item.
void onSessionSelectionChanged(const QItemSelection &, const QItemSelection &)
Propagates selection from model to scene.
~MaskGraphicsScene() override
void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
void updateCursors()
Change cursor to stress that hovered item is movable (when not in PanZoom mode)
SessionItem * m_currentItem
QSharedPointer< ISceneAdaptor > m_adaptor
void onActivityModeChanged(MaskEditorFlags::Activity value)
This is a View of polygon mask (represented by PolygonItem) on GraphicsScene.
Base class for a GUI data item.
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....