#pragma once #include #include #include "iPlotCurveT_global.h" class QPointF; class ZxRenderItem; class ZxPlotBase; /// 通用Tool,消息分发 class I_PLOTCURVE_T_EXPORT ZxCmdTool : public ZxSimpleTool { Q_OBJECT public: ZxCmdTool(); ZxCmdTool(const ZxCmdTool& c); void setPlotRect(QRectF rc); void setChartObj(ZxPlotBase* pObj); protected: virtual void onPaint(QPainter* painter, const ZxPaintParam& param); virtual bool onLeftDown(const QPointF& pt); virtual bool onLeftUp(const QPointF& pt); virtual bool onMouseMove(const QPointF& pt); virtual bool onMouseWheel(const QPointF& pt, int delta); virtual bool onLeftDoubleClick(const QPointF& pt); virtual void onKeyPress(QKeyEvent *event); void changeCursor(int nOpType); signals: // 鼠标交互式选择点后,触发信号,允许外界创建Object void sigTakeMousePts(QVector& vecPts, \ int n, bool& b); private: void verifyPos(QPointF& pt); // 鼠标移动时的辅助信息显示 virtual bool _runShowWithMoving(const QPointF& pt); // 鼠标Up时的相应操作 virtual bool _runCmdAddObj(const QPointF& pt); virtual bool _runCmdZoom(const QPointF& pt); virtual bool _runCmdMove(const QPointF& pt); virtual bool _runCmdSelect(const QPointF& pt); virtual bool _runCmdHitPoint(const QPointF& pt); protected: bool m_bTracking; // 图的有效矩形 QPointF m_ptStart; QPointF m_ptMove; QRectF m_rtPlot; QRectF m_rtTracker; ZxPlotBase* m_pPlot; QVector m_vecPosPoints; bool m_bLeftDown; };