alearner
路人甲
路人甲
  • 注册日期2006-09-11
  • 发帖数74
  • QQ
  • 铜币433枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1687回复:3

基于AE的三维查询源代码

楼主#
更多 发布于:2007-05-17 18:49
基于AE的三维查询源代码<BR><BR>
<DIV >Public Type m_pObjArray<BR>      iFeature As iFeature<BR>      iLayerName As String<BR>End Type<BR>Public M_pFeatureArray() As m_pObjArray<BR><BR>Private Sub ArcSceneControl_OnMouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal X As Long, ByVal Y As Long)<BR>              ArcSceneControl.SceneGraph.IsNavigating = False<BR>              Call Identify3DMap(X, Y)<BR>end sub<BR><BR>'输入:当前3D地图,x坐标,y坐标,引用公共变量M_pFeatureArray<BR>'输出:对3D地图上的目标选中,调用frmidentify显示选中目标的信息<BR>'功能:单点查询<BR>'程序:tjh 2005.1.29<BR>Private Sub Identify3DMap(X As Long, Y As Long)<BR>    <BR>    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>    <BR>        'QI for IBasicMap from IScene<BR>      Dim pBasicMap As IBasicMap<BR>      Set pBasicMap = ArcSceneControl.SceneGraph.Scene<BR>      'QI for IScreenDisplay from ISceneGraph<BR>      Dim pScreenDisplay As IScreenDisplay<BR>      Set pScreenDisplay = ArcSceneControl.SceneGraph<BR>   <BR>      'Translate screen coordinates into mulitple 3D objects<BR>      Dim pHit3DSet As IHit3DSet<BR>      ArcSceneControl.SceneGraph.LocateMultiple ArcSceneControl.SceneGraph.ActiveViewer, X, Y, esriScenePickGeography, False, pHit3DSet<BR>      <BR>      'Reduce the hit set to the top<BR>      'most hits and one hit per layer<BR>      pHit3DSet.Topmost 1.5<BR>      pHit3DSet.OnePerLayer<BR>      pHit3DSet.Topmost 1.1<BR>      <BR>      'Get an array of hits<BR>      Dim pArray As IArray<BR>      Set pArray = pHit3DSet.Hits<BR>      If pArray.Count = 0 Then Exit Sub<BR>    <BR>      'Loop through each hit<BR>      Dim i As Integer<BR>      ReDim M_pFeatureArray(0)<BR>      For i = 0 To pArray.Count - 1<BR>        <BR>        'Get the hit<BR>        Dim pHit3D As IHit3D<BR>        Set pHit3D = pArray.Element(i)<BR>        'Get the hit location<BR>        Dim pPoint As IPoint<BR>        Set pPoint = pHit3D.Point<BR>        If pPoint Is Nothing Then Exit Sub<BR>        'Get the layer that was hit<BR>        If Not TypeOf pHit3D.Owner Is ILayer Then Exit Sub<BR>        Dim pLayer As ILayer<BR>        Set pLayer = pHit3D.Owner<BR>        'Get the feature that was hit<BR>        Dim pObject As IUnknown<BR>        Set pObject = pHit3D.object<BR>        <BR>        'Add to identify dialog<BR>        ReDim Preserve M_pFeatureArray(UBound(M_pFeatureArray) + 1)<BR>        Dim pFeature As iFeature<BR>        Set pFeature = pHit3D.object<BR>        Set M_pFeatureArray(UBound(M_pFeatureArray) - 1).iFeature = pFeature<BR>        M_pFeatureArray(UBound(M_pFeatureArray) - 1).iLayerName = CStr(pLayer.Name)<BR>    <BR>      Next i<BR>    <BR>     '''''''''''''''''''''''''''''''''''''''''''''''''<BR>     If frmIdentify.Visible = False Then<BR>        frmIdentify.Show 0<BR>     End If<BR>      frmIdentify.SetFocus<BR>     Call frmIdentify.InitTreeView<BR>End Sub</DIV>
喜欢0 评分0
alearner
路人甲
路人甲
  • 注册日期2006-09-11
  • 发帖数74
  • QQ
  • 铜币433枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-05-17 18:49
<DIV 12px">Private m_hwndTV As Long<BR>'输入:外部公共变量M_pFeatureArray<BR>'输出:<BR>'功能:将查询到的目标的属性和所属图层添加到treeview中<BR>'程序:tjh 2005.1.29<BR>Public Sub InitTreeView()<BR>     Dim i As Long, j As Long<BR>     Dim blCheck As Boolean<BR>     On Error Resume Next<BR>     TreeView.Nodes.Clear<BR>     For i = 0 To UBound(M_pFeatureArray) - 1<BR>         blCheck = False<BR>         For j = 0 To ComboLayer.ListCount<BR>             If M_pFeatureArray(i).iLayerName = ComboLayer.List(j) Then<BR>               blCheck = True<BR>               Exit For<BR>             End If<BR>         Next j<BR>         If blCheck = False Then<BR>             ComboLayer.AddItem M_pFeatureArray(i).iLayerName<BR>         End If<BR>     Next i<BR>     <BR>    ''''''''''''''''定制treeview树节点树'''''''''''''''''''''<BR>    MSFlexGrid.cols = 2<BR>    MSFlexGrid.ColAlignment(1) = flexAlignLeftCenter<BR>    MSFlexGrid.TextMatrix(0, 0) = "字段"<BR>    MSFlexGrid.ColWidth(0) = 1600<BR>    MSFlexGrid.ColWidth(1) = 2500<BR>    MSFlexGrid.TextMatrix(0, 1) = "值"<BR>    If UBound(M_pFeatureArray) = 0 Then Exit Sub<BR>    Dim Node1 As Node<BR>    Dim Node2 As Node<BR>    ComboLayer.Text = ComboLayer.List(0)<BR>    <BR>    For i = 0 To ComboLayer.ListCount - 1<BR>      Set Node1 = TreeView.Nodes.Add(, , , ComboLayer.List(i))<BR>      For j = 0 To UBound(M_pFeatureArray) - 1<BR>        If M_pFeatureArray(j).iLayerName = ComboLayer.List(i) Then<BR>            Set Node2 = TreeView.Nodes.Add(Node1.Index, tvwChild, , CStr(M_pFeatureArray(j).iFeature.Value(0)))<BR>        End If<BR>      Next<BR>      If i = 0 Then<BR>         Node1.Expanded = True<BR>      End If<BR>    Next i<BR>    '''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>    <BR>    MSFlexGrid.Rows = M_pFeatureArray(0).iFeature.Fields.FieldCount + 10<BR>    For i = 0 To M_pFeatureArray(0).iFeature.Fields.FieldCount - 1<BR>       MSFlexGrid.TextMatrix(i + 1, 0) = M_pFeatureArray(0).iFeature.Fields.Field(i).AliasName<BR>       If M_pFeatureArray(0).iFeature.Fields.Field(i).Type = 7 Then<BR>          MSFlexGrid.TextMatrix(i + 1, 1) = ReturnGeometryName(M_pFeatureArray(0).iFeature.Shape.GeometryType)<BR>       Else<BR>          MSFlexGrid.TextMatrix(i + 1, 1) = CStr(M_pFeatureArray(0).iFeature.Value(i)) + ""<BR>       End If<BR>    Next i<BR>     Dim strXY As String<BR>      strXY = CStr(M_pFeatureArray(0).iFeature.Extent.xMin) + " " + CStr(M_pFeatureArray(0).iFeature.Extent.yMin)<BR>      TextCor.Text = "位置: (" + strXY + ")"<BR>    Dim pobjGeometry As IGeometry<BR>    Set pobjGeometry = M_pFeatureArray(0).iFeature.Shape<BR>    Dim pDisplay3D As IDisplay3D<BR>    If m_CheckOperate = isQuery Then<BR>       ' Call FlashFeature(M_pFeatureArray(i).iFeature, frmMapControl.arcMapControl.ActiveView.FocusMap)<BR>        frmMapControl.arcMapControl.FlashShape pobjGeometry<BR>    ElseIf m_CheckOperate = iscls3dQuery Then<BR>        Set pDisplay3D = FrmMap3D.ArcSceneControl.Scene.SceneGraph<BR>        pDisplay3D.AddFlashFeature pobjGeometry<BR>        pDisplay3D.FlashFeatures<BR>    End If<BR>                <BR>    <BR>    ' Show the nodes that are blChecked.<BR>End Sub<BR><BR>Private Sub Form_Load()<BR>   ' Me.Move (frmMain.Width - Me.Width), frmMain.Top<BR><BR>End Sub<BR><BR>Private Sub Form_Unload(cancel As Integer)<BR>    ReDim M_pFeatureArray(0)<BR>End Sub<BR><BR>'输入:--调用ModFlash中的过程<BR>'输出:目标flash<BR>'功能:将点击的目标在地图上闪烁<BR>'程序:tjh 2005.1.29<BR>Private Sub TreeView_NodeClick(ByVal Node As MSComctlLib.Node)<BR>    Dim i As Long<BR>    Dim j As Long<BR>    Dim iLayerName As String<BR>    Dim ObjName As String<BR>    Dim pDisplay3D As IDisplay3D<BR><BR>    On Error Resume Next<BR>    If Not Node.Parent Is Nothing Then<BR>        iLayerName = Node.Parent.Text<BR>        ObjName = Node.Text<BR>        For i = 0 To UBound(M_pFeatureArray) - 1<BR>            If iLayerName = M_pFeatureArray(i).iLayerName And ObjName = CStr(M_pFeatureArray(i).iFeature.Value(0)) Then<BR>                MSFlexGrid.Clear<BR>                MSFlexGrid.cols = 2<BR>                MSFlexGrid.ColAlignment(1) = flexAlignLeftCenter<BR>                MSFlexGrid.TextMatrix(0, 0) = "字段"<BR>                MSFlexGrid.ColWidth(0) = 1600<BR>                MSFlexGrid.ColWidth(1) = 2500<BR>                MSFlexGrid.TextMatrix(0, 1) = "值"<BR>                MSFlexGrid.Rows = M_pFeatureArray(i).iFeature.Fields.FieldCount + 10<BR>                For j = 0 To M_pFeatureArray(i).iFeature.Fields.FieldCount - 1<BR>                   MSFlexGrid.TextMatrix(j + 1, 0) = M_pFeatureArray(i).iFeature.Fields.Field(j).AliasName<BR>                   If M_pFeatureArray(i).iFeature.Fields.Field(j).Type = 7 Then<BR>                      MSFlexGrid.TextMatrix(j + 1, 1) = ReturnGeometryName(M_pFeatureArray(i).iFeature.Shape.GeometryType)<BR>                   Else<BR>                      MSFlexGrid.TextMatrix(j + 1, 1) = M_pFeatureArray(i).iFeature.Value(j)<BR>                   End If<BR>                Next j<BR>               <BR>                Dim pobjGeometry As IGeometry<BR>                Set pobjGeometry = M_pFeatureArray(i).iFeature.Shape<BR>                If m_CheckOperate = isQuery Then<BR>                    Call FlashFeature(M_pFeatureArray(i).iFeature, frmMapControl.arcMapControl.ActiveView.FocusMap)<BR>                ElseIf m_CheckOperate = iscls3dQuery Then<BR>                    Set pDisplay3D = FrmMap3D.ArcSceneControl.Scene.SceneGraph<BR>                    pDisplay3D.AddFlashFeature M_pFeatureArray(i).iFeature.Shape<BR>                    pDisplay3D.FlashFeatures<BR>                End If<BR>                MSFlexGrid.TopRow = 1<BR>                Dim strXY As String<BR>                strXY = CStr(M_pFeatureArray(i).iFeature.Extent.xMin) + " " + CStr(M_pFeatureArray(i).iFeature.Extent.yMin)<BR>                TextCor.Text = "位置: (" + strXY + ")"<BR>                Exit For<BR>            End If<BR>        Next i<BR>    End If<BR>End Sub</DIV>
举报 回复(0) 喜欢(0)     评分
cl991036
管理员
管理员
  • 注册日期2003-07-25
  • 发帖数5913
  • QQ14265545
  • 铜币29654枚
  • 威望213点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • GIS帝国铁杆
2楼#
发布于:2007-05-18 00:40
<img src="images/post/smile/dvbbs/em02.gif" />
没钱又丑,农村户口。头可断,发型一定不能乱。 邮箱:gisempire@qq.com
举报 回复(0) 喜欢(0)     评分
whmwxhanshan123
路人甲
路人甲
  • 注册日期2006-06-17
  • 发帖数3108
  • QQ
  • 铜币6445枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-05-20 19:41
没钱又丑<img src="images/post/smile/dvbbs/em01.gif" />
举报 回复(0) 喜欢(0)     评分
游客

返回顶部