BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DistributionWidget.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/InfoWidgets/DistributionWidget.h
6 //! @brief Defines class DistributionWidget
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_COREGUI_VIEWS_INFOWIDGETS_DISTRIBUTIONWIDGET_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_INFOWIDGETS_DISTRIBUTIONWIDGET_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 WarningSign;
28 
29 //! The DistributionWidget class plots 1d functions corresponding to domain's Distribution1D
30 class DistributionWidget : public QWidget {
31  Q_OBJECT
32 
33 public:
34  DistributionWidget(QWidget* parent = 0);
36 
37  void setItem(DistributionItem* item);
38  void plotItem();
39  void setXAxisName(const QString& xAxisName);
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>& ybars);
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_COREGUI_VIEWS_INFOWIDGETS_DISTRIBUTIONWIDGET_H
The DistributionWidget class plots 1d functions corresponding to domain's Distribution1D.
void plotFunction(const QVector< double > &xFunc, const QVector< double > &ybars)
void resetView()
Reset zoom range to initial state.
void onMousePress(QMouseEvent *event)
void plot_single_value()
Plots a single bar corresponding to the value in DistributionNoteItem.
void onMouseMove(QMouseEvent *event)
Generates label with current mouse position.
QPoint positionForWarningSign()
DistributionWidget(QWidget *parent=0)
void setItem(DistributionItem *item)
void plotVerticalLine(double xMin, double yMin, double xMax, double yMax, const QColor &color=Qt::blue)
void setPlotRange(const QPair< double, double > &xRange, const QPair< double, double > &yRange)
WarningSign * m_warningSign
void plotLimits(const RealLimits &limits)
Plots red line denoting lower and upper limits, if any.
DistributionItem * m_item
void plotBars(const QVector< double > &xbars, const QVector< double > &ybars)
void init_plot()
Clears all plottables, resets axes to initial state.
void setXAxisName(const QString &xAxisName)
Limits for a real fit parameter.
Definition: RealLimits.h:24
The WarningSign controls appearance of WarningSignWidget on top of parent widget.
Definition: WarningSign.h:25