BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
axistitlecontroller.cpp
Go to the documentation of this file.
1
// ************************************************************************************************
2
//
3
// qt-mvvm: Model-view-view-model framework for large GUI applications
4
//
5
//! @file mvvm/view/mvvm/plotting/axistitlecontroller.cpp
6
//! @brief Implements class CLASS?
7
//!
8
//! @homepage http://www.bornagainproject.org
9
//! @license GNU General Public License v3 or higher (see COPYING)
10
//! @copyright Forschungszentrum Jülich GmbH 2020
11
//! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12
//
13
// ************************************************************************************************
14
15
#include "
mvvm/plotting/axistitlecontroller.h
"
16
#include "
mvvm/standarditems/plottableitems.h
"
17
#include "qcustomplot.h"
18
#include <stdexcept>
19
20
using namespace
ModelView
;
21
22
struct
AxisTitleController::AxisTitleControllerImpl
{
23
QCPAxis*
m_axis
{
nullptr
};
24
25
AxisTitleControllerImpl
(QCPAxis* axis) :
m_axis
(axis)
26
{
27
if
(!axis)
28
throw
std::runtime_error(
"AxisTitleController: axis is not initialized."
);
29
}
30
31
void
updateAxisFromItem
(
TextItem
*
item
)
32
{
33
auto
font =
m_axis
->labelFont();
34
font.setPointSize(
item
->
property
<
int
>(
TextItem::P_SIZE
));
35
font.setFamily(QString::fromStdString(
item
->
property
<std::string>(
TextItem::P_FONT
)));
36
m_axis
->setLabel(QString::fromStdString(
item
->
property
<std::string>(
TextItem::P_TEXT
)));
37
m_axis
->setLabelFont(font);
38
39
m_axis
->parentPlot()->replot();
40
}
41
};
42
43
AxisTitleController::AxisTitleController
(QCPAxis* axis)
44
: p_impl(
std
::make_unique<
AxisTitleControllerImpl
>(axis))
45
46
{
47
}
48
49
AxisTitleController::~AxisTitleController
() =
default
;
50
51
void
AxisTitleController::subscribe
()
52
{
53
auto
on_property_change = [
this
](
auto
,
auto
) {
p_impl
->updateAxisFromItem(
currentItem
()); };
54
setOnPropertyChange
(on_property_change);
55
56
p_impl
->updateAxisFromItem(
currentItem
());
57
}
axistitlecontroller.h
Defines class CLASS?
ModelView::AxisTitleController::p_impl
std::unique_ptr< AxisTitleControllerImpl > p_impl
Definition:
axistitlecontroller.h:39
ModelView::AxisTitleController::AxisTitleController
AxisTitleController(QCPAxis *axis)
Definition:
axistitlecontroller.cpp:43
ModelView::AxisTitleController::~AxisTitleController
~AxisTitleController() override
ModelView::AxisTitleController::subscribe
void subscribe() override
Definition:
axistitlecontroller.cpp:51
ModelView::ItemListenerBase::setOnPropertyChange
void setOnPropertyChange(Callbacks::item_str_t f)
Sets callback to be notified on item's property change.
Definition:
itemlistenerbase.cpp:67
ModelView::ItemListenerBase::item
SessionItem * item() const
For necessary manipulations on unsubscription.
Definition:
itemlistenerbase.cpp:112
ModelView::ItemListener< TextItem >::currentItem
TextItem * currentItem() const
Definition:
itemlistener.h:28
ModelView::SessionItem::property
T property(const std::string &tag) const
Returns data stored in property item.
Definition:
sessionitem.h:181
ModelView::TextItem
Represent text item on plot.
Definition:
plottableitems.h:27
ModelView::TextItem::P_SIZE
static const std::string P_SIZE
Definition:
plottableitems.h:31
ModelView::TextItem::P_FONT
static const std::string P_FONT
Definition:
plottableitems.h:30
ModelView::TextItem::P_TEXT
static const std::string P_TEXT
Definition:
plottableitems.h:29
ModelView
materialitems.h Collection of materials to populate MaterialModel.
Definition:
importtablewidget.h:26
std
Definition:
filesystem.h:81
plottableitems.h
Defines class CLASS?
ModelView::AxisTitleController::AxisTitleControllerImpl
Definition:
axistitlecontroller.cpp:22
ModelView::AxisTitleController::AxisTitleControllerImpl::m_axis
QCPAxis * m_axis
Definition:
axistitlecontroller.cpp:23
ModelView::AxisTitleController::AxisTitleControllerImpl::updateAxisFromItem
void updateAxisFromItem(TextItem *item)
Definition:
axistitlecontroller.cpp:31
ModelView::AxisTitleController::AxisTitleControllerImpl::AxisTitleControllerImpl
AxisTitleControllerImpl(QCPAxis *axis)
Definition:
axistitlecontroller.cpp:25
mvvm
view
mvvm
plotting
axistitlecontroller.cpp
Generated by
1.9.1