PowerMaster/dataPanel/dpLineChart.h

81 lines
2.0 KiB
C
Raw Normal View History

2024-12-25 08:34:51 +08:00
#ifndef DPLINECHART_H
#define DPLINECHART_H
/*******************************************************************************
** DataPanel-LineChart
** author dsc
**
** 线TimeLine等组件进行时间属性的交互
** QCustomPlot实现
**
******************************************************************************/
#include "dpBaseChart.h"
2024-12-25 08:34:51 +08:00
class QCustomPlot;
class QCPRange;
2024-12-25 08:34:51 +08:00
class dpLineChart : public dpBaseChart
2024-12-25 08:34:51 +08:00
{
Q_OBJECT
public:
dpLineChart(QWidget *parent = nullptr);
~dpLineChart();
void setTimeRange(TimeUnit) override;
void setDateTime(const QDateTime&) override;
void viewHistoricalData(const QDateTime&) override;
2025-07-14 15:02:29 +08:00
void synchronizeConfigData(const configurationResults&) override;
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:
//处理关联图形的策略
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();
void arrangeAxes();
void reLayoutLegend();
//void handleAssociatedGraphs();
2024-12-25 08:34:51 +08:00
QCustomPlot* m_pCustomPlot;
ChartStyle m_chartStyle;
qint64 m_timeRange;
QDateTime m_curDateTime;
2025-07-14 15:02:29 +08:00
QVector<Axis> m_axes;
QHash<QString, Graph> m_graphs;
AxisArrangementMode m_axisArrangementMode;
bool m_showLegend;
bool m_updateData;
2024-12-25 08:34:51 +08:00
};
#endif