#ifndef EDD_H_SEEN #define EDD_H_SEEN #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dic.hxx" #include "Evidence.h" #include "RawDataCTX.h" #include "PixelMap.h" #define SVN_REVISION "$Revision: 222 $" const QColor EddPlotBackgroundColor(Qt::yellow); QWidget *OpenHistory(char *, int); bool SetStatus(QWidget *, QString, int, QString, int = -1); // Base class for Edd plot // DeleteCurve() is pure virtual and needs to be implemented iin the application class class EddBasePlot: public QwtPlot { Q_OBJECT protected: QMenu *Menu; QAction *StripAction; private: struct PlotItem { QwtPlotCurve *Signal; QVector x; QVector y; double Smallest; double Largest; }; QList Items; QAction *YLogAction; QAction *NormAction; QAction *StyleAction; QwtPlotPanner *Panner; QwtPlotGrid *Grid; QwtPlotZoomer *Zoomer; QwtPlotMagnifier *Magnifier; QwtPicker *Picker; QwtDoubleRect BBox; public: EddBasePlot(QWidget * = NULL); ~EddBasePlot(); QwtPlotCurve *NewCurve(QwtText); void ClearCurve(unsigned int); void AddPoint(unsigned int, double, double); virtual void DeleteCurve(QwtPlotCurve *) = 0; protected slots: void UpdatePlot(); private slots: void HandleZoom(const QwtDoubleRect &); void MouseSelection(const QwtPolygon &); void contextMenuEvent(QContextMenuEvent *); void MenuSingleTrace(); void MenuZoomOut(); void MenuSaveASCII(); void MenuSave(); void MenuPrint(); void MenuPlotHelp(); }; // General indicator for DIM service class EddLineDisplay: public QLineEdit { Q_OBJECT QMenu *Menu; QPoint dragStart; QWidget *LastHist; QString ServiceName; int Index; void mousePressEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); void mouseMoveEvent(QMouseEvent *); public: EddLineDisplay(QString, int=0, QWidget * = NULL); ~EddLineDisplay(); bool ShowAsTime; private slots: void Update(QString, int, QByteArray, QString, QString); void contextMenuEvent(QContextMenuEvent *); void MenuOpenHistory(); void MenuCopyService(); void MenuCopyData(); }; // Sending command to DIM server class EddCommand: public QLineEdit { Q_OBJECT QString Name; public: EddCommand(QString, QWidget * = NULL); private slots: void SendCommand(); }; // Graph class for history display class EddPlot: public EddBasePlot { Q_OBJECT // Time scale for axis class EddTimeScale: public QwtScaleDraw { public: EddTimeScale() {} virtual QwtText label(double v) const { // Adapt text format to time span QString Format; if (scaleDiv().range() < 60*60) Format = "hh' h\n'mm:ss"; else if (scaleDiv().range() < 24*60*60) Format = "hh:mm"; else if (scaleDiv().range() < 30*24*60*60) Format = "h' h\n'd-MMM"; else Format = "d-MMM'\n'yyyy"; // Generate text QwtText Text = QDateTime::fromTime_t((int) v).toString(Format); QFont Font = Text.font(); Font.setPointSize(7); Text.setFont(Font); return Text; } }; struct ItemDetails { QString Name; int Index; QwtPlotCurve *Signal; }; QList List; private: QwtLegend *Legend; int SizeLimit; void dragEnterEvent(QDragEnterEvent *); void dropEvent(QDropEvent *); void paintEvent(QPaintEvent *); public: EddPlot(QString = QString(), int = 0, QWidget * = NULL); ~EddPlot(); void AddService(QString, int = 0); void DeleteCurve(QwtPlotCurve *); private slots: void Update(QString, int, QByteArray, QString, QString); void LegendClicked(QwtPlotItem *); void MenuPasteService(); }; // Text history and output class class EddText: public QTextEdit { Q_OBJECT private: QString Name; bool Pure; public: EddText(QString, bool = false, QWidget * = NULL); ~EddText(); bool Accumulate; private slots: void Update(QString, int, QByteArray, QString, QString); }; // Interface to DIM system class EddDim: public QObject, public DimInfo { Q_OBJECT private: struct Item { QString Name; DimStampedInfo *DIMService; int Count; int TimeStamp; QByteArray ByteArray; QString Format; QString Text; }; QList ServiceList; QMutex *Mutex; struct HistItem { QString Name; int Count; int LastUpdate; class EvidenceHistory *HistClass; }; QList HistoryList; long long Volume; void infoHandler(); private slots: void Update(QString, int, QByteArray, QString, QString); void UpdateStatistics(); public: EddDim(); ~EddDim(); void Subscribe(QString); void Unsubscribe (QString); class EvidenceHistory *GetHistory(QString); void DropHistory(QString); signals: void YEP(QString, int, QByteArray = QByteArray(), QString = QString(), QString = QString()); }; // // // ====== FACT specific part ====== // // // Event oscilloscope class EventScope: public EddBasePlot, public PixelMap { Q_OBJECT private: struct ItemDetails { unsigned int Board, Chip, Channel; QwtPlotCurve *Signal; QwtPlotMarker *Trigger; }; QList List; QString Name; RawDataCTX *RD; CTX_ErrCode ErrCode; QAction *PhysPipeAction; FILE *Tmpfile; public: EventScope(QWidget * = NULL); ~EventScope(); void UpdateFirst(int, int, int); void AddTrace(int, int, int); private slots: void Update(QString, int, QByteArray, QString, QString); void PlotTraces(); void DeleteCurve(QwtPlotCurve *); signals: void RunHeaderChanged(QString); void EventHeaderChanged(QString); void PixelData(QVector); }; // Tab page classes class TP_Environment: public QWidget { Q_OBJECT public: TP_Environment(); }; class TP_Bias: public QWidget { Q_OBJECT public: TP_Bias(); }; class TP_Feedback: public QWidget { Q_OBJECT private slots: void FeedbackDetails(); public: TP_Feedback(); }; class TP_DAQ: public QWidget { Q_OBJECT static const int MAXPIXEL = 1440; private: EventScope *Scope; QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay; QSpinBox *Channel, *Chip, *Board; QLineEdit *PixelID; QFormLayout *FormLayout; QWidget *Display; QPushButton **Pixel; private slots: void TranslatePixelID(); void UpdateScope(int); void KeepCurrent(); void ShowPixelDisplay(); void SetPixelData(QVector); public: TP_DAQ(); ~TP_DAQ(); }; class TP_Evidence: public QWidget { Q_OBJECT private slots: void StartDIMBrowser(); public: TP_Evidence(); }; // Main window class class GUI: public QMainWindow, public DimBrowser { Q_OBJECT private: QWidget *Central; QTabWidget *TabWidget; void closeEvent(QCloseEvent *); public: GUI(); ~GUI(); private slots: void MenuAbout(); void MenuNewHistory(); void DetachTab(int); }; #endif