source: Evidence/Edd/Edd.h@ 226

Last change on this file since 226 was 222, checked in by ogrimm, 14 years ago
History buffer contains also DIM service format
  • Property svn:keywords set to Revision
File size: 7.2 KB
Line 
1#ifndef EDD_H_SEEN
2#define EDD_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#include "RawDataCTX.h"
29#include "PixelMap.h"
30
31#define SVN_REVISION "$Revision: 222 $"
32
33const QColor EddPlotBackgroundColor(Qt::yellow);
34
35QWidget *OpenHistory(char *, int);
36bool SetStatus(QWidget *, QString, int, QString, int = -1);
37
38// Base class for Edd plot
39// DeleteCurve() is pure virtual and needs to be implemented iin the application class
40class EddBasePlot: public QwtPlot {
41 Q_OBJECT
42
43 protected:
44 QMenu *Menu;
45 QAction *StripAction;
46
47 private:
48 struct PlotItem {
49 QwtPlotCurve *Signal;
50 QVector<double> x;
51 QVector<double> y;
52 double Smallest;
53 double Largest;
54 };
55 QList<struct PlotItem> Items;
56
57 QAction *YLogAction;
58 QAction *NormAction;
59 QAction *StyleAction;
60
61 QwtPlotPanner *Panner;
62 QwtPlotGrid *Grid;
63 QwtPlotZoomer *Zoomer;
64 QwtPlotMagnifier *Magnifier;
65 QwtPicker *Picker;
66 QwtDoubleRect BBox;
67
68 public:
69 EddBasePlot(QWidget * = NULL);
70 ~EddBasePlot();
71
72 QwtPlotCurve *NewCurve(QwtText);
73 void ClearCurve(unsigned int);
74 void AddPoint(unsigned int, double, double);
75 virtual void DeleteCurve(QwtPlotCurve *) = 0;
76
77 protected slots:
78 void UpdatePlot();
79
80 private slots:
81 void HandleZoom(const QwtDoubleRect &);
82 void MouseSelection(const QwtPolygon &);
83 void contextMenuEvent(QContextMenuEvent *);
84 void MenuSingleTrace();
85 void MenuZoomOut();
86 void MenuSaveASCII();
87 void MenuSave();
88 void MenuPrint();
89 void MenuPlotHelp();
90};
91
92// General indicator for DIM service
93class EddLineDisplay: public QLineEdit {
94 Q_OBJECT
95
96 QMenu *Menu;
97 QPoint dragStart;
98 QWidget *LastHist;
99
100 QString ServiceName;
101 int Index;
102
103 void mousePressEvent(QMouseEvent *);
104 void mouseReleaseEvent(QMouseEvent *);
105 void mouseMoveEvent(QMouseEvent *);
106
107 public:
108 EddLineDisplay(QString, int=0, QWidget * = NULL);
109 ~EddLineDisplay();
110
111 bool ShowAsTime;
112
113 private slots:
114 void Update(QString, int, QByteArray, QString, QString);
115 void contextMenuEvent(QContextMenuEvent *);
116 void MenuOpenHistory();
117 void MenuCopyService();
118 void MenuCopyData();
119};
120
121// Sending command to DIM server
122class EddCommand: public QLineEdit {
123 Q_OBJECT
124
125 QString Name;
126
127 public:
128 EddCommand(QString, QWidget * = NULL);
129
130 private slots:
131 void SendCommand();
132};
133
134// Graph class for history display
135class EddPlot: public EddBasePlot {
136 Q_OBJECT
137
138 // Time scale for axis
139 class EddTimeScale: public QwtScaleDraw {
140
141 public:
142 EddTimeScale() {}
143
144 virtual QwtText label(double v) const {
145 // Adapt text format to time span
146 QString Format;
147 if (scaleDiv().range() < 60*60) Format = "hh' h\n'mm:ss";
148 else if (scaleDiv().range() < 24*60*60) Format = "hh:mm";
149 else if (scaleDiv().range() < 30*24*60*60) Format = "h' h\n'd-MMM";
150 else Format = "d-MMM'\n'yyyy";
151
152 // Generate text
153 QwtText Text = QDateTime::fromTime_t((int) v).toString(Format);
154 QFont Font = Text.font();
155 Font.setPointSize(7);
156 Text.setFont(Font);
157
158 return Text;
159 }
160 };
161
162 struct ItemDetails {
163 QString Name;
164 int Index;
165 QwtPlotCurve *Signal;
166 };
167 QList<struct ItemDetails> List;
168
169 private:
170 QwtLegend *Legend;
171 int SizeLimit;
172
173 void dragEnterEvent(QDragEnterEvent *);
174 void dropEvent(QDropEvent *);
175 void paintEvent(QPaintEvent *);
176
177 public:
178 EddPlot(QString = QString(), int = 0, QWidget * = NULL);
179 ~EddPlot();
180 void AddService(QString, int = 0);
181 void DeleteCurve(QwtPlotCurve *);
182
183 private slots:
184 void Update(QString, int, QByteArray, QString, QString);
185 void LegendClicked(QwtPlotItem *);
186 void MenuPasteService();
187};
188
189
190// Text history and output class
191class EddText: public QTextEdit {
192 Q_OBJECT
193
194 private:
195 QString Name;
196 bool Pure;
197
198 public:
199 EddText(QString, bool = false, QWidget * = NULL);
200 ~EddText();
201
202 bool Accumulate;
203
204 private slots:
205 void Update(QString, int, QByteArray, QString, QString);
206};
207
208
209// Interface to DIM system
210class EddDim: public QObject, public DimInfo {
211 Q_OBJECT
212
213 private:
214 struct Item {
215 QString Name;
216 DimStampedInfo *DIMService;
217 int Count;
218 int TimeStamp;
219 QByteArray ByteArray;
220 QString Format;
221 QString Text;
222 };
223 QList<Item> ServiceList;
224 QMutex *Mutex;
225
226 struct HistItem {
227 QString Name;
228 int Count;
229 int LastUpdate;
230 class EvidenceHistory *HistClass;
231 };
232 QList<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};
254
255//
256//
257// ====== FACT specific part ======
258//
259//
260
261// Event oscilloscope
262class EventScope: public EddBasePlot, public PixelMap {
263 Q_OBJECT
264
265 private:
266 struct ItemDetails {
267 unsigned int Board, Chip, Channel;
268 QwtPlotCurve *Signal;
269 QwtPlotMarker *Trigger;
270 };
271 QList<struct ItemDetails> List;
272
273 QString Name;
274 RawDataCTX *RD;
275 CTX_ErrCode ErrCode;
276 QAction *PhysPipeAction;
277 FILE *Tmpfile;
278
279 public:
280 EventScope(QWidget * = NULL);
281 ~EventScope();
282
283 void UpdateFirst(int, int, int);
284 void AddTrace(int, int, int);
285
286 private slots:
287 void Update(QString, int, QByteArray, QString, QString);
288 void PlotTraces();
289 void DeleteCurve(QwtPlotCurve *);
290
291 signals:
292 void RunHeaderChanged(QString);
293 void EventHeaderChanged(QString);
294 void PixelData(QVector<double>);
295};
296
297
298// Tab page classes
299class TP_Environment: public QWidget {
300 Q_OBJECT
301
302 public:
303 TP_Environment();
304};
305
306class TP_Bias: public QWidget {
307 Q_OBJECT
308
309 public:
310 TP_Bias();
311};
312
313class TP_Feedback: public QWidget {
314 Q_OBJECT
315
316 private slots:
317 void FeedbackDetails();
318
319 public:
320 TP_Feedback();
321};
322
323class TP_DAQ: public QWidget {
324 Q_OBJECT
325 static const int MAXPIXEL = 1440;
326
327 private:
328 EventScope *Scope;
329 QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay;
330
331 QSpinBox *Channel, *Chip, *Board;
332 QLineEdit *PixelID;
333 QFormLayout *FormLayout;
334 QWidget *Display;
335 QPushButton **Pixel;
336
337 private slots:
338 void TranslatePixelID();
339 void UpdateScope(int);
340 void KeepCurrent();
341 void ShowPixelDisplay();
342 void SetPixelData(QVector<double>);
343
344 public:
345 TP_DAQ();
346 ~TP_DAQ();
347};
348
349class TP_Evidence: public QWidget {
350 Q_OBJECT
351
352 private slots:
353 void StartDIMBrowser();
354
355 public:
356 TP_Evidence();
357};
358
359
360// Main window class
361class GUI: public QMainWindow, public DimBrowser {
362 Q_OBJECT
363
364 private:
365 QWidget *Central;
366 QTabWidget *TabWidget;
367
368 void closeEvent(QCloseEvent *);
369
370 public:
371 GUI();
372 ~GUI();
373
374 private slots:
375 void MenuAbout();
376 void MenuNewHistory();
377 void DetachTab(int);
378};
379
380#endif
Note: See TracBrowser for help on using the repository browser.