BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Graphics scene for MaskEditorCanvas to draw masks on top of intensity data widgets.
Definition at line 41 of file MaskGraphicsScene.h.
Public Slots | |
void | cancelCurrentDrawing () |
void | onActivityModeChanged (MaskEditorFlags::Activity value) |
void | onMaskValueChanged (MaskEditorFlags::MaskValue value) |
void | onRowsAboutToBeRemoved (const QModelIndex &parent, int first, int last) |
void | onRowsInserted (const QModelIndex &, int, int) |
void | onRowsRemoved (const QModelIndex &, int, int) |
void | resetScene () |
void | updateScene () |
Main method to update scene on various changes in the model. More... | |
Signals | |
void | itemContextMenuRequest (const QPoint &point) |
Public Member Functions | |
MaskGraphicsScene (QObject *parent=nullptr) | |
~MaskGraphicsScene () override | |
ColorMap * | colorMap () |
void | resetContext () |
void | setMaskContext (SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem) |
void | setSelectionModel (QItemSelectionModel *model) |
Protected Member Functions | |
void | contextMenuEvent (QGraphicsSceneContextMenuEvent *event) override |
Creates item context menu if there is IMaskView beneath the mouse right click. More... | |
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. More... | |
void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) override |
void | mousePressEvent (QGraphicsSceneMouseEvent *event) override |
void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override |
Finalizes item drawing or pass events to other items. More... | |
Private Slots | |
void | onSceneSelectionChanged () |
Propagates selection from scene to model. More... | |
void | onSessionSelectionChanged (const QItemSelection &, const QItemSelection &) |
Propagates selection from model to scene. More... | |
Private Member Functions | |
IShape2DView * | addViewForItem (SessionItem *item) |
Creates a view for given item. More... | |
PolygonView * | currentPolygon () const |
Returns polygon which is currently under the drawing. More... | |
void | deleteViews (const QModelIndex &parentIndex) |
Recursive delete of all views corresponding to given index. More... | |
bool | isAreaContains (QGraphicsSceneMouseEvent *event, MaskEditorHelper::EViewTypes viewType) |
Return true if area beneath the mouse contains views of given type. More... | |
bool | isDrawingInProgress () const |
bool | isValidForLineDrawing (QGraphicsSceneMouseEvent *event) |
Returns true if mouse click is in context suitable for line drawing. More... | |
bool | isValidForMaskAllDrawing (QGraphicsSceneMouseEvent *event) |
Returns true if MaskAllItem can be drawn. Only one item of such type is allowed. More... | |
bool | isValidForPolygonDrawing (QGraphicsSceneMouseEvent *event) |
Returns true if mouse click is in context suitable for polygon drawing. More... | |
bool | isValidForRectangleShapeDrawing (QGraphicsSceneMouseEvent *event) |
Returns true if mouse click is valid for rectangular/elliptic/ROI shapes. More... | |
bool | isValidMouseClick (QGraphicsSceneMouseEvent *event) |
Returns true if left mouse bottom click was inside ColorMap viewport rectangle. More... | |
void | makeViewAtMousePosSelected (QGraphicsSceneMouseEvent *event) |
void | processHorizontalLineItem (const QPointF &pos) |
void | processLineItem (QGraphicsSceneMouseEvent *event) |
void | processMaskAllItem (QGraphicsSceneMouseEvent *event) |
void | processPolygonItem (QGraphicsSceneMouseEvent *event) |
void | processRectangleShapeItem (QGraphicsSceneMouseEvent *event) |
Processes RectangleItem and EllipseItem drawing If the mouse move distance with left button down is larger than certain threshold, new item will be created. Further, this function will update size and position of current rectangle if mouse keep moving. More... | |
void | processVerticalLineItem (const QPointF &pos) |
void | removeItemViewFromScene (SessionItem *item) |
Removes single view from scene. More... | |
void | setDrawingInProgress (bool value) |
void | setInPanAndZoomMode (bool value) |
Sets the state of all views in pan&zoom mode. In pan&zoom mode, the selection is removed, all items can't receive mouse clicks, and all events are propagated down to ColorMap plot. More... | |
void | setItemName (SessionItem *itemToChange) |
Sets item name depending on alreay existent items. If there is already "Rectangle1", the new name will be "Rectangle2". More... | |
void | setZValues () |
Update Z-values of all IMaskView to reflect stacking order in SessionModel. Item with irow=0 is the top most on graphics scene (and so is having largest z-values). More... | |
void | updateCursors () |
Change cursor to stress that hovered item is movable (when not in PanZoom mode) More... | |
void | updateProxyWidget () |
Updates proxy widget for intensity data item. More... | |
void | updateViews (const QModelIndex &parentIndex={}, IShape2DView *parentView=nullptr) |
Recutsively runs through the model and creates corresponding views. More... | |
Private Attributes | |
QSharedPointer< ISceneAdaptor > | m_adaptor |
bool | m_block_selection |
MaskDrawingContext | m_context |
SessionItem * | m_currentItem |
QPointF | m_currentMousePosition |
IntensityDataItem * | m_intensityItem |
QMap< SessionItem *, IShape2DView * > | m_ItemToView |
QModelIndex | m_maskContainerIndex |
SessionModel * | m_maskModel |
MaskGraphicsProxy * | m_proxy |
QItemSelectionModel * | m_selectionModel |
MaskGraphicsScene::MaskGraphicsScene | ( | QObject * | parent = nullptr | ) |
Definition at line 43 of file MaskGraphicsScene.cpp.
References onSceneSelectionChanged().
|
override |
Definition at line 57 of file MaskGraphicsScene.cpp.
References m_proxy, and MaskGraphicsProxy::setSceneAdaptor().
|
private |
Creates a view for given item.
Definition at line 406 of file MaskGraphicsScene.cpp.
References MaskViewFactory::createMaskView(), m_adaptor, and m_ItemToView.
Referenced by updateScene(), and updateViews().
|
slot |
Definition at line 181 of file MaskGraphicsScene.cpp.
References SessionModel::indexOfItem(), isDrawingInProgress(), m_currentItem, m_maskModel, SessionModel::removeRows(), and setDrawingInProgress().
Referenced by MaskGraphicsView::cancelCurrentDrawing(), mousePressEvent(), and onActivityModeChanged().
ColorMap * MaskGraphicsScene::colorMap | ( | ) |
Definition at line 136 of file MaskGraphicsScene.cpp.
References MaskGraphicsProxy::colorMap(), and m_proxy.
Referenced by MaskEditorCanvas::onSavePlotRequest(), ProjectionsEditorCanvas::setContext(), and MaskEditorCanvas::setMaskContext().
|
overrideprotected |
Creates item context menu if there is IMaskView beneath the mouse right click.
Definition at line 360 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), and itemContextMenuRequest().
|
private |
Returns polygon which is currently under the drawing.
Definition at line 724 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), MaskDrawingContext::isPolygonMode(), m_context, m_currentItem, and m_ItemToView.
Referenced by drawForeground(), and processPolygonItem().
|
private |
Recursive delete of all views corresponding to given index.
Definition at line 423 of file MaskGraphicsScene.cpp.
References SessionModel::index(), SessionModel::itemForIndex(), m_maskModel, removeItemViewFromScene(), and SessionModel::rowCount().
Referenced by onRowsAboutToBeRemoved().
|
overrideprotected |
Draws dashed line to the current mouse position in the case of ungoing line or polygon drawing.
Definition at line 326 of file MaskGraphicsScene.cpp.
References currentPolygon(), MaskDrawingContext::isHorizontalLineMode(), MaskDrawingContext::isLineMode(), MaskDrawingContext::isVerticalLineMode(), m_adaptor, m_context, and m_currentMousePosition.
|
private |
Return true if area beneath the mouse contains views of given type.
Definition at line 536 of file MaskGraphicsScene.cpp.
Referenced by isValidForPolygonDrawing(), and isValidForRectangleShapeDrawing().
|
private |
Definition at line 545 of file MaskGraphicsScene.cpp.
References MaskDrawingContext::isDrawingInProgress(), and m_context.
Referenced by cancelCurrentDrawing(), contextMenuEvent(), currentPolygon(), isValidForLineDrawing(), isValidForMaskAllDrawing(), isValidForPolygonDrawing(), isValidForRectangleShapeDrawing(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and processRectangleShapeItem().
|
private |
Returns true if mouse click is in context suitable for line drawing.
Definition at line 502 of file MaskGraphicsScene.cpp.
References MaskEditorHelper::HORIZONTALLINE, isDrawingInProgress(), MaskDrawingContext::isLineMode(), isValidMouseClick(), m_context, and MaskEditorHelper::VERTICALLINE.
Referenced by mousePressEvent().
|
private |
Returns true if MaskAllItem can be drawn. Only one item of such type is allowed.
Definition at line 520 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), MaskDrawingContext::isMaskAllMode(), isValidMouseClick(), m_context, m_ItemToView, and MaskAllItem::M_TYPE.
Referenced by mousePressEvent().
|
private |
Returns true if mouse click is in context suitable for polygon drawing.
Definition at line 487 of file MaskGraphicsScene.cpp.
References isAreaContains(), isDrawingInProgress(), MaskDrawingContext::isPolygonMode(), isValidMouseClick(), m_context, and MaskEditorHelper::POLYGONPOINT.
Referenced by mousePressEvent().
|
private |
Returns true if mouse click is valid for rectangular/elliptic/ROI shapes.
Definition at line 466 of file MaskGraphicsScene.cpp.
References isAreaContains(), isDrawingInProgress(), MaskDrawingContext::isRectangleShapeMode(), MaskDrawingContext::isROIMode(), isValidMouseClick(), m_context, m_ItemToView, RegionOfInterestItem::M_TYPE, and MaskEditorHelper::SIZEHANDLE.
Referenced by mousePressEvent().
|
private |
Returns true if left mouse bottom click was inside ColorMap viewport rectangle.
Definition at line 453 of file MaskGraphicsScene.cpp.
References m_adaptor.
Referenced by isValidForLineDrawing(), isValidForMaskAllDrawing(), isValidForPolygonDrawing(), and isValidForRectangleShapeDrawing().
|
signal |
Referenced by contextMenuEvent(), and MaskEditor::setup_connections().
|
private |
Definition at line 585 of file MaskGraphicsScene.cpp.
Referenced by mousePressEvent(), and mouseReleaseEvent().
|
overrideprotected |
Definition at line 286 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), MaskDrawingContext::isLineMode(), MaskDrawingContext::isPolygonMode(), MaskDrawingContext::isRectangleShapeMode(), m_context, m_currentMousePosition, and processRectangleShapeItem().
|
overrideprotected |
Definition at line 258 of file MaskGraphicsScene.cpp.
References cancelCurrentDrawing(), isDrawingInProgress(), isValidForLineDrawing(), isValidForMaskAllDrawing(), isValidForPolygonDrawing(), isValidForRectangleShapeDrawing(), makeViewAtMousePosSelected(), processLineItem(), processMaskAllItem(), processPolygonItem(), and processRectangleShapeItem().
|
overrideprotected |
Finalizes item drawing or pass events to other items.
Definition at line 302 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), MaskDrawingContext::isRectangleShapeMode(), m_context, m_currentItem, m_ItemToView, makeViewAtMousePosSelected(), and setDrawingInProgress().
|
slot |
Definition at line 142 of file MaskGraphicsScene.cpp.
References cancelCurrentDrawing(), MaskDrawingContext::isActivityRequiresDrawingCancel(), MaskDrawingContext::isInZoomMode(), m_context, m_proxy, MaskDrawingContext::setActivityType(), setInPanAndZoomMode(), and updateCursors().
Referenced by ProjectionsEditorCanvas::onActivityModeChanged(), ProjectionsEditorCanvas::setContext(), and MaskEditor::setup_connections().
|
slot |
Definition at line 156 of file MaskGraphicsScene.cpp.
References m_context, and MaskDrawingContext::setMaskValue().
Referenced by MaskEditor::setup_connections().
|
slot |
Definition at line 166 of file MaskGraphicsScene.cpp.
References deleteViews(), SessionModel::index(), m_block_selection, and m_maskModel.
Referenced by resetContext(), and setMaskContext().
|
slot |
Definition at line 161 of file MaskGraphicsScene.cpp.
References updateScene().
Referenced by resetContext(), and setMaskContext().
|
slot |
Definition at line 176 of file MaskGraphicsScene.cpp.
References updateScene().
Referenced by resetContext(), and setMaskContext().
|
privateslot |
Propagates selection from scene to model.
Definition at line 238 of file MaskGraphicsScene.cpp.
References SessionModel::indexOfItem(), m_block_selection, m_maskModel, and m_selectionModel.
Referenced by MaskGraphicsScene().
|
privateslot |
Propagates selection from model to scene.
Definition at line 221 of file MaskGraphicsScene.cpp.
References SessionModel::indexOfItem(), m_block_selection, m_ItemToView, m_maskModel, and m_selectionModel.
Referenced by setSelectionModel().
|
private |
Definition at line 692 of file MaskGraphicsScene.cpp.
References SessionModel::insertItem(), m_adaptor, m_currentItem, m_maskContainerIndex, and m_maskModel.
Referenced by processLineItem().
|
private |
Definition at line 666 of file MaskGraphicsScene.cpp.
References MaskDrawingContext::getMaskValue(), SessionModel::indexOfItem(), MaskDrawingContext::isHorizontalLineMode(), MaskDrawingContext::isVerticalLineMode(), m_context, m_currentItem, m_maskModel, m_selectionModel, processHorizontalLineItem(), processVerticalLineItem(), setDrawingInProgress(), and setItemName().
Referenced by mousePressEvent().
|
private |
Definition at line 699 of file MaskGraphicsScene.cpp.
References SessionModel::insertItem(), m_currentItem, m_maskContainerIndex, m_maskModel, m_selectionModel, and setDrawingInProgress().
Referenced by mousePressEvent().
|
private |
Definition at line 636 of file MaskGraphicsScene.cpp.
References currentPolygon(), MaskDrawingContext::getMaskValue(), SessionModel::indexOfItem(), SessionModel::insertItem(), MaskDrawingContext::isPolygonMode(), m_adaptor, m_context, m_currentItem, m_currentMousePosition, m_maskContainerIndex, m_maskModel, m_selectionModel, PolygonItem::M_TYPE, SessionItem::modelType(), setDrawingInProgress(), setItemName(), MaskItem::setMaskValue(), and PolygonPointItem::setPosX().
Referenced by mousePressEvent().
|
private |
Processes RectangleItem and EllipseItem drawing If the mouse move distance with left button down is larger than certain threshold, new item will be created. Further, this function will update size and position of current rectangle if mouse keep moving.
Definition at line 596 of file MaskGraphicsScene.cpp.
References MaskDrawingContext::activityToModelType(), MaskDrawingContext::activityToRow(), MaskDrawingContext::getMaskValue(), SessionModel::insertNewItem(), isDrawingInProgress(), MaskDrawingContext::isROIMode(), m_adaptor, m_context, m_currentItem, m_maskContainerIndex, m_maskModel, RectangleItem::M_TYPE, RegionOfInterestItem::M_TYPE, EllipseItem::M_TYPE, SessionItem::modelType(), setDrawingInProgress(), and setItemName().
Referenced by mouseMoveEvent(), and mousePressEvent().
|
private |
Definition at line 685 of file MaskGraphicsScene.cpp.
References SessionModel::insertItem(), m_adaptor, m_currentItem, m_maskContainerIndex, and m_maskModel.
Referenced by processLineItem().
|
private |
Removes single view from scene.
Definition at line 438 of file MaskGraphicsScene.cpp.
References m_ItemToView.
Referenced by deleteViews().
void MaskGraphicsScene::resetContext | ( | ) |
Definition at line 109 of file MaskGraphicsScene.cpp.
References m_intensityItem, m_maskContainerIndex, m_maskModel, onRowsAboutToBeRemoved(), onRowsInserted(), onRowsRemoved(), resetScene(), and updateScene().
Referenced by MaskEditorCanvas::resetContext(), and ProjectionsEditorCanvas::resetContext().
|
slot |
Definition at line 191 of file MaskGraphicsScene.cpp.
References m_adaptor, m_block_selection, m_ItemToView, m_proxy, and m_selectionModel.
Referenced by resetContext(), and setMaskContext().
|
private |
Definition at line 550 of file MaskGraphicsScene.cpp.
References m_context, m_currentItem, and MaskDrawingContext::setDrawingInProgress().
Referenced by cancelCurrentDrawing(), mouseReleaseEvent(), processLineItem(), processMaskAllItem(), processPolygonItem(), and processRectangleShapeItem().
|
private |
Sets the state of all views in pan&zoom mode. In pan&zoom mode, the selection is removed, all items can't receive mouse clicks, and all events are propagated down to ColorMap plot.
Definition at line 561 of file MaskGraphicsScene.cpp.
References m_ItemToView, m_proxy, m_selectionModel, and MaskGraphicsProxy::setInZoomMode().
Referenced by onActivityModeChanged().
|
private |
Sets item name depending on alreay existent items. If there is already "Rectangle1", the new name will be "Rectangle2".
Definition at line 737 of file MaskGraphicsScene.cpp.
References SessionModel::index(), SessionModel::itemForIndex(), SessionItem::itemName(), m_maskContainerIndex, m_maskModel, RegionOfInterestItem::M_TYPE, SessionItem::modelType(), SessionModel::rowCount(), and SessionItem::setItemName().
Referenced by processLineItem(), processPolygonItem(), and processRectangleShapeItem().
void MaskGraphicsScene::setMaskContext | ( | SessionModel * | model, |
const QModelIndex & | maskContainerIndex, | ||
IntensityDataItem * | intensityItem | ||
) |
Definition at line 64 of file MaskGraphicsScene.cpp.
References Error, SessionModel::itemForIndex(), m_intensityItem, m_maskContainerIndex, m_maskModel, ProjectionContainerItem::M_TYPE, MaskContainerItem::M_TYPE, SessionItem::modelType(), onRowsAboutToBeRemoved(), onRowsInserted(), onRowsRemoved(), resetScene(), and updateScene().
Referenced by ProjectionsEditorCanvas::setContext(), and MaskEditorCanvas::setMaskContext().
void MaskGraphicsScene::setSelectionModel | ( | QItemSelectionModel * | model | ) |
Definition at line 128 of file MaskGraphicsScene.cpp.
References m_selectionModel, and onSessionSelectionChanged().
Referenced by MaskEditorCanvas::setSelectionModel(), and ProjectionsEditorCanvas::setSelectionModel().
|
private |
Update Z-values of all IMaskView to reflect stacking order in SessionModel. Item with irow=0 is the top most on graphics scene (and so is having largest z-values).
Definition at line 711 of file MaskGraphicsScene.cpp.
References SessionModel::index(), SessionModel::itemForIndex(), m_ItemToView, m_maskContainerIndex, m_maskModel, and SessionModel::rowCount().
Referenced by updateScene().
|
private |
Change cursor to stress that hovered item is movable (when not in PanZoom mode)
Definition at line 575 of file MaskGraphicsScene.cpp.
References MaskDrawingContext::isInZoomMode(), m_context, m_ItemToView, VerticalLineItem::M_TYPE, and HorizontalLineItem::M_TYPE.
Referenced by onActivityModeChanged().
|
private |
Updates proxy widget for intensity data item.
Definition at line 371 of file MaskGraphicsScene.cpp.
References m_adaptor, m_intensityItem, m_proxy, MaskGraphicsProxy::setIntensityItem(), and MaskGraphicsProxy::setSceneAdaptor().
Referenced by updateScene().
|
slot |
Main method to update scene on various changes in the model.
Definition at line 208 of file MaskGraphicsScene.cpp.
References addViewForItem(), SessionModel::itemForIndex(), m_maskContainerIndex, m_maskModel, setZValues(), updateProxyWidget(), and updateViews().
Referenced by onRowsInserted(), onRowsRemoved(), resetContext(), and setMaskContext().
|
private |
Recutsively runs through the model and creates corresponding views.
Definition at line 384 of file MaskGraphicsScene.cpp.
References IShape2DView::addView(), addViewForItem(), SessionItem::hasModelType(), SessionModel::index(), SessionModel::itemForIndex(), m_maskModel, and SessionModel::rowCount().
Referenced by updateScene().
|
private |
Definition at line 116 of file MaskGraphicsScene.h.
Referenced by addViewForItem(), drawForeground(), isValidMouseClick(), processHorizontalLineItem(), processPolygonItem(), processRectangleShapeItem(), processVerticalLineItem(), resetScene(), and updateProxyWidget().
|
private |
Definition at line 117 of file MaskGraphicsScene.h.
Referenced by onRowsAboutToBeRemoved(), onSceneSelectionChanged(), onSessionSelectionChanged(), and resetScene().
|
private |
Definition at line 122 of file MaskGraphicsScene.h.
Referenced by currentPolygon(), drawForeground(), isDrawingInProgress(), isValidForLineDrawing(), isValidForMaskAllDrawing(), isValidForPolygonDrawing(), isValidForRectangleShapeDrawing(), mouseMoveEvent(), mouseReleaseEvent(), onActivityModeChanged(), onMaskValueChanged(), processLineItem(), processPolygonItem(), processRectangleShapeItem(), setDrawingInProgress(), and updateCursors().
|
private |
Definition at line 120 of file MaskGraphicsScene.h.
Referenced by cancelCurrentDrawing(), currentPolygon(), mouseReleaseEvent(), processHorizontalLineItem(), processLineItem(), processMaskAllItem(), processPolygonItem(), processRectangleShapeItem(), processVerticalLineItem(), and setDrawingInProgress().
|
private |
Definition at line 121 of file MaskGraphicsScene.h.
Referenced by drawForeground(), mouseMoveEvent(), and processPolygonItem().
|
private |
Definition at line 119 of file MaskGraphicsScene.h.
Referenced by resetContext(), setMaskContext(), and updateProxyWidget().
|
private |
Definition at line 114 of file MaskGraphicsScene.h.
Referenced by addViewForItem(), currentPolygon(), isValidForMaskAllDrawing(), isValidForRectangleShapeDrawing(), mouseReleaseEvent(), onSessionSelectionChanged(), removeItemViewFromScene(), resetScene(), setInPanAndZoomMode(), setZValues(), and updateCursors().
|
private |
Definition at line 118 of file MaskGraphicsScene.h.
Referenced by processHorizontalLineItem(), processMaskAllItem(), processPolygonItem(), processRectangleShapeItem(), processVerticalLineItem(), resetContext(), setItemName(), setMaskContext(), setZValues(), and updateScene().
|
private |
Definition at line 112 of file MaskGraphicsScene.h.
Referenced by cancelCurrentDrawing(), deleteViews(), onRowsAboutToBeRemoved(), onSceneSelectionChanged(), onSessionSelectionChanged(), processHorizontalLineItem(), processLineItem(), processMaskAllItem(), processPolygonItem(), processRectangleShapeItem(), processVerticalLineItem(), resetContext(), setItemName(), setMaskContext(), setZValues(), updateScene(), and updateViews().
|
private |
Definition at line 115 of file MaskGraphicsScene.h.
Referenced by ~MaskGraphicsScene(), colorMap(), onActivityModeChanged(), resetScene(), setInPanAndZoomMode(), and updateProxyWidget().
|
private |
Definition at line 113 of file MaskGraphicsScene.h.
Referenced by onSceneSelectionChanged(), onSessionSelectionChanged(), processLineItem(), processMaskAllItem(), processPolygonItem(), resetScene(), setInPanAndZoomMode(), and setSelectionModel().