在Arcscene绘制管线三维横断面(AE绘制三维点阵文字)

根据数据信息动态生成三维管线及横断面表格。效果图如下:

在获取信息后,直接构造点阵进行文字绘制即可。

绘制IElement代码:

        /// <summary>
        /// 绘制三维文字
       /// </summary>
       /// <param name="ppp">位置</param>
       /// <param name="text">文本</param>
       /// <param name="Fsize"></param>
       /// <param name="rgb">颜色</param>
       /// <param name="pTextJustification">对齐</param>
       /// <returns></returns>
        public IElement CreateElement( IPoint ppp, string text, double Fsize, int rgb,esriT3DJustification pTextJustification)
        {
            try
            {
                IPoint point = new PointClass();
                point = ppp;
                //point.Z = deep;
                IText3DElement Ptext3DElement = new Text3DElementClass();
                Ptext3DElement.AnchorPoint = point;
                Ptext3DElement.Text = text;
                Ptext3DElement.BoldFont = false;
                Ptext3DElement.Alignment = esriT3DAlignment.esriT3DAlignHorizontal;//对齐-控制字是横排还是竖排
                Ptext3DElement.AxisRotation = esriT3DRotationAxis.esriT3DRotateAxisX;//旋转轴x y z
                Ptext3DElement.ZAxisScale = 1;// 1.6;//z轴比例尺
                Ptext3DElement.Justification = pTextJustification;//对齐
                Ptext3DElement.Height = Fsize;

                Ptext3DElement.Depth = Fsize/5;
                Ptext3DElement.OrientationPlane = esriT3DOrientationPlane.esriT3DPlaneYZ;//初始方向,即文字所在平面

                //字体颜色
                IRgbColor Fcolor = new RgbColorClass();
                Fcolor.RGB = rgb;
                IFillSymbol pFillSymbol = new SimpleFillSymbol();
                pFillSymbol.Color = Fcolor;
                IFillShapeElement pFillShapeElement = Ptext3DElement as IFillShapeElement;
                pFillShapeElement.Symbol = pFillSymbol;

                return pFillShapeElement as IElement;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

绘制线:

        public IElement CreateLineElement(IPoint pS,IPoint pE ,int rgb,double lineWidth)
        {
            try
            {
                IRgbColor pRgbColor = new RgbColorClass();
                pRgbColor.RGB = rgb;
                ISimpleLine3DSymbol pSimpleLine3DSymbol = new SimpleLine3DSymbolClass();
                pSimpleLine3DSymbol.Style = esriSimple3DLineStyle.esriS3DLSTube;
                ILineSymbol pLineSymbol = pSimpleLine3DSymbol as ILineSymbol;
                pLineSymbol.Color = pRgbColor;
                pLineSymbol.Width = lineWidth;
               
                //将线段对象添加到多义线对象polyline  
                IPolyline polyline = new PolylineClass();
                object Missing1 = Type.Missing;
                object Missing2 = Type.Missing;
                polyline.FromPoint = pS;
                polyline.ToPoint = pE;

                //让Z值生效  
                IZAware Zaware = polyline as IZAware;
                Zaware.ZAware = true;

                IGeometry geometry = (IGeometry)polyline;
                IElement pElement = new LineElementClass();
                pElement.Geometry = geometry;
                ILineElement pLineElement = pElement as ILineElement;
                pLineElement.Symbol = pLineSymbol;

                return pLineElement as IElement;
  
            }
            catch (Exception ex)
            {
                return null;
            }
        }

 

将IElementCollection添加至控件:

        public void ADDElementCollectionToSceneControl2(AxSceneControl pSceneControl, IElementCollection pElCol)//IElementCollection
        {
            IScene pScene = pSceneControl.Scene;
            IGraphicsLayer m_GraphLayer = new GraphicsLayer3DClass();
            ILayer thisilayer = (ILayer)m_GraphLayer;
            thisilayer.Name = "label3d" + System.DateTime.Now.Minute + System.DateTime.Now.Second;
            pScene.AddLayer(thisilayer, true);
             
            I3DProperties p3DProps = RenderClass.Get3DPropsFromLayer(thisilayer);
            if (p3DProps != null)
            {
                p3DProps.RenderMode = esriRenderMode.esriRenderCache;
                p3DProps.Illuminate = false;
                p3DProps.Apply3DProperties(thisilayer);
            }
            //IGraphicsContainer3D pGC3D = (IGraphicsContainer3D)new ESRI.ArcGIS.GlobeCore.GlobeGraphicsLayer();
            //IGraphicsContainer3D pGC3D = (IGraphicsContainer3D)new ESRI.ArcGIS.GlobeCore.GlobeGraphicsLayerClass();
            IGraphicsContainer3D pGC3D = (IGraphicsContainer3D)new ESRI.ArcGIS.Analyst3D.GraphicsLayer3DClass();
            pGC3D = (IGraphicsContainer3D)m_GraphLayer; //让m_GraphLayer获得Container
            pGC3D.AddElements(pElCol);
            pScene.SceneGraph.RefreshViewers();
        }

 

posted @ 2016-11-29 16:05  Hxxxxxxyyyyyy  阅读(2635)  评论(0编辑  收藏  举报