BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectionsPlot.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Projection/ProjectionsPlot.h
6 //! @brief Defines class ProjectionsPlot
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_PROJECTION_PROJECTIONSPLOT_H
16 #define BORNAGAIN_GUI_VIEW_PROJECTION_PROJECTIONSPLOT_H
17 
19 #include <QMap>
20 #include <memory>
21 #include <qcustomplot.h>
22 
23 class IntensityDataItem;
25 class Datafield;
26 class QCPGraph;
27 
28 //! A customplot based widget to display projections of IntensityDataItem on X,Y axes.
29 
31  Q_OBJECT
32 
33 public:
34  ProjectionsPlot(QString projectionType, QWidget* parent = nullptr);
35  ~ProjectionsPlot() override;
36 
37 public slots:
38  void onMarginsChanged(double left, double right);
39 
40 protected:
41  void subscribeToItem() override;
42  void unsubscribeFromItem() override;
43 
44  void onProjectionPropertyChanged(SessionItem* item, const QString& property);
45 
46 private:
49  QVector<SessionItem*> projectionItems();
50  QCPGraph* graphForItem(SessionItem* item);
52 
53  void updateProjectionsData();
54  void updateProjections();
55  void updateAxesRange();
56  void updateAxesTitle();
57  void clearProjections();
58  void clearProjection(SessionItem* item);
59  void onIntensityItemPropertyChanged(const QString& propertyName);
60  void onAxisPropertyChanged(const QString& axisName, const QString& propertyName);
61 
62  void setGraphFromItem(QCPGraph* graph, SessionItem* item);
63 
64  void setInterpolate(bool isInterpolated);
65  void setLogz(bool isLogz);
66 
67  void replot();
68 
69  bool isHorizontalType();
70 
72  QCustomPlot* m_customPlot;
73  std::unique_ptr<Datafield> m_field;
74  QMap<SessionItem*, QCPGraph*> m_item_to_graph;
76 };
77 
78 #endif // BORNAGAIN_GUI_VIEW_PROJECTION_PROJECTIONSPLOT_H
Defines class ItemComboWidget.
A container to hold ProjectionItems, intended to store projections of color map on X,...
A customplot based widget to display projections of IntensityDataItem on X,Y axes.
~ProjectionsPlot() override
QCustomPlot * m_customPlot
void updateProjectionsData()
Creates cached 2D histogram for later projection calculations.
IntensityDataItem * intensityItem()
std::unique_ptr< Datafield > m_field
void onIntensityItemPropertyChanged(const QString &propertyName)
Updates projection appearance (line style, etc)
QVector< SessionItem * > projectionItems()
void clearProjection(SessionItem *item)
Removes plot corresponding to given projection item.
void setGraphFromItem(QCPGraph *graph, SessionItem *item)
Sets the data to graph from given projection iten.
void onMarginsChanged(double left, double right)
QString m_projectionType
void unsubscribeFromItem() override
void unsubscribeFromChildren()
void updateAxesRange()
Updates canva's axes to match current zoom level of IntensityDataItem.
void setLogz(bool isLogz)
QCPGraph * graphForItem(SessionItem *item)
void subscribeToItem() override
QMap< SessionItem *, QCPGraph * > m_item_to_graph
bool isHorizontalType()
Returns true, if widget is intended for horizontal projections.
void updateProjections()
Runs through all projection items and generates missed plots.
ProjectionContainerItem * projectionContainerItem()
void onAxisPropertyChanged(const QString &axisName, const QString &propertyName)
Updates zoom of projections in accordance with IntensityDataItem.
ProjectionsPlot(QString projectionType, QWidget *parent=nullptr)
void setInterpolate(bool isInterpolated)
void clearProjections()
Clears all graphs corresponding to projection items.
void onProjectionPropertyChanged(SessionItem *item, const QString &property)
The SessionItemWidget class is a base for all widgets representing the content of SessionItem....
Base class for a GUI data item.
Definition: SessionItem.h:204