source: fact/Evidence/GUI.h@ 11002

Last change on this file since 11002 was 10984, checked in by ogrimm, 14 years ago
Edd allows to set plot update rate
  • Property svn:keywords set to Revision
File size: 5.8 KB
Line 
1#ifndef GUI_H_SEEN
2#define GUI_H_SEEN
3
4#include <QtGui>
5#include <QtConcurrentRun>
6
7#include <qwt_plot.h>
8#include <qwt_plot_curve.h>
9#include <qwt_plot_grid.h>
10#include <qwt_plot_zoomer.h>
11#include <qwt_plot_magnifier.h>
12#include <qwt_plot_panner.h>
13#include <qwt_scale_engine.h>
14#include <qwt_analog_clock.h>
15#include <qwt_scale_widget.h>
16#include <qwt_plot_layout.h>
17#include <qwt_legend.h>
18#include <qwt_legend_item.h>
19#include <qwt_symbol.h>
20#include <qwt_plot_marker.h>
21#include <qwt_data.h>
22#include <qwt_color_map.h>
23
24#include <limits>
25#include <float.h>
26#include <limits>
27
28#include "dic.hxx"
29#include "Evidence.h"
30
31const QColor EddPlotBackgroundColor(Qt::yellow);
32
33QWidget *OpenHistory(char *, int);
34bool SetStatus(QWidget *, QString, int, QString, int = -1);
35
36
37// Base class for Edd plot
38// DeleteCurve() is pure virtual and needs to be implemented iin the application class
39class EddBasePlot: public QwtPlot {
40 Q_OBJECT
41
42 protected:
43 QMenu *Menu;
44 QAction *StripAction;
45
46 private:
47 struct PlotItem {
48 QwtPlotCurve *Signal;
49 QVector<double> x;
50 QVector<double> y;
51 double Smallest;
52 double Largest;
53 double Mean;
54 double Sigma;
55 };
56 QList<struct PlotItem> Items;
57
58 QAction *YLogAction;
59 QAction *NormAction;
60 QAction *StyleAction;
61 QAction *StatisticsAction;
62
63 QwtPlotPanner *Panner;
64 QwtPlotGrid *Grid;
65 QwtPlotZoomer *Zoomer;
66 QwtPlotMagnifier *Magnifier;
67 QwtPicker *Picker;
68 QwtDoubleRect BBox;
69 QwtPlotMarker *Stats;
70
71 public:
72 EddBasePlot(QWidget * = NULL);
73 ~EddBasePlot();
74
75 QTimer *Timer;
76 bool NewData;
77 QwtPlotCurve *NewCurve(QwtText);
78 void ClearCurve(unsigned int);
79 void AddPoint(unsigned int, double, double);
80 virtual void DeleteCurve(QwtPlotCurve *) = 0;
81
82 protected slots:
83 void UpdatePlot();
84
85 private slots:
86 void ReDoStats();
87 void HandleZoom(const QwtDoubleRect &);
88 void MouseSelection(const QwtPolygon &);
89 void contextMenuEvent(QContextMenuEvent *);
90 void MenuSingleTrace();
91 void MenuSetUpdateRate();
92 void MenuZoomOut();
93 void MenuSaveASCII();
94 void MenuSave();
95 void MenuPrint();
96 void MenuPlotHelp();
97};
98
99// General indicator for DIM service
100class EddLineDisplay: public QLineEdit {
101 Q_OBJECT
102
103 QMenu *Menu;
104 QPoint dragStart;
105 QWidget *LastHist;
106
107 QString ServiceName;
108 int Index;
109
110 void mousePressEvent(QMouseEvent *);
111 void mouseReleaseEvent(QMouseEvent *);
112 void mouseMoveEvent(QMouseEvent *);
113
114 public:
115 EddLineDisplay(QString, int=0, QWidget * = NULL);
116 ~EddLineDisplay();
117
118 bool ShowAsTime;
119
120 private slots:
121 void Update(QString, int, QByteArray, QString, QString);
122 void contextMenuEvent(QContextMenuEvent *);
123 void MenuOpenHistory();
124 void MenuCopyService();
125 void MenuCopyData();
126};
127
128// Sending command to DIM server
129class EddCommand: public QLineEdit {
130 Q_OBJECT
131
132 QString Name;
133
134 public:
135 EddCommand(QString, QWidget * = NULL);
136
137 private slots:
138 void SendCommand();
139};
140
141// Graph class for history display
142class EddPlot: public EddBasePlot {
143 Q_OBJECT
144
145 // Time scale for axis
146 class EddTimeScale: public QwtScaleDraw {
147
148 public:
149 EddTimeScale() {}
150
151 virtual QwtText label(double v) const {
152 // Adapt text format to time span
153 QString Format;
154 if (scaleDiv().range() < 60*60) Format = "hh' h\n'mm:ss";
155 else if (scaleDiv().range() < 24*60*60) Format = "hh:mm";
156 else if (scaleDiv().range() < 30*24*60*60) Format = "h' h\n'd-MMM";
157 else Format = "d-MMM'\n'yyyy";
158
159 // Generate text
160 QwtText Text = QDateTime::fromTime_t((int) v).toString(Format);
161 QFont Font = Text.font();
162 Font.setPointSize(7);
163 Text.setFont(Font);
164
165 return Text;
166 }
167 };
168
169 struct ItemDetails {
170 QString Name;
171 int Index;
172 QwtPlotCurve *Signal;
173 };
174 QList<struct ItemDetails> List;
175
176 private:
177 QwtLegend *Legend;
178 QTimer *SingleShot;
179
180 void dragEnterEvent(QDragEnterEvent *);
181 void dropEvent(QDropEvent *);
182 void paintEvent(QPaintEvent *);
183
184 public:
185 EddPlot(QString = QString(), int = 0, QWidget * = NULL);
186 ~EddPlot();
187 void AddService(QString, int = 0);
188 void DeleteCurve(QwtPlotCurve *);
189
190 private slots:
191 void Update(QString, int, QByteArray, QString, QString);
192 void LegendClicked(QwtPlotItem *);
193 void MenuPasteService();
194};
195
196
197// Text history and output class
198class EddText: public QTextEdit {
199 Q_OBJECT
200
201 private:
202 QString Name;
203 bool Pure;
204
205 public:
206 EddText(QString, bool = false, QWidget * = NULL);
207 ~EddText();
208
209 bool Accumulate;
210
211 private slots:
212 void Update(QString, int, QByteArray, QString, QString);
213};
214
215
216// Interface to DIM system
217class EddDim: public QObject, public DimInfo {
218 Q_OBJECT
219
220 private:
221 struct Item {
222 DimStampedInfo *DIMService;
223 int Count;
224 int TimeStamp;
225 QByteArray ByteArray;
226 QString Format;
227 QString Text;
228 };
229 QMap<QString, struct Item> ServiceList;
230 QMutex *Mutex;
231 QList<QString> WaitingList;
232
233 struct HistItem {
234 int Count;
235 int LastUpdate;
236 class EvidenceHistory *HistClass;
237 };
238 QMap<QString, struct HistItem> HistoryList;
239
240 long long Volume;
241
242 void infoHandler();
243
244 private slots:
245 void Update(QString, int, QByteArray, QString, QString);
246 void UpdateStatistics();
247 void MakeSubscriptions();
248
249 public:
250 EddDim();
251 ~EddDim();
252
253 void Subscribe(QString);
254 void Unsubscribe (QString);
255 class EvidenceHistory *GetHistory(QString);
256 void DropHistory(QString);
257 void ForceEmit();
258
259 signals:
260 void YEP(QString, int, QByteArray = QByteArray(), QString = QString(), QString = QString());
261 void INT(QString, int, QByteArray = QByteArray(), QString = QString(), QString = QString());
262};
263
264// Open new window
265class EddWindow: public QPushButton {
266 Q_OBJECT
267
268 QMainWindow *M;
269 QGridLayout *L;
270
271 public:
272 EddWindow(QString, QString);
273 QGridLayout *Layout();
274 QMainWindow *Window();
275 private slots:
276 void Toggle();
277};
278
279#endif
Note: See TracBrowser for help on using the repository browser.