免费视频|新人指南|投诉删帖|广告合作|地信网APP下载

查看: 2303|回复: 1
收起左侧

VC+MapX鹰眼实现

[复制链接]

2072

主题

100000万

铜板

363

好友

地信专家组

每一次的分离都是为了下一次的相聚

Rank: 14Rank: 14Rank: 14Rank: 14

积分
17622

精华勋章宣传勋章爱心勋章组织勋章地信元老灌水勋章荣誉会员勋章活跃勋章贡献勋章

发表于 2009-12-4 20:30 | 显示全部楼层 |阅读模式
在同一个View窗口下家两个CMapX控件,一个称为主图,一个称为鹰眼图。
CMapX m_ctrlMapX; ///主图
CMapX m_eagleMapX; ///鹰眼图
注意事项:在View里的OnCreate函数一定要想创建m_eagleMapX,这样才能看见鹰眼图。既如此:
m_eagleMapX.Create(NULL, WS_VISIBLE, CRect(0, 0, 120, 120), this, IDC_MAP_EAGLE);
m_eagleMapX.SetGeoSet(NULL);
m_ctrlMapX.Create(NULL, WS_VISIBLE, CRect(0, 0, 100, 100), this, IDC_MAP);
m_ctrlMapX.SetGeoSet(NULL);
接下来,可以在主图里挑几层加到鹰眼图中(区域图层)
再在消息中映射几个消息:
ON_EVENT(CMTRSView, IDC_MAP_EAGLE, DISPID_MOUSEMOVE /* MouseMove */, onMouseMoveEagleMap, VTS_I2 VTS_I2 VTS_R4 VTS_R4)
ON_EVENT(CMTRSView, IDC_MAP_EAGLE, DISPID_MOUSEDOWN /* MouseDown */, onMouseDownEagleMap, VTS_I2 VTS_I2 VTS_R4 VTS_R4)
ON_EVENT(CMTRSView, IDC_MAP_EAGLE, DISPID_MOUSEUP /* MouseUp */, onMouseUpEagleMap, VTS_I2 VTS_I2 VTS_R4 VTS_R4)
最后实现这几个函数:
void CMTRSView:nMouseUpEagleMap(short Button, short Shift, float X, float Y)
{
///用户单击导航图上某点的处理
if(strMouseState == "Begin")
{
double dblMapX1, dblMapY1;
///求出该点的地理坐标
m_eagleMapX.ConvertCoord(&X, &Y, &dblMapX1, &dblMapY1, miScreenToMap);
///设置主图的地理坐标
m_ctrlMapX.SetCenterX(dblMapX1);
m_ctrlMapX.SetCenterY(dblMapY1);
}
///用户在导航图上框出矩形区域时的处理
if(strMouseState == "Move")
{
Single sngXMax, sngXMin, sngYMax, sngYMin;
if(PreX < X)
{
sngXMax = X;
sngXMin = PreX;
}
else
{
sngXMax = PreX;
sngXMin = X;
}
if(PreX < Y)
{
sngYMax = Y;
sngYMin = PreY;
}
else
{
sngYMax = PreY;
sngYMin = Y;
}
double dblXMax, dblXMin, dblYMax, dblYMin;
m_eagleMapX.ConvertCoord(&sngXMin, &sngYMin, &dblXMin, &dblYMin, miScreenToMap);
m_eagleMapX.ConvertCoord(&sngXMax, &sngYMax, &dblXMax, &dblYMax, miScreenToMap);
CMapXRectangle rect;
rect.CreateDispatch(rect.GetClsid());
rect.Set(dblXMin, dblYMin, dblXMin, dblYMax);
m_ctrlMapX.SetBounds(rect.m_lpDispatch);
}
strMouseState = "Stop";
}
void CMTRSView::onMouseDownEagleMap(short Button, short Shift, float X, float Y)
{
CMapXFeatures ftrs = m_eagleMapX.GetLayers().Item("EagleLayer").AllFeatures();
for(int i = 1; i <= ftrs.GetCount(); i++)
{
m_eagleMapX.GetLayers().Item("EagleLayer").DeleteFeature(ftrs.Item(i));
}
if(Button == vbLeftButton)
{
strMouseState = "Begin";
PreX = X;
PreY = Y;
}
}
void CMTRSView::onMouseMoveEagleMap(short Button, short Shift, float X, float Y)
{
if(Button != vbLeftButton) return;
CMapXRectangle rctMap;
CMapXPoints pntsMap;
CMapXPoint pntMap1, pntMap2, pntMap3, pntMap4;
CMapXStyle styLine;
CMapXFeatures ftrs;
CMapXFeature ftr;
Single sngX, sngY;

///得到鼠标单击点的地理坐标
sngX = PreX;
sngY = PreY;
double dblMapX1, dblMapY1;
m_eagleMapX.ConvertCoord(&sngX, &sngY, &dblMapX1, &dblMapY1, miScreenToMap);
///得到鼠标当前点的地理坐标
double dblMapX2, dblMapY2;
m_eagleMapX.ConvertCoord(&X, &Y, &dblMapX2, &dblMapY2, miScreenToMap);
///设置矩形的四角
pntMap1.CreateDispatch(pntMap1.GetClsid());
pntMap2.CreateDispatch(pntMap2.GetClsid());
pntMap3.CreateDispatch(pntMap3.GetClsid());
pntMap4.CreateDispatch(pntMap4.GetClsid());
pntMap1.Set(dblMapX1, dblMapY2);
pntMap2.Set(dblMapX2, dblMapY2);
pntMap3.Set(dblMapX2, dblMapY1);
pntMap4.Set(dblMapX1, dblMapY1);
///将矩形的四角加入点集中
pntsMap.CreateDispatch(pntsMap.GetClsid());
pntsMap.Add(pntMap1);
pntsMap.Add(pntMap2);
pntsMap.Add(pntMap3);
pntsMap.Add(pntMap4);
pntsMap.Add(pntMap1);
styLine.SetLineColor(miColorBlack); ///定义样式的线条颜色
styLine.SetLineWidth(1); ///定义样式的线条宽度
styLine.SetLineStyle(3); ///虚线
///将导航图鹰眼层所有对象清空
ftrs = m_eagleMapX.GetLayers().Item("EagleLayer").AllFeatures();
for(int i = 1; i <= ftrs.GetCount(); i++)
{
m_eagleMapX.GetLayers().Item("EagleLayer").DeleteFeature(ftrs.Item(i));
}
///在导航图鹰眼层画虚线矩形框,框出用户预选择的范围
CMapXFeature ftrMap;
COleVariant pntsVt, styVt;
pntsVt.vt = VT_DISPATCH;
pntsVt.pdispVal = pntsMap.m_lpDispatch;
pntsVt.pdispVal->AddRef();
styVt.vt = VT_DISPATCH;
styLine.CreateDispatch(styLine.GetClsid());
styVt.pdispVal = styLine.m_lpDispatch;
styVt.pdispVal->AddRef();
ftrMap = m_eagleMapX.GetFeatureFactory().CreateLine(pntsVt, styVt);
m_eagleMapX.GetLayers().Item("EagleLayer").AddFeature(ftrMap);
///设置鼠标状态为"Move"
strMouseState = "Move";
}
还有,可以在OnSize里面设置一下鹰眼图的大小.

0

主题

2632

铜板

0

好友

教授级高工

Rank: 12Rank: 12Rank: 12

积分
1542
发表于 2025-1-9 15:29 | 显示全部楼层
探矿者软件可以提高矿体的命中率,减少找矿的成本和难度,主要功能:数据管理、二维制图、三维建模、储量估算、三维立体预测等,有需要免费试用可以联系负责人邓帅15377311476(微信同号),软件针对单位或者企业试用,不面向个人试用
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

在线客服
快速回复 返回顶部 返回列表