转自原文ArcEngine数据编辑--选择要素

好久没有写博文了,这段时间相对空闲一点,把AE数据编辑实现总结下。

要编辑要素,首先要选中要素,按shift键进行多选,按esc键清空选择。

个人了解的选择高亮显示有两种方式,都是在public override void OnMouseDown(int Button, int Shift, int X, int Y)事件中处理实现:

1、  IFeatureSelection 这个要求明确选择的图层

IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
IEnvelope pEnvelope;
double tol = ;
pEnvelope = pPoint.Envelope;
pEnvelope.Width = pEnvelope.Width + tol;
pEnvelope.Height = pEnvelope.Height + tol;
pEnvelope.CenterAt(pPoint); ISpatialFilter pSpatialFilter;
pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.Geometry = pEnvelope;
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureSelection pFeatureSelection;
pFeatureSelection = ucDrawPanel.currentFeatureLayer as IFeatureSelection;
IFeature pFeature;
ucDrawPanel.unionFeature = new List<IFeature>();//实例化合并要素集
if (Shift == )
{
if (ucDrawPanel.currentFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
pFeatureSelection.SelectFeatures(pSpatialFilter,
esriSelectionResultEnum.esriSelectionResultAdd, true);
ICursor pCursor;
pFeatureSelection.SelectionSet.Search(null, false, out pCursor);
}
}
else
{
pActiveView.FocusMap.ClearSelection();
pFeatureSelection.SelectFeatures(pSpatialFilter,
esriSelectionResultEnum.esriSelectionResultNew, true); ICursor pCursor;
pFeatureSelection.SelectionSet.Search(null, false, out pCursor);
}
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, ucDrawPanel.currentFeatureLayer, null);
//高亮显示出来
ISimpleFillSymbol iFillSymbol;
ISymbol iSymbol;
IRgbColor iRgbColor;
iFillSymbol = new SimpleFillSymbol();
iFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
iRgbColor = new RgbColor();
iRgbColor.Green = ;
iFillSymbol.Color = iRgbColor;
iSymbol = (ISymbol)iFillSymbol;
iSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; IEnumFeature pEnumFeature = pActiveView.FocusMap.FeatureSelection as IEnumFeature;
pEnumFeature.Reset();
pFeature = pEnumFeature.Next();
//选中要素高亮显示
if (pFeature != null)
{
IGeometry pGeometry = pFeature.Shape;
ITopologicalOperator pTop = pGeometry as ITopologicalOperator;
while (pFeature != null)
{
ucDrawPanel.unionFeature.Add(pFeature); pGeometry = pTop.Union(pFeature.Shape);
pTop = pGeometry as ITopologicalOperator;
pFeature = pEnumFeature.Next();
}
ucDrawPanel.currentFeature = ucDrawPanel.unionFeature[ucDrawPanel.unionFeature.Count - ];
_mapCtrl.FlashShape(pGeometry, , , iSymbol);
}
//清空选择要素
else
{
pActiveView.FocusMap.ClearSelection();
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, pActiveView.Extent);
}

2、  SelectByMap 基于整个地图,当然也可以先将图层的selectable属性动态设置下

if (Button == )
{
//清空地图视图
_mapCtrl.Map.ClearSelection();
IGraphicsContainer pContainer = _mapCtrl.Map as IGraphicsContainer;
pContainer.DeleteAllElements();
_mapCtrl.ActiveView.Refresh(); base.OnMouseDown(Button, Shift, X, Y); IActiveView pActiveView = _mapCtrl.ActiveView;
IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
IPoint TempPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X + , Y + ); IEnvelope objEnvelope;
double tol = Math.Abs(TempPoint.X - pPoint.X);
objEnvelope = pPoint.Envelope;
objEnvelope.Width = objEnvelope.Width + tol;
objEnvelope.Height = objEnvelope.Height + tol;
objEnvelope.CenterAt(pPoint);
setSelectable(ucDrawPanel.currentLayerName);//只有当前编辑图层可选 _mapCtrl.Map.SelectByShape((IGeometry)objEnvelope, null, true);//只选择一个要素
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, _mapCtrl.ActiveView.Extent); ucDrawPanel.currentFeatureLayer = GetLayerByName(_mapCtrl, ucDrawPanel.currentLayerName);
if (ucDrawPanel.currentFeatureLayer != null)
{
ucDrawPanel.currentFeature = GetFeatureBySelection(ucDrawPanel.currentFeatureLayer);
}
else
{
MessWin messWin = new MessWin();
messWin.SetTitleAndMess("提示", @"获取选择要素出错!", false);
return;
}
}

PS:esc键退出,在OnKeyDown事件中实现

public override void OnKeyDown(int keyCode, int Shift)
{
if (keyCode == (int)Keys.Escape)
{
IActiveView pActiveView = _mapCtrl.ActiveView;
pActiveView.FocusMap.ClearSelection();
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, pActiveView.Extent);
_mapCtrl.CurrentTool = null;
}
}

ArcEngine数据编辑--选择要素的更多相关文章

  1. 利用IIdentify接口实现点选和矩形选择要素

    duckweeds 原文利用IIdentify接口实现点选和矩形选择要素 Identify接口定义了获得要素图层单个要素的属性的捷径方法.它有一个Identify方法,返回一个IArray数组对象. ...

  2. AE,按照属性值关系选择要素

    if(axMapControl2.LayerCount<=0) { MessageBox.Show("请加载图层后使用该功能","系统提示",Messag ...

  3. ArcEngine选中面要素样式修改

    //只用前五行,可以直接将选中的面要素的颜色全部修改成红色,也就是填充颜色 IRgbColor pRgbColor= new RgbColor();; pRgbColor.Red = ; pRgbCo ...

  4. ArcEngine 创建线要素图层

    在创建要素图层的时候,默认的几何类型是Polygon: Dim objectClassDescription As IObjectClassDescription = New FeatureClass ...

  5. ArcEngine 数据编辑(IWorkspaceFactory)

    数据编辑做过很多次,没怎么出现问题,今天出现了问题,浪费了大半天,记录一下. 问题:修改Featrue的属性,修改后停止编辑,但是没有提示是否保存修改 原因:在编辑数据的时候没有加StartEditO ...

  6. Arcengine 实现要素选取的方法(转载)

    转自原文Arcengine 实现要素选取的方法(转载) 选择一个要素或者一个要素集(FeatureSelection)的方法很多,如IMap::SelectByShape.ILayer::search ...

  7. ArcGIS Engine中如何获取Map中已经选择的要素呢

    1.使用IEnumFeturea对象获取map中的FeatureSelection,该方法可以获取所有图层的选择要素.IMap中的FeatureSelection可不是IFeatureSelectio ...

  8. Dotspatial 空间要素选择

    //通过遍历选择要素,获取选择要素相交的要素 private void toolStripButton43_Click(object sender, EventArgs e) { //查看与选中要素重 ...

  9. ArcGIS Engine中如何获取Map中已经选择的要素呢(转)

    ArcGIS Engine中如何获取Map中已经选择的要素呢   1.使用IEnumFeturea对象获取map中的FeatureSelection,该方法可以获取所有图层的选择要素.IMap中的Fe ...

随机推荐

  1. 自定义控件学习——下拉刷新ListView

    效果 开始用Android Studio写了,还有挺多不明白这IDE用法的地方....蛋疼 主要思路 1. 添加了自定义的头布局    2. 默认让头布局隐藏setPadding.设置 -自身的高度  ...

  2. 用djbdns为域名解析服务护航

      上期回顾:http://chenguang.blog.51cto.com/350944/292195       650) this.width=650;" alt="&quo ...

  3. POJ 3220 Jessica's Reading Problem

    Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12944   Accep ...

  4. 最简单的实体手机测试移动端前端Vue Cli3搭建网站的方法

    手机和PC同用一个路由的情况下,直接在手机的浏览器上输入Ip: 192.168.1.100:8080 就能看到了. 其中192.168.1.100是PC的IP.不同的自己改下就好. 就这么简单.啥都不 ...

  5. django 简单会议室预约(5)

    再来看看views.py的后半部分,对数据库的增删改查 #获取学院列表 def get_acad_list(): room_list = ConfeRoom.objects.all() #对数据库的操 ...

  6. java解压多目录Zip文件(解决中文乱码问题)--转载

    原文地址:http://zhangyongbo.iteye.com/blog/1749439 import java.io.BufferedOutputStream; import java.io.F ...

  7. 洛谷P1876 开灯

    题目背景 该题的题目是不是感到很眼熟呢? 事实上,如果你懂的方法,该题的代码简直不能再短. 但是如果你不懂得呢?那...(自己去想) 题目描述 首先所有的灯都是关的(注意是关!),编号为1的人走过来, ...

  8. Java基础学习总结(38)——Lombok的使用和原理

    一.项目背景 在写Java程序的时候经常会遇到如下情形:  新建了一个Class类,然后在其中设置了几个字段,最后还需要花费很多时间来建立getter和setter方法  lombok项目的产生就是为 ...

  9. BAT面试题 - 找一个无序实数数组中的最大差值

    题目描写叙述: 一个无序的实数数组a[i].要求求里面大小相邻的实数的差的最大值.比方 double a[]={1,5,4,0.2,100} 这个无序的数组,相邻的数的最大差值为100-5=95. 题 ...

  10. Android实践 -- 对apk进行系统签名

    对apk进行系统签名 签名工具 网盘下载 ,需要Android系统的签名的文件 platform.x509.pem 和 platform.pk8 这个两个文件在Android源码中的 ./build/ ...