|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
|
|
|
|
|
|
#include "Defines.h"
|
|
|
|
|
#include "ZxRenderItem.h"
|
|
|
|
|
#include "ZxDrawHelper.h"
|
|
|
|
|
#include "iPlotCurveT_global.h"
|
|
|
|
|
|
|
|
|
|
class ZxSubAxisX;
|
|
|
|
|
class ZxSubAxisY;
|
|
|
|
|
class ZxSubAxisBase;
|
|
|
|
|
class ZxSubTitle;
|
|
|
|
|
class ZxSubNaviBar;
|
|
|
|
|
class ZxObjCurveBase;
|
|
|
|
|
class ZxSubLegend;
|
|
|
|
|
class IxPtyItem;
|
|
|
|
|
class ZxCmdTool;
|
|
|
|
|
class ZxObjBase;
|
|
|
|
|
class ZxSimpleTool;
|
|
|
|
|
|
|
|
|
|
// 绘图载体
|
|
|
|
|
class I_PLOTCURVE_T_EXPORT ZxPlotBase : public ZxRenderItem
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
ZX_DECLARE_DYNAMIC
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
ZxPlotBase();
|
|
|
|
|
ZxPlotBase(ZxRenderView* pView);
|
|
|
|
|
~ZxPlotBase();
|
|
|
|
|
|
|
|
|
|
// 初始化及Tool管理
|
|
|
|
|
virtual void init(ZxRenderView* pView);
|
|
|
|
|
virtual void initTools();
|
|
|
|
|
void removeTools(ZxSimpleTool *pSubTool = NULL);
|
|
|
|
|
void appendTools(ZxSimpleTool *pSubTool = NULL);
|
|
|
|
|
void resetTools(ZxRenderView* pView);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// 响应从ZxCmdTool过来的鼠标处理
|
|
|
|
|
virtual bool runCmdSelect(PlotOperationMode o, \
|
|
|
|
|
const QPointF& ptStart, \
|
|
|
|
|
const QPointF& ptEnd);
|
|
|
|
|
virtual bool runCmdHitPoint(PlotOperationMode o, \
|
|
|
|
|
const QPointF& pt);
|
|
|
|
|
|
|
|
|
|
// 整体移动,20190222
|
|
|
|
|
virtual bool runWholeMove(const QPointF& ptStart,
|
|
|
|
|
const QPointF& ptEnd);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
virtual void release();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
static const int AXISHEIGHT = 12;
|
|
|
|
|
static const int AXISWIDTH = 12;
|
|
|
|
|
static const int TITLEHEIGHT = 13;
|
|
|
|
|
static const int NAVIBARHEIGHT = 5;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void paintBack(QPainter* painter,
|
|
|
|
|
const ZxPaintParam& param);
|
|
|
|
|
virtual void paintBackground(QPainter* painter);
|
|
|
|
|
virtual void paintGrid(QPainter* painter);
|
|
|
|
|
|
|
|
|
|
// 属性填充
|
|
|
|
|
virtual void fillPtyPano(IxPtyPano* sheet);
|
|
|
|
|
|
|
|
|
|
// 序列化
|
|
|
|
|
virtual void onSerialize(ZxSerializer* ser);
|
|
|
|
|
virtual void onDeserialize(ZxSerializer* ser);
|
|
|
|
|
virtual void onDeserialized();
|
|
|
|
|
|
|
|
|
|
// 序列化之后重新进行一下成员变量的遍历(遍历以及绑定)
|
|
|
|
|
virtual void reparseMembers();
|
|
|
|
|
virtual void rebindObjs();
|
|
|
|
|
virtual void rebindObjOf(ZxObjBase*& p);
|
|
|
|
|
virtual void rebindLegend();
|
|
|
|
|
|
|
|
|
|
// 模版序列化
|
|
|
|
|
virtual void onLoadTempl(ZxSerializer* ser);
|
|
|
|
|
virtual void onSaveTempl(ZxSerializer* ser);
|
|
|
|
|
|
|
|
|
|
// 布局
|
|
|
|
|
// 刷新激活(重新布局的开关)
|
|
|
|
|
void setNeedLayout(bool b);
|
|
|
|
|
bool isNeedLayout();
|
|
|
|
|
virtual void onLayout();
|
|
|
|
|
|
|
|
|
|
// 是否发生更改的状态标识
|
|
|
|
|
virtual void setModified(bool b);
|
|
|
|
|
virtual bool isModified();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// 鼠标
|
|
|
|
|
virtual bool onLeftDown(const QPointF& pt);
|
|
|
|
|
virtual bool onLeftUp(const QPointF& pt);
|
|
|
|
|
virtual bool onMouseMove(const QPointF& pt);
|
|
|
|
|
virtual void onLeftDoubleClick(const QPointF& pt);
|
|
|
|
|
|
|
|
|
|
// Tips
|
|
|
|
|
virtual void onShowTips(const QPointF &point);
|
|
|
|
|
|
|
|
|
|
// 删除(这是响应键盘Delete键)
|
|
|
|
|
virtual void onDeleteItem();
|
|
|
|
|
virtual void deleteCurvePtsWithin(QRectF rt);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// 操作类型
|
|
|
|
|
int getOpType(void) const;
|
|
|
|
|
void setOpType(int nOpType);
|
|
|
|
|
|
|
|
|
|
// 图元对象相关
|
|
|
|
|
int getObjCount(void);
|
|
|
|
|
ZxObjBase* getObjByIndex(int nIndex);
|
|
|
|
|
ZxObjBase* getObjByName(QString sName);
|
|
|
|
|
virtual void removeObjByIndex(int nIndex);
|
|
|
|
|
virtual void removeObjByName(QString sName);
|
|
|
|
|
virtual void removeAllObjects(bool bTestMode = false);
|
|
|
|
|
|
|
|
|
|
// 内部绘图区域,不包括标题区,坐标轴
|
|
|
|
|
virtual QRectF getInnerRectF();
|
|
|
|
|
|
|
|
|
|
// 恢复撤销
|
|
|
|
|
virtual void runCmdUndo();
|
|
|
|
|
virtual void runCmdRedo();
|
|
|
|
|
virtual bool canRedo();
|
|
|
|
|
virtual bool canUndo();
|
|
|
|
|
virtual void clearUndoStack();
|
|
|
|
|
|
|
|
|
|
// 动态创建添加坐标轴(该函数暂未启用,在应用时,应该已经设定了pAxis的位置)
|
|
|
|
|
virtual void appendAxis(ZxSubAxisBase* pAxis);
|
|
|
|
|
|
|
|
|
|
// 对坐标轴进行配置及绑定(主要是一些信号关联)
|
|
|
|
|
virtual void configAxis(ZxSubAxisBase* pAxis);
|
|
|
|
|
|
|
|
|
|
// 关联各个子项
|
|
|
|
|
virtual void bindSubMembers(ZxRenderView* pView);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// 坐标轴、标题、图例
|
|
|
|
|
ZxSubTitle* getTitle();
|
|
|
|
|
virtual void setTitle(ZxSubTitle* pTitle);
|
|
|
|
|
ZxSubLegend* getLegend();
|
|
|
|
|
|
|
|
|
|
// 获取当前起作用的主坐标轴,比如画网格线时需要的
|
|
|
|
|
virtual ZxSubAxisX* getMainAxisX();
|
|
|
|
|
virtual ZxSubAxisY* getMainAxisY();
|
|
|
|
|
void setMainAxisX(ZxSubAxisX* pAxis);
|
|
|
|
|
void setMainAxisY(ZxSubAxisY* pAxis);
|
|
|
|
|
|
|
|
|
|
// 坐标轴
|
|
|
|
|
ZxSubAxisX* getSysAxisX(AxisPos o);
|
|
|
|
|
ZxSubAxisY* getSysAxisY(AxisPos o);
|
|
|
|
|
ZxSubAxisBase* getSysAxisOf(AxisPos o);
|
|
|
|
|
|
|
|
|
|
// 坐标轴显示隐藏
|
|
|
|
|
void setAxisVisibleByObjName(QString sAxisObjectName, bool bVisible);
|
|
|
|
|
void setAxisVisibleByPos(AxisPos o, bool bVisible);
|
|
|
|
|
void setAxisVisibleByPtr(ZxSubAxisBase* pAxis, bool bVisible);
|
|
|
|
|
|
|
|
|
|
// 坐标轴最小化
|
|
|
|
|
void setMinimizeAxisX(bool b);
|
|
|
|
|
void setMinimizeAxisY(bool b);
|
|
|
|
|
|
|
|
|
|
// 导航,暂时没用到
|
|
|
|
|
ZxSubNaviBar* getNaviBar();
|
|
|
|
|
void setNaviBar(ZxSubNaviBar* p);
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
|
// 通用成员变量的处理
|
|
|
|
|
|
|
|
|
|
// 背景渐变色
|
|
|
|
|
QColor getBKColor(void);
|
|
|
|
|
virtual void setBKColor(QColor color);
|
|
|
|
|
QColor getBKColorEx(void);
|
|
|
|
|
virtual void setBKColorEx(QColor color);
|
|
|
|
|
|
|
|
|
|
// 外边框颜色
|
|
|
|
|
QColor getFrameColor(void);
|
|
|
|
|
virtual void setFrameColor(QColor color);
|
|
|
|
|
|
|
|
|
|
// Margin
|
|
|
|
|
float getMargin();
|
|
|
|
|
virtual void setMargin(float fMargin);
|
|
|
|
|
|
|
|
|
|
// 是否显示图标题
|
|
|
|
|
virtual void setTitleVisible(bool bVisible);
|
|
|
|
|
bool isTitleVisible();
|
|
|
|
|
|
|
|
|
|
// 是否显示导航(暂未启用)
|
|
|
|
|
virtual void setNaviBarVisible(bool bVisible);
|
|
|
|
|
bool isNaviBarVisible();
|
|
|
|
|
|
|
|
|
|
// 是否显示图例
|
|
|
|
|
virtual void setLegendVisible(bool bVisible);
|
|
|
|
|
bool isLegendVisible();
|
|
|
|
|
virtual void setLegendGroups(QStringList list);
|
|
|
|
|
|
|
|
|
|
// 是否显示tip
|
|
|
|
|
bool isBkTipVisible(void) const;
|
|
|
|
|
virtual void setBkTipVisible(bool bVisible);
|
|
|
|
|
|
|
|
|
|
// 是否显示边框
|
|
|
|
|
bool isFrameVisible(void) const;
|
|
|
|
|
virtual void setFrameVisible(bool bVisible);
|
|
|
|
|
|
|
|
|
|
// 标题位置,0顶部和1底部
|
|
|
|
|
int getTitlePos(void) const;
|
|
|
|
|
virtual void setTitlePos(int nShowPos);
|
|
|
|
|
|
|
|
|
|
// 是否显示网格线
|
|
|
|
|
bool isScaleBigXVisible();
|
|
|
|
|
virtual void setScaleBigXVisible(bool b);
|
|
|
|
|
bool isScaleBigYVisible();
|
|
|
|
|
virtual void setScaleBigYVisible(bool b);
|
|
|
|
|
bool isScaleSmallXVisible();
|
|
|
|
|
virtual void setScaleSmallXVisible(bool b);
|
|
|
|
|
bool isScaleSmallYVisible();
|
|
|
|
|
virtual void setScaleSmallYVisible(bool b);
|
|
|
|
|
bool _isScaleXYVisible(bool bX, bool bBigScale);
|
|
|
|
|
void _setScaleXYVisible(bool bX, bool bBigScale, bool b);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// x/y轴每一个的Span,这是统一设定(每个坐标轴还可以单独设定)
|
|
|
|
|
// 请在plot的init时候调用该函数
|
|
|
|
|
float getPerAxisSpanX();
|
|
|
|
|
void setPerAxisSpanX(float f);
|
|
|
|
|
float getPerAxisSpanY();
|
|
|
|
|
void setPerAxisSpanY(float f);
|
|
|
|
|
|
|
|
|
|
// 设置四个方向各自总的Span(然后每个坐标轴按比例拆分)
|
|
|
|
|
void setSumAxisSpan(AxisPos o, float f);
|
|
|
|
|
float getSumAxisSpan(AxisPos o);
|
|
|
|
|
|
|
|
|
|
// 主要为了触发对象创建完成
|
|
|
|
|
virtual void objCompleted(ZxObjBase* p);
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
|
|
virtual void slotAxisScaleCountChanged(int);
|
|
|
|
|
|
|
|
|
|
// 获取(发送者)坐标轴上对应数据中的最小的正值
|
|
|
|
|
virtual void slotGetLeastPositive(float& f);
|
|
|
|
|
|
|
|
|
|
// 响应信号 鼠标交互式选择点后,允许Plot自行创建Object
|
|
|
|
|
virtual void slotTakeMousePts(QVector<QPointF>& vecPts, \
|
|
|
|
|
int nMode, bool& b);
|
|
|
|
|
|
|
|
|
|
// 由于刻度显示与Plot相互关联,所以此处进行额外处理
|
|
|
|
|
virtual void slotScaleVisibleChanged(bool bBigScale, bool bVisible);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// 背景图像
|
|
|
|
|
void setBkImgFile(QString s);
|
|
|
|
|
|
|
|
|
|
// 旋转(倾斜度校正)
|
|
|
|
|
// 顺时针旋转的角度,不需弧度转换, fAngle:0-360
|
|
|
|
|
bool rotateImg(float fAngle);
|
|
|
|
|
QSize getBkImgSize();
|
|
|
|
|
QImage* getBkImg();
|
|
|
|
|
static bool loadImg(QImage& oImg, QString sFile);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
|
|
void sigOpTypeChanged(int nOpType);//鼠标操作模式发生改变
|
|
|
|
|
|
|
|
|
|
void sigObjAdding(ZxObjBase*); //新对象添加前触发
|
|
|
|
|
void sigObjAdded(ZxObjBase*); //新对象添加后触发,此时对象没有数据
|
|
|
|
|
void sigObjCompleted(ZxObjBase*);//新对象添加后触发,已经可以正常使用
|
|
|
|
|
void sigObjDeleting(ZxObjBase*); //对象删除前触发
|
|
|
|
|
void sigObjDeleted(ZxObjBase*); //对象删除后触发
|
|
|
|
|
|
|
|
|
|
// void sigPlotModified(bool); //该信号废弃
|
|
|
|
|
|
|
|
|
|
/// @brief 工具框选时推送信号,告知主窗体进行相关处理
|
|
|
|
|
/// @param rtBoundV这是框选的窗体(是实际数值坐标,非屏幕坐标)
|
|
|
|
|
/// @param oPom当前的操作模态
|
|
|
|
|
void sigOpRectChanged(const QRectF& rtBoundV, \
|
|
|
|
|
PlotOperationMode oPom);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
// 图元
|
|
|
|
|
ZxSubTitle* m_pTitle;
|
|
|
|
|
ZxSubNaviBar* m_pNaviBar;
|
|
|
|
|
ZxSubLegend* m_pLegend;
|
|
|
|
|
|
|
|
|
|
// 本身有次序和主次,靠前者为主
|
|
|
|
|
// 另外,就是先左后右、先下后上
|
|
|
|
|
QVector<ZxSubAxisBase*> m_vecAxises;
|
|
|
|
|
|
|
|
|
|
// x/y轴每一个的Span,这是统一设定(每个坐标轴还可以单独设定)
|
|
|
|
|
// 请在plot的init时候进行设置
|
|
|
|
|
float m_fPerAxisSpanX;
|
|
|
|
|
float m_fPerAxisSpanY;
|
|
|
|
|
|
|
|
|
|
// 设置四个方向各自总的Span(然后每个坐标轴按比例拆分)
|
|
|
|
|
//0:Left,1:top,2right,3 bottom与AxisPos定义相同
|
|
|
|
|
VecFloat m_vecSumSpans;
|
|
|
|
|
|
|
|
|
|
// 内在图元
|
|
|
|
|
QVector<ZxObjBase*> m_vecAllObjs;
|
|
|
|
|
|
|
|
|
|
// Tool
|
|
|
|
|
ZxCmdTool* m_pCmdTool;
|
|
|
|
|
|
|
|
|
|
// View
|
|
|
|
|
ZxRenderView* m_pView;
|
|
|
|
|
|
|
|
|
|
// 操作类型
|
|
|
|
|
int m_nOpType;
|
|
|
|
|
|
|
|
|
|
// 范围、位置
|
|
|
|
|
QRectF m_rcInner;
|
|
|
|
|
float m_fMargin;
|
|
|
|
|
int m_nTitlePos; //标题位置
|
|
|
|
|
|
|
|
|
|
// 颜色
|
|
|
|
|
QColor m_clrBKColor;
|
|
|
|
|
QColor m_clrBKColorEx;
|
|
|
|
|
QColor m_clrFrameColor;
|
|
|
|
|
|
|
|
|
|
// 显示
|
|
|
|
|
// 对绘图区的网格线与坐标轴的网格线分开控制
|
|
|
|
|
bool m_bScaleBigXVisible;
|
|
|
|
|
bool m_bScaleBigYVisible;
|
|
|
|
|
bool m_bScaleSmallXVisible;
|
|
|
|
|
bool m_bScaleSmallYVisible;
|
|
|
|
|
|
|
|
|
|
// 显示辅助
|
|
|
|
|
bool m_bBkTipVisible;
|
|
|
|
|
bool m_bFrameVisible;
|
|
|
|
|
|
|
|
|
|
// 临时变量
|
|
|
|
|
bool m_bModified;
|
|
|
|
|
bool m_bNeedLayout;
|
|
|
|
|
|
|
|
|
|
QString m_sBkImgFile;
|
|
|
|
|
QImage m_oBkImg;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|