#ifndef DPLINECHART_H #define DPLINECHART_H /******************************************************************************* ** DataPanel-LineChart ** author dsc ** ** 折线图展示面板,用来展示带有时序数据,可以和TimeLine等组件进行时间属性的交互 ** 采用QCustomPlot实现 ** ******************************************************************************/ #include "dpBaseChart.h" class QCustomPlot; class QCPRange; 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 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 m_axes; QHash m_graphs; AxisArrangementMode m_axisArrangementMode; bool m_showLegend; bool m_updateData; }; #endif