VC++开发GIS系统(264)移动注释之类的设计及实现
发布时间: 2016-06-29
所属分类: VC++开发GIS系统
本文介绍GIS系统中移动一个注释所对应类的设计及实现。功能演示如下:
移动注释类的定义
在_malaLabel.h中定义移动注释的类,代码如下:
/*
* 移动注释
*/
class malalabeldll CmalaLabelsMove :public CmalaMouseAction
{
public:
CmalaLabelsMove(CView* mView, malaScreen *pScreen, CString &fileFullPath);
~CmalaLabelsMove();
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;//选择的注释
malaLabelPro m_LabelPro;//选择的注释的属性
malaPointPro m_PointPro;//选择的点的属性
CmalaLabelsSelect m_SelectPnt;
CString mPath;//文件路径
bool m_bDraw;
malaPoint m_ptOrigin;//起点
malaPoint m_perPoint;//临时点
malaScreen *m_Screen;
};
- @
mSelected
是否有注释被选中 - @
m_Point
选中的注释 - @
m_LabelPro
选中注释属性 - @
m_LabelPro
绘制坐标点的属性 - @
m_SelectPnt
选中的注释 - @
mPath
注释文件路径 - @
m_bDraw
记录是否按下鼠标左键(用于橡皮筋绘图) - @
m_ptOrigin
移动的起点 - @
m_perPoint
临时的点 - @
m_Screen
屏幕坐标
移动注释类实现
在_malaLabel.cpp中实现上述类的定义
/*
* 移动注释实现
*/
CmalaLabelsMove::CmalaLabelsMove(CView* mView, malaScreen *pScreen, CString &fileFullPath)
{
mBaseView = mView;
mPath = fileFullPath;
m_Screen = pScreen;
CmalaLabelsSelect obj(mView, pScreen, fileFullPath);
m_SelectPnt = obj;
m_Selected = FALSE;
m_bDraw = FALSE;
}
CmalaLabelsMove::~CmalaLabelsMove()
{
}
void CmalaLabelsMove::LButtonDown(UINT nFlags, malaPoint point)
{
if (!m_Selected)
m_SelectPnt.LButtonDown(nFlags, point);
else
{
m_bDraw = TRUE;
m_ptOrigin = point;
}
}
void CmalaLabelsMove::LButtonUp(UINT nFlags, malaPoint point)
{
if (!m_Selected)
m_SelectPnt.LButtonUp(nFlags, point);
else
{
CLabelIO lio;
lio.labelUpdate(point, m_LabelPro, mPath);
mBaseView->Invalidate(TRUE);
m_bDraw = FALSE;
m_Selected = FALSE;
m_SelectPnt.m_Selected = FALSE;
}
m_Selected = m_SelectPnt.m_Selected;
if (m_Selected)
{
this->m_Point = m_SelectPnt.m_pnt;
this->m_LabelPro = m_SelectPnt.mLablePro;
m_perPoint = m_Point;
}
}
void CmalaLabelsMove::MouseMove(UINT nFlags, malaPoint point)
{
if (!m_Selected)
m_SelectPnt.MouseMove(nFlags, point);
else if (m_bDraw)
{
malaCDC dc(mBaseView, *m_Screen);
m_PointPro.pointColor = RGB(0, 255, 0);
m_PointPro.pointRadio = 10;
m_PointPro.pointStyle = 2;
dc.pointDrawAutoX(m_perPoint, m_PointPro);
m_perPoint.x = m_ptOrigin.x + point.x - m_ptOrigin.x;
m_perPoint.y = m_ptOrigin.y + point.y - m_ptOrigin.y;
dc.pointDrawAutoX(m_perPoint, m_PointPro);
}
}
其中 labelUpdate
函数参考《VC++开发GIS系统(263)更新注释参数》
详细代码可以参考:GitHub
相关阅读
声明
1.本文所分享的所有需要用户下载使用的内容(包括但不限于软件、数据、图片)来自于网络或者麻辣GIS粉丝自行分享,版权归该下载资源的合法拥有者所有,如有侵权请第一时间联系本站删除。
2.下载内容仅限个人学习使用,请切勿用作商用等其他用途,否则后果自负。
手机阅读
公众号关注
知识星球
手机阅读
最新GIS干货
私享圈子