VC++开发GIS系统(137)修改点参数之类的定义及实现

前文已经实现了移动点复制点的功能,本文的工作是——修改点参数。过程如下:

  1. 选中点
  2. 弹出点的参数对话框(参考VC++开发GIS系统(136)修改点参数之导出参数对话框
  3. 点击确定,修改点属性。

修改点属性类CmalaPointsModify的定义

在_malaPoints.h中定义修改的点的类:CmalaPointsModify,代码如下:

/*
* 修改点参数
*/
class malapointsdll  CmalaPointsModify :public CmalaMouseAction
{
public:
    CmalaPointsModify(CView* mView, malaScreen *pScreen, CString &fileFullPath);
    ~CmalaPointsModify();
    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;//选择的点的属性
    CmalaPointsSelect m_SelectPnt;

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

修改点属性类CmalaPointsModify的实现

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

/*
* 修改点参数实现
*/
CmalaPointsModify::CmalaPointsModify(CView* mView, malaScreen *pScreen, CString &fileFullPath)
{
    mBaseView = mView;
    mPath = fileFullPath;
    m_Screen = pScreen;
    CmalaPointsSelect obj(mView, pScreen, fileFullPath);
    m_SelectPnt = obj;
    m_Selected = FALSE;
}

CmalaPointsModify::~CmalaPointsModify()
{

}

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

void CmalaPointsModify::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_PointPro = m_SelectPnt.m_PntPro;

        if (dlgModifyPointPro(m_PointPro))
        {
            CPointIO pio;
            pio.pointUpdate(m_Point, m_PointPro, mPath);
            mBaseView->Invalidate(TRUE);
        }

        m_Point.x = m_Point.y = 0;
        m_Selected = FALSE;
        m_SelectPnt.m_Selected = FALSE;
    }

}

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

可以看出修改点参数调用的是pointUpdate函数。

详细代码可以参考:GitHub

VC++开发GIS系统(136)修改点参数之导出参数对话框 VC++开发GIS系统(138)修改点参数之菜单响应

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

发表评论