BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ScientificPlot.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/PlotUtil/ScientificPlot.h
6 //! @brief Declares class ScientificPlot
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_PLOTUTIL_SCIENTIFICPLOT_H
16 #define BORNAGAIN_GUI_VIEW_PLOTUTIL_SCIENTIFICPLOT_H
17 
19 #include <memory>
20 
21 class PlotEventInfo;
22 class QCustomPlot;
24 
25 //! Common interface for plot-descriptor interaction
26 
28  Q_OBJECT
29 
30 public:
31  enum class PLOT_TYPE { Plot1D, Plot2D };
32 
33  explicit ScientificPlot(QWidget* parent, PLOT_TYPE plot_type);
34  ~ScientificPlot() override;
35 
36  //! Returns plot descriptor corresponding to given axes coordinates.
37  virtual PlotEventInfo eventInfo(double xpos, double ypos) const = 0;
38 
39  virtual QCustomPlot* customPlot() = 0;
40  virtual const QCustomPlot* customPlot() const = 0;
41 
43 
44  //! transform axes coordinates to CustomPlot widget coordinates
45  double xAxisCoordToPixel(double axis_coordinate) const;
46  double yAxisCoordToPixel(double axis_coordinate) const;
47 
48  //! transform widget coordinates to axes coordinates
49  double pixelToXaxisCoord(double pixel) const;
50  double pixelToYaxisCoord(double pixel) const;
51 
52  //! Tracks move events (used when showing profile histograms and printing status string)
53  void setMouseTrackingEnabled(bool enable);
54 
55  //! Returns true if axes rectangle contains given in axes coordinates.
56  bool axesRangeContains(double xpos, double ypos) const;
57 
58  //! Returns the type of current plot
59  PLOT_TYPE plotType() const { return m_plot_type; }
60 
61 signals:
62  void statusString(const QString& text);
63 
64 private:
67 };
68 
69 #endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_SCIENTIFICPLOT_H
Defines class ItemComboWidget.
Contains parameters of mouse position in 1D or 2D plot.
Definition: PlotEventInfo.h:26
Helps ScientificPlot to handle mouse events. Particularly, it constructs a valid status string....
Common interface for plot-descriptor interaction.
ScientificPlotEvent * plotEvent()
PLOT_TYPE plotType() const
Returns the type of current plot.
ScientificPlot(QWidget *parent, PLOT_TYPE plot_type)
virtual PlotEventInfo eventInfo(double xpos, double ypos) const =0
Returns plot descriptor corresponding to given axes coordinates.
PLOT_TYPE m_plot_type
bool axesRangeContains(double xpos, double ypos) const
Returns true if axes rectangle contains given in axes coordinates.
void statusString(const QString &text)
virtual QCustomPlot * customPlot()=0
double yAxisCoordToPixel(double axis_coordinate) const
~ScientificPlot() override
double pixelToYaxisCoord(double pixel) const
virtual const QCustomPlot * customPlot() const =0
ScientificPlotEvent * m_event
double pixelToXaxisCoord(double pixel) const
transform widget coordinates to axes coordinates
void setMouseTrackingEnabled(bool enable)
Tracks move events (used when showing profile histograms and printing status string)
double xAxisCoordToPixel(double axis_coordinate) const
transform axes coordinates to CustomPlot widget coordinates
The SessionItemWidget class is a base for all widgets representing the content of SessionItem....