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

Description

Holds a graphics scene to draw projections on top of ColorMap. Being a part of ProjectionEditor, provides interaction logic between graphics scene and ProjectionsWidget.

Particularly, it creates temporary ProjectionItem in projection container, when mouse is inside ColorMap viewport.

Definition at line 37 of file ProjectionsEditorCanvas.h.

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

Public Slots

void onActivityModeChanged (MaskEditorFlags::Activity value)
 
void onEnteringColorMap ()
 
void onLeavingColorMap ()
 
void onPositionChanged (double x, double y)
 
void onResetViewRequest ()
 

Signals

void changeActivityRequest (MaskEditorFlags::Activity)
 
void deleteSelectedRequest ()
 
void marginsChanged (double left, double right)
 

Public Member Functions

 ProjectionsEditorCanvas (QWidget *parent=nullptr)
 
MaskGraphicsScenegetScene ()
 
void resetContext ()
 
void setContext (SessionModel *model, const QModelIndex &shapeContainerIndex, IntensityDataItem *intensityItem)
 
void setSelectionModel (QItemSelectionModel *model)
 

Private Member Functions

void setColorMap (ColorMap *colorMap)
 
void setConnected (bool isConnected)
 

Private Attributes

bool m_block_update
 
ColorMapm_colorMap
 
QModelIndex m_containerIndex
 
MaskEditorFlags::Activity m_currentActivity
 
IntensityDataItemm_intensityDataItem
 
MaskItemm_liveProjection
 temporary projection item matching mouse move More...
 
SessionModelm_model
 
MaskGraphicsScenem_scene
 
PlotStatusLabelm_statusLabel
 
MaskGraphicsViewm_view
 

Constructor & Destructor Documentation

◆ ProjectionsEditorCanvas()

ProjectionsEditorCanvas::ProjectionsEditorCanvas ( QWidget *  parent = nullptr)

Definition at line 31 of file ProjectionsEditorCanvas.cpp.

32  : QWidget(parent)
33  , m_scene(new MaskGraphicsScene(this))
35  , m_colorMap(nullptr)
36  , m_statusLabel(new PlotStatusLabel(nullptr, this))
37  , m_liveProjection(nullptr)
38  , m_model(nullptr)
39  , m_intensityDataItem(nullptr)
41  , m_block_update(false)
42 {
43  setObjectName("MaskEditorCanvas");
44  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
45 
46  auto* mainLayout = new QVBoxLayout;
47  mainLayout->addWidget(m_view);
48  mainLayout->addWidget(m_statusLabel);
49  mainLayout->setMargin(0);
50  mainLayout->setSpacing(0);
51  setLayout(mainLayout);
52 
57 }
Graphics scene for MaskEditorCanvas to draw masks on top of intensity data widgets.
Graphics view for MaskEditorCanvas.
void changeActivityRequest(MaskEditorFlags::Activity)
void deleteSelectedRequest()
The PlotStatusLabel class shows status string as reported by DescriptedPlot in a frame....
MaskEditorFlags::Activity m_currentActivity
MaskItem * m_liveProjection
temporary projection item matching mouse move
void changeActivityRequest(MaskEditorFlags::Activity)
IntensityDataItem * m_intensityDataItem

References MaskGraphicsView::changeActivityRequest(), changeActivityRequest(), MaskGraphicsView::deleteSelectedRequest(), deleteSelectedRequest(), m_statusLabel, and m_view.

Member Function Documentation

◆ changeActivityRequest

void ProjectionsEditorCanvas::changeActivityRequest ( MaskEditorFlags::Activity  )
signal

◆ deleteSelectedRequest

void ProjectionsEditorCanvas::deleteSelectedRequest ( )
signal

◆ getScene()

MaskGraphicsScene* ProjectionsEditorCanvas::getScene ( )
inline

Definition at line 50 of file ProjectionsEditorCanvas.h.

50 { return m_scene; }

References m_scene.

Referenced by onActivityModeChanged(), setContext(), and setSelectionModel().

◆ marginsChanged

void ProjectionsEditorCanvas::marginsChanged ( double  left,
double  right 
)
signal

◆ onActivityModeChanged

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

Definition at line 147 of file ProjectionsEditorCanvas.cpp.

148 {
149  m_currentActivity = value;
152 }
void onActivityModeChanged(MaskEditorFlags::Activity value)
MaskGraphicsScene * getScene()

References getScene(), m_currentActivity, MaskGraphicsScene::onActivityModeChanged(), and onLeavingColorMap().

Referenced by ProjectionsEditor::setup_connections().

Here is the call graph for this function:

◆ onEnteringColorMap

void ProjectionsEditorCanvas::onEnteringColorMap ( )
slot

Definition at line 89 of file ProjectionsEditorCanvas.cpp.

90 {
92  return;
93 
94  m_block_update = true;
95 
100 
101  if (m_liveProjection)
103 
104  m_block_update = false;
105 }
void setIsVisibleValue(bool visible)
Definition: MaskItems.cpp:100
T * insertItem(SessionItem *parent=nullptr, int row=-1, QString tag="")
Definition: SessionModel.h:137

References MaskEditorFlags::HORIZONTAL_LINE_MODE, SessionModel::insertItem(), m_block_update, m_containerIndex, m_currentActivity, m_liveProjection, m_model, MaskItem::setIsVisibleValue(), and MaskEditorFlags::VERTICAL_LINE_MODE.

Referenced by setConnected().

Here is the call graph for this function:

◆ onLeavingColorMap

void ProjectionsEditorCanvas::onLeavingColorMap ( )
slot

Definition at line 107 of file ProjectionsEditorCanvas.cpp.

108 {
109  if (m_block_update)
110  return;
111 
112  m_block_update = true;
113 
114  if (m_liveProjection) {
117  delete m_liveProjection;
118  m_liveProjection = nullptr;
119  }
120 
121  m_block_update = false;
122 }
int rowOfChild(SessionItem *child) const
Returns row index of given child.
SessionItem * takeRow(int row)
Removes row from item and returns the item.
SessionItem * parentItem() const
Returns parent of this item.
Definition: SessionItem.cpp:67

References m_block_update, m_liveProjection, SessionItem::parentItem(), SessionItem::rowOfChild(), and SessionItem::takeRow().

Referenced by onActivityModeChanged(), and setConnected().

Here is the call graph for this function:

◆ onPositionChanged

void ProjectionsEditorCanvas::onPositionChanged ( double  x,
double  y 
)
slot

Definition at line 124 of file ProjectionsEditorCanvas.cpp.

125 {
126  if (m_block_update)
127  return;
128 
129  m_block_update = true;
130 
131  if (m_liveProjection) {
133  polymorphic_downcast<HorizontalLineItem*>(m_liveProjection)->setPosY(y);
135  polymorphic_downcast<VerticalLineItem*>(m_liveProjection)->setPosX(x);
136  }
137 
138  m_block_update = false;
139 }

References MaskEditorFlags::HORIZONTAL_LINE_MODE, m_block_update, m_currentActivity, m_liveProjection, and MaskEditorFlags::VERTICAL_LINE_MODE.

Referenced by setConnected().

◆ onResetViewRequest

void ProjectionsEditorCanvas::onResetViewRequest ( )
slot

Definition at line 141 of file ProjectionsEditorCanvas.cpp.

142 {
145 }
void resetView()
Set axes viewport to original data.
void onResetViewRequest()
Reset given view to original zoom state. Also asks graphics scene to do the same with color map.

References m_intensityDataItem, m_view, MaskGraphicsView::onResetViewRequest(), and IntensityDataItem::resetView().

Referenced by ProjectionsEditor::setup_connections().

Here is the call graph for this function:

◆ resetContext()

void ProjectionsEditorCanvas::resetContext ( )

Definition at line 75 of file ProjectionsEditorCanvas.cpp.

76 {
77  m_intensityDataItem = nullptr;
78  m_containerIndex = {};
79  setConnected(false);
80  m_colorMap = nullptr;
82 }
void setConnected(bool isConnected)

References m_colorMap, m_containerIndex, m_intensityDataItem, m_scene, MaskGraphicsScene::resetContext(), and setConnected().

Referenced by ProjectionsEditor::resetContext().

Here is the call graph for this function:

◆ setColorMap()

void ProjectionsEditorCanvas::setColorMap ( ColorMap colorMap)
private

Definition at line 154 of file ProjectionsEditorCanvas.cpp.

155 {
156  ASSERT(colorMap);
157  setConnected(false);
158 
159  m_colorMap = colorMap;
160  setConnected(true);
161 
162  m_statusLabel->reset();
163  m_statusLabel->addPlot(colorMap);
164 }
void reset()
Disconnects all color maps from the label.
void addPlot(ScientificPlot *plot)

References PlotStatusLabel::addPlot(), m_colorMap, m_statusLabel, PlotStatusLabel::reset(), and setConnected().

Referenced by setContext().

Here is the call graph for this function:

◆ setConnected()

void ProjectionsEditorCanvas::setConnected ( bool  isConnected)
private

Definition at line 166 of file ProjectionsEditorCanvas.cpp.

167 {
168  if (!m_colorMap)
169  return;
170 
171  if (isConnected) {
173  &ProjectionsEditorCanvas::onEnteringColorMap, Qt::UniqueConnection);
175  &ProjectionsEditorCanvas::onLeavingColorMap, Qt::UniqueConnection);
177  &ProjectionsEditorCanvas::onPositionChanged, Qt::UniqueConnection);
178  connect(m_colorMap, &ColorMap::marginsChanged, this,
179  &ProjectionsEditorCanvas::marginsChanged, Qt::UniqueConnection);
180  }
181 
182  else {
189  disconnect(m_colorMap, &ColorMap::marginsChanged, this,
191  }
192 }
void marginsChanged(double left, double right)
void onPositionChanged(double x, double y)
void marginsChanged(double left, double right)
void positionChanged(double x, double y)
ScientificPlotEvent * plotEvent()

References ScientificPlotEvent::enteringPlot(), ScientificPlotEvent::leavingPlot(), m_colorMap, ColorMap::marginsChanged(), marginsChanged(), onEnteringColorMap(), onLeavingColorMap(), onPositionChanged(), ScientificPlot::plotEvent(), and ScientificPlotEvent::positionChanged().

Referenced by resetContext(), and setColorMap().

Here is the call graph for this function:

◆ setContext()

void ProjectionsEditorCanvas::setContext ( SessionModel model,
const QModelIndex &  shapeContainerIndex,
IntensityDataItem intensityItem 
)

Definition at line 59 of file ProjectionsEditorCanvas.cpp.

62 {
63  m_model = model;
64  m_scene->setMaskContext(model, shapeContainerIndex, intensityItem);
65  m_view->updateSize(m_view->size());
66 
67  m_containerIndex = shapeContainerIndex;
68  m_intensityDataItem = intensityItem;
69 
71 
73 }
void setMaskContext(SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
void updateSize(const QSize &newSize)
void setColorMap(ColorMap *colorMap)

References MaskGraphicsScene::colorMap(), getScene(), m_containerIndex, m_currentActivity, m_intensityDataItem, m_model, m_scene, m_view, MaskGraphicsScene::onActivityModeChanged(), setColorMap(), MaskGraphicsScene::setMaskContext(), and MaskGraphicsView::updateSize().

Referenced by ProjectionsEditor::setContext().

Here is the call graph for this function:

◆ setSelectionModel()

void ProjectionsEditorCanvas::setSelectionModel ( QItemSelectionModel *  model)

Definition at line 84 of file ProjectionsEditorCanvas.cpp.

85 {
86  getScene()->setSelectionModel(model);
87 }
void setSelectionModel(QItemSelectionModel *model)

References getScene(), and MaskGraphicsScene::setSelectionModel().

Referenced by ProjectionsEditor::setContext().

Here is the call graph for this function:

Member Data Documentation

◆ m_block_update

bool ProjectionsEditorCanvas::m_block_update
private

◆ m_colorMap

ColorMap* ProjectionsEditorCanvas::m_colorMap
private

Definition at line 70 of file ProjectionsEditorCanvas.h.

Referenced by resetContext(), setColorMap(), and setConnected().

◆ m_containerIndex

QModelIndex ProjectionsEditorCanvas::m_containerIndex
private

Definition at line 75 of file ProjectionsEditorCanvas.h.

Referenced by onEnteringColorMap(), resetContext(), and setContext().

◆ m_currentActivity

MaskEditorFlags::Activity ProjectionsEditorCanvas::m_currentActivity
private

◆ m_intensityDataItem

IntensityDataItem* ProjectionsEditorCanvas::m_intensityDataItem
private

Definition at line 76 of file ProjectionsEditorCanvas.h.

Referenced by onResetViewRequest(), resetContext(), and setContext().

◆ m_liveProjection

MaskItem* ProjectionsEditorCanvas::m_liveProjection
private

temporary projection item matching mouse move

Definition at line 73 of file ProjectionsEditorCanvas.h.

Referenced by onEnteringColorMap(), onLeavingColorMap(), and onPositionChanged().

◆ m_model

SessionModel* ProjectionsEditorCanvas::m_model
private

Definition at line 74 of file ProjectionsEditorCanvas.h.

Referenced by onEnteringColorMap(), and setContext().

◆ m_scene

MaskGraphicsScene* ProjectionsEditorCanvas::m_scene
private

Definition at line 68 of file ProjectionsEditorCanvas.h.

Referenced by getScene(), resetContext(), and setContext().

◆ m_statusLabel

PlotStatusLabel* ProjectionsEditorCanvas::m_statusLabel
private

Definition at line 71 of file ProjectionsEditorCanvas.h.

Referenced by ProjectionsEditorCanvas(), and setColorMap().

◆ m_view

MaskGraphicsView* ProjectionsEditorCanvas::m_view
private

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