2024-12-25 08:34:51 +08:00
|
|
|
|
#ifndef DPLINECHART_H
|
|
|
|
|
|
#define DPLINECHART_H
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
** DataPanel-LineChart
|
|
|
|
|
|
** author dsc
|
|
|
|
|
|
**
|
|
|
|
|
|
** 折线图展示面板,用来展示带有时序数据,可以和TimeLine等组件进行时间属性的交互
|
|
|
|
|
|
** 采用QCustomPlot实现
|
|
|
|
|
|
**
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
2025-07-09 14:29:29 +08:00
|
|
|
|
#include "dpBaseChart.h"
|
2024-12-25 08:34:51 +08:00
|
|
|
|
|
|
|
|
|
|
class QCustomPlot;
|
2025-01-04 18:18:19 +08:00
|
|
|
|
class QCPRange;
|
2024-12-25 08:34:51 +08:00
|
|
|
|
|
2025-07-09 14:29:29 +08:00
|
|
|
|
class dpLineChart : public dpBaseChart
|
2024-12-25 08:34:51 +08:00
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
dpLineChart(QWidget *parent = nullptr);
|
|
|
|
|
|
~dpLineChart();
|
|
|
|
|
|
|
2025-07-09 14:29:29 +08:00
|
|
|
|
void setTimeRange(TimeUnit) override;
|
|
|
|
|
|
void setDateTime(const QDateTime&) override;
|
|
|
|
|
|
void viewHistoricalData(const QDateTime&) override;
|
2025-01-04 18:18:19 +08:00
|
|
|
|
|
2025-07-14 15:02:29 +08:00
|
|
|
|
void synchronizeConfigData(const configurationResults&) override;
|
|
|
|
|
|
|
2025-01-04 18:18:19 +08:00
|
|
|
|
public slots:
|
|
|
|
|
|
void onSignal_rangeChanged_xAxis(const QCPRange&);
|
2025-08-25 15:10:02 +08:00
|
|
|
|
void onSignal_dataUpdated(const QString& dataKey, const QVariant& data, const QDateTime& timestamp);
|
2024-12-25 08:34:51 +08:00
|
|
|
|
|
|
|
|
|
|
private:
|
2025-07-31 15:47:32 +08:00
|
|
|
|
//处理关联图形的策略
|
|
|
|
|
|
enum HandleGraphPolicy
|
|
|
|
|
|
{
|
|
|
|
|
|
Remove, //删除
|
|
|
|
|
|
ReassignToOthrer //重新分配到其它坐标轴
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-09-01 19:57:02 +08:00
|
|
|
|
struct Graph
|
|
|
|
|
|
{
|
|
|
|
|
|
QColor color;
|
|
|
|
|
|
RealTimeDataType dataType;
|
|
|
|
|
|
//QCPGraph* qGraph;
|
|
|
|
|
|
QPointer<QCPGraph> qGraph;
|
|
|
|
|
|
|
|
|
|
|
|
QString dataID;
|
|
|
|
|
|
QString synchronizeTagging; //同步配置数据时的标记,new、update两种,没有的就是要被删除
|
|
|
|
|
|
QString name; //用户legend图例展示用
|
|
|
|
|
|
|
|
|
|
|
|
Graph()
|
|
|
|
|
|
{
|
|
|
|
|
|
dataID = "";
|
|
|
|
|
|
//qGraph = nullptr;
|
|
|
|
|
|
synchronizeTagging = "noTagging";
|
|
|
|
|
|
name = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-12-25 08:34:51 +08:00
|
|
|
|
void initQCP();
|
2025-07-25 17:42:15 +08:00
|
|
|
|
void arrangeAxes();
|
2025-08-07 11:48:08 +08:00
|
|
|
|
void reLayoutLegend();
|
2025-07-31 15:47:32 +08:00
|
|
|
|
//void handleAssociatedGraphs();
|
2024-12-25 08:34:51 +08:00
|
|
|
|
|
|
|
|
|
|
QCustomPlot* m_pCustomPlot;
|
2025-07-09 10:58:52 +08:00
|
|
|
|
ChartStyle m_chartStyle;
|
2025-01-04 18:18:19 +08:00
|
|
|
|
qint64 m_timeRange;
|
|
|
|
|
|
QDateTime m_curDateTime;
|
2025-07-14 15:02:29 +08:00
|
|
|
|
QVector<Axis> m_axes;
|
2025-07-31 15:47:32 +08:00
|
|
|
|
QHash<QString, Graph> m_graphs;
|
2025-07-25 17:42:15 +08:00
|
|
|
|
AxisArrangementMode m_axisArrangementMode;
|
2025-08-07 11:48:08 +08:00
|
|
|
|
bool m_showLegend;
|
2025-07-31 15:47:32 +08:00
|
|
|
|
bool m_updateData;
|
2024-12-25 08:34:51 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|