BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaskGraphicsScene Class Reference

Description

Graphics scene for MaskEditorCanvas to draw masks on top of intensity data widgets.

Definition at line 41 of file MaskGraphicsScene.h.

Inheritance diagram for MaskGraphicsScene:
[legend]
Collaboration diagram for MaskGraphicsScene:
[legend]

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
 
ColorMapcolorMap ()
 
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

IShape2DViewaddViewForItem (SessionItem *item)
 Creates a view for given item. More...
 
PolygonViewcurrentPolygon () 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< ISceneAdaptorm_adaptor
 
bool m_block_selection
 
MaskDrawingContext m_context
 
SessionItemm_currentItem
 
QPointF m_currentMousePosition
 
IntensityDataItemm_intensityItem
 
QMap< SessionItem *, IShape2DView * > m_ItemToView
 
QModelIndex m_maskContainerIndex
 
SessionModelm_maskModel
 
MaskGraphicsProxym_proxy
 
QItemSelectionModel * m_selectionModel
 

Constructor & Destructor Documentation

◆ MaskGraphicsScene()

MaskGraphicsScene::MaskGraphicsScene ( QObject *  parent = nullptr)

Definition at line 43 of file MaskGraphicsScene.cpp.

44  : QGraphicsScene(parent)
45  , m_maskModel(nullptr)
46  , m_selectionModel(nullptr)
47  , m_proxy(nullptr)
48  , m_block_selection(false)
49  , m_intensityItem(nullptr)
50  , m_currentItem(nullptr)
51 {
52  setSceneRect(default_scene_rect);
53  connect(this, &MaskGraphicsScene::selectionChanged, this,
55 }
SessionModel * m_maskModel
QItemSelectionModel * m_selectionModel
IntensityDataItem * m_intensityItem
MaskGraphicsProxy * m_proxy
void onSceneSelectionChanged()
Propagates selection from scene to model.
SessionItem * m_currentItem

References onSceneSelectionChanged().

Here is the call graph for this function:

◆ ~MaskGraphicsScene()

MaskGraphicsScene::~MaskGraphicsScene ( )
override

Definition at line 57 of file MaskGraphicsScene.cpp.

58 {
59  // Fix within #1792
60  if (m_proxy)
61  m_proxy->setSceneAdaptor(nullptr);
62 }
void setSceneAdaptor(ISceneAdaptor *sceneAdaptor)

References m_proxy, and MaskGraphicsProxy::setSceneAdaptor().

Here is the call graph for this function:

Member Function Documentation

◆ addViewForItem()

IShape2DView * MaskGraphicsScene::addViewForItem ( SessionItem item)
private

Creates a view for given item.

Definition at line 406 of file MaskGraphicsScene.cpp.

407 {
408  ASSERT(item);
409  IShape2DView* view = m_ItemToView[item];
410  if (!view) {
411  view = MaskViewFactory::createMaskView(item, m_adaptor.data());
412  if (view) {
413  m_ItemToView[item] = view;
414  addItem(view);
415  return view;
416  }
417  }
418  return view;
419 }
Main interface class for views representing MaskItems, Projections on graphics scene.
Definition: IShape2DView.h:27
QMap< SessionItem *, IShape2DView * > m_ItemToView
QSharedPointer< ISceneAdaptor > m_adaptor
static IShape2DView * createMaskView(SessionItem *item, ISceneAdaptor *adaptor=nullptr)

References MaskViewFactory::createMaskView(), m_adaptor, and m_ItemToView.

Referenced by updateScene(), and updateViews().

Here is the call graph for this function:

◆ cancelCurrentDrawing

void MaskGraphicsScene::cancelCurrentDrawing ( )
slot

Definition at line 181 of file MaskGraphicsScene.cpp.

182 {
183  if (isDrawingInProgress()) {
184  ASSERT(m_currentItem);
185  QModelIndex index = m_maskModel->indexOfItem(m_currentItem);
186  m_maskModel->removeRows(index.row(), 1, index.parent());
187  setDrawingInProgress(false);
188  }
189 }
void setDrawingInProgress(bool value)
bool isDrawingInProgress() const
bool removeRows(int row, int count, const QModelIndex &parent) override
QModelIndex indexOfItem(SessionItem *item) const

References SessionModel::indexOfItem(), isDrawingInProgress(), m_currentItem, m_maskModel, SessionModel::removeRows(), and setDrawingInProgress().

Referenced by MaskGraphicsView::cancelCurrentDrawing(), mousePressEvent(), and onActivityModeChanged().

Here is the call graph for this function:

◆ colorMap()

ColorMap * MaskGraphicsScene::colorMap ( )

Definition at line 136 of file MaskGraphicsScene.cpp.

137 {
138  ASSERT(m_proxy);
139  return m_proxy->colorMap();
140 }

References MaskGraphicsProxy::colorMap(), and m_proxy.

Referenced by MaskEditorCanvas::onSavePlotRequest(), ProjectionsEditorCanvas::setContext(), and MaskEditorCanvas::setMaskContext().

Here is the call graph for this function:

◆ contextMenuEvent()

void MaskGraphicsScene::contextMenuEvent ( QGraphicsSceneContextMenuEvent *  event)
overrideprotected

Creates item context menu if there is IMaskView beneath the mouse right click.

Definition at line 360 of file MaskGraphicsScene.cpp.

361 {
362  if (isDrawingInProgress())
363  return;
364 
365  if (dynamic_cast<IShape2DView*>(itemAt(event->scenePos(), QTransform())))
366  emit itemContextMenuRequest(event->screenPos());
367 }
void itemContextMenuRequest(const QPoint &point)

References isDrawingInProgress(), and itemContextMenuRequest().

Here is the call graph for this function:

◆ currentPolygon()

PolygonView * MaskGraphicsScene::currentPolygon ( ) const
private

Returns polygon which is currently under the drawing.

Definition at line 724 of file MaskGraphicsScene.cpp.

725 {
726  PolygonView* result(nullptr);
728  if (m_currentItem)
729  result = dynamic_cast<PolygonView*>(m_ItemToView[m_currentItem]);
730  }
731  return result;
732 }
MaskDrawingContext m_context
This is a View of polygon mask (represented by PolygonItem) on GraphicsScene.
Definition: PolygonView.h:26

References isDrawingInProgress(), MaskDrawingContext::isPolygonMode(), m_context, m_currentItem, and m_ItemToView.

Referenced by drawForeground(), and processPolygonItem().

Here is the call graph for this function:

◆ deleteViews()

void MaskGraphicsScene::deleteViews ( const QModelIndex &  parentIndex)
private

Recursive delete of all views corresponding to given index.

Definition at line 423 of file MaskGraphicsScene.cpp.

424 {
425  for (int i_row = 0; i_row < m_maskModel->rowCount(parentIndex); ++i_row) {
426  QModelIndex itemIndex = m_maskModel->index(i_row, 0, parentIndex);
427 
428  if (SessionItem* item = m_maskModel->itemForIndex(itemIndex))
430 
431  deleteViews(itemIndex);
432  }
433  removeItemViewFromScene(m_maskModel->itemForIndex(parentIndex)); // deleting parent item
434 }
void removeItemViewFromScene(SessionItem *item)
Removes single view from scene.
void deleteViews(const QModelIndex &parentIndex)
Recursive delete of all views corresponding to given index.
Base class for a GUI data item.
Definition: SessionItem.h:204
SessionItem * itemForIndex(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent) const override
int rowCount(const QModelIndex &parent) const override

References SessionModel::index(), SessionModel::itemForIndex(), m_maskModel, removeItemViewFromScene(), and SessionModel::rowCount().

Referenced by onRowsAboutToBeRemoved().

Here is the call graph for this function:

◆ drawForeground()

void MaskGraphicsScene::drawForeground ( QPainter *  painter,
const QRectF &  rect 
)
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.

327 {
328  // if(!isDrawingInProgress())
329  // return;
330 
331  if (m_currentMousePosition == QPointF())
332  return;
333 
334  if (PolygonView* polygon = currentPolygon()) {
335  painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
336  painter->drawLine(QLineF(polygon->lastAddedPoint(), m_currentMousePosition));
337  } else {
338  if (m_context.isLineMode()) {
339  const QRectF& plot_scene_rectangle = m_adaptor->viewportRectangle();
340  if (!plot_scene_rectangle.contains(m_currentMousePosition))
341  return;
342 
343  painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
345  QPointF p1(m_currentMousePosition.x(), plot_scene_rectangle.bottom());
346  QPointF p2(m_currentMousePosition.x(), plot_scene_rectangle.top());
347  painter->drawLine(QLineF(p1, p2));
348  }
350  QPointF p1(plot_scene_rectangle.left(), m_currentMousePosition.y());
351  QPointF p2(plot_scene_rectangle.right(), m_currentMousePosition.y());
352  painter->drawLine(QLineF(p1, p2));
353  }
354  }
355  }
356 }
bool isVerticalLineMode() const
bool isHorizontalLineMode() const
PolygonView * currentPolygon() const
Returns polygon which is currently under the drawing.

References currentPolygon(), MaskDrawingContext::isHorizontalLineMode(), MaskDrawingContext::isLineMode(), MaskDrawingContext::isVerticalLineMode(), m_adaptor, m_context, and m_currentMousePosition.

Here is the call graph for this function:

◆ isAreaContains()

bool MaskGraphicsScene::isAreaContains ( QGraphicsSceneMouseEvent *  event,
MaskEditorHelper::EViewTypes  viewType 
)
private

Return true if area beneath the mouse contains views of given type.

Definition at line 536 of file MaskGraphicsScene.cpp.

538 {
539  for (QGraphicsItem* graphicsItem : this->items(event->scenePos()))
540  if (graphicsItem->type() == viewType)
541  return true;
542  return false;
543 }

Referenced by isValidForPolygonDrawing(), and isValidForRectangleShapeDrawing().

◆ isDrawingInProgress()

bool MaskGraphicsScene::isDrawingInProgress ( ) const
private

Definition at line 545 of file MaskGraphicsScene.cpp.

546 {
548 }
bool isDrawingInProgress() const

References MaskDrawingContext::isDrawingInProgress(), and m_context.

Referenced by cancelCurrentDrawing(), contextMenuEvent(), currentPolygon(), isValidForLineDrawing(), isValidForMaskAllDrawing(), isValidForPolygonDrawing(), isValidForRectangleShapeDrawing(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and processRectangleShapeItem().

Here is the call graph for this function:

◆ isValidForLineDrawing()

bool MaskGraphicsScene::isValidForLineDrawing ( QGraphicsSceneMouseEvent *  event)
private

Returns true if mouse click is in context suitable for line drawing.

Definition at line 502 of file MaskGraphicsScene.cpp.

503 {
504  if (!isValidMouseClick(event))
505  return false;
506  if (isDrawingInProgress())
507  return false;
508  if (!m_context.isLineMode())
509  return false;
510  if (QGraphicsItem* graphicsItem = itemAt(event->scenePos(), QTransform())) {
511  if (graphicsItem->type() == MaskEditorHelper::VERTICALLINE
512  || graphicsItem->type() == MaskEditorHelper::HORIZONTALLINE)
513  return false;
514  }
515  return true;
516 }
bool isValidMouseClick(QGraphicsSceneMouseEvent *event)
Returns true if left mouse bottom click was inside ColorMap viewport rectangle.

References MaskEditorHelper::HORIZONTALLINE, isDrawingInProgress(), MaskDrawingContext::isLineMode(), isValidMouseClick(), m_context, and MaskEditorHelper::VERTICALLINE.

Referenced by mousePressEvent().

Here is the call graph for this function:

◆ isValidForMaskAllDrawing()

bool MaskGraphicsScene::isValidForMaskAllDrawing ( QGraphicsSceneMouseEvent *  event)
private

Returns true if MaskAllItem can be drawn. Only one item of such type is allowed.

Definition at line 520 of file MaskGraphicsScene.cpp.

521 {
522  if (!isValidMouseClick(event))
523  return false;
524  if (isDrawingInProgress())
525  return false;
526  if (!m_context.isMaskAllMode())
527  return false;
528  for (SessionItem* item : m_ItemToView.keys())
529  if (item->modelType() == MaskAllItem::M_TYPE)
530  return false;
531  return true;
532 }
static constexpr auto M_TYPE
Definition: MaskItems.h:192

References isDrawingInProgress(), MaskDrawingContext::isMaskAllMode(), isValidMouseClick(), m_context, m_ItemToView, and MaskAllItem::M_TYPE.

Referenced by mousePressEvent().

Here is the call graph for this function:

◆ isValidForPolygonDrawing()

bool MaskGraphicsScene::isValidForPolygonDrawing ( QGraphicsSceneMouseEvent *  event)
private

Returns true if mouse click is in context suitable for polygon drawing.

Definition at line 487 of file MaskGraphicsScene.cpp.

488 {
489  if (!isValidMouseClick(event))
490  return false;
491  if (!m_context.isPolygonMode())
492  return false;
493  if (!isDrawingInProgress()) {
495  return false;
496  }
497  return true;
498 }
bool isAreaContains(QGraphicsSceneMouseEvent *event, MaskEditorHelper::EViewTypes viewType)
Return true if area beneath the mouse contains views of given type.

References isAreaContains(), isDrawingInProgress(), MaskDrawingContext::isPolygonMode(), isValidMouseClick(), m_context, and MaskEditorHelper::POLYGONPOINT.

Referenced by mousePressEvent().

Here is the call graph for this function:

◆ isValidForRectangleShapeDrawing()

bool MaskGraphicsScene::isValidForRectangleShapeDrawing ( QGraphicsSceneMouseEvent *  event)
private

Returns true if mouse click is valid for rectangular/elliptic/ROI shapes.

Definition at line 466 of file MaskGraphicsScene.cpp.

467 {
468  if (isDrawingInProgress())
469  return false;
470  if (!isValidMouseClick(event))
471  return false;
473  return false;
475  return false;
476  if (m_context.isROIMode()) {
477  // only one ROI is allowed
478  for (SessionItem* item : m_ItemToView.keys())
479  if (item->modelType() == RegionOfInterestItem::M_TYPE)
480  return false;
481  }
482  return true;
483 }
bool isRectangleShapeMode() const
static constexpr auto M_TYPE
Definition: MaskItems.h:83

References isAreaContains(), isDrawingInProgress(), MaskDrawingContext::isRectangleShapeMode(), MaskDrawingContext::isROIMode(), isValidMouseClick(), m_context, m_ItemToView, RegionOfInterestItem::M_TYPE, and MaskEditorHelper::SIZEHANDLE.

Referenced by mousePressEvent().

Here is the call graph for this function:

◆ isValidMouseClick()

bool MaskGraphicsScene::isValidMouseClick ( QGraphicsSceneMouseEvent *  event)
private

Returns true if left mouse bottom click was inside ColorMap viewport rectangle.

Definition at line 453 of file MaskGraphicsScene.cpp.

454 {
455  if (!m_adaptor)
456  return false;
457  if (!(event->buttons() & Qt::LeftButton))
458  return false;
459  if (!m_adaptor->viewportRectangle().contains(event->scenePos()))
460  return false;
461  return true;
462 }

References m_adaptor.

Referenced by isValidForLineDrawing(), isValidForMaskAllDrawing(), isValidForPolygonDrawing(), and isValidForRectangleShapeDrawing().

◆ itemContextMenuRequest

void MaskGraphicsScene::itemContextMenuRequest ( const QPoint &  point)
signal

◆ makeViewAtMousePosSelected()

void MaskGraphicsScene::makeViewAtMousePosSelected ( QGraphicsSceneMouseEvent *  event)
private

Definition at line 585 of file MaskGraphicsScene.cpp.

586 {
587  if (QGraphicsItem* graphicsItem = itemAt(event->scenePos(), QTransform()))
588  graphicsItem->setSelected(true);
589 }

Referenced by mousePressEvent(), and mouseReleaseEvent().

◆ mouseMoveEvent()

void MaskGraphicsScene::mouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

Definition at line 286 of file MaskGraphicsScene.cpp.

287 {
290  return;
291  }
292  QGraphicsScene::mouseMoveEvent(event);
293 
295  m_currentMousePosition = event->scenePos();
296  invalidate();
297  }
298 }
void processRectangleShapeItem(QGraphicsSceneMouseEvent *event)
Processes RectangleItem and EllipseItem drawing If the mouse move distance with left button down is l...

References isDrawingInProgress(), MaskDrawingContext::isLineMode(), MaskDrawingContext::isPolygonMode(), MaskDrawingContext::isRectangleShapeMode(), m_context, m_currentMousePosition, and processRectangleShapeItem().

Here is the call graph for this function:

◆ mousePressEvent()

void MaskGraphicsScene::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

Definition at line 258 of file MaskGraphicsScene.cpp.

259 {
260  if (event->buttons() & Qt::RightButton) {
261  if (isDrawingInProgress())
263  else
265  return;
266  }
267  if (isValidForPolygonDrawing(event)) {
268  processPolygonItem(event);
269  return;
270  }
271  if (isValidForLineDrawing(event)) {
272  processLineItem(event);
273  return;
274  }
275  if (isValidForMaskAllDrawing(event)) {
276  processMaskAllItem(event);
277  return;
278  }
279  if (isValidForRectangleShapeDrawing(event)) {
281  return;
282  }
283  QGraphicsScene::mousePressEvent(event);
284 }
void processLineItem(QGraphicsSceneMouseEvent *event)
void processPolygonItem(QGraphicsSceneMouseEvent *event)
void processMaskAllItem(QGraphicsSceneMouseEvent *event)
bool isValidForMaskAllDrawing(QGraphicsSceneMouseEvent *event)
Returns true if MaskAllItem can be drawn. Only one item of such type is allowed.
bool isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent *event)
Returns true if mouse click is valid for rectangular/elliptic/ROI shapes.
bool isValidForPolygonDrawing(QGraphicsSceneMouseEvent *event)
Returns true if mouse click is in context suitable for polygon drawing.
bool isValidForLineDrawing(QGraphicsSceneMouseEvent *event)
Returns true if mouse click is in context suitable for line drawing.
void makeViewAtMousePosSelected(QGraphicsSceneMouseEvent *event)

References cancelCurrentDrawing(), isDrawingInProgress(), isValidForLineDrawing(), isValidForMaskAllDrawing(), isValidForPolygonDrawing(), isValidForRectangleShapeDrawing(), makeViewAtMousePosSelected(), processLineItem(), processMaskAllItem(), processPolygonItem(), and processRectangleShapeItem().

Here is the call graph for this function:

◆ mouseReleaseEvent()

void MaskGraphicsScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

Finalizes item drawing or pass events to other items.

Definition at line 302 of file MaskGraphicsScene.cpp.

303 {
304  if (isDrawingInProgress()) {
306  clearSelection();
307  if (m_currentItem) {
308  // drawing ended up with item drawn, let's make it selected
310  view->setSelected(true);
311  } else {
312  // drawing ended without item to be draw (too short mouse move)
313  // making item beneath of mouse release position to be selected
315  }
316  setDrawingInProgress(false);
317  }
318  } else {
319  QGraphicsScene::mouseReleaseEvent(event);
320  }
321 }

References isDrawingInProgress(), MaskDrawingContext::isRectangleShapeMode(), m_context, m_currentItem, m_ItemToView, makeViewAtMousePosSelected(), and setDrawingInProgress().

Here is the call graph for this function:

◆ onActivityModeChanged

void MaskGraphicsScene::onActivityModeChanged ( MaskEditorFlags::Activity  value)
slot

Definition at line 142 of file MaskGraphicsScene.cpp.

143 {
144  if (!m_proxy)
145  return;
146 
149 
150  m_context.setActivityType(value);
152 
153  updateCursors();
154 }
void setActivityType(MaskEditorFlags::Activity value)
bool isActivityRequiresDrawingCancel(MaskEditorFlags::Activity proposed_new_activity) const
Returns true, if proposed activity requires the cancel of drawing i.e. there is an ungoing polygon dr...
void setInPanAndZoomMode(bool value)
Sets the state of all views in pan&zoom mode. In pan&zoom mode, the selection is removed,...
void updateCursors()
Change cursor to stress that hovered item is movable (when not in PanZoom mode)

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().

Here is the call graph for this function:

◆ onMaskValueChanged

void MaskGraphicsScene::onMaskValueChanged ( MaskEditorFlags::MaskValue  value)
slot

Definition at line 156 of file MaskGraphicsScene.cpp.

157 {
158  m_context.setMaskValue(value);
159 }
void setMaskValue(MaskEditorFlags::MaskValue value)

References m_context, and MaskDrawingContext::setMaskValue().

Referenced by MaskEditor::setup_connections().

Here is the call graph for this function:

◆ onRowsAboutToBeRemoved

void MaskGraphicsScene::onRowsAboutToBeRemoved ( const QModelIndex &  parent,
int  first,
int  last 
)
slot

Definition at line 166 of file MaskGraphicsScene.cpp.

167 {
168  m_block_selection = true;
169  for (int irow = first; irow <= last; ++irow) {
170  QModelIndex itemIndex = m_maskModel->index(irow, 0, parent);
171  deleteViews(itemIndex); // deleting all child items
172  }
173  m_block_selection = false;
174 }

References deleteViews(), SessionModel::index(), m_block_selection, and m_maskModel.

Referenced by resetContext(), and setMaskContext().

Here is the call graph for this function:

◆ onRowsInserted

void MaskGraphicsScene::onRowsInserted ( const QModelIndex &  ,
int  ,
int   
)
slot

Definition at line 161 of file MaskGraphicsScene.cpp.

162 {
163  updateScene();
164 }
void updateScene()
Main method to update scene on various changes in the model.

References updateScene().

Referenced by resetContext(), and setMaskContext().

Here is the call graph for this function:

◆ onRowsRemoved

void MaskGraphicsScene::onRowsRemoved ( const QModelIndex &  ,
int  ,
int   
)
slot

Definition at line 176 of file MaskGraphicsScene.cpp.

177 {
178  updateScene();
179 }

References updateScene().

Referenced by resetContext(), and setMaskContext().

Here is the call graph for this function:

◆ onSceneSelectionChanged

void MaskGraphicsScene::onSceneSelectionChanged ( )
privateslot

Propagates selection from scene to model.

Definition at line 238 of file MaskGraphicsScene.cpp.

239 {
240  if (m_block_selection)
241  return;
242 
243  m_block_selection = true;
244 
245  m_selectionModel->clearSelection();
246 
247  for (QGraphicsItem* graphicsItem : selectedItems()) {
248  if (auto* view = dynamic_cast<IShape2DView*>(graphicsItem)) {
249  QModelIndex itemIndex = m_maskModel->indexOfItem(view->parameterizedItem());
250  ASSERT(itemIndex.isValid());
251  if (!m_selectionModel->isSelected(itemIndex))
252  m_selectionModel->select(itemIndex, QItemSelectionModel::Select);
253  }
254  }
255  m_block_selection = false;
256 }

References SessionModel::indexOfItem(), m_block_selection, m_maskModel, and m_selectionModel.

Referenced by MaskGraphicsScene().

Here is the call graph for this function:

◆ onSessionSelectionChanged

void MaskGraphicsScene::onSessionSelectionChanged ( const QItemSelection &  ,
const QItemSelection &   
)
privateslot

Propagates selection from model to scene.

Definition at line 221 of file MaskGraphicsScene.cpp.

222 {
223  if (m_block_selection)
224  return;
225 
226  m_block_selection = true;
227 
228  for (auto it = m_ItemToView.begin(); it != m_ItemToView.end(); ++it) {
229  QModelIndex index = m_maskModel->indexOfItem(it.key());
230  if (index.isValid())
231  it.value()->setSelected(m_selectionModel->isSelected(index));
232  }
233  m_block_selection = false;
234 }

References SessionModel::indexOfItem(), m_block_selection, m_ItemToView, m_maskModel, and m_selectionModel.

Referenced by setSelectionModel().

Here is the call graph for this function:

◆ processHorizontalLineItem()

void MaskGraphicsScene::processHorizontalLineItem ( const QPointF &  pos)
private

Definition at line 692 of file MaskGraphicsScene.cpp.

693 {
695  m_currentItem = item;
696  item->setPosY(m_adaptor->fromSceneY(pos.y()));
697 }
QModelIndex m_maskContainerIndex
T * insertItem(SessionItem *parent=nullptr, int row=-1, QString tag="")
Definition: SessionModel.h:137

References SessionModel::insertItem(), m_adaptor, m_currentItem, m_maskContainerIndex, and m_maskModel.

Referenced by processLineItem().

Here is the call graph for this function:

◆ processLineItem()

void MaskGraphicsScene::processLineItem ( QGraphicsSceneMouseEvent *  event)
private

Definition at line 666 of file MaskGraphicsScene.cpp.

667 {
668  setDrawingInProgress(true);
669  QPointF click_pos = event->buttonDownScenePos(Qt::LeftButton);
670 
672  processVerticalLineItem(click_pos);
673 
675  processHorizontalLineItem(click_pos);
676 
677  m_selectionModel->clearSelection();
678  m_selectionModel->select(m_maskModel->indexOfItem(m_currentItem), QItemSelectionModel::Select);
680  dynamic_cast<MaskItem*>(m_currentItem)->setMaskValue(m_context.getMaskValue());
681 
682  setDrawingInProgress(false);
683 }
void processVerticalLineItem(const QPointF &pos)
void processHorizontalLineItem(const QPointF &pos)
void setItemName(SessionItem *itemToChange)
Sets item name depending on alreay existent items. If there is already "Rectangle1",...
A base class for all mask items.
Definition: MaskItems.h:27

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().

Here is the call graph for this function:

◆ processMaskAllItem()

void MaskGraphicsScene::processMaskAllItem ( QGraphicsSceneMouseEvent *  event)
private

Definition at line 699 of file MaskGraphicsScene.cpp.

700 {
701  Q_UNUSED(event);
702  setDrawingInProgress(true);
704  m_selectionModel->clearSelection();
705  setDrawingInProgress(false);
706 }

References SessionModel::insertItem(), m_currentItem, m_maskContainerIndex, m_maskModel, m_selectionModel, and setDrawingInProgress().

Referenced by mousePressEvent().

Here is the call graph for this function:

◆ processPolygonItem()

void MaskGraphicsScene::processPolygonItem ( QGraphicsSceneMouseEvent *  event)
private

Definition at line 636 of file MaskGraphicsScene.cpp.

637 {
638  ASSERT(m_context.isPolygonMode());
639 
640  if (!m_currentItem) {
641  setDrawingInProgress(true);
643  new_poly->setMaskValue(m_context.getMaskValue());
644  m_currentItem = new_poly;
645  m_selectionModel->clearSelection();
647  QItemSelectionModel::Select);
649  }
651 
652  if (PolygonView* polygon = currentPolygon()) {
653  if (polygon->closePolygonIfNecessary()) {
654  setDrawingInProgress(false);
656  return;
657  }
658  }
660  QPointF click_pos = event->buttonDownScenePos(Qt::LeftButton);
661 
662  point->setPosX(m_adaptor->fromSceneX(click_pos.x()));
663  point->setPosY(m_adaptor->fromSceneY(click_pos.y()));
664 }
void setMaskValue(bool mask_value)
Definition: MaskItems.cpp:85
static constexpr auto M_TYPE
Definition: MaskItems.h:112
void setPosX(double pos_x)
Definition: MaskItems.cpp:229
QString modelType() const
Get model type.

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().

Here is the call graph for this function:

◆ processRectangleShapeItem()

void MaskGraphicsScene::processRectangleShapeItem ( QGraphicsSceneMouseEvent *  event)
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.

597 {
598  if (!isDrawingInProgress())
599  setDrawingInProgress(true);
600 
601  QPointF click_pos = event->buttonDownScenePos(Qt::LeftButton);
602  QPointF mouse_pos = event->scenePos();
603  QLineF line(mouse_pos, click_pos);
604 
605  if (!m_currentItem && line.length() > min_distance_to_create_rect) {
608  if (!m_context.isROIMode())
609  dynamic_cast<MaskItem*>(m_currentItem)->setMaskValue(m_context.getMaskValue());
611  }
612  if (!m_currentItem)
613  return;
614 
615  qreal xmin = std::min(click_pos.x(), mouse_pos.x());
616  qreal xmax = std::max(click_pos.x(), mouse_pos.x());
617  qreal ymin = std::min(click_pos.y(), mouse_pos.y());
618  qreal ymax = std::max(click_pos.y(), mouse_pos.y());
619 
622  auto* rectItem = polymorphic_downcast<RectangleItem*>(m_currentItem);
623  rectItem->setXLow(m_adaptor->fromSceneX(xmin));
624  rectItem->setYLow(m_adaptor->fromSceneY(ymax));
625  rectItem->setXUp(m_adaptor->fromSceneX(xmax));
626  rectItem->setYUp(m_adaptor->fromSceneY(ymin));
627  } else if (m_currentItem->modelType() == EllipseItem::M_TYPE) {
628  auto* ellItem = polymorphic_downcast<EllipseItem*>(m_currentItem);
629  ellItem->setXCenter(m_adaptor->fromSceneX(xmin + (xmax - xmin) / 2.));
630  ellItem->setYCenter(m_adaptor->fromSceneY(ymin + (ymax - ymin) / 2.));
631  ellItem->setXRadius((m_adaptor->fromSceneX(xmax) - m_adaptor->fromSceneX(xmin)) / 2.);
632  ellItem->setYRadius((m_adaptor->fromSceneY(ymin) - m_adaptor->fromSceneY(ymax)) / 2.);
633  }
634 }
static constexpr auto M_TYPE
Definition: MaskItems.h:167
QString activityToModelType() const
Returns model type corresponding to current activity.
int activityToRow() const
Returns model row corresponding to given activity. All shapes, except ROI, will be added on top of ea...
static constexpr auto M_TYPE
Definition: MaskItems.h:61
SessionItem * insertNewItem(QString model_type, SessionItem *parent_item=nullptr, int row=-1, QString tag="")

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().

Here is the call graph for this function:

◆ processVerticalLineItem()

void MaskGraphicsScene::processVerticalLineItem ( const QPointF &  pos)
private

Definition at line 685 of file MaskGraphicsScene.cpp.

686 {
688  m_currentItem = item;
689  item->setPosX(m_adaptor->fromSceneX(pos.x()));
690 }

References SessionModel::insertItem(), m_adaptor, m_currentItem, m_maskContainerIndex, and m_maskModel.

Referenced by processLineItem().

Here is the call graph for this function:

◆ removeItemViewFromScene()

void MaskGraphicsScene::removeItemViewFromScene ( SessionItem item)
private

Removes single view from scene.

Definition at line 438 of file MaskGraphicsScene.cpp.

439 {
440  for (auto it = m_ItemToView.begin(); it != m_ItemToView.end(); ++it) {
441  if (it.key() == item) {
442  IShape2DView* view = it.value();
443  view->setSelected(false);
444  m_ItemToView.erase(it);
445  delete view;
446  break;
447  }
448  }
449 }

References m_ItemToView.

Referenced by deleteViews().

◆ resetContext()

void MaskGraphicsScene::resetContext ( )

Definition at line 109 of file MaskGraphicsScene.cpp.

110 {
111  m_intensityItem = nullptr;
112  if (m_maskModel) {
113  disconnect(m_maskModel, &SessionModel::modelAboutToBeReset, this,
115  disconnect(m_maskModel, &SessionModel::rowsInserted, this,
117  disconnect(m_maskModel, &SessionModel::rowsAboutToBeRemoved, this,
119  disconnect(m_maskModel, &SessionModel::rowsRemoved, this,
121  disconnect(m_maskModel, &SessionModel::modelReset, this, &MaskGraphicsScene::updateScene);
122  }
123  m_maskModel = nullptr;
125  resetScene();
126 }
void onRowsInserted(const QModelIndex &, int, int)
void onRowsRemoved(const QModelIndex &, int, int)
void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)

References m_intensityItem, m_maskContainerIndex, m_maskModel, onRowsAboutToBeRemoved(), onRowsInserted(), onRowsRemoved(), resetScene(), and updateScene().

Referenced by MaskEditorCanvas::resetContext(), and ProjectionsEditorCanvas::resetContext().

Here is the call graph for this function:

◆ resetScene

void MaskGraphicsScene::resetScene ( )
slot

Definition at line 191 of file MaskGraphicsScene.cpp.

192 {
193  ASSERT(m_selectionModel);
194  m_block_selection = true;
195  m_selectionModel->clearSelection();
196  clearSelection();
197 
198  clear();
199  m_ItemToView.clear();
200  m_proxy = nullptr;
201  m_adaptor.reset(new ColorMapSceneAdaptor);
202 
203  m_block_selection = false;
204 }
Performs conversion of MaskItems coordinates between ColorMap and GraphicsScene.

References m_adaptor, m_block_selection, m_ItemToView, m_proxy, and m_selectionModel.

Referenced by resetContext(), and setMaskContext().

◆ setDrawingInProgress()

void MaskGraphicsScene::setDrawingInProgress ( bool  value)
private

Definition at line 550 of file MaskGraphicsScene.cpp.

551 {
553  if (!value)
554  m_currentItem = nullptr;
555 }
void setDrawingInProgress(bool value)

References m_context, m_currentItem, and MaskDrawingContext::setDrawingInProgress().

Referenced by cancelCurrentDrawing(), mouseReleaseEvent(), processLineItem(), processMaskAllItem(), processPolygonItem(), and processRectangleShapeItem().

Here is the call graph for this function:

◆ setInPanAndZoomMode()

void MaskGraphicsScene::setInPanAndZoomMode ( bool  value)
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.

562 {
563  if (value)
564  m_selectionModel->clearSelection();
565 
566  Qt::MouseButtons acceptedButton = (value ? Qt::NoButton : Qt::LeftButton);
567  for (IShape2DView* view : m_ItemToView.values())
568  view->setAcceptedMouseButtons(acceptedButton);
569 
570  m_proxy->setInZoomMode(value);
571 }
void setInZoomMode(bool value)
Sets widget to zoom mode, when signals (zoom wheel, mouse clicks) are send down to ColorMap plot....

References m_ItemToView, m_proxy, m_selectionModel, and MaskGraphicsProxy::setInZoomMode().

Referenced by onActivityModeChanged().

Here is the call graph for this function:

◆ setItemName()

void MaskGraphicsScene::setItemName ( SessionItem itemToChange)
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.

738 {
739  if (itemToChange->modelType() == RegionOfInterestItem::M_TYPE)
740  return;
741 
742  int glob_index(0);
743  for (int i_row = 0; i_row < m_maskModel->rowCount(m_maskContainerIndex); ++i_row) {
744  QModelIndex itemIndex = m_maskModel->index(i_row, 0, m_maskContainerIndex);
745  if (SessionItem* currentItem = m_maskModel->itemForIndex(itemIndex)) {
746  if (currentItem->modelType() == itemToChange->modelType()) {
747  QString itemName = currentItem->itemName();
748  if (itemName.startsWith(itemToChange->itemName())) {
749  int item_index = itemName.remove(0, itemToChange->itemName().size()).toInt();
750  if (item_index > glob_index)
751  glob_index = item_index;
752  }
753  }
754  }
755  }
756  itemToChange->setItemName(itemToChange->itemName() + QString::number(++glob_index));
757 }
QString itemName() const
Get item name, return display name if no name is set.
void setItemName(const QString &name)
Set item name, add property if necessary.

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().

Here is the call graph for this function:

◆ setMaskContext()

void MaskGraphicsScene::setMaskContext ( SessionModel model,
const QModelIndex &  maskContainerIndex,
IntensityDataItem intensityItem 
)

Definition at line 64 of file MaskGraphicsScene.cpp.

66 {
67  m_intensityItem = intensityItem;
68 
69  if (model != m_maskModel || m_maskContainerIndex != maskContainerIndex) {
70  if (m_maskModel) {
71  disconnect(m_maskModel, &SessionModel::modelAboutToBeReset, this,
73  disconnect(m_maskModel, &SessionModel::rowsInserted, this,
75  disconnect(m_maskModel, &SessionModel::rowsAboutToBeRemoved, this,
77  disconnect(m_maskModel, &SessionModel::rowsRemoved, this,
79  disconnect(m_maskModel, &SessionModel::modelReset, this,
81  }
82 
83  m_maskModel = model;
84 
85  QString containerType = m_maskModel->itemForIndex(maskContainerIndex)->modelType();
86  if (containerType != MaskContainerItem::M_TYPE
87  && containerType != ProjectionContainerItem::M_TYPE)
88  throw Error("MaskGraphicsScene::setMaskContext() -> Error. Not a container");
89 
90  m_maskContainerIndex = maskContainerIndex;
91 
92  if (m_maskModel) {
93  connect(m_maskModel, &SessionModel::modelAboutToBeReset, this,
95  connect(m_maskModel, &SessionModel::rowsInserted, this,
97  connect(m_maskModel, &SessionModel::rowsAboutToBeRemoved, this,
99  connect(m_maskModel, &SessionModel::rowsRemoved, this,
101  connect(m_maskModel, &SessionModel::modelReset, this, &MaskGraphicsScene::updateScene);
102  }
103 
104  resetScene();
105  updateScene();
106  }
107 }
static constexpr auto M_TYPE
Definition: MaskItems.h:204
static constexpr auto M_TYPE

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().

Here is the call graph for this function:

◆ setSelectionModel()

void MaskGraphicsScene::setSelectionModel ( QItemSelectionModel *  model)

Definition at line 128 of file MaskGraphicsScene.cpp.

129 {
130  ASSERT(model);
131  m_selectionModel = model;
132  connect(m_selectionModel, &QItemSelectionModel::selectionChanged, this,
133  &MaskGraphicsScene::onSessionSelectionChanged, Qt::UniqueConnection);
134 }
void onSessionSelectionChanged(const QItemSelection &, const QItemSelection &)
Propagates selection from model to scene.

References m_selectionModel, and onSessionSelectionChanged().

Referenced by MaskEditorCanvas::setSelectionModel(), and ProjectionsEditorCanvas::setSelectionModel().

Here is the call graph for this function:

◆ setZValues()

void MaskGraphicsScene::setZValues ( )
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.

712 {
713  ASSERT(m_maskContainerIndex.isValid());
714  for (int i = 0; i < m_maskModel->rowCount(m_maskContainerIndex); i++) {
715  QModelIndex itemIndex = m_maskModel->index(i, 0, m_maskContainerIndex);
716  SessionItem* item = m_maskModel->itemForIndex(itemIndex);
717  if (IShape2DView* view = m_ItemToView[item])
718  view->setZValue(m_maskModel->rowCount(m_maskContainerIndex) - itemIndex.row() + 1);
719  }
720 }

References SessionModel::index(), SessionModel::itemForIndex(), m_ItemToView, m_maskContainerIndex, m_maskModel, and SessionModel::rowCount().

Referenced by updateScene().

Here is the call graph for this function:

◆ updateCursors()

void MaskGraphicsScene::updateCursors ( )
private

Change cursor to stress that hovered item is movable (when not in PanZoom mode)

Definition at line 575 of file MaskGraphicsScene.cpp.

576 {
577  for (auto it = m_ItemToView.begin(); it != m_ItemToView.end(); ++it) {
578  if (it.key()->modelType() == VerticalLineItem::M_TYPE)
579  it.value()->setCursor(m_context.isInZoomMode() ? Qt::ArrowCursor : Qt::SizeHorCursor);
580  else if (it.key()->modelType() == HorizontalLineItem::M_TYPE)
581  it.value()->setCursor(m_context.isInZoomMode() ? Qt::ArrowCursor : Qt::SizeVerCursor);
582  }
583 }
static constexpr auto M_TYPE
Definition: MaskItems.h:147
static constexpr auto M_TYPE
Definition: MaskItems.h:131

References MaskDrawingContext::isInZoomMode(), m_context, m_ItemToView, VerticalLineItem::M_TYPE, and HorizontalLineItem::M_TYPE.

Referenced by onActivityModeChanged().

Here is the call graph for this function:

◆ updateProxyWidget()

void MaskGraphicsScene::updateProxyWidget ( )
private

Updates proxy widget for intensity data item.

Definition at line 371 of file MaskGraphicsScene.cpp.

372 {
373  ASSERT(m_intensityItem);
374  if (!m_proxy) {
378  addItem(m_proxy);
379  }
380 }
Graphics proxy to place QWidget inside QGraphicsScene, used by MaskEditorCanvas.
void setIntensityItem(IntensityDataItem *item)

References m_adaptor, m_intensityItem, m_proxy, MaskGraphicsProxy::setIntensityItem(), and MaskGraphicsProxy::setSceneAdaptor().

Referenced by updateScene().

Here is the call graph for this function:

◆ updateScene

void MaskGraphicsScene::updateScene ( )
slot

Main method to update scene on various changes in the model.

Definition at line 208 of file MaskGraphicsScene.cpp.

209 {
210  if (!m_maskModel)
211  return;
212 
216  setZValues();
217 }
void setZValues()
Update Z-values of all IMaskView to reflect stacking order in SessionModel. Item with irow=0 is the t...
IShape2DView * addViewForItem(SessionItem *item)
Creates a view for given item.
void updateViews(const QModelIndex &parentIndex={}, IShape2DView *parentView=nullptr)
Recutsively runs through the model and creates corresponding views.
void updateProxyWidget()
Updates proxy widget for intensity data item.

References addViewForItem(), SessionModel::itemForIndex(), m_maskContainerIndex, m_maskModel, setZValues(), updateProxyWidget(), and updateViews().

Referenced by onRowsInserted(), onRowsRemoved(), resetContext(), and setMaskContext().

Here is the call graph for this function:

◆ updateViews()

void MaskGraphicsScene::updateViews ( const QModelIndex &  parentIndex = {},
IShape2DView parentView = nullptr 
)
private

Recutsively runs through the model and creates corresponding views.

Definition at line 384 of file MaskGraphicsScene.cpp.

385 {
386  ASSERT(m_maskModel);
387  IShape2DView* childView(nullptr);
388  for (int i_row = 0; i_row < m_maskModel->rowCount(parentIndex); ++i_row) {
389  QModelIndex itemIndex = m_maskModel->index(i_row, 0, parentIndex);
390  if (SessionItem* item = m_maskModel->itemForIndex(itemIndex)) {
391  if (item->hasModelType<GroupItem>() || item->hasModelType<PropertyItem>())
392  continue;
393 
394  childView = addViewForItem(item);
395  if (childView) {
396  if (parentView)
397  parentView->addView(childView, i_row);
398  }
399  }
400  updateViews(itemIndex, childView);
401  }
402 }
virtual void addView(IShape2DView *childView, int row=0)
bool hasModelType() const
Definition: SessionItem.h:421

References IShape2DView::addView(), addViewForItem(), SessionItem::hasModelType(), SessionModel::index(), SessionModel::itemForIndex(), m_maskModel, and SessionModel::rowCount().

Referenced by updateScene().

Here is the call graph for this function:

Member Data Documentation

◆ m_adaptor

◆ m_block_selection

bool MaskGraphicsScene::m_block_selection
private

◆ m_context

◆ m_currentItem

◆ m_currentMousePosition

QPointF MaskGraphicsScene::m_currentMousePosition
private

Definition at line 121 of file MaskGraphicsScene.h.

Referenced by drawForeground(), mouseMoveEvent(), and processPolygonItem().

◆ m_intensityItem

IntensityDataItem* MaskGraphicsScene::m_intensityItem
private

Definition at line 119 of file MaskGraphicsScene.h.

Referenced by resetContext(), setMaskContext(), and updateProxyWidget().

◆ m_ItemToView

◆ m_maskContainerIndex

◆ m_maskModel

◆ m_proxy

MaskGraphicsProxy* MaskGraphicsScene::m_proxy
private

◆ m_selectionModel

QItemSelectionModel* MaskGraphicsScene::m_selectionModel
private

The documentation for this class was generated from the following files: