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

Description

Definition at line 21 of file HistogramPlot.h.

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

Public Slots

void addData (const QVector< double > &x, const QVector< double > &y)
 
void addData (double x, double y)
 
void clearData ()
 
void setData (const QVector< double > &x, const QVector< double > &y)
 

Public Member Functions

 HistogramPlot (QWidget *parent=nullptr)
 

Private Member Functions

void initGraph ()
 

Private Attributes

QCustomPlot * m_customPlot
 

Constructor & Destructor Documentation

◆ HistogramPlot()

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

Definition at line 18 of file HistogramPlot.cpp.

19  : QWidget(parent)
20  , m_customPlot(new QCustomPlot)
21 
22 {
23  auto* vlayout = new QVBoxLayout(this);
24  vlayout->setMargin(0);
25  vlayout->setSpacing(0);
26  vlayout->setContentsMargins(0, 0, 0, 0);
27  vlayout->addWidget(m_customPlot);
28  m_customPlot->setAttribute(Qt::WA_NoMousePropagation, false);
29  setLayout(vlayout);
30  setStyleSheet("background-color:white;");
31 
32  initGraph();
33 
34  m_customPlot->xAxis->setTickLabelFont(
35  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
36  m_customPlot->yAxis->setTickLabelFont(
37  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
38 
39  m_customPlot->yAxis->setScaleType(QCPAxis::stLogarithmic);
40  m_customPlot->yAxis->setNumberFormat("eb");
41  m_customPlot->yAxis->setNumberPrecision(0);
42 
43  m_customPlot->xAxis->setLabel("iteration");
44  m_customPlot->yAxis->setLabel("chi2");
45 
46  m_customPlot->xAxis->setLabelFont(
47  QFont(QFont().family(), GUI::Constants::plot_axes_label_size()));
48  m_customPlot->yAxis->setLabelFont(
49  QFont(QFont().family(), GUI::Constants::plot_axes_label_size()));
50 }
QCustomPlot * m_customPlot
Definition: HistogramPlot.h:35
int plot_tick_label_size()
Definition: PlotConstants.h:23
int plot_axes_label_size()
Definition: PlotConstants.h:28

References initGraph(), m_customPlot, GUI::Constants::plot_axes_label_size(), and GUI::Constants::plot_tick_label_size().

Here is the call graph for this function:

Member Function Documentation

◆ addData [1/2]

void HistogramPlot::addData ( const QVector< double > &  x,
const QVector< double > &  y 
)
slot

Definition at line 59 of file HistogramPlot.cpp.

60 {
61  m_customPlot->graph()->addData(x, y);
62  m_customPlot->graph()->rescaleAxes();
63  m_customPlot->replot();
64 }

References m_customPlot.

◆ addData [2/2]

void HistogramPlot::addData ( double  x,
double  y 
)
slot

Definition at line 52 of file HistogramPlot.cpp.

53 {
54  m_customPlot->graph()->addData(x, y);
55  m_customPlot->graph()->rescaleAxes();
56  m_customPlot->replot();
57 }

References m_customPlot.

Referenced by FitFlowWidget::subscribeToItem().

◆ clearData

void HistogramPlot::clearData ( )
slot

Definition at line 73 of file HistogramPlot.cpp.

74 {
75  m_customPlot->removeGraph(m_customPlot->graph());
76  initGraph();
77  m_customPlot->replot();
78 }

References initGraph(), and m_customPlot.

Referenced by FitFlowWidget::subscribeToItem(), and FitFlowWidget::unsubscribeFromItem().

Here is the call graph for this function:

◆ initGraph()

void HistogramPlot::initGraph ( )
private

Definition at line 80 of file HistogramPlot.cpp.

81 {
82  m_customPlot->addGraph();
83 
84  QPen pen(QColor(0, 0, 255, 200));
85  m_customPlot->graph()->setLineStyle(QCPGraph::lsLine);
86  m_customPlot->graph()->setPen(pen);
87  m_customPlot->graph()->setBrush(QBrush(QColor(255 / 4, 160, 50, 150)));
88 
89  auto base_size = GUI::Util::Style::SizeOfLetterM();
90  auto* axisRectangle = m_customPlot->axisRect();
91  axisRectangle->setAutoMargins(QCP::msTop | QCP::msBottom);
92  axisRectangle->setMargins(QMargins(base_size.width() * 4, base_size.height() * 2,
93  base_size.width() * 2, base_size.height() * 2));
94 }
QSize SizeOfLetterM(const QWidget *widget=nullptr)
Returns size of largest letter of default system font.
Definition: StyleUtils.cpp:113

References m_customPlot, and GUI::Util::Style::SizeOfLetterM().

Referenced by HistogramPlot(), and clearData().

Here is the call graph for this function:

◆ setData

void HistogramPlot::setData ( const QVector< double > &  x,
const QVector< double > &  y 
)
slot

Definition at line 66 of file HistogramPlot.cpp.

67 {
68  m_customPlot->graph()->setData(x, y);
69  m_customPlot->graph()->rescaleAxes();
70  m_customPlot->replot();
71 }

References m_customPlot.

Member Data Documentation

◆ m_customPlot

QCustomPlot* HistogramPlot::m_customPlot
private

Definition at line 35 of file HistogramPlot.h.

Referenced by HistogramPlot(), addData(), clearData(), initGraph(), and setData().


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