Files
gcs-nf/App/ComponentUI/Scope/Scope.h
T
2020-08-01 10:53:17 +08:00

115 lines
2.3 KiB
C++

#ifndef SCOPE_H
#define SCOPE_H
#include <QWidget>
#include "QDebug"
#include <QKeyEvent>
#include "QTimer"
#include "QChart"
#include <QChartView>
#include <QLineSeries>
#include <QValueAxis>
#include <QDateTimeAxis>
#include <QMouseEvent>
#include "QMimeData"
using namespace QtCharts;
namespace ColorMap{
static QColor Color[16] = {
QColor(165, 42, 42), //Channel1Color
QColor (255, 127, 80), //Channel2Color
QColor (30, 144, 255), //Channel3Color
QColor (218, 165, 32), //Channel4Color
QColor (255, 0, 255), //Channel5Color
QColor (147, 112, 219), //Channel6Color
QColor (0, 255, 255), //Channel7Color
QColor (0, 0, 128), //Channel8Color
QColor (128, 0, 128), //Channel9Color
QColor (46, 139, 87), //Channel10Color
QColor (152, 251, 152), //Channel11Color
QColor (0, 255, 127), //Channel12Color
QColor (0, 0, 255), //Channel13Color
QColor (135, 206, 250), //Channel14Color
QColor (255, 192, 203), //Channel15Color
QColor (127, 255, 0) //Channel16Color
};
}
namespace Ui {
class Scope;
}
class Scope : public QWidget
{
Q_OBJECT
public:
explicit Scope(QWidget *parent = nullptr);
~Scope();
static int ChannelIndex;
protected:
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseDoubleClickEvent(QMouseEvent *e);
void wheelEvent(QWheelEvent *e);
void resizeEvent(QResizeEvent *e);
signals:
void clearall(void);
void willcloase(void);
public slots:
void setUseOpenGL(const bool &value);
bool addSeries(QString name);
bool addSeries(QString name,int index);
bool addSeries(QString name, QColor color);
void removeSerie(QString name);
void setSerieData(QString name,QVariant data);
private slots:
void timeout(void);
void chartUpdate(void);
void on_pushButton_Pause_clicked();
void on_pushButton_Clear_clicked();
void on_pushButton_Flag1_clicked();
void on_pushButton_Flag2_clicked();
void on_pushButton_Close_clicked();
private:
Ui::Scope *ui;
QChartView *chartView;
QLineSeries *series;
qreal timeseries = 0;//时间基准,注意时间长度,可能会出现时间反转的情况
bool isOpenGL = false;
bool isScroll = true;
bool isPress = false;
};
#endif // SCOPE_H