2023-02-09 18:27:20 -05:00
|
|
|
#ifndef Scope_H
|
|
|
|
#define Scope_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QChart>
|
2023-02-09 19:05:30 -05:00
|
|
|
#include <QChartView>
|
2023-02-09 18:27:20 -05:00
|
|
|
#include <QSpinBox>
|
2023-03-24 18:07:48 -04:00
|
|
|
#include <QLabel>
|
2023-02-09 18:27:20 -05:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QCheckBox>
|
2023-02-13 17:07:26 -05:00
|
|
|
#include <QLineEdit>
|
2023-02-09 18:27:20 -05:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QLineSeries>
|
2023-02-09 19:05:30 -05:00
|
|
|
#include <QRubberBand>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QGestureEvent>
|
2023-02-09 18:27:20 -05:00
|
|
|
|
2023-03-16 17:28:55 -04:00
|
|
|
#include "macro.h"
|
2023-02-09 18:27:20 -05:00
|
|
|
#include "ClassDigitizer2Gen.h"
|
|
|
|
#include "manyThread.h"
|
2023-03-10 17:28:02 -05:00
|
|
|
#include "CustomWidgets.h"
|
2023-02-09 18:27:20 -05:00
|
|
|
|
2023-02-09 19:05:30 -05:00
|
|
|
class Trace : public QChart{
|
|
|
|
public:
|
|
|
|
explicit Trace(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = {})
|
|
|
|
: QChart(QChart::ChartTypeCartesian, parent, wFlags){
|
|
|
|
grabGesture(Qt::PanGesture);
|
|
|
|
grabGesture(Qt::PinchGesture);
|
|
|
|
}
|
|
|
|
~Trace(){}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool sceneEvent(QEvent *event){
|
|
|
|
if (event->type() == QEvent::Gesture) return gestureEvent(static_cast<QGestureEvent *>(event));
|
|
|
|
return QChart::event(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool gestureEvent(QGestureEvent *event){
|
|
|
|
if (QGesture *gesture = event->gesture(Qt::PanGesture)) {
|
|
|
|
QPanGesture *pan = static_cast<QPanGesture *>(gesture);
|
|
|
|
QChart::scroll(-(pan->delta().x()), pan->delta().y());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QGesture *gesture = event->gesture(Qt::PinchGesture)) {
|
|
|
|
QPinchGesture *pinch = static_cast<QPinchGesture *>(gesture);
|
|
|
|
if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged) QChart::zoom(pinch->scaleFactor());
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class TraceView : public QChartView{
|
|
|
|
public:
|
|
|
|
TraceView(QChart * chart, QWidget * parent = nullptr): QChartView(chart, parent){
|
|
|
|
m_isTouching = false;
|
|
|
|
this->setRubberBand(QChartView::RectangleRubberBand);
|
2023-03-24 18:07:48 -04:00
|
|
|
|
|
|
|
m_coordinateLabel = new QLabel(this);
|
|
|
|
m_coordinateLabel->setStyleSheet("QLabel { color : black; }");
|
|
|
|
m_coordinateLabel->setVisible(false);
|
|
|
|
m_coordinateLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
|
|
setMouseTracking(true);
|
2023-02-09 19:05:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool viewportEvent(QEvent *event){
|
|
|
|
if (event->type() == QEvent::TouchBegin) {
|
|
|
|
m_isTouching = true;
|
|
|
|
chart()->setAnimationOptions(QChart::NoAnimation);
|
|
|
|
}
|
|
|
|
return QChartView::viewportEvent(event);
|
|
|
|
}
|
|
|
|
void mousePressEvent(QMouseEvent *event){
|
|
|
|
if (m_isTouching) return;
|
|
|
|
QChartView::mousePressEvent(event);
|
|
|
|
}
|
|
|
|
void mouseMoveEvent(QMouseEvent *event){
|
2023-03-24 18:07:48 -04:00
|
|
|
|
|
|
|
QPointF chartPoint = this->chart()->mapToValue(event->pos());
|
|
|
|
QString coordinateText = QString("x: %1, y: %2").arg(QString::number(chartPoint.x(), 'f', 0)).arg(QString::number(chartPoint.y(), 'f', 0));
|
|
|
|
m_coordinateLabel->setText(coordinateText);
|
|
|
|
m_coordinateLabel->move(event->pos() + QPoint(10, -10));
|
|
|
|
m_coordinateLabel->setVisible(true);
|
2023-02-09 19:05:30 -05:00
|
|
|
if (m_isTouching) return;
|
|
|
|
QChartView::mouseMoveEvent(event);
|
2023-03-24 18:07:48 -04:00
|
|
|
|
2023-02-09 19:05:30 -05:00
|
|
|
}
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event){
|
|
|
|
if (m_isTouching) m_isTouching = false;
|
|
|
|
chart()->setAnimationOptions(QChart::SeriesAnimations);
|
|
|
|
QChartView::mouseReleaseEvent(event);
|
|
|
|
}
|
2023-03-24 18:07:48 -04:00
|
|
|
void leaveEvent(QEvent *event) override {
|
|
|
|
m_coordinateLabel->setVisible(false);
|
|
|
|
QChartView::leaveEvent(event);
|
|
|
|
}
|
2023-02-09 19:05:30 -05:00
|
|
|
void keyPressEvent(QKeyEvent *event){
|
|
|
|
switch (event->key()) {
|
|
|
|
case Qt::Key_Plus: chart()->zoomIn(); break;
|
|
|
|
case Qt::Key_Minus: chart()->zoomOut(); break;
|
|
|
|
case Qt::Key_Left: chart()->scroll(-10, 0); break;
|
|
|
|
case Qt::Key_Right: chart()->scroll(10, 0); break;
|
|
|
|
case Qt::Key_Up: chart()->scroll(0, 10); break;
|
|
|
|
case Qt::Key_Down: chart()->scroll(0, -10); break;
|
|
|
|
case Qt::Key_R : chart()->axes(Qt::Vertical).first()->setRange(-16384, 65536); break;
|
|
|
|
default: QGraphicsView::keyPressEvent(event); break;
|
|
|
|
}
|
|
|
|
}
|
2023-03-24 18:07:48 -04:00
|
|
|
|
2023-02-09 19:05:30 -05:00
|
|
|
private:
|
|
|
|
bool m_isTouching;
|
2023-03-24 18:07:48 -04:00
|
|
|
QLabel * m_coordinateLabel;
|
2023-02-09 19:05:30 -05:00
|
|
|
};
|
|
|
|
|
2023-03-10 17:28:02 -05:00
|
|
|
//^=======================================
|
2023-02-09 18:27:20 -05:00
|
|
|
class Scope : public QMainWindow{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Scope(Digitizer2Gen ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent = nullptr);
|
|
|
|
~Scope();
|
|
|
|
|
2023-03-10 17:28:02 -05:00
|
|
|
public slots:
|
|
|
|
void ReadScopeSettings(); // read from digitizer and show;
|
2023-03-24 17:23:59 -04:00
|
|
|
void UpdateSettingsFromMemeory();
|
2023-02-09 18:27:20 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void StartScope();
|
|
|
|
void StopScope();
|
|
|
|
void UpdateScope();
|
|
|
|
void ScopeControlOnOff(bool on);
|
2023-03-10 17:28:02 -05:00
|
|
|
void ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara);
|
|
|
|
void ScopeReadComboBoxValue(int iDigi, int ch, RComboBox *cb, const Reg digPara);
|
|
|
|
void ScopeMakeSpinBox(RSpinBox * &sb, QString str, QGridLayout* layout, int row, int col, const Reg digPara);
|
|
|
|
void ScopeMakeComoBox(RComboBox * &cb, QString str, QGridLayout* layout, int row, int col, const Reg digPara);
|
|
|
|
void ProbeChange(RComboBox * cb[], const int size);
|
2023-02-09 18:27:20 -05:00
|
|
|
|
|
|
|
void closeEvent(QCloseEvent * event){
|
|
|
|
StopScope();
|
2023-02-09 18:40:47 -05:00
|
|
|
emit CloseWindow();
|
2023-02-09 18:27:20 -05:00
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
2023-02-09 18:40:47 -05:00
|
|
|
void CloseWindow();
|
2023-02-13 17:56:15 -05:00
|
|
|
void UpdateScalar();
|
2023-03-24 17:23:59 -04:00
|
|
|
void SendLogMsg(const QString &msg);
|
2023-03-23 16:36:47 -04:00
|
|
|
void UpdateOtherPanels();
|
2023-03-10 17:28:02 -05:00
|
|
|
void TellSettingsPanelControlOnOff();
|
2023-03-16 17:28:55 -04:00
|
|
|
void TellACQOnOff(const bool onOff);
|
2023-02-09 18:40:47 -05:00
|
|
|
|
2023-02-09 18:27:20 -05:00
|
|
|
private:
|
|
|
|
|
|
|
|
Digitizer2Gen ** digi;
|
|
|
|
unsigned short nDigi;
|
|
|
|
|
|
|
|
ReadDataThread ** readDataThread;
|
|
|
|
UpdateTraceThread * updateTraceThread;
|
|
|
|
|
|
|
|
QChart * plot;
|
|
|
|
QLineSeries * dataTrace[6];
|
2023-03-10 17:28:02 -05:00
|
|
|
RComboBox * cbScopeDigi;
|
|
|
|
RComboBox * cbScopeCh;
|
2023-02-09 18:27:20 -05:00
|
|
|
QPushButton * bnScopeReset;
|
|
|
|
QPushButton * bnScopeReadSettings;
|
|
|
|
|
2023-03-10 18:09:25 -05:00
|
|
|
QCheckBox * chkSetAllChannel;
|
2023-02-09 18:27:20 -05:00
|
|
|
QPushButton * bnScopeStart;
|
|
|
|
QPushButton * bnScopeStop;
|
|
|
|
|
2023-03-10 17:28:02 -05:00
|
|
|
RComboBox * cbAnaProbe[2];
|
|
|
|
RComboBox * cbDigProbe[4];
|
|
|
|
RSpinBox * sbRL; // record length
|
|
|
|
RSpinBox * sbPT; // pre trigger
|
|
|
|
RSpinBox * sbDCOffset;
|
|
|
|
RSpinBox * sbThreshold;
|
|
|
|
RSpinBox * sbTimeRiseTime;
|
|
|
|
RSpinBox * sbTimeGuard;
|
|
|
|
RSpinBox * sbTrapRiseTime;
|
|
|
|
RSpinBox * sbTrapFlatTop;
|
|
|
|
RSpinBox * sbTrapPoleZero;
|
|
|
|
RSpinBox * sbEnergyFineGain;
|
|
|
|
RSpinBox * sbTrapPeaking;
|
|
|
|
RComboBox * cbPolarity;
|
|
|
|
RComboBox * cbWaveRes;
|
|
|
|
RComboBox * cbTrapPeakAvg;
|
2023-02-09 18:27:20 -05:00
|
|
|
|
2023-02-13 17:07:26 -05:00
|
|
|
QLineEdit * leTriggerRate;
|
|
|
|
|
2023-03-10 17:28:02 -05:00
|
|
|
RSpinBox * sbBaselineGuard;
|
|
|
|
RSpinBox * sbPileUpGuard;
|
|
|
|
RComboBox * cbBaselineAvg;
|
|
|
|
RComboBox * cbLowFreqFilter;
|
2023-02-09 18:27:20 -05:00
|
|
|
|
|
|
|
bool allowChange;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|