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.

98 lines
2.7 KiB
C++

#include "StdAfx.h"
#include "MouseToolPointer.h"
#include "LogMgr.h"
#include "GlobalDrawMgr.h"
#include "DrawSimpleShape.h"
#include "GlobalFunction.h"
#include "MarkAreaMgr.h"
#define PT_SEL_SCALE 0.1 //点选rect 的比例
CMouseToolPointer::CMouseToolPointer(void)
{
}
CMouseToolPointer::~CMouseToolPointer(void)
{
}
void CMouseToolPointer::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
CLayer &layer = gLayer;
if(m_Status==_STATUS_1)
{
SaveDownPoint(point);//记录第一个点
ToNextStatus();
}
else
{
DbRect rect;
Dbxy pt2 = gDraw->CPoint2Dbxy(point);
if(gDraw->IsbRectSel())//只有框选的时候才绘制
{
DrawRect(&dc,gDraw->GetMouseRectPen(),m_DownPoint,pt2);
}
//创建鼠标选择矩形区域
rect.Creat(m_DownPoint,pt2);
if(rect.IsZero())//点选
{
if(gDraw->IsbPointSel())
{
rect = gDraw->GetCurPointRect(pt2,PT_SEL_SCALE);
layer.SelObjectInRect(rect,false);
}
}
else
{
if(gDraw->IsbRectSel())//允许框选
{
//正向拉需要全部包住才算
if(m_DownPoint.x<pt2.x)
{
layer.SelObjectInRect(rect,true);
}
else//反向拉挂到边也算
{
layer.SelObjectInRect(rect,false);
}
gMarkAreaMgr->SelAreaByPt(rect.GetCenterPt());
}
}
GetCurViewPtr()->RefreshView();
m_Status = _STATUS_1;
}
}
void CMouseToolPointer::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
if(m_Status!=_STATUS_1)//点选
{
Dbxy pt2 = gDraw->CPoint2Dbxy(point);
DbRect rect;
rect = gDraw->GetCurPointRect(pt2,PT_SEL_SCALE);
if(gDraw->IsbPointSel())
{
if(gLayer.SelObjectInRect(rect,false))
{
GetCurViewPtr()->RefreshView();
m_Status = _STATUS_1;
}
}
}
}
void CMouseToolPointer::OnMouseMove(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy pt2 = gDraw->CPoint2Dbxy(m_PreMovePt);
Dbxy pt2New = gDraw->CPoint2Dbxy(point);
if(m_Status!=_STATUS_1)//框选图形
{
if(gDraw->IsbRectSel())//只有框选的时候才绘制
{
if(HasPreMovePt())//擦除之前的
{
DrawRect(&dc,gDraw->GetMouseRectPen(),m_DownPoint,pt2);
}
DrawRect(&dc,gDraw->GetMouseRectPen(),m_DownPoint,pt2New);
}
SavePreMovePt(point);
}
}