CFEL - ASG Software Suite  2.5.0
CASS
one_d_viewer.h
Go to the documentation of this file.
1 // Copyright (C) 2013, 2014 Lutz Foucar
2 
3 /**
4  * @file one_d_viewer.h contains the viewer for 1d data
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _ONEDVIEWER_
10 #define _ONEDVIEWER_
11 
12 #include <QtCore/QList>
13 
14 #include "data_viewer.h"
15 
16 namespace cass
17 {
18 class Histogram1DFloat;
19 }//end namespace cass
20 class QAction;
21 class QwtPlot;
22 class QwtPlotGrid;
23 class QwtLegend;
24 class QwtPlotItem;
25 
26 namespace jocassview
27 {
28 class MinMaxControl;
29 class OneDViewerData;
30 class PlotCurve;
31 
32 /** a viewer that displays 1d data
33  *
34  * @author Stephan Kassemeyer
35  * @author Lutz Foucar
36  */
37 class OneDViewer : public DataViewer
38 {
39  Q_OBJECT
40 
41 public:
42  /** constructor
43  *
44  * @param title The title of this view
45  * @param parent The parent of this
46  */
47  OneDViewer(QString title, QWidget *parent=0);
48 
49  /** destructor */
50  virtual ~OneDViewer();
51 
52  /** retrieve the displayed data
53  *
54  * @return pointer to the viewed data
55  */
56  virtual QList<Data*> data();
57 
58  /** retrieve the type of the data viewer
59  *
60  * @return the type as name
61  */
62  virtual QString type() const;
63 
64  /** save the data to file
65  *
66  * @param filename the filename to save the data to
67  */
68  virtual void saveData(const QString &filename);
69 
70  /** update the plot */
71  virtual void dataChanged();
72 
73  /** suffixes for the data of this viewer
74  *
75  * @return suffixes for the data of this viewer
76  */
77  virtual QStringList dataFileSuffixes() const;
78 
79 private slots:
80  /** redraw the plot */
81  void replot();
82 
83  /** react when an legend item has been selected
84  *
85  * open a context menue at the position of the legenditem.
86  *
87  * @param pos the position where the context menu should be opened
88  */
90 
91  /** react when an legend item has been clicked
92  *
93  * toggle hide / show the curve
94  *
95  * @param item the plot item assiciated with the legend entry
96  * @param on when true the associated curve will be shown
97  */
98  void on_legend_checked(const QVariant &item, bool on);
99 
100  /** change the curves color
101  *
102  * if no parameter is given try to retrieve the curve from the sender
103  * signal that is connected to this slot. We're assuming this is an QAction
104  * whos parent is the curve.
105  *
106  * @param curve the curve to change is the senders parent widget
107  */
108  void change_curve_color(PlotCurve *curve=0);
109 
110  /** change the curves line width
111  *
112  * if no parameter is given try to retrieve the curve from the sender
113  * signal that is connected to this slot. We're assuming this is an QAction
114  * whos parent is the curve.
115  *
116  * @param curve the curve to change is the senders parent widget
117  */
118  void change_curve_width(PlotCurve *curve=0);
119 
120  /** remove the curve from the plot
121  *
122  * if no parameter is given try to retrieve the curve from the sender
123  * signal that is connected to this slot. We're assuming this is an QAction
124  * whos parent is the curve.
125  *
126  * @param curve the curve to remove from the plot
127  */
128  void remove_curve(PlotCurve *curve=0);
129 
130  /** react when addGraph action has been triggered
131  *
132  * use the openfile dialog to get the graph. Then use the FileHandler to
133  * retrieve the data form the file.
134  */
135  void on_add_graph_triggered();
136 
137  /** react on when the gridControl has been triggered
138  *
139  * increase the the _gridLines variable and mask off the unneeded bits
140  */
141  void on_grid_triggered();
142 
143 private:
144  /** control for the x-axis */
146 
147  /** control for the y-axis */
149 
150  /** this plots curves */
152 
153  /** this plots curves */
155 
156  /** an action to control the grid in the plot */
158 
159  /** a grid in the plot */
160  QwtPlotGrid *_grid;
161 
162  /** flags to tell which grid lines should be drawn */
163  quint8 _gridLines;
164 
165  /** an action to control the legend of curves */
167 
168  /** a legend for the different curves */
169  QwtLegend *_legend;
170 
171  /** an action to control the legend of curves */
173 };
174 }//end namespace jocassview
175 
176 #endif
virtual QList< Data * > data()
retrieve the displayed data
QAction * _legendControl
an action to control the legend of curves
Definition: one_d_viewer.h:166
base class for viewers
Definition: data_viewer.h:37
OneDViewer(QString title, QWidget *parent=0)
constructor
contains the base class for all data viewers
true Then one can use the IsHit Processor later on
quint8 _gridLines
flags to tell which grid lines should be drawn
Definition: one_d_viewer.h:163
virtual QString type() const
retrieve the type of the data viewer
virtual QStringList dataFileSuffixes() const
suffixes for the data of this viewer
a viewer that displays 1d data
Definition: one_d_viewer.h:37
widget to control the min and max values
QAction * _axisTitleControl
an action to control the legend of curves
Definition: one_d_viewer.h:172
QAction * _gridControl
an action to control the grid in the plot
Definition: one_d_viewer.h:157
virtual void saveData(const QString &filename)
save the data to file
void change_curve_color(PlotCurve *curve=0)
change the curves color
void on_legend_checked(const QVariant &item, bool on)
react when an legend item has been clicked
void change_curve_width(PlotCurve *curve=0)
change the curves line width
virtual void dataChanged()
update the plot
void on_grid_triggered()
react on when the gridControl has been triggered
void on_legend_right_clicked(QPoint pos)
react when an legend item has been selected
QList< OneDViewerData * > _curvesData
this plots curves
Definition: one_d_viewer.h:154
MinMaxControl * _xControl
control for the x-axis
Definition: one_d_viewer.h:145
void replot()
redraw the plot
MinMaxControl * _yControl
control for the y-axis
Definition: one_d_viewer.h:148
QwtPlotGrid * _grid
a grid in the plot
Definition: one_d_viewer.h:160
an alternative curve plot
Definition: curve_plot.h:26
QwtLegend * _legend
a legend for the different curves
Definition: one_d_viewer.h:169
QList< PlotCurve * > _curves
this plots curves
Definition: one_d_viewer.h:151
void on_add_graph_triggered()
react when addGraph action has been triggered
virtual ~OneDViewer()
destructor
void remove_curve(PlotCurve *curve=0)
remove the curve from the plot