Beispiel #1
0
        /// <summary>
        /// 创建图元
        /// </summary>
        /// <param name="kml">模型的kml</param>
        /// <param name="layer">模型所在的图层</param>
        /// <returns></returns>
        public IMFElement CreateElement(Kml kml, ILayer layer)
        {
            KmlModel3d modelkml = kml.Placemark.Graph as KmlModel3d;

            if (modelkml == null)
            {
                return(null);
            }
            if (modelkml.Position == null)
            {
                return(null);
            }
            if (!File.Exists(modelkml.ModelFilePath))
            {
                return(null);
            }
            int index = -1;

            //图层
            IGlobeGraphicsLayer graphicLayer = layer as IGlobeGraphicsLayer;

            if (graphicLayer == null)
            {
                return(null);
            }

            //实例化图元
            Model3d_ArcGlobe modelElement = null;

            //添加图元
            this.Dosomething((Action) delegate()
            {
                IImport3DFile import3Dfile = null;
                if (!filePathDic.ContainsKey(modelkml.ModelFilePath))
                {
                    import3Dfile = new Import3DFileClass();
                    import3Dfile.CreateFromFile(modelkml.ModelFilePath);
                    filePathDic.Add(modelkml.ModelFilePath, import3Dfile);
                }
                else//模型已创建
                {
                    import3Dfile = filePathDic[modelkml.ModelFilePath];
                }

                modelElement = new Model3d_ArcGlobe(graphicLayer, modelkml, import3Dfile);

                //设置属性
                GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass();
                properties.Rasterize = modelkml.Rasterize;

                graphicLayer.AddElement(modelElement, properties, out index);
                modelElement.Index       = index;
                modelElement.ElementName = kml.Placemark.Name;
            }, true);

            return(modelElement);
        }
Beispiel #2
0
        /// <summary>
        /// 删除图元
        /// </summary>
        /// <param name="element">图元对象</param>
        /// <param name="layer">图元所在的图层</param>
        /// <returns></returns>
        public bool RemoveElement(IMFElement element, ILayer layer)
        {
            Model3d_ArcGlobe   modelElement      = element as Model3d_ArcGlobe;
            IGraphicsContainer graphicsContainer = layer as IGraphicsContainer;

            this.Dosomething((Action) delegate()
            {
                graphicsContainer.DeleteElement(modelElement);
            }, true);

            return(true);
        }