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 ...
随机推荐
- Python:文件操作
#!/usr/bin/python3 str1 = input("请输入:") print("你输入的是:",str1) f=open("abc.tx ...
- nl命令很好,很强大
指令名称: nl - 显示文件的行数及内容 语法: nl [OPTION]... [FILE]... 说明: 将指定文件的内容附加上行数,显示到标准输出. 当没有指定文件名或使用 ...
- 帝国cms7.0跳过[会员注册类型]这步的方法
改 e/config/config.php 文件,把$ecms_config['member']['changeregisterurl']="ChangeRegister.php" ...
- 2016022604 - redis命令介绍
Redis keys命令用于在Redis的管理键. Redis keys命令使用语法如下所示: redis最新版本目前是3.0.7 redis 127.0.0.1:6379> COMMAND K ...
- 用typedef给结构体一个别名
转:typedef 一.用typedef给结构体一个别名 typedef struct tagMyStruct { int iNum; long lLength; } MyStruct; 这语句实际上 ...
- GMM+Kalman Filter+Blob 目标跟踪
转 http://www.cnblogs.com/YangQiaoblog/p/5462453.html ==========图片版================================== ...
- adb的logcat使用
预备:安装刷机精灵,实用工具->adb命令行 1. 对于多机设备,首先使用adb devices来获知设备名称: 2. 将log输出到电脑:adb –s [设备名称] shell logcat ...
- SpringSecurity数据库中存储用户、角色、资源
这几天项目中用到了SpringSecurity做登陆安全.所以在这写一下也许可以帮助一下其他人,自己也熟悉一下 SpringSecurity配置文件如下: <beans:beans xmlns= ...
- 共享式以太网与交换式以太网的性能比较(OPNET网络仿真实验)
一.实验目的 比较共享式以太网和交换式以太网在不同网络规模下的性能. 二.实验方法 使用opnet来创建和模拟网络拓扑,并运行分析其性能. 三.实验内容 3.1 实验设置(网络拓扑.参数设置. ...
- JS模块加载器加载原理是怎么样的?
路人一: 原理一:id即路径 原则.通常我们的入口是这样的: require( [ 'a', 'b' ], callback ) .这里的 'a'.'b' 都是 ModuleId.通过 id 和路径的 ...