VC++开发GIS系统(272)删除注释之类的设计及实现

本文为GIS中删除注释的操作设计一个类,以实现删除注释的相关功能,其演示如下:

GIS系统删除注释类的定义

在_malaLabel.h中定义GIS删除注释的类,代码如下:

/*
* 删除注释
*/
class malalabeldll  CmalaLabelsDelete :public CmalaMouseAction
{
public:
  CmalaLabelsDelete(CView* mView, malaScreen *pScreen, CString &fileFullPath);
  ~CmalaLabelsDelete();
  void LButtonDown(UINT nFlags, malaPoint point);
  void LButtonUp(UINT nFlags, malaPoint point);
  void MouseMove(UINT nFlags, malaPoint point);
private:
  bool m_Selected;
  malaPoint m_Point;//选择的点
  malaPointPro m_PointPro;//选择的点的属性
  malaLabelPro m_LabelPro;//选择的注释的属性
  CmalaLabelsSelect m_SelectPnt;

  CString mPath;//文件路径
  malaScreen *m_Screen;
};

类的实现

在_malaLabel.cpp中实现上述类的定义,代码如下:

/*
* 删除注释实现
*/
CmalaLabelsDelete::CmalaLabelsDelete(CView* mView, malaScreen *pScreen, CString &fileFullPath)
{
  mBaseView = mView;
  mPath = fileFullPath;
  m_Screen = pScreen;
  CmalaLabelsSelect obj(mView, pScreen, fileFullPath);
  m_SelectPnt = obj;
  m_Selected = FALSE;
}

CmalaLabelsDelete::~CmalaLabelsDelete()
{

}

void CmalaLabelsDelete::LButtonDown(UINT nFlags, malaPoint point)
{
  if (!m_Selected)
    m_SelectPnt.LButtonDown(nFlags, point);
}

void CmalaLabelsDelete::LButtonUp(UINT nFlags, malaPoint point)
{
  if (!m_Selected)
    m_SelectPnt.LButtonUp(nFlags, point);

  m_Selected = m_SelectPnt.m_Selected;
  if (m_Selected)
  {
    this->m_Point = m_SelectPnt.m_pnt;
    this->m_LabelPro = m_SelectPnt.mLablePro;

    if (MessageBox(mBaseView->m_hWnd, L"删除后将无法恢复,确定删除该注释吗?", L"警告", MB_YESNO | MB_ICONQUESTION) == IDYES)
    {
      CLabelIO pio;
      pio.labelDelete(m_LabelPro, mPath);
      mBaseView->Invalidate(TRUE);
    }
    m_Point.x = m_Point.y = 0;
    m_Selected = FALSE;
    m_SelectPnt.m_Selected = FALSE;

  }

}

void CmalaLabelsDelete::MouseMove(UINT nFlags, malaPoint point)
{
  if (!m_Selected)
    m_SelectPnt.MouseMove(nFlags, point);
}

主要思路是选中注释,并调用删除函数 labelDelete (参考:VC++开发GIS系统(271)删除注释之函数定义) 从注释文件中移除。

详细代码可以参考:GitHub

VC++开发GIS系统(271)删除注释之函数定义 VC++开发GIS系统(273)删除注释之菜单响应

作者:,GIS爱好者。
分享本文,请您带上本文链接
分享到:

发表评论