How to get and set the drawing order of layers in globe(获取并设置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,分离叠加图层和高程图层,并分别存储。(依据其图层属性分离)
	IGlobeLayerProperties globeLayerProperties;
	// It is not set to anything here but is used later in the loop.
	IGlobeDisplayLayers globeDisplayLayers = (IGlobeDisplayLayers)globeDisplay; 
   	 // Explicit cast.
	// Store the separate draw order (elevation and draped) into ArrayLists.
	ILayer layer = baseLayers.Next();
	while (layer != null)
	{
   	 globeLayerProperties = globeDisplayLayers.FindGlobeProperties(layer);
    	// globeLayerProperties is finally set to something.
   	 if (globeLayerProperties.Type != esriGlobeDataType.esriGlobeDataElevation)
   	 {
       		 DrapedLayers.Add(layer);
  	  }
  	  else if (globeLayerProperties.Type == esriGlobeDataType.esriGlobeDataElevation)
  	  {
      	  ElevationLayers.Add(layer);
  	  }
   	 //Get the next layer.
    	layer = baseLayers.Next();
	}

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

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





How to get and set the drawing order of layers in globe(获取并设置Globe图层的叠加次序:),布布扣,bubuko.com

How to get and set the drawing order of layers in globe(获取并设置Globe图层的叠加次序:)

上一篇:Windows Azure Pack快速部署的软硬件需要


下一篇:简单实用的Windows命令