|
|
#pragma once
|
|
|
|
|
|
#include <QPen>
|
|
|
#include <QColor>
|
|
|
#include <QVector>
|
|
|
#include <QPainter>
|
|
|
|
|
|
#include "ZxDot.h"
|
|
|
#include "Defines.h"
|
|
|
#include "ZxRenderItem.h"
|
|
|
#include "ZxDrawHelper.h"
|
|
|
|
|
|
#include "iPlotCurveT_global.h"
|
|
|
|
|
|
#define _isNearLine ZxDrawHelper::isPointNearLine
|
|
|
|
|
|
class ZxPlot;
|
|
|
class ZxSubAxisX;
|
|
|
class ZxSubAxisY;
|
|
|
class IxPtyItem;
|
|
|
class ZxObjToolBase;
|
|
|
|
|
|
// 绘图对象基类
|
|
|
class I_PLOTCURVE_T_EXPORT ZxObjBase : public ZxRenderItem
|
|
|
{
|
|
|
Q_OBJECT
|
|
|
ZX_DECLARE_DYNAMIC
|
|
|
|
|
|
public:
|
|
|
|
|
|
ZxObjBase();
|
|
|
ZxObjBase(const QString& sName, ZxSubAxisX* pAxisX, ZxSubAxisY* pAxisY);
|
|
|
~ZxObjBase(void);
|
|
|
virtual void init(const QString& sName, ZxSubAxisX* pAxisX, ZxSubAxisY* pAxisY);
|
|
|
|
|
|
public:
|
|
|
///////////////////////////////////
|
|
|
///SubObjs
|
|
|
|
|
|
// 自己创建、此处管理
|
|
|
virtual void initSubObjs();
|
|
|
|
|
|
// 外界传入,此处管理
|
|
|
virtual void appendSubObjs(ZxObjBase* p);
|
|
|
|
|
|
// 是否显示,统一控制
|
|
|
virtual bool isShowSubObjs();
|
|
|
virtual void showSubObjs(bool b);
|
|
|
|
|
|
// 删除或添加时的消息处理
|
|
|
void setAddOrDel(bool bAdd);
|
|
|
bool getAddOrDel();
|
|
|
|
|
|
// 取得鼠标移动时的tip信息
|
|
|
virtual QString getTipOf(const QPointF& point);
|
|
|
|
|
|
public:
|
|
|
|
|
|
virtual void initTools();
|
|
|
virtual void removeTools();
|
|
|
virtual void resetTools(ZxRenderView* pView);
|
|
|
|
|
|
protected:
|
|
|
|
|
|
// 这是根据当前点再次计算出来Bound
|
|
|
virtual QRectF getBoundsEx();
|
|
|
|
|
|
// 设置图元对象的属性标志
|
|
|
virtual void initFlags();
|
|
|
|
|
|
// 删除所有子节点
|
|
|
virtual void clear();
|
|
|
|
|
|
public:
|
|
|
|
|
|
///////////////////////////////////
|
|
|
///Brother
|
|
|
// 仅仅是关联一下,比如在移动至,二者同步移动
|
|
|
virtual void bindBrother(ZxObjBase* p);
|
|
|
virtual void detachBrother(ZxObjBase* p);
|
|
|
void resetBrotherOffset();
|
|
|
int getBrotherCount();
|
|
|
ZxObjBase* getBrotherOfIndex(int n);
|
|
|
|
|
|
public:
|
|
|
|
|
|
// 移动模式判断
|
|
|
virtual bool canMovePoint();
|
|
|
virtual bool canMoveBound();
|
|
|
virtual bool canMoveWhole();
|
|
|
|
|
|
public:
|
|
|
|
|
|
// 击中
|
|
|
virtual bool hitTest(const QPointF& pt);
|
|
|
|
|
|
// 具体击中实现的函数,单纯击中,不做选项的改变
|
|
|
// nOption用int是因为Rect类的击中选项不一致
|
|
|
// nOption为负值,表示未击中,此时返回false
|
|
|
virtual bool _runHitTest(const QPointF& pt, int& nOption, int& nSubIndex);
|
|
|
|
|
|
// 击中后,ButtonUp后的处理
|
|
|
// pt1:鼠标Down点,pt2:鼠标Up点
|
|
|
virtual bool runMove(const QPointF& pt1,
|
|
|
const QPointF& pt2);
|
|
|
|
|
|
// 新增接口,20210918 为了流量和压力对齐,只支持右移动
|
|
|
// dOffsetX > 0,且是Value而不是Pos
|
|
|
// 20210919 更改支持:左右移动,压力
|
|
|
virtual bool runMoveByV(const double dOffsetX);
|
|
|
|
|
|
// 整体移动时,对Brother的同步处理
|
|
|
virtual bool runMoveBrother(const float &fOffsetX,
|
|
|
const float &fOffsetY);
|
|
|
virtual bool moveToPos(const float& l, const float& r,
|
|
|
const float& t, const float& b);
|
|
|
virtual bool moveToPos(const QVector<QPointF>& vecPoss);
|
|
|
|
|
|
// 根据pt1--->pt2的偏移,获取pt的偏移后的点
|
|
|
// pt1:鼠标Down点,pt2:鼠标Up点
|
|
|
QPointF offsetPoint(QPointF& pt,
|
|
|
const QPointF& pt1, const QPointF& pt2);
|
|
|
|
|
|
// 当该对象未选中,反选其它,如文本框
|
|
|
virtual void deselectOthers();
|
|
|
|
|
|
public:
|
|
|
|
|
|
// paint
|
|
|
virtual void paintBack(QPainter* painter,
|
|
|
const ZxPaintParam& param);
|
|
|
virtual void paintSubObjs(QPainter* painter,
|
|
|
const ZxPaintParam& param);
|
|
|
virtual void paintDotPt(QPainter* painter,
|
|
|
QPointF pt,
|
|
|
ZxDot& dot,
|
|
|
bool bSelChanged = true);
|
|
|
|
|
|
// 序列化
|
|
|
virtual void onSerialize(ZxSerializer* ser);
|
|
|
virtual void onDeserialize(ZxSerializer* ser);
|
|
|
|
|
|
virtual void onLoadTempl(ZxSerializer* ser);
|
|
|
virtual void onSaveTempl(ZxSerializer* ser);
|
|
|
|
|
|
virtual void onDeserialized();
|
|
|
virtual void fillPtyPano(IxPtyPano* sheet);
|
|
|
|
|
|
//
|
|
|
virtual bool isItemBody(float x, float y);
|
|
|
virtual void onLeftDoubleClick(const QPointF& pt);
|
|
|
|
|
|
// 这是在整体移动Obj时,同步绘制其绑定的Obj
|
|
|
virtual void drawBrotherWhenMoving(QPainter* painter,
|
|
|
QPointF ptOld,
|
|
|
QPointF ptNew);
|
|
|
virtual void paintWithBrotherMode(QPainter* painter,
|
|
|
QPointF ptOld,
|
|
|
QPointF ptNew);
|
|
|
|
|
|
virtual void update();
|
|
|
|
|
|
virtual QRectF getBounds4Update();
|
|
|
virtual void updateRect(QRectF);
|
|
|
|
|
|
public:
|
|
|
|
|
|
// 得到/设置名称
|
|
|
QString getName(void) const;
|
|
|
void setName(QString sName);
|
|
|
|
|
|
// 点
|
|
|
QPointF getPtValueOf(int nIndex) const; //Value值
|
|
|
void setPtValueOf(int nIndex, QPointF ptValue);
|
|
|
|
|
|
QPointF getPtPosOf(int nIndex) const; //Pos值
|
|
|
void setPtPosOf(int nIndex, QPointF ptPos);
|
|
|
|
|
|
QPointF getPosOf(QPointF ptValue) const; //根据Value求Pos
|
|
|
QPointF getValueOf(QPointF ptPos) const; //根据Pos求Value
|
|
|
|
|
|
QVector<QPointF> getPosOf(QVector<QPointF> vecValues) const; //根据Value求Pos
|
|
|
QVector<QPointF> getValueOf(QVector<QPointF> vecPoss) const; //根据Pos求Value
|
|
|
|
|
|
// 设置所有的Value,外界调用
|
|
|
virtual void setAllValues(QVector<QPointF> vecValues);
|
|
|
virtual QVector<QPointF> getAllValues() const;
|
|
|
|
|
|
// 设置所有的Pos,外界调用
|
|
|
virtual void setAllPos(QVector<QPointF> vecPoss, QVector<int>* pVecIndexes = NULL);
|
|
|
virtual QVector<QPointF> getAllPos(bool bFuzzyMode = false,
|
|
|
float fZoom = 1.f,
|
|
|
int nMax = 20000,
|
|
|
QVector<QPointF>* pVecSelecteds = NULL,
|
|
|
QVector<int>* pVecIndexes = NULL) const;
|
|
|
virtual QVector<QPointF> fuzzyAllPos(QVector<QPointF> vec,
|
|
|
float fZoom = 1.f,
|
|
|
int nMax = 20000,
|
|
|
QVector<QPointF>* pVecSelecteds = NULL,
|
|
|
QVector<int>* pVecIndexes = NULL) const;
|
|
|
virtual int fuzzyPosTimes(float fZoom, int nPtCount) const;
|
|
|
virtual void resetBounds();
|
|
|
virtual QRectF calValueBounds(); //计算数值的Bound,对于对数坐标,去除小于0
|
|
|
virtual void resetOthers(); //resetBounds内部调用
|
|
|
|
|
|
// 坐标轴
|
|
|
ZxSubAxisX* getAxisX(void);
|
|
|
const ZxSubAxisX* getAxisX(void) const;
|
|
|
void setAxisX(ZxSubAxisX* pAxis);
|
|
|
ZxSubAxisY* getAxisY(void);
|
|
|
const ZxSubAxisY* getAxisY(void) const;
|
|
|
void setAxisY(ZxSubAxisY* pAxis);
|
|
|
void setAxisObjectNameX(QString s);
|
|
|
void setAxisObjectNameY(QString s);
|
|
|
QString getAxisObjectNameX();
|
|
|
QString getAxisObjectNameY();
|
|
|
|
|
|
// 类型
|
|
|
void setObjType(PlotObjectType o);
|
|
|
PlotObjectType getObjType();
|
|
|
|
|
|
// 类型
|
|
|
//void setObjTag(QString s);
|
|
|
QString getObjTag();
|
|
|
|
|
|
// 逐级获取Plot
|
|
|
ZxPlot* getPlot();
|
|
|
|
|
|
// ZxPlot的InnerRect
|
|
|
QRectF getOuterRect();
|
|
|
// ClipRect
|
|
|
QRectF getClipRect(QRectF rtViewClip);
|
|
|
|
|
|
// 设置View
|
|
|
void setView(ZxRenderView* pView);
|
|
|
ZxRenderView* getView();
|
|
|
|
|
|
// 该函数主要是触发信号: sigObjSelectionChanged
|
|
|
void dealSelChanged(bool bSelected);
|
|
|
|
|
|
// 返回数据点在水平和竖直最大最小值,是数值非POS
|
|
|
float getScaleVL();
|
|
|
float getScaleVR();
|
|
|
float getScaleVT();
|
|
|
float getScaleVB();
|
|
|
|
|
|
// 绘制的内容Set Get
|
|
|
virtual void setPen(QPen o);
|
|
|
virtual QPen getPen();
|
|
|
|
|
|
virtual void setDot(ZxDot o);
|
|
|
virtual ZxDot getDot();
|
|
|
|
|
|
virtual float getDotRadius(void) const;
|
|
|
virtual void setDotRadius(float fRadius);
|
|
|
virtual void setDotStyle(int oStyle);
|
|
|
virtual int getDotStyle();
|
|
|
virtual QColor getDotColor(void) const;
|
|
|
virtual void setDotColor(QColor color);
|
|
|
virtual void setDotFilling(bool b);
|
|
|
virtual bool getDotFilling();
|
|
|
|
|
|
virtual void setDotSel(ZxDot o); //选中状态下的点
|
|
|
virtual ZxDot getDotSel();
|
|
|
|
|
|
signals:
|
|
|
|
|
|
// 部分关联信号
|
|
|
void sigNameChanged(QString sName);
|
|
|
void sigColorChanged(QColor clr);
|
|
|
void sigObjSelectionChanged(bool bSelected);
|
|
|
|
|
|
// 通知数据点改变
|
|
|
void sigPtsChanged();
|
|
|
// 通知数据点改变,并告知改变前后的数据点
|
|
|
void sigPtValuesChanged(QVector<QPointF>& vecOlds,
|
|
|
QVector<QPointF>& vecNews);
|
|
|
|
|
|
// 当Obj被双击选中时触发
|
|
|
void sigObjDblCliked(const QPointF& pt);
|
|
|
|
|
|
// 在外界修改tip
|
|
|
void sigGetObjTip(QString& s);
|
|
|
|
|
|
public:
|
|
|
|
|
|
// 击中
|
|
|
ObjHitOption m_oHitOption;
|
|
|
int m_nHitIndex; //对于点和边界有效
|
|
|
|
|
|
protected:
|
|
|
|
|
|
// 从外界传入,本身不负责创建及释放
|
|
|
ZxSubAxisX* m_pAxisX;
|
|
|
ZxSubAxisY* m_pAxisY;
|
|
|
|
|
|
// Tool
|
|
|
ZxObjToolBase* m_pTool;
|
|
|
// View
|
|
|
ZxRenderView* m_pView;
|
|
|
|
|
|
protected:
|
|
|
|
|
|
// 名称
|
|
|
QString m_sName;
|
|
|
|
|
|
PlotObjectType m_oObjType;
|
|
|
QString m_sObjTag;
|
|
|
|
|
|
// 组成的点,实际的数值
|
|
|
QVector<QPointF> m_vecPoints;
|
|
|
|
|
|
// 内部创建(或外部传入)、本对象进行管理的子对象,如文本显示
|
|
|
bool m_bShowSubObjs;
|
|
|
|
|
|
QRectF m_rtBoundVs;//所有点的数值的范围
|
|
|
|
|
|
// brother
|
|
|
QVector<ZxObjBase*> m_vecBrothers;
|
|
|
float m_fOffsetX; //整体移动时,Brother的偏移量,为了redo/undo
|
|
|
float m_fOffsetY;
|
|
|
|
|
|
// 为了方便放在父类
|
|
|
ZxDot m_oDot;
|
|
|
ZxDot m_oDotSel; //选中点的样式
|
|
|
QPen m_oPen;
|
|
|
|
|
|
QString m_sAxisObjectNameX; //为了序列化
|
|
|
QString m_sAxisObjectNameY;
|
|
|
|
|
|
bool m_bAddMode; //Add Or Del模式,临时变量
|
|
|
|
|
|
// 在MoveToPos函数中涉及到哪些点进行了修改,不涉及序列化
|
|
|
VecInt m_vecIndexesModified;
|
|
|
};
|