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.

77 lines
3.4 KiB
C++

#pragma once
#include "GlobalDefine.h"
#include "SmartPtr.h"
#include "ObjBase.h"
#include "ObjContainer.h"
#include "ObjPline.h"
#if 1//命令
#define CMD_TOOL_CIRCLE_DIA_EDGE "_circle 指定圆的[直径] [边数]"
#define CMD_TOOL_CIRCLE_CENTER "_circle 指定圆的[圆心] "
#define CMD_LINE_FIRST_PT "_line 指定第一点"
#define CMD_LINE_NEXT_PT "_line 指定线段的[长度] [角度]"
#define CMD_RECT_FIRST_PT "_rectang 指定第一点"
#define CMD_RECT_SIZE "_rectang 指定矩形的[宽度][高度]"
#define CMD_TOOL_ROTATO_ANGLE "_rotato 指定旋转的[角度]"
#define CMD_TOOL_ROTATO_CENTER "_rotato指定旋转中心"
#define CMD_TOOL_MOVE_FIRST_PT "_move 指定基点"
#define CMD_TOOL_MOVE_DIS "_move指定移动距离[x 方向][y 方向]"
#define CMD_TOOL_MEASURE_FIRST_PT "_measure 指定第一点"
#define CMD_TOOL_MEASURE_SECOND_PT "_measure 指定第二点"
#define CMD_TOOL_MEASURE_RESULT "_measure [距离]"
#define CMD_TOOL_MEASURE_RESULT2 "_measure [x 偏移量] [y 偏移量]"
#define CMD_TOOL_MEASURE_RESULT3 "_measure [角度]"
#define CMD_TOOL_MEASURE_RESULT4 "_measure [原点角度]"
#define CMD_TOOL_COPY_BASE_PT "_copy 指定基点"
#define REDRAW_CNT 5
#endif
class CMouseTool
{
public:
CMouseTool(void);
virtual ~CMouseTool(void);
virtual void OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc);
virtual void OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc);
virtual void OnRButtonDown(UINT nFlags, CPoint point,CClientDC &dc);
virtual void OnRButtonUp(UINT nFlags, CPoint point,CClientDC &dc){};
virtual void OnMouseMove(UINT nFlags, CPoint point,CClientDC &dc){};
virtual void OnEscapeKey();
virtual void OperateOver();
virtual bool OnSetCmd(CString str){return false;};
virtual bool NeedToPointTool(){return false;};//工具结束时是否需要转换为指针工具
public:
void SetOperatePar(SObjOperatePar par){m_Par = par;};
bool IsEndStatus();
bool IsStartStatus();
STATUS GetStatus(){return m_Status;};
Dbxy GetDownPoint(){return m_DownPoint;};
protected:
virtual void OperateObj(Dbxy StartPt,Dbxy EndPt){};
void SaveDownPoint(CPoint point);
void SaveDownPoint(Dbxy point);
void SavePreMovePt(CPoint point){m_PreMovePt = point;};
bool HasPreMovePt();
void ClearFirstPoint();
void AddCreatCommand();
void ToNextStatus();
void AddObject(CObjBase *pMarkObject);
void CreatOpSimulateObj();
void XorRedrawOpSimulateObj(CDC* pDC);
void OpSimulateObj(SObjOperatePar &par);
protected:
CObjContainer m_TmpObjContainer;//临时obj 对象管理
STATUS m_Status;//用于确定每一步做什么事情
Dbxy m_DownPoint;//鼠标按下的点
CPoint m_PreMovePt;//上一个移动位置
bool m_bFirstMove;//用于标记第一次移动
CObjPline m_OpSimulateObjBak;//用于模拟操作的对象原始数据
CObjPline m_OpSimulateObj;//用于模拟操作的对象
SObjOperatePar m_Par;//操作参数
};