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);

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

其他方法

private void DrawLine()
{
ILineElement pLineElement;
IElement pLElement; IPolyline pLine; RgbColor pColor = new RgbColor();
pColor.Red = ;
pColor.Green = ;
pColor.Blue = ; ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
pSimpleLineSymbol.Color = pColor;
pSimpleLineSymbol.Width = ; pLineElement = new LineElementClass();
pLineElement.Symbol = pSimpleLineSymbol; pLElement = pLineElement as IElement; IRubberBand pRubberBand;
pRubberBand = new RubberLineClass();
pLine = pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null) as IPolyline; pLElement.Geometry = pLine; IGraphicsContainer pGraphicsContainer;
pGraphicsContainer = axMapControl1.ActiveView as IGraphicsContainer; //把地图的当前view作为图片的容器 pGraphicsContainer.AddElement(pLElement, );//把刚刚的element转到容器上
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}

2、编辑

点编辑:

IPoint pt;
pt = axMapControl1.ToMapPoint(e.x, e.y);
IMarkerElement pMarkerElement;
pMarkerElement = new MarkerElementClass();
IElement pElement;
pElement = pMarkerElement as IElement;
pElement.Geometry = pt;
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)pMarkerElement, );
pActiveView.Refresh();

线编辑:

IGeometry polyline;
polyline = axMapControl1.TrackLine();
ILineElement pLineElement;
pLineElement = new LineElementClass();
IElement pElement;
pElement = pLineElement as IElement;
pElement.Geometry = polyline;
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)pLineElement, 0);
pActiveView.Refresh();

面编辑:

IGeometry Polygon;
Polygon = axMapControl1.TrackPolygon();
IPolygonElement PolygonElement;
PolygonElement = new PolygonElementClass();
IElement pElement;
pElement = PolygonElement as IElement;
pElement.Geometry = Polygon;
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
pActiveView.Refresh();

ArcEngine中画shape点的另一种方法

public override void OnMouseDown(int Button, int Shift, int X, int Y)
{ //base.OnMouseDown(Button, Shift, X, Y);
IFeatureLayer pFeatureLayer = mapControl.Map.get_Layer() as IFeatureLayer;
IFeatureClass fc = pFeatureLayer.FeatureClass;
IFeatureClassWrite fr = fc as IFeatureClassWrite;
IWorkspaceEdit pWorkspaceEdit = (fc as IDataset).Workspace as IWorkspaceEdit; IFeature pFeature;
IPoint pPoint;
//开始事物操作
pWorkspaceEdit.StartEditing(false); //开始编辑
pWorkspaceEdit.StartEditOperation(); pFeature = fc.CreateFeature();
pPoint = new PointClass();
IPoint Mp = mapControl.ToMapPoint(X, Y);
pPoint.PutCoords(Mp.X, Mp.Y);
pPoint.SpatialReference = mapControl.SpatialReference;
pFeature.Shape = pPoint;
pFeature.Store();
mapControl.ActiveView.Refresh();
if (Button == )
{
pWorkspaceEdit.StopEditOperation();
pWorkspaceEdit.StopEditing(true);
}
}

3、绘制Element、Symbol 在控件上

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

3.1 绘制在Panel上

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

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

例如:绘制在Panel上:

int width=Panel.Width;
int heigth=Panel.Heigth;
//绘制方法
Graphics graph=Graphics.FromHwnd(Panel.Handle);
graph.Clear(Panel.BackColor);
//分辨率
double dpi=graph.DpiX;
IEnvelope pEnve=new EnvelopeClass();
pEnve.PutCoords(,,width,heigth);
Ipoint pCenterPt=new PointClass;
pCenter.PutCoords(width/,height/); tagRECT myRect=new tagRECT();
设置MyRect 的 top=;bottom=heigh; left=,right=width; IDisplayransformation pDisTrans=new DisplayTrabsformation();
pDisTrans.VisiableBounds=pEnve;
pDisTrans.Bounds=pEnv;
pDisTrans.Set_DeviceFrame(ref myRect);
pDisTrans.Resolution=dpi; intPtr hdc=graph.GetHdc();
ISymbol.SetupDC(hec.ToInt32,pDisTrans);
ISymbol.Draw(pCenterPt);
ISymbol.ResetDC(); //绘制完成后 是否绘图对象
graph.ReleaseHdc(hdc);
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. Web开发者不容错过的10个HTML5工具

    HTML5已经成为当今世界的一个必然组成部分.由于World Wide Web万维网是使用超文本标记语言来架构和呈现的,于是HTML5成为了最流行的编程语言之一.随着网络的不断扩张,Web开发人员非常 ...

  2. 嵌入式C语言-学习书籍推荐(pdf附上百度云链接)

    先推荐学习视频网站: https://www.bilibili.com/video/av22631677?from=search&seid=800092160484173881 书籍只推荐2本 ...

  3. Python3简明教程(二)—— 变量和数据类型

    关键字和标识符 下列的标识符是Python3的关键字,并且不能用于通常的标识符.关键字必须严格按照下面的拼写: False def if raise None del import return Tr ...

  4. 关于websocket的代码,实现发送信息和监听信息(前端 后端(node.js))

    文件结构 node.js代码 // 需要HTTP 模块来启动服务器和Socket.IOvar http= require('http');var fs = require('fs');// 在8080 ...

  5. STL || Gym 101653U Top 25

    一组字符串给出两种排列方式, 求最小分成多少组 如 A     A B     C C    D D    B E    E 则分成3组 A B C D E 即为1 3 1 #include < ...

  6. 使用plsql导入dmp文件缺少imp*.exe

    在C:\app\Administrator\product\11.2.0\client_2\BIN 找到imp.exe 导入

  7. springmvc下载那些事

    文件的上传下载一般在项目中还是非常实用的,此处专门整理一下文件的下载,至于文件的上传实现将在后续中补上.文件的下载多用于模板文件的下载,这在项目中用的还是挺多的.今天用到了就整理出来了,以供搬运工们借 ...

  8. C++ new delete(一)

    在C#.Java這種managed語言,因為有garbage collection,所以完全不用考慮free()或delete,但在C/C++,有時候要delete的,有時又不用,到底哪些改delet ...

  9. Vue通信、传值的多种方式,详解

    Vue通信.传值的多种方式,详解 转自:https://blog.csdn.net/qq_35430000/article/details/79291287 一.通过路由带参数进行传值 ①两个组件 A ...

  10. SQL的几种连接

    1. 内连接 结果: 从左表中取出每一条记录,去右表中与所有的记录进行匹配: 匹配必须是某个条件是左表中与右表中相同,才会保留结果,否则不保留: 1.等值连接:在连接条件中使用等于号(=)运算符比较被 ...