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 ...
随机推荐
- Input的readonly 属性与disabled属性
readonly 不可编辑,可以获得焦点,背景颜色默认灰色,值的字体颜色默认为灰色,值可以在请求中传递 disabled 不可编辑,不可以获得焦点,背景颜色默认灰色,值的字体颜色默认为灰色,值不可以在 ...
- 配置hive元数据库mysql时候出现 Unable to find the JDBC database jar on host : master
解决办法: cd /usr/share/java/,(没有java文件夹,自行创建)rz mysql-connector-java-***.jar,mv mysql-connector-java-* ...
- libConfuse的使用
前言 在软件编程中经常会使用到一些参数,在存储方面一般有使用XML的,也有使用文本文件的,或者使用数据库的等.我们软件平台一些参数是使用XML文件存储,在读取方面的速度还可以,但在写回文件速度一般.也 ...
- web版扫雷小游戏(三)
~~~接上篇,上篇介绍了游戏实现过程中第一个比较繁琐的地方,现在展现在玩家面前的是一个有血有肉的棋盘,从某种意义上说玩家已经可以开始游戏了,但是不够人性化,玩家只能一个一个节点的点开,然后判断,然后标 ...
- .net 对配置文件内容的操作
配置文件分为两种 :一种是winform应用程序的配置文件, 一种是web的配置文件. 两种配置文件最大的区别是web的配置文件更新之后会时时更新, 应用程序的配置文件不会实时更新. 更新应用程序的配 ...
- JavaScript学习心得(七)
一 创建事件监听器 开发人员往往使用事件和元素组合来命名事件处理函数. 创建事件监听器方法: 嵌入式事件处理器即将JavaScript函数赋值给HTML元素属性(不推荐使用:污染HTML:无法应用渐进 ...
- 移动端Web开发如何处理横竖屏
<!Doctype html> <html> <head> <meta charset="utf-8"> <meta id=& ...
- Linux 多用户和多用户边界
1. 需求背景 2. 多用户的边界: 独立的工作目录 3. 多用户的边界:可操作/访问的资源 4. 多用户的边界: 可执行的操作 5. 多用户的特性标识: UID和GID -------------- ...
- mvc action 参数绑定——值提供器【学习笔记】
每次http请求的各种数据(表单数据.url的数据.路由数据等等)都保存在不同的IValueProvider接口的实现类中. 而IValueProvider接口的实现类是通过ValueProvider ...
- [BZOJ 1028] [JSOI2007] 麻将 【枚举+贪心判断】
题目链接:BZOJ - 1028 题目分析 枚举听的是哪种牌,再枚举成对的是哪种牌,再贪心判断: 从1到n枚举每一种牌,如果这种牌的个数小于0,就返回不合法. 将这种牌的张数 % 3, 剩下的只能和 ...