CFEL - ASG Software Suite  2.5.0
CASS
data_viewer.h
Go to the documentation of this file.
1 // Copyright (C) 2013 Lutz Foucar
2 
3 /**
4  * @file data_viewer.h contains the base class for all data viewers
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _DATAVIEWER_
10 #define _DATAVIEWER_
11 
12 #include <QtGlobal>
13 
14 #if QT_VERSION >= 0x050000
15 #include <QtWidgets/QMainWindow>
16 #else
17 #include <QtGui/QMainWindow>
18 #endif
19 
20 class QCloseEvent;
21 
22 namespace cass
23 {
24 class HistogramBackend;
25 }//end namespace cass
26 
27 class QwtPlot;
28 
29 namespace jocassview
30 {
31 class Data;
32 
33 /** base class for viewers
34  *
35  * @author Lutz Foucar
36  */
37 class DataViewer : public QMainWindow
38 {
39  Q_OBJECT
40 
41 public:
42  /** constructor
43  *
44  * sets the window title
45  *
46  * @param title the window title of this viewer
47  * @param parent the parent widget of this viewer
48  */
49  DataViewer(QString title, QWidget *parent);
50 
51  /** destructor
52  *
53  * virtual to make this a base class
54  */
55  virtual ~DataViewer();
56 
57  /** retrieve the data displayed by this viewer
58  *
59  * @return the list of data displayed by this viewer
60  */
61  virtual QList<Data*> data() = 0;
62 
63  /** retrieve the type of the data viewer
64  *
65  * @return the type as name
66  */
67  virtual QString type() const = 0;
68 
69  /** print the plot */
70  virtual void print()const;
71 
72  /** save the data to file
73  *
74  * @param filename the name of the file to save the data to
75  */
76  virtual void saveData(const QString & filename)=0;
77 
78  /** use this to tell that the data has changed */
79  virtual void dataChanged();
80 
81  /** the list of file types that the data can be stored as by this viewer
82  *
83  * @return list or suffixes that the data by this viewer can be saveData
84  */
85  virtual QStringList dataFileSuffixes()const = 0;
86 
87 signals:
88  /** signal emitted when viewer is about to be destroyed
89  *
90  * @param viewer the viewer that is closed (this)
91  */
92  void viewerClosed(DataViewer *viewer);
93 
94 protected:
95  /** react when a close event is send to this viewer
96  *
97  * @param event the close event
98  */
100 
101  /** receive move events to store the current position to the settings
102  *
103  * @param event the move event
104  */
105  void moveEvent(QMoveEvent *event);
106 
107  /** receive resize events to store the current size to the settings
108  *
109  * @param event the resize event
110  */
111  void resizeEvent(QResizeEvent *event);
112 
113 protected:
114  /** the plot inside which the data will be displayed */
115  QwtPlot *_plot;
116 };
117 }//end namespace jocassview
118 #endif
virtual void print() const
print the plot
Definition: data_viewer.cpp:40
base class for viewers
Definition: data_viewer.h:37
void viewerClosed(DataViewer *viewer)
signal emitted when viewer is about to be destroyed
virtual QList< Data * > data()=0
retrieve the data displayed by this viewer
QwtPlot * _plot
the plot inside which the data will be displayed
Definition: data_viewer.h:115
virtual ~DataViewer()
destructor
Definition: data_viewer.cpp:35
void resizeEvent(QResizeEvent *event)
receive resize events to store the current size to the settings
Definition: data_viewer.cpp:82
void closeEvent(QCloseEvent *event)
react when a close event is send to this viewer
Definition: data_viewer.cpp:67
event(QEvent *event)
DataViewer(QString title, QWidget *parent)
constructor
Definition: data_viewer.cpp:27
virtual QString type() const =0
retrieve the type of the data viewer
virtual QStringList dataFileSuffixes() const =0
the list of file types that the data can be stored as by this viewer
virtual void saveData(const QString &filename)=0
save the data to file
virtual void dataChanged()
use this to tell that the data has changed
Definition: data_viewer.cpp:62
void moveEvent(QMoveEvent *event)
receive move events to store the current position to the settings
Definition: data_viewer.cpp:73