天天看點

ArcGIS Engine 中的繪制與編輯1、線段繪制2、編輯3、繪制Element、Symbol 在控件上參考文章

基本步驟

建構形狀

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

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

其他方法

 View Code

點編輯:

<a></a>

線編輯:

1

2

3

4

5

6

7

8

9

10

<code>IGeometry polyline; </code>

<code>polyline = axMapControl1.TrackLine(); </code>

<code>ILineElement pLineElement; </code>

<code>pLineElement = </code><code>new</code> <code>LineElementClass(); </code>

<code>IElement pElement; </code>

<code>pElement = pLineElement </code><code>as</code> <code>IElement; </code>

<code>pElement.Geometry = polyline; </code>

<code>pGraphicsContainer = pMap </code><code>as</code> <code>IGraphicsContainer; </code>

<code>pGraphicsContainer.AddElement((IElement)pLineElement, 0); </code>

<code>pActiveView.Refresh(); </code>

 面編輯:

<code>IGeometry Polygon; </code>

<code>Polygon = axMapControl1.TrackPolygon(); </code>

<code>IPolygonElement PolygonElement; </code>

<code>PolygonElement = </code><code>new</code> <code>PolygonElementClass(); </code>

<code>pElement = PolygonElement </code><code>as</code> <code>IElement; </code>

<code>pElement.Geometry = Polygon; </code>

<code>pGraphicsContainer.AddElement((IElement)PolygonElement, 0); </code>

ArcEngine中畫shape點的另一種方法

做符号預覽的時候需要将ISymbol或IElement繪制到指定的控件上,下面邊碼邊說,一起讨論讨論:

ISymbol接口有Draw函數,查詢其接口可以發現,我們需要執行ISymbol.SetupDC -&gt; ISymbol.Draw -&gt; ISymbol.ResetDC 這三個步驟;

首先SetupDC需要參數 hDC和IDisplayTransformation;貼代碼:

例如:繪制在Panel上:

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;

其中 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幫助中找吧

<a href="http://blog.csdn.net/lab2013/article/details/6890474" target="_blank">ArcGIS Engine 線段繪制研究</a>

<a href="http://blog.csdn.net/scarlett_ohara/article/details/51159162">ArcEngine畫shapefile點,線,面</a>

<a href="http://blog.csdn.net/scarlett_ohara/article/details/51163573">ArcEngine中畫shape點的另一種方法</a>

<a href="http://blog.csdn.net/wangtao510/article/details/48675681" target="_blank">Arcengine 繪制Element、Symbol 在控件上</a>

沒有整理與歸納的知識,一文不值!高度概括與梳理的知識,才是自己真正的知識與技能。 永遠不要讓自己的自由、好奇、充滿創造力的想法被現實的架構所束縛,讓創造力自由成長吧! 多花時間,關心他(她)人,正如别人所關心你的。理想的騰飛與實作,沒有别人的支援與幫助,是萬萬不能的。

    本文轉自wenglabs部落格園部落格,原文連結:http://www.cnblogs.com/arxive/p/8145435.html,如需轉載請自行聯系原作者

繼續閱讀