BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DistributionPlot.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/DistributionPlot.h
6 //! @brief Defines class DistributionPlot
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_DISTRIBUTIONPLOT_H
16 #define BORNAGAIN_GUI_VIEW_INSTRUMENT_DISTRIBUTIONPLOT_H
17 
18 #include <QWidget>
19 #include <qcustomplot.h>
20 
21 class SessionItem;
22 class QLabel;
23 class QCustomPlot;
24 class DistributionItem;
25 class QAction;
26 class RealLimits;
27 class CautionSign;
28 
29 //! The DistributionPlot class plots 1d functions corresponding to domain's Distribution1D
30 class DistributionPlot : public QWidget {
31  Q_OBJECT
32 
33 public:
34  DistributionPlot(QWidget* parent = nullptr);
35 
36  void setItem(DistributionItem* item);
37  void plotItem();
38  void setXAxisName(const QString& xAxisName);
39  void setShowMouseCoords(bool b);
40 
41 public slots:
42  void onMouseMove(QMouseEvent* event);
43  void onMousePress(QMouseEvent* event);
44 
45 private slots:
46  void resetView();
47 
48 private:
49  void init_plot();
50  void plot_distributions();
51  void plot_single_value();
52  void plot_multiple_values();
53  void setPlotRange(const QPair<double, double>& xRange, const QPair<double, double>& yRange);
54  void plotBars(const QVector<double>& xbars, const QVector<double>& ybars);
55  void plotFunction(const QVector<double>& xFunc, const QVector<double>& yFunc);
56  void plotVerticalLine(double xMin, double yMin, double xMax, double yMax,
57  const QColor& color = Qt::blue);
58  void plotLimits(const RealLimits& limits);
60 
61  QCustomPlot* m_plot;
63  QLabel* m_label;
64  QAction* m_resetAction;
65  QCPRange m_xRange, m_yRange;
67 };
68 
69 #endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_DISTRIBUTIONPLOT_H
The CautionSign controls appearance of CautionSignWidget on top of parent widget.
Definition: CautionSign.h:25
The DistributionPlot class plots 1d functions corresponding to domain's Distribution1D.
void plotFunction(const QVector< double > &xFunc, const QVector< double > &yFunc)
void setShowMouseCoords(bool b)
void plotLimits(const RealLimits &limits)
Plots red line denoting lower and upper limits, if any.
void plotVerticalLine(double xMin, double yMin, double xMax, double yMax, const QColor &color=Qt::blue)
CautionSign * m_cautionSign
void plot_single_value()
Plots a single bar corresponding to the value in DistributionNoteItem.
QPoint positionForCautionSign()
DistributionPlot(QWidget *parent=nullptr)
QAction * m_resetAction
void onMouseMove(QMouseEvent *event)
Generates label with current mouse position.
void init_plot()
Clears all plottables, resets axes to initial state.
void setXAxisName(const QString &xAxisName)
void plotBars(const QVector< double > &xbars, const QVector< double > &ybars)
DistributionItem * m_item
void setItem(DistributionItem *item)
void setPlotRange(const QPair< double, double > &xRange, const QPair< double, double > &yRange)
void onMousePress(QMouseEvent *event)
void resetView()
Reset zoom range to initial state.
QCustomPlot * m_plot
Base class for a GUI data item.
Definition: SessionItem.h:204