BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
Data1DViewItem.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Data/Data1DViewItem.h
6 //! @brief Defines class Data1DViewItem
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_MODEL_DATA_DATA1DVIEWITEM_H
16 #define BORNAGAIN_GUI_MODEL_DATA_DATA1DVIEWITEM_H
17 
20 
21 class AmplitudeAxisItem;
22 class BasicAxisItem;
23 class ComboProperty;
25 class Data1DProperties;
26 class DataItem;
27 class JobItem;
28 class Datafield;
29 
30 //! View model for 1D DataItem. Can represent several items
31 //! at once. In current implementation the first of carried
32 //! items determines axes' limits.
33 
34 class BA_CORE_API_ Data1DViewItem : public SessionItem {
35 private:
36  static constexpr auto P_TITLE{"Title"};
37  static constexpr auto P_XAXIS{"x-axis"};
38  static constexpr auto P_YAXIS{"y-axis"};
39  static constexpr auto P_AXES_UNITS{"Axes Units"};
40  static constexpr auto T_DATA_PROPERTIES{"Data property container"};
41 
42 public:
43  static constexpr auto M_TYPE{"Data1DViewItem"};
44 
46 
47  //! Number of bins in data
48  int getNbins() const;
49 
50  //! Returns lower and upper zoom ranges of x-axis
51  double getLowerX() const;
52  double getUpperX() const;
53 
54  //! Returns lower and upper zoom ranges of y-axis
55  double getLowerY() const;
56  double getUpperY() const;
57 
58  bool isLog() const;
59  QString getXaxisTitle() const;
60  QString getYaxisTitle() const;
61 
62  const BasicAxisItem* xAxisItem() const;
63  BasicAxisItem* xAxisItem();
64  const AmplitudeAxisItem* yAxisItem() const;
65  AmplitudeAxisItem* yAxisItem();
66 
67  static bool isXAxisPropertyName(const QString& name);
68  static bool isYAxisPropertyName(const QString& name);
69 
70  void resetView();
71 
72  void setXaxisTitle(const QString& title);
73  void setYaxisTitle(const QString& title);
74  void setAxesRangeToData();
75 
76  ComboProperty axesUnits() const;
77  void setAxesUnits(const ComboProperty& units);
78  SelectionDescriptor<QString> axesUnitsDescriptor() const;
79  static bool isAxesUnitsPropertyName(const QString& name);
80 
81  //! Returns data view to default state (no dimensional units, default axes' names)
82  void resetToDefault();
83 
84  //! Returns point data for drawing
85  QPair<QVector<double>, QVector<double>> graphData(Data1DProperties* property_item);
86 
87  //! Sets job item (for unit conversion) if DataItemView
88  //! is dynamically created outside of JobModel
89  void setJobItem(JobItem* job_item) { m_job_item = job_item; }
90 
91  //! Returns either parenting JobItem or
92  //! job item set with DataItem1DView::setJobItem.
93  JobItem* jobItem();
94 
95  void setLowerX(double value);
96  void setUpperX(double value);
97  void setLowerY(double value);
98  void setUpperY(double value);
99  void setLog(bool log_flag);
100 
101  DataPropertyContainer* propertyContainerItem();
102  DataPropertyContainer* createPropertyContainerItem();
103 
104 private:
105  QPair<double, double> dataRange(const Datafield* data) const;
106 
108 };
109 
110 #endif // BORNAGAIN_GUI_MODEL_DATA_DATA1DVIEWITEM_H
Defines class SelectionDescriptor.
Defines class SessionItem.
Custom property to define list of string values with multiple selections. Intended for QVariant.
Definition: ComboProperty.h:25
Holds data required for 1D DataItem representation.
View model for 1D DataItem. Can represent several items at once. In current implementation the first ...
JobItem * m_job_item
void setJobItem(JobItem *job_item)
Sets job item (for unit conversion) if DataItemView is dynamically created outside of JobModel.
Abstract base class for IntensityDataItem and SpecularDataItem. Owns one simulated data set of type D...
Definition: DataItem.h:34
Describes a selection (various possibilities and the current one).
Base class for a GUI data item.
Definition: SessionItem.h:204
QString const & name(EShape k)
Definition: particles.cpp:20