1、线段绘制

基本步骤

构建形状

1. 创建 IPoint
IPoint m_Point = new PointClass();
m_Point.PutCoords(x, y);

2. 创建 IPointCollection
IPointCollection m_PointCollection = new PolylineClass();
m_PointCollection.AddPoint(m_Point, ref Type.Missing, ref Type.Missing);

3. 创建 IPolyline
IPolyline m_Polyline = new PolylineClass();
m_Polyline = m_PointCollection as IPolyline;

4. 创建 IElement
// Element 不能实例化,需要用其派生类实例化
IElement m_Element = m_SimpleLineSymbol as IElement;
m_Element.Geometry = m_Polyline;

设置形状样式
1. 创建 ISimpleLineSymbol
ISimpleLineSymbol m_SimpleLineSymbol = new SimpleLineSymbolClass();

2. 创建 ILineElement
ILineElement m_LineElement = new LineElementClass();
m_LineElement.Symbol = m_SimpleLineSymbol;

加载到地图
IMap m_Map = axMapControl1.Map;
IActiveView m_ActiveView = m_Map as IActiveView;
IGraphicsContainer m_Container = m_Map as IGraphicsContainer;

m_Container.AddElement(m_Element, 0);

m_Active.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

-----------------------------------------------------------------------------------------------------------

其他方法

  1. private void DrawLine()
  2. {
  3. ILineElement pLineElement;
  4. IElement pLElement;
  5.  
  6. IPolyline pLine;
  7.  
  8. RgbColor pColor = new RgbColor();
  9. pColor.Red = ;
  10. pColor.Green = ;
  11. pColor.Blue = ;
  12.  
  13. ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
  14. pSimpleLineSymbol.Color = pColor;
  15. pSimpleLineSymbol.Width = ;
  16.  
  17. pLineElement = new LineElementClass();
  18. pLineElement.Symbol = pSimpleLineSymbol;
  19.  
  20. pLElement = pLineElement as IElement;
  21.  
  22. IRubberBand pRubberBand;
  23. pRubberBand = new RubberLineClass();
  24. pLine = pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null) as IPolyline;
  25.  
  26. pLElement.Geometry = pLine;
  27.  
  28. IGraphicsContainer pGraphicsContainer;
  29. pGraphicsContainer = axMapControl1.ActiveView as IGraphicsContainer; //把地图的当前view作为图片的容器
  30.  
  31. pGraphicsContainer.AddElement(pLElement, );//把刚刚的element转到容器上
  32. axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
  33. }

2、编辑

点编辑:

  1. IPoint pt;
  2. pt = axMapControl1.ToMapPoint(e.x, e.y);
  3. IMarkerElement pMarkerElement;
  4. pMarkerElement = new MarkerElementClass();
  5. IElement pElement;
  6. pElement = pMarkerElement as IElement;
  7. pElement.Geometry = pt;
  8. pGraphicsContainer = pMap as IGraphicsContainer;
  9. pGraphicsContainer.AddElement((IElement)pMarkerElement, );
  10. pActiveView.Refresh();

线编辑:

  1. IGeometry polyline;
  2. polyline = axMapControl1.TrackLine();
  3. ILineElement pLineElement;
  4. pLineElement = new LineElementClass();
  5. IElement pElement;
  6. pElement = pLineElement as IElement;
  7. pElement.Geometry = polyline;
  8. pGraphicsContainer = pMap as IGraphicsContainer;
  9. pGraphicsContainer.AddElement((IElement)pLineElement, 0);
  10. pActiveView.Refresh();

面编辑:

  1. IGeometry Polygon;
  2. Polygon = axMapControl1.TrackPolygon();
  3. IPolygonElement PolygonElement;
  4. PolygonElement = new PolygonElementClass();
  5. IElement pElement;
  6. pElement = PolygonElement as IElement;
  7. pElement.Geometry = Polygon;
  8. pGraphicsContainer = pMap as IGraphicsContainer;
  9. pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
  10. pActiveView.Refresh();

ArcEngine中画shape点的另一种方法

  1. public override void OnMouseDown(int Button, int Shift, int X, int Y)
  2. {
  3.  
  4. //base.OnMouseDown(Button, Shift, X, Y);
  5. IFeatureLayer pFeatureLayer = mapControl.Map.get_Layer() as IFeatureLayer;
  6. IFeatureClass fc = pFeatureLayer.FeatureClass;
  7. IFeatureClassWrite fr = fc as IFeatureClassWrite;
  8. IWorkspaceEdit pWorkspaceEdit = (fc as IDataset).Workspace as IWorkspaceEdit;
  9.  
  10. IFeature pFeature;
  11. IPoint pPoint;
  12. //开始事物操作
  13. pWorkspaceEdit.StartEditing(false);
  14.  
  15. //开始编辑
  16. pWorkspaceEdit.StartEditOperation();
  17.  
  18. pFeature = fc.CreateFeature();
  19. pPoint = new PointClass();
  20. IPoint Mp = mapControl.ToMapPoint(X, Y);
  21. pPoint.PutCoords(Mp.X, Mp.Y);
  22. pPoint.SpatialReference = mapControl.SpatialReference;
  23. pFeature.Shape = pPoint;
  24. pFeature.Store();
  25. mapControl.ActiveView.Refresh();
  26. if (Button == )
  27. {
  28. pWorkspaceEdit.StopEditOperation();
  29. pWorkspaceEdit.StopEditing(true);
  30. }
  31. }

3、绘制Element、Symbol 在控件上

做符号预览的时候需要将ISymbol或IElement绘制到指定的控件上,下面边码边说,一起讨论讨论:

3.1 绘制在Panel上

ISymbol接口有Draw函数,查询其接口可以发现,我们需要执行ISymbol.SetupDC -> ISymbol.Draw -> ISymbol.ResetDC 这三个步骤;

首先SetupDC需要参数 hDC和IDisplayTransformation;贴代码:

例如:绘制在Panel上:

  1. int width=Panel.Width;
  2. int heigth=Panel.Heigth;
  3. //绘制方法
  4. Graphics graph=Graphics.FromHwnd(Panel.Handle);
  5. graph.Clear(Panel.BackColor);
  6. //分辨率
  7. double dpi=graph.DpiX;
  8. IEnvelope pEnve=new EnvelopeClass();
  9. pEnve.PutCoords(,,width,heigth);
  10. Ipoint pCenterPt=new PointClass;
  11. pCenter.PutCoords(width/,height/);
  12.  
  13. tagRECT myRect=new tagRECT();
  14. 设置MyRect top=;bottom=heigh; left=,right=width;
  15.  
  16. IDisplayransformation pDisTrans=new DisplayTrabsformation();
  17. pDisTrans.VisiableBounds=pEnve;
  18. pDisTrans.Bounds=pEnv;
  19. pDisTrans.Set_DeviceFrame(ref myRect);
  20. pDisTrans.Resolution=dpi;
  21.  
  22. intPtr hdc=graph.GetHdc();
  23. ISymbol.SetupDC(hec.ToInt32,pDisTrans);
  24. ISymbol.Draw(pCenterPt);
  25. ISymbol.ResetDC();
  26.  
  27. //绘制完成后 是否绘图对象
  28. graph.ReleaseHdc(hdc);
  29. graph.Dispose();

Symbol的第二种方法

IStyleGalleryItem item=new ServerStyleGalleryItemClass();

item.Item=youSymbol;//你需要预览的ISymbol

stdole.IPictureDisp pic=axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass).PriviewItem(item,100,100);

Image img=Image.FormHbitmap(new IntPtr(pic.Handle));

picPriview.Image=img;

3.2 绘制Element 在Panel控件上

其中 graph、pCenterPoint、pDisTrans 的设置方式和上面一样

以绘制线段为例:

IDisplay pDisplay=new SimpleDisplay();

pDisplay.StartDrawing(graph.GetHdc(),ToInt32(),(short)esriScreeCache.esriNoScreeCache);

pDisplay.DisplayTransformation=pDisTrans;

pDisplay.SetSymbol(LineSymbol);//设置绘制线段的符号

pDisplay.DrawPolyline(IGeometry) ;//设置绘制线段的几何数据

//在arcgis帮助中找吧

参考文章

ArcGIS Engine 线段绘制研究

ArcEngine画shapefile点,线,面

ArcEngine中画shape点的另一种方法

Arcengine 绘制Element、Symbol 在控件上

Normal
0

7.8 磅
0
2

false
false
false

EN-US
ZH-CN
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-font-kerning:1.0pt;}

ArcGIS Engine 中的绘制与编辑的更多相关文章

  1. ArcGIS engine中Display类库——Display

    转自原文  ArcGIS engine中Display类库——Display Display类库包括了用于显示GIS数据的对象.除了负责实际输出图像的主要显示对象(display object)外,这 ...

  2. ArcGIS engine中Display类库 (局部刷新)

    转自原文 ArcGIS engine中Display类库 (局部刷新) Display类库包括了用于显示GIS数据的对象.除了负责实际输出图像的主要显示对象(display object)外,这个类库 ...

  3. ArcGIS Engine中的8种数据访问 (转)

    数据是GIS的基础, 访问数据也是进行任何复杂的空间分析及空间可视化表达的前提.ArcGIS支持的数据格式比较丰富,对不同的数据格式支持的程度也有很大差异.本文主要介绍一下以下八种数据格式在ArcGI ...

  4. ArcGIS Engine中的数据访问

    ArcGIS Engine中的数据访问 数据是GIS的基础, 访问数据也是进行任何复杂的空间分析及空间可视化表达的前提.ArcGIS支持的数据格式比较丰富,对不同的数据格式支持的程度也有很大差异.本文 ...

  5. ArcGIS Engine中的8种数据访问

    数据是GIS的基础, 访问数据也是进行任何复杂的空间分析及空间可视化表达的前提.ArcGIS支持的数据格式比较丰富,对不同的数据格式支持的程度也有很大差异.本文主要介绍一下以下八种数据格式在ArcGI ...

  6. [转] ArcGIS engine中气泡标注的添加、修改

    小生 原文 ArcGIS engine中气泡标注的添加.修改! 你微微地笑着,不同我说什么话.而我觉得,为了这个,我已等待得久了.                                   ...

  7. ArcGIS Engine中的Symbols详解

    转自原文ArcGIS Engine中的Symbols详解 本文由本人翻译ESRI官方帮助文档.尊重劳动成果,转载请注明来源. Symbols ArcObjects用了三种类型的Symbol(符号样式) ...

  8. ArcGIS Engine中的重点类库介绍

    转自原文ArcGIS Engine中的重点类库介绍 System类库 System类库是ArcGIS体系结构中最底层的类库.System类库包含给构成ArcGIS的其他类库提供服务的组件.System ...

  9. ArcGIS Engine中添加点、线、面元素

    转自原文 ArcGIS Engine中添加点.线.面元素 此种方式为IElement的方式在axMapControl的GraphicsContainer中好绘制图形. //画点 IPoint pt = ...

随机推荐

  1. vs2010 在函数级别设置优化

    平时开发的时候,为了方便调试,visual studio 的Configuration 设置成Release. 同时为了事后调试,Optimization总是设置成Disabled.这样做是方便查看变 ...

  2. params.row[params.column.key] vue h函数 当前单元格 h函数 div 属性 值或数组 render

    params.row[params.column.key] vue h函数 当前单元格 h函数 div 属性 值或数组 render

  3. DLL动态库多次加载问题

    原因涉及DLL加载和运行机制,主要有两点:1)DLL动态链接库无法独立运行,必须由一个应用程序进程加载到进程空间后才能使用.加载DLL的进程称为宿主进程.被加载的DLL属于宿主进程,不属于宿主进程内某 ...

  4. Mathematics-基础:斐波那契数列

    f(1)=1 f(2)=1 f(n)=f(n-1)+f(n-2) n>2

  5. 暑假集训 || bitset

    bitset是一个存储0和1的数组 可以快速的把两个bitset的每一位对应做与或啥的 在可以用01串表示某个状态的时候可以应用到它 就是有两个集合,求它们的交集 bitset <> a, ...

  6. Linux之常用Shell脚本总结

    一.简介本文将总结一些常用的shell脚本,方便以后工作中使用. 二.shell脚本[a]定期备份mysql数据库,需结合cronb定时任务调度实现. #!/bin/bash#首先声明一些自定义变量 ...

  7. HTML基础(五)表单

    表单的工作原理 简单来说就是客户在浏览器输入信息之后,浏览器将用户在表单中的数据进行打包发送给服务器,服务器接收到之后进行处理,如下图 语法 <form> 表单元素</form> ...

  8. sublime中项目无法添加文件夹

    问题记录 mac中,使用vue init webpack project 后,在sublime中打开,但是添加新文件夹和删除,总提示没有权限, 然后用git提交吧 也不行,每次都要sudo 出现的提示 ...

  9. 高逼格关闭Win10防火墙

    作为一个开发人员,你还需要进入这个界面来关闭防火墙么? 如果是,那么现在,我将为大家介绍一种高逼格的方式: 第一步: 打开Windows PowerShell(管理员) 第二步:查看当前防火墙状态:n ...

  10. composer 插件安装

    https://packagist.org/?q=phpmyadmin&p=0 Github:笔记 https://github.com/13431/php 类库包下载地址:packagist ...