技术开发 频道

使用API在Scene或Globe中画橡皮条线


【IT168技术文档】

  在Scene或Globe中绘制橡皮条线的工具,其中wsUtilityBaseTool是我自己封装的基类,
  大家只需要把它替换成AE的BaseTool,把其中相应的代码放在相应的函数中,然后再进行一些简单的修改就好了
  附上VB.Net源码
Imports ESRI.ArcGIS.Analyst3D Imports ESRI.ArcGIS.Carto Imports ESRI.ArcGIS.Controls Imports ESRI.ArcGIS.Display Imports ESRI.ArcGIS.Geometry Imports ESRI.ArcGIS.GlobeCore Imports ESRI.ArcGIS.SystemUI Public Class wsSceneDrawLine Inherits wsUtilityBaseTool Private Declare Function Polygon Lib "gdi32" (ByVal hDC As Integer, ByVal lpPoint As Integer, ByVal nCount As Integer) As Integer Private Declare Function SetCapture Lib "USER32" (ByVal hWnd As Integer) As Integer Private Declare Function GetCapture Lib "USER32" () As Integer Private Declare Function ReleaseCapture Lib "USER32" () As Integer Private Declare Function GetCursorPos Lib "USER32" (ByVal lpPoint As PointAPI) As Integer Private Declare Function SetCursor Lib "USER32" (ByVal hCursor As Integer) As Integer Private Declare Function GetClientRect Lib "USER32" (ByVal hWnd As Integer, ByVal lpRect As rect) As Integer Private Declare Function GetWindowRect Lib "USER32" (ByVal hWnd As Integer, ByVal lpRect As rect) As Integer Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Integer, ByVal nWidth As Integer, ByVal crColor As Integer) As Integer Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Integer) As Integer Private Declare Function GetROP2 Lib "gdi32" (ByVal hDC As Integer) As Integer Private Declare Function SetROP2 Lib "gdi32" (ByVal hDC As Integer, ByVal nDrawMode As Integer) As Integer Private Declare Function Rectangle Lib "gdi32" (ByVal hDC As Integer, ByVal X1 As Integer, ByVal Y1 As Integer, ByVal X2 As Integer, ByVal Y2 As Integer) As Integer Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Integer) As Integer Private Declare Function Polyline Lib "gdi32" (ByVal hDC As Integer, ByVal lpPoint() As PointAPI, ByVal nCount As Integer) As Integer Private Declare Function CreatePolygonRgn Lib "gdi32" (ByVal lpPoint As Integer, ByVal nCount As Integer, ByVal nPolyFillMode As Integer) As Integer Private Structure rect Dim Left As Integer Dim Top As Integer Dim Right As Integer Dim Bottom As Integer End Structure Private Structure PointAPI Dim x As Integer Dim y As Integer End Structure Private m_pSceneHookhelper As ISceneHookHelper Private m_pGlobeHookhelper As IGlobeHookHelper Private m_bInUse As Boolean Private m_Pen As Long, m_Brush As Long Private m_lDrawMode As Long Private m_pUserLine As IPointCollection Private m_pGeoLine As IPointCollection Private m_MovePoint_Old As IPoint '当前点 Private m_pScene As IScene Private m_pSceneViewer As ISceneViewer Public Sub New() MyBase.New() MyBase.Tool = New ControlsScenePanTool MyBase.m_Caption = "画线" MyBase.m_ToolTip = "画线" MyBase.m_Name = "画线" MyBase.m_Message = "画线" m_pSceneHookHelper = New SceneHookHelper End Sub Public Overrides Sub OnCreate(ByVal hook As Object) m_pSceneHookhelper = New SceneHookHelper m_pSceneHookhelper.Hook = hook m_pSceneViewer = m_pSceneHookhelper.ActiveViewer m_pScene = m_pSceneHookhelper.Scene If m_pScene Is Nothing Then m_pGlobeHookhelper = New GlobeHookHelper m_pGlobeHookhelper.Hook = hook m_pSceneViewer = m_pGlobeHookhelper.ActiveViewer m_pScene = m_pGlobeHookhelper.Globe End If End Sub Public Overrides ReadOnly Property Enabled() As Boolean Get If (m_pSceneHookhelper.Scene Is Nothing) Then Return False Else Return True End If End Get End Property
0
相关文章