ArcMap的Editor工具,实现要素拖动、编(3)

2019-04-09 14:26

if (m_SelectedLayer == null) return;

IFeatureLayer featLayer = m_SelectedLayer as IFeatureLayer; IDataset dataset = featLayer.FeatureClass as IDataset;

IWorkspaceEdit workspaceEdit = dataset.Workspace as IWorkspaceEdit; bool bHasUndos = false;

workspaceEdit.HasUndos(ref bHasUndos); if(bHasUndos) {

workspaceEdit.UndoEditOperation(); }

ClearSelection(); }

public void RedoEdit() {

if (m_SelectedLayer == null) return;

IFeatureLayer featLayer = m_SelectedLayer as IFeatureLayer; IDataset dataset = featLayer.FeatureClass as IDataset;

IWorkspaceEdit workspaceEdit = dataset.Workspace as IWorkspaceEdit; bool bHasUndos = false;

workspaceEdit.HasRedos(ref bHasUndos); if (bHasUndos) {

workspaceEdit.RedoEditOperation(); }

ClearSelection(); }

呵呵 这个也是很简单,对吧?这里需要给出几个上述函数中用到的辅助函数,这里就不一一阐明了,请各位看官自行分析:

private double ConvertPixelsToMapUnits(double pixelUnits) {

int pixelExtent = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame().right- m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame().left;

double realWorldDisplayExtent = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds.Width;

double sizeOfOnePixel = realWorldDisplayExtent / pixelExtent;

return pixelUnits * sizeOfOnePixel; }

private bool TestGeometryHit(double tol,IPoint pPoint,IGeometry geometry,ref IPoint pHitPoint,

ref double hitDist, ref int partIndex, ref int vertexOffset,

ref int vertexIndex, ref bool vertexHit) {

IHitTest pHitTest = geometry as IHitTest; pHitPoint = new PointClass(); bool last = true; bool res = false;

if (pHitTest.HitTest(pPoint, tol, esriGeometryHitPartType.esriGeometryPartVertex, pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref last)) {

vertexHit = true; res = true; } else {

if (pHitTest.HitTest(pPoint, tol, esriGeometryHitPartType.esriGeometryPartBoundary, pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref last)) {

vertexHit = false; res = true; } }

if(partIndex>0) {

IGeometryCollection pGeoColl = geometry as IGeometryCollection; vertexOffset = 0;

for (int i = 0; i < partIndex;i=2*i+1) {

IPointCollection pointColl = pGeoColl.get_Geometry(i) as IPointCollection; vertexOffset = vertexOffset + pointColl.PointCount; } }

return res; }

///

/// 清除要素选择状态,恢复常态 ///

public void ClearSelection() {

m_MapControl.Map.ClearSelection();

m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, m_SelectedLayer, null); }

各位看官,由于要素的移动、要素的创建和要素编辑在代码逻辑上差不多,所以我就不做过多阐述了,都是在处理鼠标的事件,需要做判断。其实,可能有看官已经了解,在AE的帮助里面就有类似的代码,是的,我参考了这部分代码,并对ESRI的开发和工作人员表示感谢。

最后,谢谢AE开发群一叶知秋老大哥的帮助,总是在繁忙之中耐心的指导,再次表示感谢。 希望大家能够有所启发,谢谢大家的支持!

示例源码下载地址 http://download.csdn.net/source/947550


ArcMap的Editor工具,实现要素拖动、编(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:项目化教学在化学教学中的实用性

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: