Пример #1
0
        /// <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();
        }
Пример #2
0
        public void AddGraphic(IScene iscene_0, IGeometry igeometry_0, ISymbol isymbol_0, bool bool_1, bool bool_2, string string_0)
        {
            if (!igeometry_0.IsEmpty)
            {
                IGraphicsLayer   basicGraphicsLayer = iscene_0.BasicGraphicsLayer;
                IElement         element            = null;
                esriGeometryType geometryType       = igeometry_0.GeometryType;
                switch (geometryType)
                {
                case esriGeometryType.esriGeometryPoint:
                {
                    element = new MarkerElement();
                    IMarkerElement markerElement = element as IMarkerElement;
                    if (isymbol_0 != null)
                    {
                        markerElement.Symbol = (isymbol_0 as IMarkerSymbol);
                    }
                    else
                    {
                        markerElement.Symbol = new SimpleMarkerSymbol();
                    }
                    break;
                }

                case esriGeometryType.esriGeometryMultipoint:
                    break;

                case esriGeometryType.esriGeometryPolyline:
                {
                    element = new LineElement();
                    ILineElement lineElement = element as ILineElement;
                    if (isymbol_0 != null)
                    {
                        lineElement.Symbol = (isymbol_0 as ILineSymbol);
                    }
                    else
                    {
                        lineElement.Symbol = new SimpleLineSymbol();
                    }
                    break;
                }

                case esriGeometryType.esriGeometryPolygon:
                {
                    element = new PolygonElement();
                    IFillShapeElement fillShapeElement = element as IFillShapeElement;
                    if (isymbol_0 != null)
                    {
                        fillShapeElement.Symbol = (isymbol_0 as IFillSymbol);
                    }
                    else
                    {
                        fillShapeElement.Symbol = new SimpleFillSymbol();
                    }
                    break;
                }

                default:
                    if (geometryType == esriGeometryType.esriGeometryMultiPatch)
                    {
                        element = new MultiPatchElement();
                        IFillShapeElement fillShapeElement = element as IFillShapeElement;
                        if (isymbol_0 != null)
                        {
                            fillShapeElement.Symbol = (isymbol_0 as IFillSymbol);
                        }
                        else
                        {
                            fillShapeElement.Symbol = new SimpleFillSymbol();
                        }
                    }
                    break;
                }
                if (element != null)
                {
                    element.Geometry = igeometry_0;
                    if (string_0.Length > 0)
                    {
                        IElementProperties elementProperties = element as IElementProperties;
                        elementProperties.Name = string_0;
                    }
                    IGraphicsContainer3D graphicsContainer3D = basicGraphicsLayer as IGraphicsContainer3D;
                    graphicsContainer3D.AddElement(element);
                    IGraphicsSelection graphicsSelection = graphicsContainer3D as IGraphicsSelection;
                    if (bool_2)
                    {
                        if (!bool_1)
                        {
                            graphicsSelection.UnselectAllElements();
                        }
                        graphicsSelection.SelectElement(element);
                    }
                    iscene_0.SceneGraph.RefreshViewers();
                }
            }
        }