AE 线编辑
转自原文 AE 线编辑
1、高亮显示节点
//高亮显示节点和端点
public void HighLightNode()
{
//清空
_mapCtrl.Map.ClearSelection();
_mapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, _mapCtrl.ActiveView.Extent);
var pGraphicsContainer = _mapCtrl.Map as IGraphicsContainer;
pGraphicsContainer.DeleteAllElements();
_mapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, _mapCtrl.ActiveView.Extent); //增加
ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass
{
Color = new RgbColorClass { Red = , Green = , Blue = },
Width = ,
Style = esriSimpleLineStyle.esriSLSSolid
}; ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass
{
Color =
new RgbColorClass { Red = , Green = , Blue = },
Style = esriSimpleMarkerStyle.esriSMSCircle,
Size =
};
switch (currentFeature.Shape.GeometryType)
{
case esriGeometryType.esriGeometryPoint:
//IMarkerElement pMarkerElement = new MarkerElementClass();
//pMarkerElement.Symbol = simpleMarkerSymbol;
//var pEla = pMarkerElement as IElement;
//pEla.Geometry = currentFeature.Shape;
//var pActiveView = _mapCtrl.ActiveView;
//var pGraphicsContainer = _mapCtrl.Map as IGraphicsContainer;
//pGraphicsContainer.AddElement(pEla, 0);
//pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, _mapCtrl.ActiveView.Extent);
break;
case esriGeometryType.esriGeometryPolyline:
ILineElement pLineElement = new LineElementClass();
pLineElement.Symbol = simpleLineSymbol;
var pEla1 = pLineElement as IElement;
pEla1.Geometry = currentFeature.Shape;
var pActiveView1 = _mapCtrl.ActiveView;
var pGraphicsContainer1 = _mapCtrl.Map as IGraphicsContainer;
pGraphicsContainer1.AddElement(pEla1, );
pActiveView1.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, _mapCtrl.ActiveView.Extent);
break;
case esriGeometryType.esriGeometryPolygon:
IPolygonElement pPolygonElement = new PolygonElementClass { Symbol = simpleFillSymbol };
var pEla2 = pPolygonElement as IElement;
pEla2.Geometry = currentFeature.Shape;
var pActiveView2 = _mapCtrl.ActiveView;
var pGraphicsContainer2 = _mapCtrl.Map as IGraphicsContainer;
pGraphicsContainer2.AddElement(pEla2, );
pActiveView2.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, _mapCtrl.ActiveView.Extent);
break;
}
//显示节点
//step1:创建节点符号
ISimpleMarkerSymbol pVertexMarkerSymbol = new SimpleMarkerSymbolClass();
pVertexMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;
pVertexMarkerSymbol.Size = ;
pVertexMarkerSymbol.Angle = ;
IRgbColor rgbVertex = new RgbColorClass();
rgbVertex.Green = ;
pVertexMarkerSymbol.Color = rgbVertex;
ISimpleMarkerSymbol pEndPointMarkerSymbol = new SimpleMarkerSymbol();
pEndPointMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;
pEndPointMarkerSymbol.Size = ;
pEndPointMarkerSymbol.Angle = ;
IRgbColor rgbEndPoint = new RgbColorClass();
rgbEndPoint.Red = ;
pEndPointMarkerSymbol.Color = rgbEndPoint; //判D断要素的类型
if (currentFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
{
IGeometryCollection pGeoColl;
ISegmentCollection pSegColl;
ISegment pSegment;
IPath path;
IPointCollection pEndPointCol;
IMultipoint pEndPoints;
IPoint pEndPoint;
pEndPoints = new MultipointClass();
pEndPointCol = pEndPoints as IPointCollection;
pGeoColl = currentFeature.Shape as IGeometryCollection;
for (int i = ; i < pGeoColl.GeometryCount; i++)
{
pSegColl = pGeoColl.get_Geometry(i) as ISegmentCollection;
path = pGeoColl.get_Geometry(i) as IPath;
pEndPointCol.AddPoint(path.FromPoint);
pEndPointCol.AddPoint(path.ToPoint); for (int j = ; j < pSegColl.SegmentCount; j++)
{
pSegment = pSegColl.get_Segment(j);
//show vertex
AddPointSymbolToMap(pSegment.FromPoint, pVertexMarkerSymbol);
AddPointSymbolToMap(pSegment.ToPoint, pVertexMarkerSymbol);
}
}
//show endpoint
for (int k = ; k < pEndPointCol.PointCount; k++)
{
pEndPoint = pEndPointCol.get_Point(k);
AddPointSymbolToMap(pEndPoint, pEndPointMarkerSymbol);
} }
else if (currentFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
{
IPoint pEndPoint;
pEndPoint = currentFeature.Shape as IPoint;
AddPointSymbolToMap(pEndPoint, pEndPointMarkerSymbol);
}
}
2、添加节点
OnMouseDown事件:
IProximityOperator proximityOperator = ucDrawPanel.currentFeature.Shape as IProximityOperator;
ptInsert = proximityOperator.ReturnNearestPoint(pPt, esriSegmentExtension.esriNoExtension); //step1: 创建节点符号
ISimpleMarkerSymbol pVertexMarkerSymbol = new SimpleMarkerSymbolClass();
pVertexMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;
pVertexMarkerSymbol.Size = ;
pVertexMarkerSymbol.Angle = ;
IRgbColor rgbVertex = new RgbColorClass();
rgbVertex.Green = ;
pVertexMarkerSymbol.Color = rgbVertex;
//step2: 显示在地图上
IMarkerElement pMarkerElement = new MarkerElementClass();
pMarkerElement.Symbol = pVertexMarkerSymbol;
var pEla = pMarkerElement as IElement;
pEla.Geometry = ptInsert as IGeometry;
pGraphicContainer.AddElement(pEla, );
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pActiveView.Extent); OnMouseUp事件,添加一个节点,但不打断线:
// 注意:如果第三个参数createPart设为true,线会被打断,不可取
//线?splitAtPoint
bool isSplitted;
int newPartIndex;
int newSegmentIndex;
IPolyline polyline = ucDrawPanel.currentFeature.Shape as IPolyline;
//插入一点,newSegmentIndex记录插入点的相对线的节点位置
polyline.SplitAtPoint(ptInsert, true, false, out isSplitted, out newPartIndex, out newSegmentIndex);
ucDrawPanel.currentFeature.Store();
3、删除节点
OnMouseDown事件:
//step1:获取预删除的节点
IPolyline pPolyline;
IHitTest pHitTest;
bool BoolHitTest;
double dist = ;
double DbHitDis = ;
int LngPrtIdx = ;
bool BoolHitRt = false;
hitElement = getElement(pPt, esriGeometryType.esriGeometryPolyline);
if (hitElement != null)
{
pPolyline = hitElement.Geometry as IPolyline;
pHitTest = pPolyline as IHitTest;
ptDelete = new PointClass();
BoolHitTest = pHitTest.HitTest(pPt, pActiveView.Extent.Width / ,
esriGeometryHitPartType.esriGeometryPartVertex, ptDelete, ref DbHitDis, ref LngPrtIdx, ref indexDelete, ref BoolHitRt);
// pHitTest.HitTest(pPt, pActiveView.Extent.Width / 100,esriGeometryHitPartType.esriGeometryPartVertex, ptDelete,ref DbHitDis, ref LngPrtIdx, ref LngSegIdx, ref BoolHitRt); if (BoolHitTest)
{
//step2:高?亮显示,符号黑色边框镂空填充
ISimpleMarkerSymbol pVertexMarkerSymbol = new SimpleMarkerSymbolClass();
pVertexMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;
pVertexMarkerSymbol.Size = ;
pVertexMarkerSymbol.Angle = ;
IRgbColor rgbVertex = new RgbColorClass();
rgbVertex.Red = ;
rgbVertex.Blue = ;
rgbVertex.Green = ;
pVertexMarkerSymbol.Color = rgbVertex; IMarkerElement pMarkerElement = new MarkerElementClass();
pMarkerElement.Symbol = pVertexMarkerSymbol;
var pEla = pMarkerElement as IElement;
pEla.Geometry = ptDelete as IGeometry;
pGraphicContainer.AddElement(pEla, );
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pActiveView.Extent);
}
} OnMouseUp事件,删除节点:
IPointCollection pointCollection = ucDrawPanel.currentFeature.Shape as IPointCollection;
pointCollection.RemovePoints(indexDelete, );
IPolyline polylineNew = pointCollection as IPolyline;
StoreFeatureGeometry(ucDrawPanel.currentFeature, polylineNew);
保存图形要素:
private bool StoreFeatureGeometry(IFeature pFeature, IGeometry pIGeometry)
{
try
{
var pFeatureClass = pFeature.Class as IFeatureClass;
var pDataset = pFeatureClass as IDataset;
IWorkspace pWorkspace = pDataset.Workspace;
var pWorkspaceEdit = pWorkspace as IWorkspaceEdit; pWorkspaceEdit.StartEditing(false);
pWorkspaceEdit.StartEditOperation();
pFeature.Shape = pIGeometry;
pFeature.Store();
pWorkspaceEdit.StopEditOperation();
pWorkspaceEdit.StopEditing(true);
return true;
}
catch (Exception ex)
{
return false;
}
}
4、打断线
关键字:Split。
OnMouseDown事件:
IProximityOperator proximityOperator = ucDrawPanel.currentFeature.Shape as IProximityOperator;
ptSplit = proximityOperator.ReturnNearestPoint(pPt, esriSegmentExtension.esriNoExtension); //step1:创建节点符号
ISimpleMarkerSymbol pVertexMarkerSymbol = new SimpleMarkerSymbolClass();
pVertexMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;
pVertexMarkerSymbol.Size = ;
pVertexMarkerSymbol.Angle = ;
IRgbColor rgbVertex = new RgbColorClass();
rgbVertex.Red = ;
pVertexMarkerSymbol.Color = rgbVertex;
//step2:显示在地图上
IMarkerElement pMarkerElement = new MarkerElementClass();
pMarkerElement.Symbol = pVertexMarkerSymbol;
var pEla = pMarkerElement as IElement;
pEla.Geometry = ptSplit as IGeometry;
pGraphicContainer.AddElement(pEla, );
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pActiveView.Extent); OnMouseUp事件打断线:
IFeatureEdit featureEdit = ucDrawPanel.currentFeature as IFeatureEdit;
ISet newFeaturesSet = featureEdit.Split(ptSplit);
newFeaturesSet.Reset();
IFeature feature = newFeaturesSet.Next() as IFeature;
5、合并线
AE 线编辑的更多相关文章
- ArcGIS API for Silverlight 编辑Geometry
概述 ArcMap的编辑功能是非常强大的,ArcEngine编写的CS程序也可以用到ArcMap中提供的编辑功能,那么ArcGIS API forSilverlight针对Geometry的编辑提供了 ...
- ArcGIS Engine 中的绘制与编辑
1.线段绘制 基本步骤 构建形状 1. 创建 IPoint IPoint m_Point = new PointClass(); m_Point.PutCoords(x, y); 2. 创建 IPoi ...
- [转载]jQuery UI 使用
最近项目中使用了一些插件来做页面,这里把jQuery UI的使用分享出来,希望 对新手有帮助.文章结尾附源码下载. 1 jQuery UI 2 为我所用 2.1 Tabs 2. ...
- 3DMAX-模型制作简介
本文由博主(YinaPan)原创,转载请注明出处:http://www.cnblogs.com/YinaPan/p/3dmax_moxingzhizuo.html 一.快捷键: ALT + X 透明 ...
- Ubuntu下屏幕录像、后期处理不完全攻略
提要 如果要做成果展示或者效果演示,通常需要录取屏幕生成视频文件,在windows中我们可以用屏幕录像专家在录像, vegas 来做后期处理,Ubuntu可以么? 答案时当然可以!虽然第一次用觉得有点 ...
- Lottie安卓开源动画库使用
碉堡的Lottie Airbnb最近开源了一个名叫Lottie的动画库,它能够同时支持iOS,Android与ReactNative的开发.此消息一出,还在苦于探索自定义控件各种炫酷特效的我,兴奋地就 ...
- 配置 Sublime Text 3 作为Python R LaTeX Markdown IDE
配置 Sublime Text 3 作为Python R LaTeX Markdown IDE 配置 Sublime Text 3 作为Python IDE IDE的基本功能:代码提醒.补全:编译文件 ...
- 3ds max学习笔记(十五)-- 二维图形的操作
(二维图形的创建) 1,在命令面板的[新建],单击第二个按钮: 从中选择对象名称,在视图种单击拖动进行创建,特殊:线:摁[shift]限制水平,垂直方向: 2,二维对象参数: 在渲染中启用:显示二维线 ...
- Bash 翻译
Bash参考手册 目录 1简介 1.1什么是Bash? 1.2什么是shell? 2定义 3基本外壳功能 3.1 Shell语法 3.1.1外壳操作 3.1.2报价 3.1.2.1逃逸角色 3.1.2 ...
随机推荐
- .net平台下socket异步通讯
1,首先添加两个windows窗体项目,一个作为服务端server,一个作为客户端Client 2,然后添加服务端代码,添加命名空间,界面上添加TextBox控件 using System.Net; ...
- CentOS 6.4 64位 安装 mysql 5.6.24
下载安装包 由于官网访问及版本选择下载不太方便,使用 suho 的源进行下载 http://mirrors.sohu.com/mysql/MySQL-5.6/ 下载如下三个安装包: MySQL-ser ...
- mysql的查询缓存模式介绍
mysql的查询缓存 查询是数据库技术中最常用的操作.查询操作的过程比较简单,首先从客户端发出查询的SQL语句,数据库服务端在接收到由客户端发来的 SQL语句后, 执行这条SQL语句,然后将查询到的结 ...
- 精通 Oracle+Python,第 4 部分:事务和大型对象
通过 Python 管理数据事务.处理大型对象 2010 年 3 月发布 事务包含一组 SQL 语句,这组 SQL 语句构成数据库中的一个逻辑操作,如转帐或信用卡支付操作.将 SQL 语句聚合到一个逻 ...
- Python 手册——Python的非正式介绍
在后面的例子中,区分输入和输出的方法是看是否有提示符(“>>> ”和“.. ”):想要重复这些例子的话,你就要在提示符显示后输入所有的一切:没有以提示符开始的行,是解释器输出的信息. ...
- iOS 实现脉冲雷达以及动态增减元素 By Swift-感谢分享
Swift经过Xcode6 Beta4一版更新后,基本上已经可以作为生产工具了,虽然有一些地方和ObjC比起来要“落后”一些,但也无伤大雅.这里就用Xcode6 Beta4+iOS SDK 8.0开发 ...
- 自定义UICollectionViewController之后 如何设置UICollectionView的布局方式--备用
我们很多时候使用UICollectionView 可能都是直接创建 UICollectionView 通过初始化的时候 传入一个布局对象的方式来使用UICollectionView 比如我们之前 ...
- Java实现希尔排序
华杰让我看了一道面试题:现有一段程序S,可以对任意n个数进行排序.如果现在需要对n^2个数进行排序,最少需要调用S多少次?(只允许调用S,不可以做别的操作). 看到了这 ...
- 转:synchronized和LOCK的实现原理---深入JVM锁机制
JVM底层又是如何实现synchronized的? 目前在Java中存在两种锁机制:synchronized和Lock,Lock接口及其实现类是JDK5增加的内容,其作者是大名鼎鼎的并发专家Doug ...
- Ajaxupload插件超级简单使用(php的ci框架)
Ajaxupload简单使用 友情提示:1.蓝色文字为必修改内容.2.#字符后面是解释该代码段的主要内容 备注: 该实例是用php的ci框架直接接收图片并 ...