| 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: 274 $"
|
|---|
| 32 |
|
|---|
| 33 | const QColor EddPlotBackgroundColor(Qt::yellow);
|
|---|
| 34 |
|
|---|
| 35 | QWidget *OpenHistory(char *, int);
|
|---|
| 36 | bool SetStatus(QWidget *, QString, int, QString, int = -1);
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | // Base class for Edd plot
|
|---|
| 40 | // DeleteCurve() is pure virtual and needs to be implemented iin the application class
|
|---|
| 41 | class EddBasePlot: public QwtPlot {
|
|---|
| 42 | Q_OBJECT
|
|---|
| 43 |
|
|---|
| 44 | protected:
|
|---|
| 45 | QMenu *Menu;
|
|---|
| 46 | QAction *StripAction;
|
|---|
| 47 |
|
|---|
| 48 | private:
|
|---|
| 49 | struct PlotItem {
|
|---|
| 50 | QwtPlotCurve *Signal;
|
|---|
| 51 | QVector<double> x;
|
|---|
| 52 | QVector<double> y;
|
|---|
| 53 | double Smallest;
|
|---|
| 54 | double Largest;
|
|---|
| 55 | };
|
|---|
| 56 | QList<struct PlotItem> Items;
|
|---|
| 57 |
|
|---|
| 58 | QAction *YLogAction;
|
|---|
| 59 | QAction *NormAction;
|
|---|
| 60 | QAction *StyleAction;
|
|---|
| 61 |
|
|---|
| 62 | QwtPlotPanner *Panner;
|
|---|
| 63 | QwtPlotGrid *Grid;
|
|---|
| 64 | QwtPlotZoomer *Zoomer;
|
|---|
| 65 | QwtPlotMagnifier *Magnifier;
|
|---|
| 66 | QwtPicker *Picker;
|
|---|
| 67 | QwtDoubleRect BBox;
|
|---|
| 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 HandleZoom(const QwtDoubleRect &);
|
|---|
| 83 | void MouseSelection(const QwtPolygon &);
|
|---|
| 84 | void contextMenuEvent(QContextMenuEvent *);
|
|---|
| 85 | void MenuSingleTrace();
|
|---|
| 86 | void MenuZoomOut();
|
|---|
| 87 | void MenuSaveASCII();
|
|---|
| 88 | void MenuSave();
|
|---|
| 89 | void MenuPrint();
|
|---|
| 90 | void MenuPlotHelp();
|
|---|
| 91 | };
|
|---|
| 92 |
|
|---|
| 93 | // General indicator for DIM service
|
|---|
| 94 | class EddLineDisplay: public QLineEdit {
|
|---|
| 95 | Q_OBJECT
|
|---|
| 96 |
|
|---|
| 97 | QMenu *Menu;
|
|---|
| 98 | QPoint dragStart;
|
|---|
| 99 | QWidget *LastHist;
|
|---|
| 100 |
|
|---|
| 101 | QString ServiceName;
|
|---|
| 102 | int Index;
|
|---|
| 103 |
|
|---|
| 104 | void mousePressEvent(QMouseEvent *);
|
|---|
| 105 | void mouseReleaseEvent(QMouseEvent *);
|
|---|
| 106 | void mouseMoveEvent(QMouseEvent *);
|
|---|
| 107 |
|
|---|
| 108 | public:
|
|---|
| 109 | EddLineDisplay(QString, int=0, QWidget * = NULL);
|
|---|
| 110 | ~EddLineDisplay();
|
|---|
| 111 |
|
|---|
| 112 | bool ShowAsTime;
|
|---|
| 113 |
|
|---|
| 114 | private slots:
|
|---|
| 115 | void Update(QString, int, QByteArray, QString, QString);
|
|---|
| 116 | void contextMenuEvent(QContextMenuEvent *);
|
|---|
| 117 | void MenuOpenHistory();
|
|---|
| 118 | void MenuCopyService();
|
|---|
| 119 | void MenuCopyData();
|
|---|
| 120 | };
|
|---|
| 121 |
|
|---|
| 122 | // Sending command to DIM server
|
|---|
| 123 | class EddCommand: public QLineEdit {
|
|---|
| 124 | Q_OBJECT
|
|---|
| 125 |
|
|---|
| 126 | QString Name;
|
|---|
| 127 |
|
|---|
| 128 | public:
|
|---|
| 129 | EddCommand(QString, QWidget * = NULL);
|
|---|
| 130 |
|
|---|
| 131 | private slots:
|
|---|
| 132 | void SendCommand();
|
|---|
| 133 | };
|
|---|
| 134 |
|
|---|
| 135 | // Graph class for history display
|
|---|
| 136 | class EddPlot: public EddBasePlot {
|
|---|
| 137 | Q_OBJECT
|
|---|
| 138 |
|
|---|
| 139 | // Time scale for axis
|
|---|
| 140 | class EddTimeScale: public QwtScaleDraw {
|
|---|
| 141 |
|
|---|
| 142 | public:
|
|---|
| 143 | EddTimeScale() {}
|
|---|
| 144 |
|
|---|
| 145 | virtual QwtText label(double v) const {
|
|---|
| 146 | // Adapt text format to time span
|
|---|
| 147 | QString Format;
|
|---|
| 148 | if (scaleDiv().range() < 60*60) Format = "hh' h\n'mm:ss";
|
|---|
| 149 | else if (scaleDiv().range() < 24*60*60) Format = "hh:mm";
|
|---|
| 150 | else if (scaleDiv().range() < 30*24*60*60) Format = "h' h\n'd-MMM";
|
|---|
| 151 | else Format = "d-MMM'\n'yyyy";
|
|---|
| 152 |
|
|---|
| 153 | // Generate text
|
|---|
| 154 | QwtText Text = QDateTime::fromTime_t((int) v).toString(Format);
|
|---|
| 155 | QFont Font = Text.font();
|
|---|
| 156 | Font.setPointSize(7);
|
|---|
| 157 | Text.setFont(Font);
|
|---|
| 158 |
|
|---|
| 159 | return Text;
|
|---|
| 160 | }
|
|---|
| 161 | };
|
|---|
| 162 |
|
|---|
| 163 | struct ItemDetails {
|
|---|
| 164 | QString Name;
|
|---|
| 165 | int Index;
|
|---|
| 166 | QwtPlotCurve *Signal;
|
|---|
| 167 | };
|
|---|
| 168 | QList<struct ItemDetails> List;
|
|---|
| 169 |
|
|---|
| 170 | private:
|
|---|
| 171 | QwtLegend *Legend;
|
|---|
| 172 | int SizeLimit;
|
|---|
| 173 |
|
|---|
| 174 | void dragEnterEvent(QDragEnterEvent *);
|
|---|
| 175 | void dropEvent(QDropEvent *);
|
|---|
| 176 | void paintEvent(QPaintEvent *);
|
|---|
| 177 |
|
|---|
| 178 | public:
|
|---|
| 179 | EddPlot(QString = QString(), int = 0, QWidget * = NULL);
|
|---|
| 180 | ~EddPlot();
|
|---|
| 181 | void AddService(QString, int = 0);
|
|---|
| 182 | void DeleteCurve(QwtPlotCurve *);
|
|---|
| 183 |
|
|---|
| 184 | private slots:
|
|---|
| 185 | void Update(QString, int, QByteArray, QString, QString);
|
|---|
| 186 | void LegendClicked(QwtPlotItem *);
|
|---|
| 187 | void MenuPasteService();
|
|---|
| 188 | };
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 | // Text history and output class
|
|---|
| 192 | class EddText: public QTextEdit {
|
|---|
| 193 | Q_OBJECT
|
|---|
| 194 |
|
|---|
| 195 | private:
|
|---|
| 196 | QString Name;
|
|---|
| 197 | bool Pure;
|
|---|
| 198 |
|
|---|
| 199 | public:
|
|---|
| 200 | EddText(QString, bool = false, QWidget * = NULL);
|
|---|
| 201 | ~EddText();
|
|---|
| 202 |
|
|---|
| 203 | bool Accumulate;
|
|---|
| 204 |
|
|---|
| 205 | private slots:
|
|---|
| 206 | void Update(QString, int, QByteArray, QString, QString);
|
|---|
| 207 | };
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 | // Interface to DIM system
|
|---|
| 211 | class EddDim: public QObject, public DimInfo {
|
|---|
| 212 | Q_OBJECT
|
|---|
| 213 |
|
|---|
| 214 | private:
|
|---|
| 215 | struct Item {
|
|---|
| 216 | DimStampedInfo *DIMService;
|
|---|
| 217 | int Count;
|
|---|
| 218 | int TimeStamp;
|
|---|
| 219 | QByteArray ByteArray;
|
|---|
| 220 | QString Format;
|
|---|
| 221 | QString Text;
|
|---|
| 222 | };
|
|---|
| 223 | QMap<QString, struct Item> ServiceList;
|
|---|
| 224 | QMutex *Mutex;
|
|---|
| 225 |
|
|---|
| 226 | struct HistItem {
|
|---|
| 227 | int Count;
|
|---|
| 228 | int LastUpdate;
|
|---|
| 229 | class EvidenceHistory *HistClass;
|
|---|
| 230 | };
|
|---|
| 231 | QMap<QString, struct HistItem> HistoryList;
|
|---|
| 232 |
|
|---|
| 233 | long long Volume;
|
|---|
| 234 |
|
|---|
| 235 | void infoHandler();
|
|---|
| 236 |
|
|---|
| 237 | private slots:
|
|---|
| 238 | void Update(QString, int, QByteArray, QString, QString);
|
|---|
| 239 | void UpdateStatistics();
|
|---|
| 240 |
|
|---|
| 241 | public:
|
|---|
| 242 | EddDim();
|
|---|
| 243 | ~EddDim();
|
|---|
| 244 |
|
|---|
| 245 | void Subscribe(QString);
|
|---|
| 246 | void Unsubscribe (QString);
|
|---|
| 247 | class EvidenceHistory *GetHistory(QString);
|
|---|
| 248 | void DropHistory(QString);
|
|---|
| 249 |
|
|---|
| 250 | signals:
|
|---|
| 251 | void YEP(QString, int, QByteArray = QByteArray(), QString = QString(), QString = QString());
|
|---|
| 252 | void INT(QString, int, QByteArray = QByteArray(), QString = QString(), QString = QString());
|
|---|
| 253 | };
|
|---|
| 254 |
|
|---|
| 255 | //
|
|---|
| 256 | //
|
|---|
| 257 | // ====== FACT specific part ======
|
|---|
| 258 | //
|
|---|
| 259 | //
|
|---|
| 260 |
|
|---|
| 261 | // Event oscilloscope
|
|---|
| 262 | class 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
|
|---|
| 299 | class TP_Environment: public QWidget {
|
|---|
| 300 | Q_OBJECT
|
|---|
| 301 |
|
|---|
| 302 | public:
|
|---|
| 303 | TP_Environment();
|
|---|
| 304 | };
|
|---|
| 305 |
|
|---|
| 306 | class TP_Bias: public QWidget {
|
|---|
| 307 | Q_OBJECT
|
|---|
| 308 |
|
|---|
| 309 | public:
|
|---|
| 310 | TP_Bias();
|
|---|
| 311 | };
|
|---|
| 312 |
|
|---|
| 313 | class TP_Feedback: public QWidget {
|
|---|
| 314 | Q_OBJECT
|
|---|
| 315 |
|
|---|
| 316 | private slots:
|
|---|
| 317 | void FeedbackDetails();
|
|---|
| 318 |
|
|---|
| 319 | public:
|
|---|
| 320 | TP_Feedback();
|
|---|
| 321 | };
|
|---|
| 322 |
|
|---|
| 323 | class 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 |
|
|---|
| 349 | class TP_Evidence: public QWidget {
|
|---|
| 350 | Q_OBJECT
|
|---|
| 351 |
|
|---|
| 352 | private slots:
|
|---|
| 353 | void StartDIMBrowser();
|
|---|
| 354 | void StartELog();
|
|---|
| 355 |
|
|---|
| 356 | public:
|
|---|
| 357 | TP_Evidence();
|
|---|
| 358 | };
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 | // Main window class
|
|---|
| 362 | class GUI: public QMainWindow, public DimBrowser {
|
|---|
| 363 | Q_OBJECT
|
|---|
| 364 |
|
|---|
| 365 | private:
|
|---|
| 366 | QWidget *Central;
|
|---|
| 367 | QTabWidget *TabWidget;
|
|---|
| 368 |
|
|---|
| 369 | void closeEvent(QCloseEvent *);
|
|---|
| 370 |
|
|---|
| 371 | public:
|
|---|
| 372 | GUI();
|
|---|
| 373 | ~GUI();
|
|---|
| 374 |
|
|---|
| 375 | private slots:
|
|---|
| 376 | void MenuAbout();
|
|---|
| 377 | void MenuNewHistory();
|
|---|
| 378 | void DetachTab(int);
|
|---|
| 379 | };
|
|---|
| 380 |
|
|---|
| 381 | #endif
|
|---|