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

Description

Painting widget for MaskEditor, contains graphics scene and graphics view.

Definition at line 33 of file MaskEditorCanvas.h.

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

Public Slots

void onPresentationTypeRequest (MaskEditorFlags::PresentationType presentationType)
 
void onResetViewRequest ()
 
void onSavePlotRequest ()
 Saves plot into project directory. More...
 

Signals

void changeActivityRequest (MaskEditorFlags::Activity)
 
void deleteSelectedRequest ()
 

Public Member Functions

 MaskEditorCanvas (QWidget *parent=nullptr)
 
MaskGraphicsScenegetScene ()
 
void resetContext ()
 
void setMaskContext (SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
 
void setSelectionModel (QItemSelectionModel *model)
 

Private Member Functions

bool isAxisRangeMatchData () const
 Returns true if IntensityData is currently at 100% zoom level. More...
 
void setZoomToROI ()
 

Private Attributes

IntensityDataItemm_intensityDataItem
 
MaskResultsPresenterm_resultsPresenter
 
MaskGraphicsScenem_scene
 
PlotStatusLabelm_statusLabel
 
MaskGraphicsViewm_view
 

Constructor & Destructor Documentation

◆ MaskEditorCanvas()

MaskEditorCanvas::MaskEditorCanvas ( QWidget *  parent = nullptr)

Definition at line 28 of file MaskEditorCanvas.cpp.

29  : QWidget(parent)
30  , m_scene(new MaskGraphicsScene(this))
32  , m_intensityDataItem(nullptr)
33  , m_statusLabel(new PlotStatusLabel(nullptr, this))
35 {
36  setObjectName("MaskEditorCanvas");
37  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
38 
39  auto* mainLayout = new QVBoxLayout;
40  mainLayout->addWidget(m_view);
41  mainLayout->addWidget(m_statusLabel);
42  mainLayout->setMargin(0);
43  mainLayout->setSpacing(0);
44  setLayout(mainLayout);
45 
50 }
void deleteSelectedRequest()
MaskGraphicsView * m_view
PlotStatusLabel * m_statusLabel
void changeActivityRequest(MaskEditorFlags::Activity)
MaskResultsPresenter * m_resultsPresenter
IntensityDataItem * m_intensityDataItem
MaskGraphicsScene * m_scene
Graphics scene for MaskEditorCanvas to draw masks on top of intensity data widgets.
Graphics view for MaskEditorCanvas.
void changeActivityRequest(MaskEditorFlags::Activity)
void deleteSelectedRequest()
Updates bin values inside IntensityData to display current mask state. Returns IntensityData to origi...
The PlotStatusLabel class shows status string as reported by DescriptedPlot in a frame....

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

Member Function Documentation

◆ changeActivityRequest

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

◆ deleteSelectedRequest

void MaskEditorCanvas::deleteSelectedRequest ( )
signal

◆ getScene()

MaskGraphicsScene * MaskEditorCanvas::getScene ( )

Definition at line 76 of file MaskEditorCanvas.cpp.

77 {
78  return m_scene;
79 }

References m_scene.

Referenced by MaskEditor::setup_connections().

◆ isAxisRangeMatchData()

bool MaskEditorCanvas::isAxisRangeMatchData ( ) const
private

Returns true if IntensityData is currently at 100% zoom level.

Definition at line 115 of file MaskEditorCanvas.cpp.

116 {
117  ASSERT(m_intensityDataItem);
118 
120  return false;
122  return false;
124  return false;
126  return false;
127  return true;
128 }
double xMin() const
Returns min and max range of x-axis as given by IntensityData.
double getLowerY() const
Returns lower and upper zoom ranges of y-axis.
double getUpperY() const
double getUpperX() const
double getLowerX() const
Returns lower and upper zoom ranges of x-axis.
double yMin() const
Returns min and max range of y-axis as given by IntensityData.

References IntensityDataItem::getLowerX(), IntensityDataItem::getLowerY(), IntensityDataItem::getUpperX(), IntensityDataItem::getUpperY(), m_intensityDataItem, IntensityDataItem::xMax(), IntensityDataItem::xMin(), IntensityDataItem::yMax(), and IntensityDataItem::yMin().

Referenced by onResetViewRequest().

Here is the call graph for this function:

◆ onPresentationTypeRequest

void MaskEditorCanvas::onPresentationTypeRequest ( MaskEditorFlags::PresentationType  presentationType)
slot

Definition at line 81 of file MaskEditorCanvas.cpp.

82 {
83  m_scene->clearSelection(); // important to avoid crash (unsubscribe while calling subscribers)
84  m_resultsPresenter->updatePresenter(presentationType);
85 
86  if (auto* container = m_intensityDataItem->maskContainerItem()) {
87  bool isVisible = presentationType.testFlag(MaskEditorFlags::MASK_EDITOR);
88  for (MaskItem* mask : container->maskItems())
89  mask->setIsVisibleValue(isVisible);
90  }
91 }
MaskContainerItem * maskContainerItem()
A base class for all mask items.
Definition: MaskItems.h:27
void updatePresenter(MaskEditorFlags::PresentationType presentationType)

References m_intensityDataItem, m_resultsPresenter, m_scene, MaskEditorFlags::MASK_EDITOR, IntensityDataItem::maskContainerItem(), and MaskResultsPresenter::updatePresenter().

Referenced by MaskEditor::setup_connections().

Here is the call graph for this function:

◆ onResetViewRequest

void MaskEditorCanvas::onResetViewRequest ( )
slot

Definition at line 103 of file MaskEditorCanvas.cpp.

104 {
106 
107  if (isAxisRangeMatchData())
108  setZoomToROI();
109  else
111 }
void resetView()
Set axes viewport to original data.
bool isAxisRangeMatchData() const
Returns true if IntensityData is currently at 100% zoom level.
void onResetViewRequest()
Reset given view to original zoom state. Also asks graphics scene to do the same with color map.

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

Referenced by MaskEditor::setup_connections().

Here is the call graph for this function:

◆ onSavePlotRequest

void MaskEditorCanvas::onSavePlotRequest ( )
slot

Saves plot into project directory.

Definition at line 95 of file MaskEditorCanvas.cpp.

96 {
97  QString dirname = gSessionData->projectDocument.value()->userExportDir();
98 
101 }
SessionData * gSessionData
global pointer to the single instance
Definition: SessionData.cpp:17
QCustomPlot * customPlot() override
Definition: ColorMap.h:45
Datafield * getDatafield()
Definition: DataItem.h:41
void savePlot(const QString &dirname, QCustomPlot *plot, Datafield *output_data)
std::optional< ProjectDocument * > projectDocument
Definition: SessionData.h:27

References MaskGraphicsScene::colorMap(), ColorMap::customPlot(), DataItem::getDatafield(), gSessionData, m_intensityDataItem, m_scene, SessionData::projectDocument, and GUI::Plot::savePlot().

Referenced by MaskEditor::setup_connections().

Here is the call graph for this function:

◆ resetContext()

void MaskEditorCanvas::resetContext ( )

Definition at line 64 of file MaskEditorCanvas.cpp.

65 {
66  m_intensityDataItem = nullptr;
69 }
void reset()
Disconnects all color maps from the label.

References m_intensityDataItem, m_scene, m_statusLabel, PlotStatusLabel::reset(), and MaskGraphicsScene::resetContext().

Referenced by MaskEditor::resetContext().

Here is the call graph for this function:

◆ setMaskContext()

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

Definition at line 52 of file MaskEditorCanvas.cpp.

54 {
55  m_intensityDataItem = intensityItem;
56 
57  m_scene->setMaskContext(model, maskContainerIndex, intensityItem);
58  m_resultsPresenter->setMaskContext(model, maskContainerIndex, intensityItem);
59  m_view->updateSize(m_view->size());
60 
62 }
void setMaskContext(SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
void updateSize(const QSize &newSize)
void setMaskContext(SessionModel *maskModel, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
void addPlot(ScientificPlot *plot)

References PlotStatusLabel::addPlot(), MaskGraphicsScene::colorMap(), m_intensityDataItem, m_resultsPresenter, m_scene, m_statusLabel, m_view, MaskResultsPresenter::setMaskContext(), MaskGraphicsScene::setMaskContext(), and MaskGraphicsView::updateSize().

Referenced by MaskEditor::setMaskContext().

Here is the call graph for this function:

◆ setSelectionModel()

void MaskEditorCanvas::setSelectionModel ( QItemSelectionModel *  model)

Definition at line 71 of file MaskEditorCanvas.cpp.

72 {
73  m_scene->setSelectionModel(model);
74 }
void setSelectionModel(QItemSelectionModel *model)

References m_scene, and MaskGraphicsScene::setSelectionModel().

Referenced by MaskEditor::setMaskContext().

Here is the call graph for this function:

◆ setZoomToROI()

void MaskEditorCanvas::setZoomToROI ( )
private

Definition at line 130 of file MaskEditorCanvas.cpp.

131 {
132  if (MaskContainerItem* maskContainer = m_intensityDataItem->maskContainerItem()) {
133  if (auto* roiItem = maskContainer->regionOfInterestItem()) {
134  m_intensityDataItem->setLowerX(roiItem->xLow());
135  m_intensityDataItem->setUpperX(roiItem->xUp());
136  m_intensityDataItem->setLowerY(roiItem->yLow());
137  m_intensityDataItem->setUpperY(roiItem->yUp());
138  }
139  }
140 }
void setLowerX(double value)
void setLowerY(double value)
void setUpperX(double value)
void setUpperY(double value)
Container holding various masks as children.
Definition: MaskItems.h:202

References m_intensityDataItem, IntensityDataItem::maskContainerItem(), IntensityDataItem::setLowerX(), IntensityDataItem::setLowerY(), IntensityDataItem::setUpperX(), and IntensityDataItem::setUpperY().

Referenced by onResetViewRequest().

Here is the call graph for this function:

Member Data Documentation

◆ m_intensityDataItem

◆ m_resultsPresenter

MaskResultsPresenter* MaskEditorCanvas::m_resultsPresenter
private

Definition at line 64 of file MaskEditorCanvas.h.

Referenced by onPresentationTypeRequest(), and setMaskContext().

◆ m_scene

MaskGraphicsScene* MaskEditorCanvas::m_scene
private

◆ m_statusLabel

PlotStatusLabel* MaskEditorCanvas::m_statusLabel
private

Definition at line 63 of file MaskEditorCanvas.h.

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

◆ m_view

MaskGraphicsView* MaskEditorCanvas::m_view
private

Definition at line 61 of file MaskEditorCanvas.h.

Referenced by MaskEditorCanvas(), onResetViewRequest(), and setMaskContext().


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