/// <summary> /// 根据输入的要素在SceneControl中绘制元素 张琪 20110621 /// </summary> /// <param name="pSceneControl"></param> /// <param name="pGeom">几何要素</param> /// <param name="pSym"></param> public void AddGraphic(ISceneControl pSceneControl, IGeometry pGeom, ISymbol pSym) { if (pGeom == null) { return; } IElement pElement = null; switch (pGeom.GeometryType.ToString()) { case "esriGeometryPoint": //点要素 pElement = new MarkerElementClass(); IMarkerElement pPointElement = pElement as IMarkerElement; if (pSym != null) { IMarkerSymbol pMarker3DSymbol = pSym as IMarkerSymbol; pPointElement.Symbol = pMarker3DSymbol as IMarkerSymbol; } break; case "esriGeometryPolyline": //线要素 pElement = new LineElementClass(); ILineElement pLineElement = pElement as ILineElement; if (pSym != null) { ILineSymbol pLineSymbol = pSym as ILineSymbol; pLineElement.Symbol = pLineSymbol; } break; case "esriGeometryPolygon": //面要素 pElement = new PolygonElementClass(); IFillShapeElement pFillElement = pElement as IFillShapeElement; if (pSym != null) { IFillSymbol pFillSymbol = pSym as IFillSymbol; pFillElement.Symbol = pFillSymbol; } break; case "esriGeometryMultiPatch": //多面体要素 pElement = new MultiPatchElementClass(); IFillShapeElement pMultiPatchElement = pElement as IFillShapeElement; if (pSym != null) { IFillSymbol pFillSymbol = pSym as IFillSymbol; pMultiPatchElement.Symbol = pFillSymbol as IFillSymbol; } break; } pElement.Geometry = pGeom; IGraphicsContainer3D pGCon3D = pSceneControl.Scene.BasicGraphicsLayer as IGraphicsContainer3D; pGCon3D.AddElement(pElement);//在SceneControl中绘制要素 IGraphicsSelection pGS = pGCon3D as IGraphicsSelection; pSceneControl.Scene.SceneGraph.RefreshViewers(); }
/// <summary> /// 根据IGeometry 生成一个Element,显示在地图上 /// </summary> /// <param name="pGC3D">element的容器</param> /// <param name="pGeom">element的几何信息</param> /// <param name="pSym">符号</param> /// <param name="sElementName">element的名称</param> public static void AddGraphics(IGraphicsContainer pGC, IGeometry pGeom, ISymbol pSym, string sElementName) { if (pGeom.IsEmpty) { return; } IElementProperties pElemProps; IElement pElement = null; IFillShapeElement pFillElement; //Point Type if (pGeom.GeometryType == esriGeometryType.esriGeometryPoint) { pElement = new MarkerElementClass(); IMarkerElement pPointElement; pPointElement = (IMarkerElement)pElement; pPointElement.Symbol = (IMarkerSymbol)pSym; pElement.Geometry = pGeom; } //Polyline Type else if (pGeom.GeometryType == esriGeometryType.esriGeometryPolyline) { pElement = new LineElementClass(); ILineElement pLineElement; pLineElement = (ILineElement)pElement; pLineElement.Symbol = (ILineSymbol)pSym; pElement.Geometry = pGeom; } //Polygon Type else if (pGeom.GeometryType == esriGeometryType.esriGeometryPolygon) { pElement = new PolygonElementClass(); pFillElement = (IFillShapeElement)pElement; pFillElement.Symbol = (IFillSymbol)pSym; pElement.Geometry = pGeom; } //MultiPatch Type else if (pGeom.GeometryType == esriGeometryType.esriGeometryMultiPatch) { pElement = new MultiPatchElementClass(); pFillElement = (IFillShapeElement)pElement; pFillElement.Symbol = (IFillSymbol)pSym; pElement.Geometry = pGeom; } if (pElement == null) { //Console.WriteLine("添加element时Element为null!"); return; } if (sElementName != "") { pElemProps = (IElementProperties)pElement; pElemProps.Name = sElementName; } pGC.AddElement(pElement, 1); }
public static IElement ConstructMultiPatchElement(IGeometry geometry, IColor color) { ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = color; IElement element = new MultiPatchElementClass(); element.Geometry = geometry; IFillShapeElement fillShapeElement = element as IFillShapeElement; fillShapeElement.Symbol = simpleFillSymbol; return element; }
public static IElement ConstructMultiPatchElement(IGeometry geometry, IColor color) { ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = color; IElement element = new MultiPatchElementClass(); element.Geometry = geometry; IFillShapeElement fillShapeElement = element as IFillShapeElement; fillShapeElement.Symbol = simpleFillSymbol; return(element); }
/// <summary> /// 绘制三维对象 张琪 20110628 /// </summary> /// <param name="pGeometry">三维对象</param> /// <param name="pColor">颜色</param> /// <param name="lSize">绘制的大小</param> /// <param name="sName">名称</param> /// <param name="pScene"></param> /// <param name="pGroup"></param> public static void AddSimpleGraphic(IGeometry pGeometry, IRgbColor pColor, int lSize, string sName, IScene pScene, IGroupElement pGroup) { if (pGeometry == null) { return; } IElement pElement = null; //ISymbol pSym; //根据绘制的对象类型对IElement进行不同的定义 switch (pGeometry.GeometryType.ToString()) { case "esriGeometryPoint": pElement = new MarkerElementClass(); IMarkerElement pPointElement = pElement as IMarkerElement; ISimpleMarkerSymbol pMSym = new SimpleMarkerSymbolClass(); pMSym.Color = pColor; pMSym.Size = lSize; pMSym.Style = esriSimpleMarkerStyle.esriSMSCircle; IMarkerSymbol pMarkerSymbol = pMSym as IMarkerSymbol; pPointElement.Symbol = pMarkerSymbol; break; case "esriGeometryPolyline": pElement = new LineElementClass(); ILineElement pLineElement = pElement as ILineElement; ISimpleLineSymbol pLSym = new SimpleLineSymbolClass(); pLSym.Width = lSize; pLSym.Style = esriSimpleLineStyle.esriSLSSolid; pLSym.Color = pColor; ILineSymbol pLineSymbol = pLSym as ILineSymbol; pLineElement.Symbol = pLineSymbol; break; case "esriGeometryPolygon": ISimpleLineSymbol pOutlineSym = new SimpleLineSymbolClass(); pOutlineSym.Color = pColor; pOutlineSym.Width = lSize; pOutlineSym.Style = esriSimpleLineStyle.esriSLSSolid; if (sName == "_ReferancePlane_") { pColor.Transparency = Convert.ToByte(Convert.ToInt32(255 / 2)); } pElement = new PolygonElementClass(); IFillShapeElement pPolygonElement = pElement as IFillShapeElement; IFillSymbol pFSym = new SimpleFillSymbolClass(); pFSym.Color = pColor; ILineSymbol pLineSymbol1 = pOutlineSym as ILineSymbol; pFSym.Outline = pLineSymbol1; pPolygonElement.Symbol = pFSym; break; case "esriGeometryMultiPatch": pElement = new MultiPatchElementClass(); IFillShapeElement pFElement = pElement as IFillShapeElement; IFillSymbol pFSymbol = pFElement.Symbol; if (sName == "_ReferancePlane_") { pColor.Transparency = Convert.ToByte(Convert.ToInt32(255 / 2)); } pFSymbol.Color = pColor; pFElement.Symbol = pFSymbol; break; default: break; } pElement.Geometry = pGeometry; IElementProperties pElemProps = pElement as IElementProperties; pElemProps.Name = sName; if (pGroup == null) { IGraphicsContainer3D pGCon3D = pScene.BasicGraphicsLayer as IGraphicsContainer3D; pGCon3D.AddElement(pElement); } else { pGroup.AddElement(pElement); } }