ArcGlobe三维开发之五——获取并设置Globe图层的叠加次序

Globe中的图层类型主要有以下三种:

(1)、浮动图层(floating): 通过在要素几何、要素属性或图层级别设置中包含 Z 值,来定义其自身在 3D 空间中的位置。

(2)、叠加图层(draped):被放置在某个已知表面图层之上,以从该图层获得其Z值。

(3)、高程图层(Elevation):提供要在其上放置其他图层的 3D 表面。

1、首先初始化Globe对象

2、Get IGlobeDisplay and IGlobeDrawingOrder from globe. 

	IGlobeDisplay globeDisplay = globe.GlobeDisplay;
	IGlobeDrawingOrder globeDrawingOrder = (IGlobeDrawingOrder)globe; // Explicit cast.

     3、获取当前的图层绘制顺序。包括叠加图层、浮动图层、高程图层。

     IEnumLayer enumLayer = globeDrawingOrder.OrderedLayers;

     4、 从枚举图层中分离以上三种图层

    IEnumLayer baseLayers = globe.get_GlobeLayers(null,true,true,true);

IEnumLayer floatingLayers = globe.get_GlobeLayers(null,false,false,true);

      方法说明:IEnumLayer variable = IGlobe.get_GlobeLayers(pUID, bRecursive, bInBaseGlobe, bSortedByDrawingPriority)。

布尔值bInBaseGlobe—true表示返回叠加图层和高程图层;false则表示返回浮动图层;

bSortedByDrawingPriority--- true表示返回的结果按照图层的绘制优先级来排序

5、由于baseLayers中包含叠加图层和高程图层,因此要分离开来。其排列顺序为:
Elevation0
Elevation1
Draped0
Draped1

6、创建ArrayList来分别存储叠加图层和高程图层

 	ArrayList DrapedLayers = new ArrayList();
	ArrayList ElevationLayers = new ArrayList();
     7、遍历baseLayers,分离叠加图层和高程图层,并分别存储。(依据其图层属性分离)
<span style="white-space:pre">	</span>IGlobeLayerProperties globeLayerProperties;
<span style="white-space:pre">	</span>// It is not set to anything here but is used later in the loop.
<span style="white-space:pre">	</span>IGlobeDisplayLayers globeDisplayLayers = (IGlobeDisplayLayers)globeDisplay; 
   <span style="white-space:pre">	</span> // Explicit cast.
<span style="white-space:pre">	</span>// Store the separate draw order (elevation and draped) into ArrayLists.
<span style="white-space:pre">	</span>ILayer layer = baseLayers.Next();
<span style="white-space:pre">	</span>while (layer != null)
<span style="white-space:pre">	</span>{
   <span style="white-space:pre">	</span> globeLayerProperties = globeDisplayLayers.FindGlobeProperties(layer);
    <span style="white-space:pre">	</span>// globeLayerProperties is finally set to something.
   <span style="white-space:pre">	</span> if (globeLayerProperties.Type != esriGlobeDataType.esriGlobeDataElevation)
   <span style="white-space:pre">	</span> {
       <span style="white-space:pre">		</span> DrapedLayers.Add(layer);
  <span style="white-space:pre">	</span>  }
  <span style="white-space:pre">	</span>  else if (globeLayerProperties.Type == esriGlobeDataType.esriGlobeDataElevation)
  <span style="white-space:pre">	</span>  {
      <span style="white-space:pre">	</span>  ElevationLayers.Add(layer);
  <span style="white-space:pre">	</span>  }
   <span style="white-space:pre">	</span> //Get the next layer.
    <span style="white-space:pre">	</span>layer = baseLayers.Next();
<span style="white-space:pre">	</span>}

8、一旦图层分离开来,并可以获取单个图层
<span style="white-space:pre">	</span>// To get the layers from the ArrayLists, cast individual elements to ILayer.
<span style="white-space:pre">	</span>// For example, getting the first layer in the DrapedLayers list:
<span style="white-space:pre">	</span>ILayer theDrapedLayer = (ILayer)DrapedLayers[0]; // Explicit cast.
9、 IGlobeDrawingOrder 可以用来改变图层的绘制顺序。例如,将图层向前移动。
 
<span style="white-space:pre">	</span>/ For example, to move a layer backward:
<span style="white-space:pre">	</span>globeDrawingOrder.MoveBackward(theDrapedLayer);
<span style="white-space:pre">	</span>globeDisplay.RefreshViewers();

10、浮动图层存储在floatingLayers中。单个浮动图层可通过如下代码获得:
	
	
// Get the floating layers.
ILayer theFloatingLayer = floatingLayers.Next();
while (theFloatingLayer != null)
{
    // Code to work with theFloatingLayer.
    theFloatingLayer = floatingLayers.Next();
}





你可能感兴趣的:(Gis,arcgis,地理信息,esri,ArcGlobe)