INewFeedBack接口ArcGlobe

'该函数可以在二维和三维中使用

Private Function DrawLineUseDisplay(ByVal pActiveView As IActiveView, ByVal point1 As IPoint, ByVal point2 As IPoint, ByVal pLinesym As ILineSymbol) As IElement
        '使用iNewLineFeedback接口来画,涉及到Display
        Dim pNewLineFeedback As INewLineFeedback = New NewLineFeedback
        pNewLineFeedback.Display = pActiveView.ScreenDisplay
        pNewLineFeedback.Symbol = pLinesym

        Dim pElement As IElement = New LineElement
        Dim pLineElement As ILineElement
        pLineElement = pElement
        Dim feedbackLine As IGeometry = New Polyline

        pNewLineFeedback.Start(point1)

        pNewLineFeedback.AddPoint(point1)
        pNewLineFeedback.MoveTo(point1)
        pNewLineFeedback.AddPoint(point2)
        pNewLineFeedback.MoveTo(point2)

        '把图形保存下来

        feedbackLine = pNewLineFeedback.Stop()

        pLineElement = pElement
        pLineElement.Symbol = pLinesym

        pElement.Geometry = feedbackLine '把生成的polyline赋予element

        Return pElement
    End Function

'-----------------------
'三维中调用示例
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '与显示有关的设置
        Dim pGL As IGlobeGraphicsLayer
        pGL = New GlobeGraphicsLayer

        Dim pGEP As IGlobeGraphicsElementProperties

        '显示
        Dim pScene As IScene
        Dim pGlobeDisplay As IGlobeDisplay

        pGlobeDisplay = m_globe.GlobeDisplay
        pScene = pGlobeDisplay.Scene

        '图层属性设置
        pGEP = New GlobeGraphicsElementProperties
        pGEP.DrapeElement = True
        pGEP.DrapeZOffset = 500000
        '创建layer
        Dim pLayer As ILayer
        pLayer = pGL
        'pLayer = pGC3D
        pLayer.Name = "Layer1"
        m_globe.AddLayerType(pLayer, esriGlobeLayerType.esriGlobeLayerTypeDraped)
        pScene.ActiveGraphicsLayer = pLayer
        pGL = pLayer

        Dim pelement As IElement
        Dim pActiveView As IActiveView

        Dim pRedColor As IColor = New RgbColor
        Dim pLineSym As ISimpleLineSymbol = New SimpleLineSymbol

        pRedColor.RGB = RGB(230, 0, 0)
        pLineSym.Color = pRedColor
        pLineSym.Style = esriSimpleLineStyle.esriSLSSolid
        pLineSym.Width = 2

        Dim p1 As IPoint = New Point
        Dim p2 As IPoint = New Point

        p1.PutCoords(0, 0)
        p1.Z = 100000

        p2.PutCoords(50, 50)
        p2.Z = 100000

        pActiveView = m_globeControl.Globe

        pelement = DrawLineUseDisplay(pActiveView, p1, p2, pLineSym)
        'pelement = DrawLineWithPoints3D(p1, p2, True, pLineSym)

        pGL.AddElement(pelement, pGEP, 0)

        pActiveView.Refresh()

    End Sub

'----------------------
'二维中调用示例
 Dim pActiveView As IActiveView
 pActiveView = pMap
 Dim pGraphicsContainer as IGraphicsContainer
 pGraphicsContianer =pMap

 pElement = DrawLineUseDisplay(pActiveView, StartPoint, EndPoint, pLineSymbol)
 pGraphicsContainer.AddElement(pElement, 0) '修改后的属性加入到画好线的element里面

原文地址:https://www.cnblogs.com/wangzihao/p/1902149.html