BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelView::ViewportAxisPlotController::AxesPlotControllerImpl Struct Reference
Collaboration diagram for ModelView::ViewportAxisPlotController::AxesPlotControllerImpl:
[legend]

Public Member Functions

 AxesPlotControllerImpl (ViewportAxisPlotController *controller, QCPAxis *axis)
 
 ~AxesPlotControllerImpl ()
 
void init_axis ()
 Init axis from item and setup connections. More...
 
void setAxisLogScaleFromItem ()
 Sets log scale from item. More...
 
void setAxisRangeFromItem ()
 Sets axesRange from SessionItem. More...
 
void setConnected ()
 Connects QCustomPlot signals with controller methods. More...
 
void setDisconnected ()
 Disonnects QCustomPlot signals. More...
 
void updateLowerRange (const ViewportAxisItem *item)
 
void updateUpperRange (const ViewportAxisItem *item)
 

Public Attributes

QCPAxis * m_axis {nullptr}
 
std::unique_ptr< QMetaObject::Connection > m_axisConn
 
bool m_blockUpdate {false}
 
ViewportAxisPlotControllerm_self {nullptr}
 
std::unique_ptr< AxisTitleControllerm_titleController
 

Detailed Description

Definition at line 26 of file viewportaxisplotcontroller.cpp.

Constructor & Destructor Documentation

◆ AxesPlotControllerImpl()

ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::AxesPlotControllerImpl ( ViewportAxisPlotController controller,
QCPAxis *  axis 
)
inline

Definition at line 34 of file viewportaxisplotcontroller.cpp.

35  : m_self(controller), m_axis(axis)
36  {
37  if (!axis)
38  throw std::runtime_error("AxisPlotController: axis is not initialized.");
39  m_axisConn = std::make_unique<QMetaObject::Connection>();
40  }

References ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_axisConn.

◆ ~AxesPlotControllerImpl()

ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::~AxesPlotControllerImpl ( )
inline

Definition at line 101 of file viewportaxisplotcontroller.cpp.

References ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setDisconnected().

Here is the call graph for this function:

Member Function Documentation

◆ init_axis()

void ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::init_axis ( )
inline

Init axis from item and setup connections.

Definition at line 77 of file viewportaxisplotcontroller.cpp.

78  {
79  m_titleController = std::make_unique<AxisTitleController>(m_axis);
80  auto text_item = m_self->currentItem()->item<TextItem>(ViewportAxisItem::P_TITLE);
81  m_titleController->setItem(text_item);
84  setConnected();
85  }
T * item(const std::string &tag) const
Returns first item under given tag casted to a specified type.
Definition: sessionitem.h:156
Represent text item on plot.
void setConnected()
Connects QCustomPlot signals with controller methods.

References ModelView::ItemListener< T >::currentItem(), ModelView::SessionItem::item(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_axis, ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_self, ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_titleController, ModelView::ViewportAxisItem::P_TITLE, ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setAxisLogScaleFromItem(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setAxisRangeFromItem(), and ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setConnected().

Here is the call graph for this function:

◆ setAxisLogScaleFromItem()

void ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setAxisLogScaleFromItem ( )
inline

Sets log scale from item.

Definition at line 70 of file viewportaxisplotcontroller.cpp.

71  {
73  }
MVVM_VIEW_EXPORT void SetLogarithmicScale(QCPColorScale *axis, bool is_log_scale)
Switch axis to logarithmic scale mode.

References ModelView::ItemListener< T >::currentItem(), ModelView::ViewportAxisItem::is_in_log(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_axis, ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_self, and ModelView::Utils::SetLogarithmicScale().

Referenced by ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::init_axis().

Here is the call graph for this function:

◆ setAxisRangeFromItem()

void ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setAxisRangeFromItem ( )
inline

Sets axesRange from SessionItem.

Definition at line 62 of file viewportaxisplotcontroller.cpp.

63  {
64  auto [lower, upper] = m_self->currentItem()->range();
65  m_axis->setRange(QCPRange(lower, upper));
66  }
std::pair< double, double > range() const
Returns pair of lower, upper axis range.
Definition: axisitems.cpp:44

References ModelView::ItemListener< T >::currentItem(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_axis, ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_self, and ModelView::ViewportAxisItem::range().

Referenced by ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::init_axis().

Here is the call graph for this function:

◆ setConnected()

void ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setConnected ( )
inline

Connects QCustomPlot signals with controller methods.

Definition at line 43 of file viewportaxisplotcontroller.cpp.

44  {
45  auto on_axis_range = [this](const QCPRange& newRange) {
46  m_blockUpdate = true;
47  auto item = m_self->currentItem();
48  item->set_range(newRange.lower, newRange.upper);
49  m_blockUpdate = false;
50  };
51 
52  *m_axisConn = QObject::connect(
53  m_axis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged),
54  on_axis_range);
55  }
void set_range(double lower, double upper)
Sets lower, upper range of axis to given values.
Definition: axisitems.cpp:51

References ModelView::ItemListener< T >::currentItem(), ModelView::ItemListenerBase::item(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_axis, ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_axisConn, ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_blockUpdate, and ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_self.

Referenced by ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::init_axis(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::updateLowerRange(), and ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::updateUpperRange().

Here is the call graph for this function:

◆ setDisconnected()

◆ updateLowerRange()

void ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::updateLowerRange ( const ViewportAxisItem item)
inline

Definition at line 87 of file viewportaxisplotcontroller.cpp.

88  {
90  m_axis->setRangeLower(item->property<double>(ViewportAxisItem::P_MIN));
91  setConnected();
92  }
T property(const std::string &tag) const
Returns data stored in property item.
Definition: sessionitem.h:181

References ModelView::ItemListenerBase::item(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_axis, ModelView::BasicAxisItem::P_MIN, ModelView::SessionItem::property(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setConnected(), and ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setDisconnected().

Here is the call graph for this function:

◆ updateUpperRange()

void ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::updateUpperRange ( const ViewportAxisItem item)
inline

Definition at line 94 of file viewportaxisplotcontroller.cpp.

95  {
97  m_axis->setRangeUpper(item->property<double>(ViewportAxisItem::P_MAX));
98  setConnected();
99  }

References ModelView::ItemListenerBase::item(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_axis, ModelView::BasicAxisItem::P_MAX, ModelView::SessionItem::property(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setConnected(), and ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setDisconnected().

Here is the call graph for this function:

Member Data Documentation

◆ m_axis

◆ m_axisConn

◆ m_blockUpdate

bool ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_blockUpdate {false}

◆ m_self

◆ m_titleController

std::unique_ptr<AxisTitleController> ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::m_titleController

The documentation for this struct was generated from the following file: