From 62c1d349fb26e69e83d9e816852080f0d5bc72d6 Mon Sep 17 00:00:00 2001 From: duanshengchao <519970194@qq.com> Date: Wed, 9 Jul 2025 14:29:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E6=9B=B4=E6=96=B0dataPanel=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84=EF=BC=8C=E5=A2=9E=E5=8A=A0dpBaseCha?= =?UTF-8?q?rt=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 ++ dataPanel/dpBaseChart.cpp | 9 +++++++++ dataPanel/dpBaseChart.h | 30 ++++++++++++++++++++++++++++++ dataPanel/dpBaseWidget.h | 13 ------------- dataPanel/dpLineChart.cpp | 2 +- dataPanel/dpLineChart.h | 10 +++++----- 6 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 dataPanel/dpBaseChart.cpp create mode 100644 dataPanel/dpBaseChart.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a4c5fbb..4c1114c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,8 @@ set(DATAPANEL_FILES dataPanel/dpConfigurationDialog.cpp dataPanel/dpBaseWidget.h dataPanel/dpBaseWidget.cpp + dataPanel/dpBaseChart.h + dataPanel/dpBaseChart.cpp dataPanel/dpLineChart.h dataPanel/dpLineChart.cpp ) diff --git a/dataPanel/dpBaseChart.cpp b/dataPanel/dpBaseChart.cpp new file mode 100644 index 0000000..0721b0f --- /dev/null +++ b/dataPanel/dpBaseChart.cpp @@ -0,0 +1,9 @@ +#include "dpBaseChart.h" + +dpBaseChart::dpBaseChart(QWidget* parent) + :dpBaseWidget(parent) +{} + +dpBaseChart::~dpBaseChart() +{ +} diff --git a/dataPanel/dpBaseChart.h b/dataPanel/dpBaseChart.h new file mode 100644 index 0000000..22936b6 --- /dev/null +++ b/dataPanel/dpBaseChart.h @@ -0,0 +1,30 @@ +#ifndef DPBASECHART_H +#define DPBASECHART_H + +#include "dpBaseWidget.h" + +class dpBaseChart : public dpBaseWidget +{ + Q_OBJECT + +public: + dpBaseChart(QWidget *parent = nullptr); + ~dpBaseChart(); + + void setTimeRange(TimeUnit) {} + void setDateTime(const QDateTime&) {} + void viewHistoricalData(const QDateTime&) {} + +protected: + struct ChartStyle + { + QColor bgColor; //背景颜色 + QColor axisColor; //坐标轴颜色 + QColor tickColor; //刻度颜色 + QColor tickLabelColor; //刻度label颜色 + QFont tickLabelFont; //刻度label字体 + QPen gridPen; //网格线颜色 + }; +}; + +#endif diff --git a/dataPanel/dpBaseWidget.h b/dataPanel/dpBaseWidget.h index dad2b24..30e706d 100644 --- a/dataPanel/dpBaseWidget.h +++ b/dataPanel/dpBaseWidget.h @@ -26,19 +26,6 @@ public: virtual void setTimeRange(TimeUnit) {} virtual void setDateTime(const QDateTime&) {} virtual void viewHistoricalData(const QDateTime&) {} - -protected: - struct ChartStyle - { - QColor bgColor; //背景颜色 - QColor axisColor; //坐标轴颜色 - QColor tickColor; //刻度颜色 - QColor tickLabelColor; //刻度label颜色 - QFont tickLabelFont; //刻度label字体 - QPen gridPen; //网格线颜色 - }; - -private: }; #endif diff --git a/dataPanel/dpLineChart.cpp b/dataPanel/dpLineChart.cpp index 594009b..f3beb92 100644 --- a/dataPanel/dpLineChart.cpp +++ b/dataPanel/dpLineChart.cpp @@ -2,7 +2,7 @@ #include "util/Chart/qcustomplot.h" dpLineChart::dpLineChart(QWidget* parent) - :dpBaseWidget(parent) + :dpBaseChart(parent) { setAttribute(Qt::WA_TranslucentBackground,true); diff --git a/dataPanel/dpLineChart.h b/dataPanel/dpLineChart.h index 279ed06..7fa6e81 100644 --- a/dataPanel/dpLineChart.h +++ b/dataPanel/dpLineChart.h @@ -10,12 +10,12 @@ ** ******************************************************************************/ -#include "dpBaseWidget.h" +#include "dpBaseChart.h" class QCustomPlot; class QCPRange; -class dpLineChart : public dpBaseWidget +class dpLineChart : public dpBaseChart { Q_OBJECT @@ -23,9 +23,9 @@ public: dpLineChart(QWidget *parent = nullptr); ~dpLineChart(); - void setTimeRange(TimeUnit); - void setDateTime(const QDateTime&); - void viewHistoricalData(const QDateTime&); + void setTimeRange(TimeUnit) override; + void setDateTime(const QDateTime&) override; + void viewHistoricalData(const QDateTime&) override; public slots: void onSignal_rangeChanged_xAxis(const QCPRange&);