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

Description

Definition at line 25 of file SpecularDataCanvas.h.

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

Public Slots

void onMousePress (QMouseEvent *event)
 
void onResetViewAction ()
 
void onSavePlotAction ()
 

Public Member Functions

 SpecularDataCanvas (QWidget *parent=nullptr)
 
QList< QAction * > actionList () override
 
SessionItemcurrentItem ()
 
const SessionItemcurrentItem () const
 
QCustomPlot * customPlot ()
 
void enableDeprecatedOnMousePress (bool b)
 Enable or disable the onMousePress() handler. For legacy reasons the onMousePress handler is enabled. It is deprecated because of: More...
 
void initScatter ()
 
QSize minimumSizeHint () const override
 
void setItem (SessionItem *intensityItem) override
 
QSize sizeHint () const override
 

Protected Member Functions

void hideEvent (QHideEvent *) override
 
void showEvent (QShowEvent *) override
 
virtual void subscribeToItem ()
 
virtual void unsubscribeFromItem ()
 

Private Member Functions

void initActions ()
 
SpecularDataItemspecularDataItem ()
 

Private Attributes

SessionItemControllerm_itemController
 
SpecularPlotCanvasm_plot_canvas
 
QAction * m_reset_view_action
 
QAction * m_save_plot_action
 

Constructor & Destructor Documentation

◆ SpecularDataCanvas()

SpecularDataCanvas::SpecularDataCanvas ( QWidget *  parent = nullptr)
explicit

Definition at line 23 of file SpecularDataCanvas.cpp.

24  : SessionItemWidget(parent)
26  , m_reset_view_action(nullptr)
27  , m_save_plot_action(nullptr)
28 
29 {
30  auto* vlayout = new QVBoxLayout(this);
31  vlayout->setSpacing(0);
32  vlayout->setContentsMargins(0, 0, 0, 0);
33  vlayout->addWidget(m_plot_canvas);
34  setLayout(vlayout);
35  setStyleSheet("background-color:white;");
36 
37  initActions();
38 
40 
41  enableDeprecatedOnMousePress(true); // true for legacy reasons
42 }
SessionItemWidget(QWidget *parent=nullptr)
SpecularPlotCanvas * m_plot_canvas
void enableDeprecatedOnMousePress(bool b)
Enable or disable the onMousePress() handler. For legacy reasons the onMousePress handler is enabled....
The SpecularPlotCanvas class contains SpecularPlot for specular data presentation,...
void setStatusLabelEnabled(bool flag)

References enableDeprecatedOnMousePress(), initActions(), m_plot_canvas, and SpecularPlotCanvas::setStatusLabelEnabled().

Here is the call graph for this function:

Member Function Documentation

◆ actionList()

QList< QAction * > SpecularDataCanvas::actionList ( )
overridevirtual

Reimplemented from SessionItemWidget.

Definition at line 60 of file SpecularDataCanvas.cpp.

61 {
62  return QList<QAction*>() << m_reset_view_action << m_save_plot_action;
63 }

References m_reset_view_action, and m_save_plot_action.

Referenced by SpecularDataWidget::actionList().

◆ currentItem() [1/2]

◆ currentItem() [2/2]

const SessionItem * SessionItemWidget::currentItem ( ) const
inherited

Definition at line 46 of file SessionItemWidget.cpp.

47 {
48  return m_itemController->currentItem();
49 }
SessionItemController * m_itemController

References SessionItemController::currentItem(), and SessionItemWidget::m_itemController.

Here is the call graph for this function:

◆ customPlot()

QCustomPlot * SpecularDataCanvas::customPlot ( )

Definition at line 65 of file SpecularDataCanvas.cpp.

66 {
67  return m_plot_canvas->customPlot();
68 }
QCustomPlot * customPlot()

References SpecularPlotCanvas::customPlot(), and m_plot_canvas.

Here is the call graph for this function:

◆ enableDeprecatedOnMousePress()

void SpecularDataCanvas::enableDeprecatedOnMousePress ( bool  b)

Enable or disable the onMousePress() handler. For legacy reasons the onMousePress handler is enabled. It is deprecated because of:

  • mousepress is the wrong event to listen to for opening a context menu
  • disables possibility to get context menu events for specific parts of the plot (e.g. context menu for axis configuration)

Definition at line 70 of file SpecularDataCanvas.cpp.

71 {
72  if (b)
73  connect(m_plot_canvas->customPlot(), &QCustomPlot::mousePress, this,
74  &SpecularDataCanvas::onMousePress, Qt::UniqueConnection);
75  else
76  disconnect(m_plot_canvas->customPlot(), &QCustomPlot::mousePress, this,
78 }
void onMousePress(QMouseEvent *event)

References SpecularPlotCanvas::customPlot(), m_plot_canvas, and onMousePress().

Referenced by SpecularDataCanvas().

Here is the call graph for this function:

◆ hideEvent()

void SessionItemWidget::hideEvent ( QHideEvent *  )
overrideprotectedinherited

Definition at line 56 of file SessionItemWidget.cpp.

57 {
59 }
void unsubscribe()
Fully unsubscribes the parent from listening item's signals. Controller stays active to track item de...

References SessionItemWidget::m_itemController, and SessionItemController::unsubscribe().

Here is the call graph for this function:

◆ initActions()

void SpecularDataCanvas::initActions ( )
private

Definition at line 110 of file SpecularDataCanvas.cpp.

111 {
112  m_reset_view_action = new QAction(this);
113  m_reset_view_action->setText("Center view");
114  m_reset_view_action->setIcon(QIcon(":/images/camera-metering-center.svg"));
115  m_reset_view_action->setToolTip("Center view\n"
116  "x,y axes range will be set to default");
117  connect(m_reset_view_action, &QAction::triggered, this, &SpecularDataCanvas::onResetViewAction);
118 
119  m_save_plot_action = new QAction(this);
120  m_save_plot_action->setText("Save");
121  m_save_plot_action->setIcon(QIcon(":/images/content-save-outline.svg"));
122  m_save_plot_action->setToolTip("Save plot");
123  connect(m_save_plot_action, &QAction::triggered, this, &SpecularDataCanvas::onSavePlotAction);
124 }

References m_reset_view_action, m_save_plot_action, onResetViewAction(), and onSavePlotAction().

Referenced by SpecularDataCanvas().

Here is the call graph for this function:

◆ initScatter()

void SpecularDataCanvas::initScatter ( )

Definition at line 80 of file SpecularDataCanvas.cpp.

81 {
83 }

References SpecularPlotCanvas::initScatter(), and m_plot_canvas.

Referenced by SpecularDataWidget::setItem().

Here is the call graph for this function:

◆ minimumSizeHint()

QSize SpecularDataCanvas::minimumSizeHint ( ) const
override

Definition at line 55 of file SpecularDataCanvas.cpp.

56 {
57  return QSize(128, 128);
58 }

◆ onMousePress

void SpecularDataCanvas::onMousePress ( QMouseEvent *  event)
slot

Definition at line 96 of file SpecularDataCanvas.cpp.

97 {
98  if (event->button() == Qt::RightButton)
99  emit customContextMenuRequested(event->globalPos());
100 }

Referenced by enableDeprecatedOnMousePress().

◆ onResetViewAction

void SpecularDataCanvas::onResetViewAction ( )
slot

Definition at line 85 of file SpecularDataCanvas.cpp.

86 {
88 }
SpecularDataItem * specularDataItem()
void resetView()
Set axes viewport to original data.

References SpecularDataItem::resetView(), and specularDataItem().

Referenced by initActions().

Here is the call graph for this function:

◆ onSavePlotAction

void SpecularDataCanvas::onSavePlotAction ( )
slot

Definition at line 90 of file SpecularDataCanvas.cpp.

91 {
92  QString dirname = gSessionData->projectDocument.value()->userExportDir();
93  GUI::Plot::savePlot(dirname, m_plot_canvas->customPlot(), specularDataItem()->getDatafield());
94 }
SessionData * gSessionData
global pointer to the single instance
Definition: SessionData.cpp:17
void savePlot(const QString &dirname, QCustomPlot *plot, Datafield *output_data)
std::optional< ProjectDocument * > projectDocument
Definition: SessionData.h:27

References SpecularPlotCanvas::customPlot(), gSessionData, m_plot_canvas, SessionData::projectDocument, GUI::Plot::savePlot(), and specularDataItem().

Referenced by initActions().

Here is the call graph for this function:

◆ setItem()

void SpecularDataCanvas::setItem ( SessionItem intensityItem)
overridevirtual

Reimplemented from SessionItemWidget.

Definition at line 44 of file SpecularDataCanvas.cpp.

45 {
46  SessionItemWidget::setItem(intensityItem);
47  m_plot_canvas->setItem(intensityItem);
48 }
virtual void setItem(SessionItem *item)
void setItem(SessionItem *specularDataItem) override

References m_plot_canvas, SessionItemWidget::setItem(), and SpecularPlotCanvas::setItem().

Referenced by SpecularDataWidget::setItem().

Here is the call graph for this function:

◆ showEvent()

void SessionItemWidget::showEvent ( QShowEvent *  )
overrideprotectedinherited

Definition at line 51 of file SessionItemWidget.cpp.

52 {
54 }
void subscribe()
Subscribe parent to item's signals.

References SessionItemWidget::m_itemController, and SessionItemController::subscribe().

Here is the call graph for this function:

◆ sizeHint()

QSize SpecularDataCanvas::sizeHint ( ) const
override

Definition at line 50 of file SpecularDataCanvas.cpp.

51 {
52  return QSize(500, 400);
53 }

◆ specularDataItem()

SpecularDataItem * SpecularDataCanvas::specularDataItem ( )
private

Definition at line 102 of file SpecularDataCanvas.cpp.

103 {
104  auto* result = dynamic_cast<SpecularDataItem*>(currentItem());
105  ASSERT(result);
106  return result;
107 }

References SessionItemWidget::currentItem().

Referenced by onResetViewAction(), and onSavePlotAction().

Here is the call graph for this function:

◆ subscribeToItem()

◆ unsubscribeFromItem()

virtual void SessionItemWidget::unsubscribeFromItem ( )
inlineprotectedvirtualinherited

Member Data Documentation

◆ m_itemController

◆ m_plot_canvas

SpecularPlotCanvas* SpecularDataCanvas::m_plot_canvas
private

◆ m_reset_view_action

QAction* SpecularDataCanvas::m_reset_view_action
private

Definition at line 57 of file SpecularDataCanvas.h.

Referenced by actionList(), and initActions().

◆ m_save_plot_action

QAction* SpecularDataCanvas::m_save_plot_action
private

Definition at line 58 of file SpecularDataCanvas.h.

Referenced by actionList(), and initActions().


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