BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
HistogramPlot Class Reference
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=0)
 

Private Member Functions

void initGraph ()
 

Private Attributes

QCustomPlot * m_customPlot
 

Detailed Description

Definition at line 21 of file HistogramPlot.h.

Constructor & Destructor Documentation

◆ HistogramPlot()

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

Definition at line 18 of file HistogramPlot.cpp.

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

References initGraph(), m_customPlot, Constants::plot_axes_label_size(), and 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 54 of file HistogramPlot.cpp.

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

References m_customPlot.

◆ addData [2/2]

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

Definition at line 47 of file HistogramPlot.cpp.

48 {
49  m_customPlot->graph()->addData(x, y);
50  m_customPlot->graph()->rescaleAxes();
51  m_customPlot->replot();
52 }

References m_customPlot.

Referenced by FitFlowWidget::subscribeToItem().

◆ clearData

void HistogramPlot::clearData ( )
slot

Definition at line 68 of file HistogramPlot.cpp.

69 {
70  m_customPlot->removeGraph(m_customPlot->graph());
71  initGraph();
72  m_customPlot->replot();
73 }

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 75 of file HistogramPlot.cpp.

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

References m_customPlot, and StyleUtils::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 61 of file HistogramPlot.cpp.

62 {
63  m_customPlot->graph()->setData(x, y);
64  m_customPlot->graph()->rescaleAxes();
65  m_customPlot->replot();
66 }

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: