上一步开发了对实体和选择集进行操作的类后,再实现捡选,删除就很简单了
删除图形只要把图形从选择集中删掉就可以了
(1)选择
class CSelect : public CComand
{
public:
CSelect();
virtual ~CSelect();
public:
void OnLButtonDown(UINT nFlags, CPosition pos);
void OnMouseMove(UINT nFlags, CPosition pos);
private:
CHandleCG* m_hand;
};
CSelect::CSelect()
{
m_hand = new CHandleCG(&g_pDoc->m_solid, &g_pDoc->m_select);
}
void CSelect::OnLButtonDown(UINT nFlags, CPosition pos)
{
m_hand->AddSelect();
}
void CSelect::OnMouseMove(UINT nFlags, CPosition pos)
{
CDC *pDC = g_pView->GetDC();
float dis = PICK_RADIU * ( g_pView->m_scale );
m_hand->DrawSelect(pDC, pos, dis, Normal, Select);
}
CSelect::~CSelect()
{
delete m_hand;//
}
(2)取消选择
class CUnSelect : public CComand
{
public:
CUnSelect();
virtual ~CUnSelect();
public:
void OnLButtonDown(UINT nFlags, CPosition pos);
void OnMouseMove(UINT nFlags, CPosition pos);
private:
CHandleCG* m_hand;
};
CUnSelect::CUnSelect()
{
m_hand = new CHandleCG(&g_pDoc->m_select, &g_pDoc->m_solid);
}
void CUnSelect::OnLButtonDown(UINT nFlags, CPosition pos)
{
m_hand->AddSelect();
}
void CUnSelect::OnMouseMove(UINT nFlags, CPosition pos)
{
CDC *pDC = g_pView->GetDC();
float dis = PICK_RADIU * ( g_pView->m_scale );
m_hand->DrawSelect(pDC, pos, dis, Select, Normal);
g_pView->ReleaseDC(pDC);
}
CUnSelect::~CUnSelect()
{
delete m_hand;//
}
(3)删除
class CDelete : public CComand
{
public:
CDelete();
virtual ~CDelete();
public:
void OnLButtonDown(UINT nFlags, CPosition pos);
void OnMouseMove(UINT nFlags, CPosition pos);
private:
CHandleCG* m_hand;
};
CDelete::CDelete()
{
m_hand = new CHandleCG(&g_pDoc->m_select, &g_pDoc->m_solid);
}
void CDelete::OnLButtonDown(UINT nFlags, CPosition pos)//删除实体并重画
{
CDC *pDC = g_pView->GetDC();
m_hand->DeleteSolid(pDC);
g_pView->ReleaseDC(pDC);
}
void CDelete::OnMouseMove(UINT nFlags, CPosition pos)//移动监测选中的实体
{
CDC *pDC = g_pView->GetDC();
float dis = PICK_RADIU * ( g_pView->m_scale );
m_hand->DrawSelect(pDC, pos, dis, Select, Normal);
g_pView->ReleaseDC(pDC);
}
CDelete::~CDelete()
{
delete m_hand;//
}