PowerMaster/dataPanel/dpLineChart.h

78 lines
2.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef DPLINECHART_H
#define DPLINECHART_H
/*******************************************************************************
** DataPanel-LineChart
** author dsc
**
** 折线图展示面板用来展示带有时序数据可以和TimeLine等组件进行时间属性的交互
** 采用QCustomPlot实现
**
******************************************************************************/
#include "dpBaseChart.h"
class dpLineChart : public dpBaseChart
{
Q_OBJECT
public:
dpLineChart(QWidget *parent = nullptr);
~dpLineChart();
void setTimeRange(TimeUnit) override;
void setDateTime(const QDateTime&) override;
void viewHistoricalData(const QDateTime&) override;
void synchronizeConfigData(const configurationResults&) override;
public slots:
void onSignal_rangeChanged_xAxis(const QCPRange&);
void onSignal_dataUpdated(const QString& dataKey, const QVariant& data, const QDateTime& timestamp);
private:
//处理关联图形的策略
enum HandleGraphPolicy
{
Remove, //删除
ReassignToOthrer //重新分配到其它坐标轴
};
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 = "";
}
};
void initQCP();
void arrangeAxes();
void reLayoutLegend();
//void handleAssociatedGraphs();
QCustomPlot* m_pCustomPlot;
ChartStyle m_chartStyle;
qint64 m_timeRange;
QDateTime m_curDateTime;
QVector<Axis> m_axes;
QHash<QString, Graph> m_graphs;
AxisArrangementMode m_axisArrangementMode;
bool m_showLegend;
bool m_updateData;
};
#endif