转自原文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. 2.Xml与多个对象的映射(聚合或组合)及注意事项

    在我们的实际应用中,Xml中的结构往往不止这么简单,一般都会有2,3层.也就是说如果映射成对象就是聚合(组合)的情况 . 就用我们上一章的例子继续来讲,简单我们的Book的author现在不止是一个S ...

  2. Maven搭建hadoop环境报Missing artifact jdk.tools:jdk.tools:jar:1.7(5种办法,2种正解)

    刚刚写的那一篇,是网上比较主流的解决办法. 鉴于实际情况,有伙伴的机器上没有遇到这个问题,我们再探究原因,最终还有4种情况需要说明. 先说,另外一种"正解". <depend ...

  3. 89.hash算法实现CSDN密码处理

    初始化,数据的行数,hash链表结构体,存储头结点 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdl ...

  4. 关于数据库中的JOIN的用法学习

    下面是例子分析 表A记录如下:  aID aNum  1 a20050111  2 a20050112  3 a20050113  4 a20050114  5 a20050115 表B记录如下:  ...

  5. hdu5389

    题意:给你n个人每一个人手里有一个id,然后给你两个数a和b.让你把n个人分为两组.条件是 一组人手里的id和等于a 另一组人的id和等于b,这里的和是指加起来之后对9取余,假设sum等于0 则sum ...

  6. Dcloud课程1 APP的架构有哪些

    Dcloud课程1 APP的架构有哪些 一.总结 一句话总结:B/S架构和C/S构架 1.APP的分类? 主流的四大APP系统:1.苹果ios系统版本,开发语言是Objective-C:2.微软Win ...

  7. es6三点运算符的用法

    扩展运算符( spread )是三个点(...).它好比 rest 参数的逆运算,将一个数组转为用逗号分隔的参数序列. console.log(...[1,2,3]); console.log(1,. ...

  8. 4、qq物联SDK介绍及实例讲解

    1.到QQ物联官网http://iot.open.qq.com中下载软件SDK S3C2440_20161122_1.6.205_r4288.tar.gz注意:在后续大家实际开发过程中,可能你会下载到 ...

  9. /bin/bash^M: bad interpreter: 没有那个文件或文件夹

    执行脚本时出现了这样一个错误,打开之后并没有找到所谓的^M,查了之后才知道原来是文件格式的问题,也就是linux和windows之间的不全然兼容... 详细细节无论,假设验证: vim test.sh ...

  10. Java反射学习总结二(用反射调用对象的私有属性和方法)

    大家都知道正常的调用是不可以访问对象的private修饰的属性和方法的,这也是Java的封装性原则. 但是有没有方法可以强制去访问对象的private修饰的属性和方法呢?那就是用反射!(这个可能在面试 ...