Source code of 3D query based on AE

Source: Internet
Author: User
Source code of 3D query based on AE

Public Type m_pObjArray
IFeature As iFeature
ILayerName As String
End Type
Public M_pFeatureArray () As m_pObjArray

Private Sub ArcSceneControl_OnMouseDown (ByVal Button As Long, ByVal Shift As Long, ByVal X As Long, ByVal Y As Long)
ArcSceneControl. SceneGraph. IsNavigating = False
Call Identify3DMap (X, Y)
End sub

'Input: Current 3D map, x coordinate, y coordinate, reference public variable M_pFeatureArray
'Output: select the target on the 3D map. Call frmidentify to display the information of the selected target.
'Function: single-point Query
'Program: tjh 2005.1.29
Private Sub Identify3DMap (X As Long, Y As Long)

'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''' ''''''''''''

'Qi for IBasicMap from IScene
Dim pBasicMap As IBasicMap
Set pBasicMap = ArcSceneControl. SceneGraph. Scene
'Qi for IScreenDisplay from ISceneGraph
Dim pScreenDisplay As IScreenDisplay
Set pScreenDisplay = ArcSceneControl. SceneGraph

'Translate screen coordinates into mulitple 3D objects
Dim pHit3DSet As IHit3DSet
ArcSceneControl. SceneGraph. LocateMultiple ArcSceneControl. SceneGraph. ActiveViewer, X, Y, esriScenePickGeography, False, pHit3DSet

'Reduce the hit set to the top
'Most hits and one hit per layer
PHit3DSet. Topmost 1.5
PHit3DSet. OnePerLayer
PHit3DSet. Topmost 1.1

'Get an array of hits
Dim pArray As IArray
Set pArray = pHit3DSet. Hits
If pArray. Count = 0 Then Exit Sub

'Loop through each hit
Dim I As Integer
ReDim M_pFeatureArray (0)
For I = 0 To pArray. Count-1

'Get the hit
Dim pHit3D As IHit3D
Set pHit3D = pArray. Element (I)
'Get the hit location
Dim pPoint As IPoint
Set pPoint = pHit3D. Point
If pPoint Is Nothing Then Exit Sub
'Get the layer that was hit
If Not TypeOf pHit3D. Owner Is ILayer Then Exit Sub
Dim pLayer As ILayer
Set pLayer = pHit3D. Owner
'Get the feature that was hit
Dim pObject As IUnknown
Set pObject = pHit3D. object

'Add to identify dialog
ReDim Preserve M_pFeatureArray (UBound (M_pFeatureArray) + 1)
Dim pFeature As iFeature
Set pFeature = pHit3D. object
Set M_pFeatureArray (UBound (M_pFeatureArray)-1). iFeature = pFeature
M_pFeatureArray (UBound (M_pFeatureArray)-1). iLayerName = CStr (pLayer. Name)

Next I

'''''''''''''''''''''''''''''''''''''''' '''''''''
If frmidenible. Visible = False Then
FrmIdentify. Show 0
End If
FrmIdentify. SetFocus
Call frmidenview. InitTreeView
End SubPrivate m_hwndTV As Long
'Input: External Public variable M_pFeatureArray
'Output:
'Function: add the attributes and layers of the target to the treeview.
'Program: tjh 2005.1.29
Public Sub InitTreeView ()
Dim I As Long, j As Long
Dim blCheck As Boolean
On Error Resume Next
TreeView. Nodes. Clear
For I = 0 To UBound (M_pFeatureArray)-1
BlCheck = False
For j = 0 To ComboLayer. ListCount
If M_pFeatureArray (I). iLayerName = ComboLayer. List (j) Then
BlCheck = True
Exit
End If
Next j
If blCheck = False Then
ComboLayer. AddItem M_pFeatureArray (I). iLayerName
End If
Next I

''''' ''' Customizes the treeview Tree node tree '''''''''''''''''''''
MSFlexGrid. cols = 2
MSFlexGrid. ColAlignment (1) = flexAlignLeftCenter
MSFlexGrid. TextMatrix (0, 0) = "field"
MSFlexGrid. ColWidth (0) = 1600
MSFlexGrid. ColWidth (1) = 2500
MSFlexGrid. TextMatrix (0, 1) = "value"
If UBound (M_pFeatureArray) = 0 Then Exit Sub
Dim Node1 As Node
Dim Node2 As Node
ComboLayer. Text = ComboLayer. List (0)

For I = 0 To ComboLayer. ListCount-1
Set Node1 = TreeView. Nodes. Add (, ComboLayer. List (I ))
For j = 0 To UBound (M_pFeatureArray)-1
If M_pFeatureArray (j). iLayerName = ComboLayer. List (I) Then
Set Node2 = TreeView. Nodes. Add (Node1.Index, tvwChild, CStr (M_pFeatureArray (j). iFeature. Value (0 )))
End If
Next
If I = 0 Then
Node1.Expanded = True
End If
Next I
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''

MSFlexGrid. Rows = M_pFeatureArray (0). iFeature. Fields. FieldCount + 10
For I = 0 To M_pFeatureArray (0). iFeature. Fields. FieldCount-1
MSFlexGrid. TextMatrix (I + 1, 0) = M_pFeatureArray (0). iFeature. Fields. Field (I). AliasName
If M_pFeatureArray (0). iFeature. Fields. Field (I). Type = 7 Then
MSFlexGrid. TextMatrix (I + 1, 1) = ReturnGeometryName (M_pFeatureArray (0). iFeature. Shape. GeometryType)
Else
MSFlexGrid. TextMatrix (I + 1, 1) = CStr (M_pFeatureArray (0). iFeature. Value (I) + ""
End If
Next I
Dim strXY As String
StrXY = CStr (M_pFeatureArray (0). iFeature. Extent. xMin) + "" + CStr (M_pFeatureArray (0). iFeature. Extent. yMin)
TextCor. Text = "Location: (" + strXY + ")"
Dim pobjGeometry As IGeometry
Set pobjGeometry = M_pFeatureArray (0). iFeature. Shape
Dim pDisplay3D As IDisplay3D
If m_CheckOperate = isQuery Then
'Call FlashFeature (M_pFeatureArray (I). iFeature, frmMapControl. arcMapControl. ActiveView. FocusMap)
FrmMapControl. arcMapControl. FlashShape pobjGeometry
ElseIf m_CheckOperate = iscls3dQuery Then
Set pDisplay3D = FrmMap3D. ArcSceneControl. Scene. SceneGraph
PDisplay3D. AddFlashFeature pobjGeometry
PDisplay3D. FlashFeatures
End If


'Show the nodes that are blChecked.
End Sub

Private Sub Form_Load ()
'Me. Move (frmMain. Width-Me. Width), frmMain. Top

End Sub

Private Sub Form_Unload (cancel As Integer)
ReDim M_pFeatureArray (0)
End Sub

'Input: -- call the ModFlash Process
'Output: Target flash
'Function: flashes the clicked target on the map.
'Program: tjh 2005.1.29
Private Sub TreeView_NodeClick (ByVal Node As MSComctlLib. Node)
Dim I As Long
Dim j As Long
Dim iLayerName As String
Dim ObjName As String
Dim pDisplay3D As IDisplay3D

On Error Resume Next
If Not Node. Parent Is Nothing Then
ILayerName = Node. Parent. Text
ObjName = Node. Text
For I = 0 To UBound (M_pFeatureArray)-1
If iLayerName = M_pFeatureArray (I). iLayerName And ObjName = CStr (M_pFeatureArray (I). iFeature. Value (0) Then
MSFlexGrid. Clear
MSFlexGrid. cols = 2
MSFlexGrid. ColAlignment (1) = flexAlignLeftCenter
MSFlexGrid. TextMatrix (0, 0) = "field"
MSFlexGrid. ColWidth (0) = 1600
MSFlexGrid. ColWidth (1) = 2500
MSFlexGrid. TextMatrix (0, 1) = "value"
MSFlexGrid. Rows = M_pFeatureArray (I). iFeature. Fields. FieldCount + 10
For j = 0 To M_pFeatureArray (I). iFeature. Fields. FieldCount-1
MSFlexGrid. TextMatrix (j + 1, 0) = M_pFeatureArray (I). iFeature. Fields. Field (j). AliasName
If M_pFeatureArray (I). iFeature. Fields. Field (j). Type = 7 Then
MSFlexGrid. TextMatrix (j + 1, 1) = ReturnGeometryName (M_pFeatureArray (I). iFeature. Shape. GeometryType)
Else
MSFlexGrid. TextMatrix (j + 1, 1) = M_pFeatureArray (I). iFeature. Value (j)
End If
Next j

Dim pobjGeometry As IGeometry
Set pobjGeometry = M_pFeatureArray (I). iFeature. Shape
If m_CheckOperate = isQuery Then
Call FlashFeature (M_pFeatureArray (I). iFeature, frmMapControl. arcMapControl. ActiveView. FocusMap)
ElseIf m_CheckOperate = iscls3dQuery Then
Set pDisplay3D = FrmMap3D. ArcSceneControl. Scene. SceneGraph
PDisplay3D. AddFlashFeature M_pFeatureArray (I). iFeature. Shape
PDisplay3D. FlashFeatures
End If
MSFlexGrid. TopRow = 1
Dim strXY As String
StrXY = CStr (M_pFeatureArray (I). iFeature. Extent. xMin) + "" + CStr (M_pFeatureArray (I). iFeature. Extent. yMin)
TextCor. Text = "Location: (" + strXY + ")"
Exit
End If
Next I
End If
End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.