Get and set globe layer drawing order to draw properly.
[C#]
///<summary>Get and set globe layer drawing order to draw properly.</summary> /// ///<param name="globe">An IGlobe interface</param> /// ///<remarks></remarks> public void DrawGlobeLayersInCorrectOrder(ESRI.ArcGIS.GlobeCore.IGlobe globe) { ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay = globe.GlobeDisplay; ESRI.ArcGIS.GlobeCore.IGlobeDrawingOrder globeDrawingOrder = (ESRI.ArcGIS.GlobeCore.IGlobeDrawingOrder)globe; // Explicit Cast // Get the current draw order - this includes draped, floating and elevation ESRI.ArcGIS.Carto.IEnumLayer enumLayer = globeDrawingOrder.OrderedLayers; // Need to separate BaseLayers from Floating // Syntax: // IEnumLayer variable = object.get_GlobeLayers(pUID, bRecursive, bInBaseGlobe, bSortedByDrawingPriority) ESRI.ArcGIS.Carto.IEnumLayer baseLayers = globe.get_GlobeLayers(null, true, true, true); ESRI.ArcGIS.Carto.IEnumLayer floatingLayers = globe.get_GlobeLayers(null, false, false, true); // weed out elevation layers from the ordered list... // note: elevation layers are always on top of the ordered list // The ordered list for baselayers is: // (Top down) // Elevation0 // Elevation1 // Draped0 // Draped1 ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties globeLayerProperties; // note: it is not set to anything here but used later in the while loop ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers globeDisplayLayers = (ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers)globeDisplay; // Explicit cast // Create ArrayLists System.Collections.ArrayList DrapedLayers = new System.Collections.ArrayList(); System.Collections.ArrayList ElevationLayers = new System.Collections.ArrayList(); // Store the separate draw order (elevation and draped) into ArrayLists ESRI.ArcGIS.Carto.ILayer layer = baseLayers.Next(); while (layer != null) { globeLayerProperties = globeDisplayLayers.FindGlobeProperties(layer); // globeLayerProperties is finally set to something if (globeLayerProperties.Type != ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation) { DrapedLayers.Add(layer); } else if (globeLayerProperties.Type == ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation) { ElevationLayers.Add(layer); } //Get the next layer layer = baseLayers.Next(); } // To get the layers from the ArrayLists - cast individual elements to ILayer // For example getting the first layer in the list: ESRI.ArcGIS.Carto.ILayer theDrapedLayer = (ESRI.ArcGIS.Carto.ILayer)DrapedLayers[0]; // Explicit cast // Changing the drawing order - use methods available on ESRI.ArcGIS.GlobeCore.IGlobeDrawingOrder // for example to move a layer backward globeDrawingOrder.MoveBackward(theDrapedLayer); globeDisplay.RefreshViewers(); // Get the floating layers ESRI.ArcGIS.Carto.ILayer theFloatingLayer = floatingLayers.Next(); while (theFloatingLayer != null) { // code to work with theFloatingLayer theFloatingLayer = floatingLayers.Next(); } }
[Visual Basic .NET]
'''<summary>Get and set globe layer drawing order to draw properly.</summary> ''' '''<param name="globe">An IGlobe interface</param> ''' '''<remarks></remarks> Public Sub DrawGlobeLayersInCorrectOrder(ByVal globe As ESRI.ArcGIS.GlobeCore.IGlobe) Dim globeDisplay As ESRI.ArcGIS.GlobeCore.IGlobeDisplay = globe.GlobeDisplay Dim globeDrawingOrder As ESRI.ArcGIS.GlobeCore.IGlobeDrawingOrder = CType(globe, ESRI.ArcGIS.GlobeCore.IGlobeDrawingOrder) ' Explicit Cast ' Get the current draw order - this includes draped, floating and elevation Dim enumLayer As ESRI.ArcGIS.Carto.IEnumLayer = globeDrawingOrder.OrderedLayers ' Need to separate BaseLayers from Floating ' Syntax: ' IEnumLayer variable = object.GlobeLayers(pUID, bRecursive, bInBaseGlobe, bSortedByDrawingPriority) Dim baseLayers As ESRI.ArcGIS.Carto.IEnumLayer = globe.GlobeLayers(Nothing, True, True, True) Dim floatingLayers As ESRI.ArcGIS.Carto.IEnumLayer = globe.GlobeLayers(Nothing, False, False, True) ' weed out elevation layers from the ordered list... ' note: elevation layers are always on top of the ordered list ' The ordered list for baselayers is: ' (Top down) ' Elevation0 ' Elevation1 ' Draped0 ' Draped1 Dim globeLayerProperties As ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties ' note: it is not set to anything here but used later in the while loop Dim globeDisplayLayers As ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers = CType(globeDisplay, ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers) ' Explicit Cast ' Create ArrayLists Dim DrapedLayers As System.Collections.ArrayList = New System.Collections.ArrayList Dim ElevationLayers As System.Collections.ArrayList = New System.Collections.ArrayList ' Store the separate draw order (elevation and draped) into ArrayLists Dim layer As ESRI.ArcGIS.Carto.ILayer = baseLayers.Next While Not (layer Is Nothing) globeLayerProperties = globeDisplayLayers.FindGlobeProperties(layer) 'globeLayerProperties is finally set to something If Not (globeLayerProperties.Type = ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation) Then DrapedLayers.Add(layer) Else If globeLayerProperties.Type = ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation Then ElevationLayers.Add(layer) End If End If layer = baseLayers.Next End While ' To get the layers from the ArrayLists - cast individual elements to ILayer ' For example getting the first layer in the list: Dim theDrapedLayer As ESRI.ArcGIS.Carto.ILayer = CType(DrapedLayers(0), ESRI.ArcGIS.Carto.ILayer) ' Explicit Cast ' Changing the drawing order - use methods available on ESRI.ArcGIS.GlobeCore.IGlobeDrawingOrder ' for example to move a layer backward globeDrawingOrder.MoveBackward(theDrapedLayer) globeDisplay.RefreshViewers() ' Get the floating layers Dim theFloatingLayer As ESRI.ArcGIS.Carto.ILayer = floatingLayers.Next While Not (theFloatingLayer Is Nothing) ' code to work with theFloatingLayer theFloatingLayer = floatingLayers.Next End While End Sub