转自原文 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、合并线

首先判断预合并的两条线拓扑关系,是否邻接关系;满足条件可以用关键字Merge实现,或者自定义方法,重新获取点的集合IPointCollection创建多线。
 

AE 线编辑的更多相关文章

  1. ArcGIS API for Silverlight 编辑Geometry

    概述 ArcMap的编辑功能是非常强大的,ArcEngine编写的CS程序也可以用到ArcMap中提供的编辑功能,那么ArcGIS API forSilverlight针对Geometry的编辑提供了 ...

  2. ArcGIS Engine 中的绘制与编辑

    1.线段绘制 基本步骤 构建形状 1. 创建 IPoint IPoint m_Point = new PointClass(); m_Point.PutCoords(x, y); 2. 创建 IPoi ...

  3. [转载]jQuery UI 使用

    最近项目中使用了一些插件来做页面,这里把jQuery UI的使用分享出来,希望 对新手有帮助.文章结尾附源码下载. 1     jQuery UI 2     为我所用 2.1     Tabs 2. ...

  4. 3DMAX-模型制作简介

    本文由博主(YinaPan)原创,转载请注明出处:http://www.cnblogs.com/YinaPan/p/3dmax_moxingzhizuo.html  一.快捷键: ALT + X 透明 ...

  5. Ubuntu下屏幕录像、后期处理不完全攻略

    提要 如果要做成果展示或者效果演示,通常需要录取屏幕生成视频文件,在windows中我们可以用屏幕录像专家在录像, vegas 来做后期处理,Ubuntu可以么? 答案时当然可以!虽然第一次用觉得有点 ...

  6. Lottie安卓开源动画库使用

    碉堡的Lottie Airbnb最近开源了一个名叫Lottie的动画库,它能够同时支持iOS,Android与ReactNative的开发.此消息一出,还在苦于探索自定义控件各种炫酷特效的我,兴奋地就 ...

  7. 配置 Sublime Text 3 作为Python R LaTeX Markdown IDE

    配置 Sublime Text 3 作为Python R LaTeX Markdown IDE 配置 Sublime Text 3 作为Python IDE IDE的基本功能:代码提醒.补全:编译文件 ...

  8. 3ds max学习笔记(十五)-- 二维图形的操作

    (二维图形的创建) 1,在命令面板的[新建],单击第二个按钮: 从中选择对象名称,在视图种单击拖动进行创建,特殊:线:摁[shift]限制水平,垂直方向: 2,二维对象参数: 在渲染中启用:显示二维线 ...

  9. 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 ...

随机推荐

  1. windows8一直更新不了的问题————解决方案

    以下是微软官方工程师的详细解答: 尊敬的佐先生: 您好! 感谢您联系微软技术支持!我是微软技术支持工程师,我姓张.我将协助您解决有关问题.您的问题编号是SRX 1274238225 对于您当前的更新问 ...

  2. web系统

    现在的web系统已经越来越多的应用缓存技术,而且缓存技术确实是能实足的增强系统性能的.我在项目中也开始接触一些缓存的需求. 开始简单的就用jvm(java托管内存)来做缓存,这样对于单个应用服务器来说 ...

  3. mysql备份sql,脚本

    MySQL 安装位置:/usr/local/mysq 论坛数据库名称为:bbs MySQL root 密码:123456 数据库备份目的地:/var/db_backup/ #! /bin/bash / ...

  4. Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法

    转自:http://blog.csdn.net/chuanchuan608/article/details/17915959 目前正在学习python,使用的工具为python3.2.3.发现3x版本 ...

  5. Axure RP的版本控制

    首先介绍一下Axure RP,Axure的发音是Ask-Sure,RP是Rapid Prototype的缩写,写到这里你知道了这是一款原型绘画工具.本节主要介绍Axure RP的版本管理也即Axure ...

  6. [译]36 Days of Web Testing(二)

    Day 7: Http 和 Https Why? 当在网络上传输一些私人,敏感信息时,应该采用加密的手段来保证这些信息在传输的过程中不被侦测到.Https协议正是这种实现机制. Https是一种广泛使 ...

  7. 关于执行ST_Geometry的st_centroid函数时报ORA-28579错误的问题

    环境 SDE版本:10./10.2/10.2.1/10.2.2 Oracle版本:11g R2 11.2.0.1 Windows版本:Windows Server 2008 R2 问题描述及原因 以全 ...

  8. Mac上RoR环境搭建问题

    昨天一晚上折磨的我啊都快疯掉了. 按照http://railstutorial-china.org方法配制,到rvm requirements这个命令执行时就麻烦事来了. WutekiMacBook- ...

  9. 【POJ1021】Intervals (最短路解差分约束)

    题目: Sample Input 5 3 7 3 8 10 3 6 8 1 1 3 1 10 11 1 Sample Output 6 题意: 我们选数,每个数只能选一次.给定n个条件[ai,bi]和 ...

  10. scanf(),fscanf的详解

    我们这里只讨论fscanf(或者scanf)的格式,因为这些细节在其他贴里并没有涉及,阅读此文,你可以少走一些弯路.只讲结果,深层原因并不分析. FILE *pFile:float x1; char ...