You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Include/mGui/mGuiPlot/iGuiPlot.h

173 lines
4.6 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "iPlotCurveWxT.h"
#include "ZxDot.h"
#include "mGuiPlot_global.h"
class ZxDataGaugeBase;
class ZxDataGaugeF;
class ZxObjCurveFlow;
class iGuiPlotCmdHelper;
class iGuiPlotTableHelper;
class ZxObjBase;
class iCurveDesc;
// 绘图窗体的再一次封装
class M_GUI_PLOT_EXPORT iGuiPlot : public iPlotCurveWxT
{
Q_OBJECT
public:
explicit iGuiPlot(bool bUseBtn = true, QWidget *parent = 0);
~iGuiPlot();
// 初始化UI
virtual void initUI(QString sTitle, QSize szDefault = QSize(265, 203));
// 设置图上数据、线的类型(点或者线)
// 这是一次性设置数据需要外界显示调用runUpdate刷新
void setCurveData(QVector<iCurveDesc> vecCurveDesc);
QVector<iCurveDesc> getCurveData();
void checkForDateMode();
// 这是在现有图形上追加数据,会自动刷新
void appendCurveData(QVector<iCurveDesc> vecCurveDesc, bool bFreshAxis = true);
//清楚后面数据的数据
void removeCurveData(QString sCurveName);
// 这是仅仅更改某条曲线的数据
bool changedCurveData(QString sTag, QVector<QPointF> vec);
int indexOfCurveDescOf(QString sTag);
// 序列化
virtual void onSerialize(ZxSerializer* ser);
virtual void onDeserialize(ZxSerializer* ser);
// 反序列化后把数据重新加入m_mapCurveData与m_mapCurveType
virtual void resetAfterDeserialized();
// 刷新图形
virtual void runUpdate();
// 图形按钮类别
void setChartCmdType(QString s);
// 设置是否显示toolbar
void setUseBtns(bool b);
void setToolBarPos(int n);
ZxObjCurve* getCurve(QString s);
// Pen and Dot
void setPenAndDotEx(ZxObjCurve* pCurve, iCurveDesc &o);
// 这是触发其它按钮
bool sendActionToParent(QString sAction);
// 设置Plot里面对象只读
bool setReadOnly(bool bReadonly, bool bCurveTypeOnly = true);
// 是否允许拖拽
void setDropEnabled(bool b);
// 状态
virtual void setModified(bool b);
virtual bool isModified();
//自动调整坐标轴大小(两边扩展点)
void setAutoExpandAxisScaleX(VecFloat vecX);
void setAutoExpandAxisScaleY(VecFloat vecY);
virtual bool runAction(QString sAction);
// 根据曲线描述获取第一个流量数据体
QString getDataIdBy(QString sName);
void keyPressEvent(QKeyEvent* e);
protected:
// 初始化Sheet
void initSheets();
// 初始化布局
virtual void initMainLayout();
virtual QWidget* initChartLayout(QString sTitle, QSize szDefault);
// 刷新
virtual void updatePlots();
// 创建添加曲线
virtual bool createAndAppendCurves(ZxPlot* pPlot,
QVector<iCurveDesc>& vecData);
// 绘制Painter函数重载
virtual void paintEvent(QPaintEvent *);
// // 拖拽支持
// void dragEnterEvent(QDragEnterEvent *event);
// void dropEvent(QDropEvent* event);
virtual bool dealwithDropCurve(ZxDataGaugeBase* pObj);
public slots:
// 这是从 tPlotCurveView传递过来的拖拽处理
void slotCheckDragAccepted(QDragEnterEvent* event, bool&b);
void slotDealwithDrop(QDropEvent* event);
// 选择曲线弹出对话框显示数据
virtual void slotShowCurveData(ZxObjCurveBase* p);
void slotSubTableSelChanged();
// 从zxPlot传递
virtual void slotPlotModified(int b);
// 刷新状态栏
void slotFresh2Status(QString&);
void slotObjCompleted(ZxObjBase*);
signals:
// 当GuiPlot的toolbar建立后触发调用方可以做调整
// 如增加一些按钮或控件
void sigToolbarBuilt(QToolBar*);
// 这是触发其它按钮
void sigParentActioned(QString sAction, bool& b);
// 触发是否允许拖拽
void sigCheckCurveDropEnabled(ZxDataGaugeBase* pObj, bool& bEnabled);
// 触发拖拽的曲线处理
void sigCurvedDropped(ZxDataGaugeBase* pObj, bool& b);
//
void sigGuiPlotModified(bool);
// 获取额外的tips比如 探测半径
void sigGetTipsExOfPos(QString& sTip, float fX, float fY);
protected:
// 曲线对应的描述信息map
QVector<iCurveDesc> m_vecCurveDesc;
// 图形Helper各类Cmd的封装
iGuiPlotCmdHelper* m_pCmdHelper;
// 图形按钮类别
QString m_sChartCmdType;
// 是否需要工具ToolBar
bool m_bUseBtns;
// 这是在图上右键显示曲线数据用的表格窗体
iGuiPlotTableHelper* m_pTableTemp;
// bool 是否允许拖拽 序列化如何处理???
bool m_bDropEnabled;
// 临时变量
bool m_bModified;
// 工具栏的位置 0-3 l t r b
int m_oToolBarPos; //默认2
};