BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Graphics scene for MaskEditorCanvas to draw masks on top of intensity data widgets. More...
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=0) | |
~MaskGraphicsScene () | |
ColorMap * | colorMap () |
void | resetContext () |
void | setMaskContext (SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem) |
void | setSelectionModel (QItemSelectionModel *model) |
Protected Member Functions | |
void | contextMenuEvent (QGraphicsSceneContextMenuEvent *event) |
Creates item context menu if there is IMaskView beneath the mouse right click. More... | |
void | drawForeground (QPainter *painter, const QRectF &rect) |
Draws dashed line to the current mouse position in the case of ungoing line or polygon drawing. More... | |
void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) |
void | mousePressEvent (QGraphicsSceneMouseEvent *event) |
void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) |
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 &itemIndex) |
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. 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. More... | |
void | setItemName (SessionItem *itemToChange) |
Sets item name depending on alreay existent items. More... | |
void | setZValues () |
Update Z-values of all IMaskView to reflect stacking order in SessionModel. 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=0) |
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 |
Graphics scene for MaskEditorCanvas to draw masks on top of intensity data widgets.
Definition at line 41 of file MaskGraphicsScene.h.
MaskGraphicsScene::MaskGraphicsScene | ( | QObject * | parent = 0 | ) |
Definition at line 35 of file MaskGraphicsScene.cpp.
References onSceneSelectionChanged().
MaskGraphicsScene::~MaskGraphicsScene | ( | ) |
Definition at line 49 of file MaskGraphicsScene.cpp.
References m_proxy, and MaskGraphicsProxy::setSceneAdaptor().
|
private |
Creates a view for given item.
Definition at line 401 of file MaskGraphicsScene.cpp.
References ASSERT, MaskViewFactory::createMaskView(), m_adaptor, and m_ItemToView.
Referenced by updateScene(), and updateViews().
|
slot |
Definition at line 174 of file MaskGraphicsScene.cpp.
References ASSERT, SessionModel::indexOfItem(), isDrawingInProgress(), m_currentItem, m_maskModel, SessionModel::removeRows(), and setDrawingInProgress().
Referenced by MaskGraphicsView::cancelCurrentDrawing(), mousePressEvent(), and onActivityModeChanged().
ColorMap * MaskGraphicsScene::colorMap | ( | ) |
Definition at line 129 of file MaskGraphicsScene.cpp.
References ASSERT, MaskGraphicsProxy::colorMap(), and m_proxy.
Referenced by MaskEditorCanvas::onSavePlotRequest(), ProjectionsEditorCanvas::setContext(), and MaskEditorCanvas::setMaskContext().
|
protected |
Creates item context menu if there is IMaskView beneath the mouse right click.
Definition at line 355 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), and itemContextMenuRequest().
|
private |
Returns polygon which is currently under the drawing.
Definition at line 721 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 418 of file MaskGraphicsScene.cpp.
References SessionModel::index(), SessionModel::itemForIndex(), m_maskModel, removeItemViewFromScene(), and SessionModel::rowCount().
Referenced by onRowsAboutToBeRemoved().
|
protected |
Draws dashed line to the current mouse position in the case of ungoing line or polygon drawing.
Definition at line 321 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 531 of file MaskGraphicsScene.cpp.
Referenced by isValidForPolygonDrawing(), and isValidForRectangleShapeDrawing().
|
private |
Definition at line 540 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 497 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 515 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), MaskDrawingContext::isMaskAllMode(), isValidMouseClick(), m_context, and m_ItemToView.
Referenced by mousePressEvent().
|
private |
Returns true if mouse click is in context suitable for polygon drawing.
Definition at line 482 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 461 of file MaskGraphicsScene.cpp.
References isAreaContains(), isDrawingInProgress(), MaskDrawingContext::isRectangleShapeMode(), MaskDrawingContext::isROIMode(), isValidMouseClick(), m_context, m_ItemToView, and MaskEditorHelper::SIZEHANDLE.
Referenced by mousePressEvent().
|
private |
Returns true if left mouse bottom click was inside ColorMap viewport rectangle.
Definition at line 448 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 581 of file MaskGraphicsScene.cpp.
Referenced by mousePressEvent(), and mouseReleaseEvent().
|
protected |
Definition at line 280 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), MaskDrawingContext::isLineMode(), MaskDrawingContext::isPolygonMode(), MaskDrawingContext::isRectangleShapeMode(), m_context, m_currentMousePosition, and processRectangleShapeItem().
|
protected |
Definition at line 251 of file MaskGraphicsScene.cpp.
References cancelCurrentDrawing(), isDrawingInProgress(), isValidForLineDrawing(), isValidForMaskAllDrawing(), isValidForPolygonDrawing(), isValidForRectangleShapeDrawing(), makeViewAtMousePosSelected(), processLineItem(), processMaskAllItem(), processPolygonItem(), and processRectangleShapeItem().
|
protected |
Finalizes item drawing or pass events to other items.
Definition at line 296 of file MaskGraphicsScene.cpp.
References isDrawingInProgress(), MaskDrawingContext::isRectangleShapeMode(), m_context, m_currentItem, m_ItemToView, makeViewAtMousePosSelected(), and setDrawingInProgress().
|
slot |
Definition at line 135 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 149 of file MaskGraphicsScene.cpp.
References m_context, and MaskDrawingContext::setMaskValue().
Referenced by MaskEditor::setup_connections().
|
slot |
Definition at line 159 of file MaskGraphicsScene.cpp.
References deleteViews(), SessionModel::index(), m_block_selection, and m_maskModel.
Referenced by resetContext(), and setMaskContext().
|
slot |
Definition at line 154 of file MaskGraphicsScene.cpp.
References updateScene().
Referenced by resetContext(), and setMaskContext().
|
slot |
Definition at line 169 of file MaskGraphicsScene.cpp.
References updateScene().
Referenced by resetContext(), and setMaskContext().
|
privateslot |
Propagates selection from scene to model.
Definition at line 231 of file MaskGraphicsScene.cpp.
References ASSERT, SessionModel::indexOfItem(), m_block_selection, m_maskModel, and m_selectionModel.
Referenced by MaskGraphicsScene().
|
privateslot |
Propagates selection from model to scene.
Definition at line 214 of file MaskGraphicsScene.cpp.
References SessionModel::indexOfItem(), m_block_selection, m_ItemToView, m_maskModel, and m_selectionModel.
Referenced by setSelectionModel().
|
private |
Definition at line 690 of file MaskGraphicsScene.cpp.
References SessionModel::insertItem(), m_adaptor, m_currentItem, m_maskContainerIndex, m_maskModel, HorizontalLineItem::P_POSY, and SessionItem::setItemValue().
Referenced by processLineItem().
|
private |
Definition at line 665 of file MaskGraphicsScene.cpp.
References MaskDrawingContext::getMaskValue(), SessionModel::indexOfItem(), MaskDrawingContext::isHorizontalLineMode(), MaskDrawingContext::isVerticalLineMode(), m_context, m_currentItem, m_maskModel, m_selectionModel, MaskItem::P_MASK_VALUE, processHorizontalLineItem(), processVerticalLineItem(), setDrawingInProgress(), setItemName(), and SessionItem::setItemValue().
Referenced by mousePressEvent().
|
private |
Definition at line 696 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 ASSERT, currentPolygon(), MaskDrawingContext::getMaskValue(), SessionModel::indexOfItem(), SessionModel::insertItem(), MaskDrawingContext::isPolygonMode(), m_adaptor, m_context, m_currentItem, m_currentMousePosition, m_maskContainerIndex, m_maskModel, m_selectionModel, SessionItem::modelType(), MaskItem::P_MASK_VALUE, PolygonPointItem::P_POSX, PolygonPointItem::P_POSY, setDrawingInProgress(), setItemName(), and SessionItem::setItemValue().
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 592 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, SessionItem::modelType(), MaskItem::P_MASK_VALUE, EllipseItem::P_XCENTER, RectangleItem::P_XLOW, EllipseItem::P_XRADIUS, RectangleItem::P_XUP, EllipseItem::P_YCENTER, RectangleItem::P_YLOW, EllipseItem::P_YRADIUS, RectangleItem::P_YUP, setDrawingInProgress(), setItemName(), and SessionItem::setItemValue().
Referenced by mouseMoveEvent(), and mousePressEvent().
|
private |
Definition at line 684 of file MaskGraphicsScene.cpp.
References SessionModel::insertItem(), m_adaptor, m_currentItem, m_maskContainerIndex, m_maskModel, VerticalLineItem::P_POSX, and SessionItem::setItemValue().
Referenced by processLineItem().
|
private |
Removes single view from scene.
Definition at line 433 of file MaskGraphicsScene.cpp.
References m_ItemToView.
Referenced by deleteViews().
void MaskGraphicsScene::resetContext | ( | ) |
Definition at line 102 of file MaskGraphicsScene.cpp.
References m_intensityItem, m_maskContainerIndex, m_maskModel, onRowsAboutToBeRemoved(), onRowsInserted(), onRowsRemoved(), resetScene(), and updateScene().
Referenced by ProjectionsEditorCanvas::resetContext(), and MaskEditorCanvas::resetContext().
|
slot |
Definition at line 184 of file MaskGraphicsScene.cpp.
References ASSERT, m_adaptor, m_block_selection, m_ItemToView, m_proxy, and m_selectionModel.
Referenced by resetContext(), and setMaskContext().
|
private |
Definition at line 545 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 556 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 734 of file MaskGraphicsScene.cpp.
References SessionModel::index(), SessionModel::itemForIndex(), SessionItem::itemName(), m_maskContainerIndex, m_maskModel, 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 56 of file MaskGraphicsScene.cpp.
References SessionModel::itemForIndex(), m_intensityItem, m_maskContainerIndex, m_maskModel, SessionItem::modelType(), onRowsAboutToBeRemoved(), onRowsInserted(), onRowsRemoved(), resetScene(), and updateScene().
Referenced by ProjectionsEditorCanvas::setContext(), and MaskEditorCanvas::setMaskContext().
void MaskGraphicsScene::setSelectionModel | ( | QItemSelectionModel * | model | ) |
Definition at line 121 of file MaskGraphicsScene.cpp.
References ASSERT, m_selectionModel, and onSessionSelectionChanged().
Referenced by ProjectionsEditorCanvas::setSelectionModel(), and MaskEditorCanvas::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 708 of file MaskGraphicsScene.cpp.
References ASSERT, 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 570 of file MaskGraphicsScene.cpp.
References MaskDrawingContext::isInZoomMode(), m_context, and m_ItemToView.
Referenced by onActivityModeChanged().
|
private |
Updates proxy widget for intensity data item.
Definition at line 366 of file MaskGraphicsScene.cpp.
References ASSERT, 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 201 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 379 of file MaskGraphicsScene.cpp.
References IShape2DView::addView(), addViewForItem(), ASSERT, 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().