source: fact/Evidence/GUI.h@ 17037

Last change on this file since 17037 was 17037, checked in by ogrimm, 11 years ago
Evidence GUI ported to qwt 6.1.0. Added highlighting of curves in GUI.
  • Property svn:keywords set to Revision
File size: 6.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_picker_machine.h>
14#include <qwt_scale_engine.h>
15#include <qwt_analog_clock.h>
16#include <qwt_scale_widget.h>
17#include <qwt_plot_layout.h>
18#include <qwt_legend.h>
19#include <qwt_legend_label.h>
20#include <qwt_symbol.h>
21#include <qwt_plot_marker.h>
22#include <qwt_color_map.h>
23#include <qwt_date_scale_draw.h>
24
25#include <limits>
26#include <float.h>
27#include <limits>
28
29#include "dic.hxx"
30#include "Evidence.h"
31
32const QColor EddPlotBackgroundColor(Qt::yellow);
33
34void OpenHistory(char *, int, int=-1);
35bool SetStatus(QWidget *, QString, int, QString, int = -1);
36
37// General Edd Widget: has Update() method called by DIM interface
38class EddWidget {
39
40 public:
41 virtual void Update(const QString &, int, const QByteArray &, const QString &, const QString &, int=-1) = 0;
42};
43
44
45// Base class for Edd plot
46// RemoveService() is pure virtual and needs to be implemented in the application class,
47// it will be called through signal by context menu of legend entries
48class EddBasePlot: public QwtPlot {
49 Q_OBJECT
50
51 protected:
52 QMenu *Menu;
53 QAction *StripAction;
54
55 private:
56 struct PlotItem {
57 QwtPlotCurve *Signal;
58 QVector<double> x;
59 QVector<double> y;
60 double Smallest;
61 double Largest;
62 double Mean;
63 double Sigma;
64 };
65 QList<struct PlotItem> Items;
66
67 QAction *YLogAction;
68 QAction *NormAction;
69 QAction *StyleAction;
70 QAction *StatisticsAction;
71
72 QwtPlotPanner *Panner;
73 QwtPlotGrid *Grid;
74 QwtPlotZoomer *Zoomer;
75 QwtPlotMagnifier *Magnifier;
76 QwtPicker *Picker;
77 QRectF BBox;
78 QwtPlotMarker *Stats;
79 class EddLegend *Legend;
80
81 public:
82 EddBasePlot(QWidget * = NULL);
83 ~EddBasePlot();
84
85 QTimer *Timer;
86 bool NewData;
87 QwtPlotCurve *NewCurve(QwtText);
88 virtual void RemoveService(QwtPlotCurve *) = 0;
89 void DeleteCurve(QwtPlotCurve *);
90 void ClearCurve(unsigned int);
91 void AddPoint(unsigned int, double, double);
92
93 protected slots:
94 void UpdatePlot();
95
96 private slots:
97 void ReDoStats();
98 void HandleZoom(const QRectF &);
99 void MouseSelection(const QPolygon &);
100 void mouseDoubleClickEvent(QMouseEvent *);
101 void contextMenuEvent(QContextMenuEvent *);
102 void MenuSetUpdateRate();
103 void MenuZoomOut();
104 void MenuSaveASCII();
105 void MenuSave();
106 void MenuPrint();
107 void MenuPlotHelp();
108};
109
110// General indicator for DIM service
111class EddLineDisplay: public QLineEdit, public EddWidget {
112 Q_OBJECT
113
114 QMenu *Menu;
115 QPoint dragStart;
116 QWidget *LastHist;
117
118 QString ServiceName;
119 int Index;
120
121 void mousePressEvent(QMouseEvent *);
122 void mouseReleaseEvent(QMouseEvent *);
123 void mouseMoveEvent(QMouseEvent *);
124
125 public:
126 EddLineDisplay(QString, int=-1, QWidget * = NULL);
127 ~EddLineDisplay();
128 void Update(const QString &, int, const QByteArray &, const QString &, const QString &, int = -1);
129
130 bool ShowAsTime;
131
132 private slots:
133 void contextMenuEvent(QContextMenuEvent *);
134 void MenuOpenHistory();
135 void MenuCopyService();
136 void MenuCopyData();
137};
138
139// Sending command to DIM server
140class EddCommand: public QLineEdit {
141 Q_OBJECT
142
143 QString Name;
144
145 QString GetFormat();
146
147 public:
148 EddCommand(QString, QWidget * = NULL);
149
150 private slots:
151 void SendCommand();
152 void contextMenuEvent(QContextMenuEvent *);
153 void MenuCommandHelp();
154};
155
156// Graph class for history display
157class EddPlot: public EddBasePlot, public EddWidget {
158 Q_OBJECT
159
160 struct ItemDetails {
161 QString Name;
162 int Index;
163 QwtPlotCurve *Curve;
164 };
165 QList<struct ItemDetails> List;
166
167 private:
168 //EddDateScale *Scale;
169 QwtLegend *Legend;
170 QTimer *SingleShot;
171 QPoint dragStart;
172
173 void dragEnterEvent(QDragEnterEvent *);
174 void dropEvent(QDropEvent *);
175
176 public:
177 EddPlot(QString = QString(), int = 0, QWidget * = NULL);
178 ~EddPlot();
179 void AddService(QString, int = 0);
180 void Update(const QString &, int, const QByteArray &, const QString &, const QString &, int = -1);
181
182 public slots:
183 void RemoveService(QwtPlotCurve *);
184 void borderPath(QRect) {}; //Dummy method for qwtPicker, prevents QMetaObject::invokeMethod: No such method EddPlot::borderPath(QRect)
185
186 private slots:
187 void ScaleUpdate();
188 void MenuPasteService();
189 void MenuShowLastHour();
190 void MenuShowLastDay();
191 void MenuAllAsText();
192};
193
194// Scale showing date and time
195class EddDateScale: public QwtDateScaleDraw {
196
197 public:
198 QwtText label(double) const;
199};
200
201// Legend and legend label with protected methods implemented
202class EddLegend: public QwtLegend {
203
204 protected:
205 QWidget *createWidget(const QwtLegendData &) const;
206};
207
208class EddLegendLabel: public QwtLegendLabel {
209 Q_OBJECT
210
211 QMenu *Menu;
212 QPoint dragStart;
213
214 public:
215 EddLegendLabel();
216
217 void contextMenuEvent(QContextMenuEvent *);
218 void mousePressEvent(QMouseEvent *);
219 void mouseReleaseEvent(QMouseEvent *);
220 void mouseMoveEvent(QMouseEvent *);
221
222 QwtPlotCurve *Curve;
223 QAction *ThickLineAction;
224
225 private slots:
226 void MenuOpenHistory();
227 void MenuCopyService();
228 void MenuThickLine(bool);
229 void MenuRemove();
230
231 signals:
232 void DeleteCurve(QwtPlotCurve *);
233};
234
235// Text history and output class
236class EddText: public QTextEdit, public EddWidget {
237 Q_OBJECT
238
239 private:
240 QString Name;
241 bool Pure;
242
243 public:
244 EddText(QString, bool = false, QWidget * = NULL);
245 ~EddText();
246 void Update(const QString &, int, const QByteArray &, const QString &, const QString &, int = -1);
247
248 bool Accumulate;
249};
250
251
252// Interface to DIM system
253class EddDim: public QObject, public DimInfo {
254 Q_OBJECT
255
256 public:
257 struct HistItem {
258 int Time;
259 QVector<QPair<int, QByteArray> > DataRaw;
260 QVector<QPair<int, QStringList> > DataText;
261 QString Format;
262 };
263
264 private:
265 struct Item {
266 DimStampedInfo *DIMService;
267 QList<QPair<class EddWidget *, int> > Subscribers;
268 int TimeStamp;
269 QByteArray ByteArray;
270 QString Format;
271 QString Text;
272 QStringList Items;
273 };
274
275 QMap<QString, struct Item> ServiceList;
276 QMap<QString, bool> IgnoreMap;
277 QMutex *Mutex, IgnoreMutex;
278 QMap<QString, struct HistItem> HistoryList;
279
280 unsigned int Period;
281 long long Volume;
282
283 void infoHandler();
284
285 private slots:
286 void Update(QString, int, QByteArray, QString);
287 void UpdateStatistics();
288
289 public:
290 EddDim();
291 ~EddDim();
292
293 void Subscribe(QString, class EddWidget *, int = -1);
294 void Unsubscribe (QString, class EddWidget *, int = -1);
295 void Ignore (QString, bool);
296 struct HistItem GetHistory(QString);
297
298 signals:
299 void INT(QString, int, QByteArray = QByteArray(), QString = QString());
300};
301
302// Open new window
303class EddWindow: public QPushButton {
304 Q_OBJECT
305
306 QMainWindow *M;
307 QGridLayout *L;
308
309 public:
310 EddWindow(QString, QString);
311 QGridLayout *Layout();
312 QMainWindow *Window();
313};
314
315#endif
Note: See TracBrowser for help on using the repository browser.