source: fact/Evidence/GUI.h@ 10531

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