lovegismore
路人甲
路人甲
  • 注册日期2006-07-25
  • 发帖数21
  • QQ
  • 铜币210枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1576回复:1

[求助]怎样更新移动顶点后的实体(附源码)?

楼主#
更多 发布于:2007-05-28 12:09
<P>我想通过移动polygon或polyline的顶点来修改这个实体,但是我在移动后却保存不了,不知道是不是我用的保存方法不对.还是要设置别的什么类的一些参数,下面是代码:</P>
<P>    Private m_ActiveView As IActiveView<BR>    Private m_pDispFeed As IDisplayFeedback<BR>    Public m_Geometry As IGeometry<BR>    Private m_StartPoint As IPoint<BR>    Private m_HitIndex As Long      '//顶点索引号<BR>    Private m_PartIndex As Long     '//part索引号</P>
<P>    Public Sub MoveVertexMouseDown(ByVal hitFeature As IFeature, ByVal hitPt As IPoint)<BR>        Dim dSrchDis As Double = 0.2  '//查找距离<BR>        Dim lParIndex As Long        '//part索引号<BR>        Dim lVerIndex As Long       '//顶点索引号<BR>        Dim pGeometry As IGeometry</P>
<P>        pGeometry = hitFeature.Shape<BR>        m_Geometry = pGeometry<BR>        m_StartPoint = hitPt<BR>        If HitTest(hitFeature, hitPt, dSrchDis, lParIndex, lVerIndex) Then<BR>            m_HitIndex = lVerIndex<BR>            m_PartIndex = lParIndex<BR>            If pGeometry.GeometryType = esriGeometryType.esriGeometryPolygon Then<BR>                m_pDispFeed = New PolygonMovePointFeedback<BR>                m_pDispFeed.Display = m_ActiveView.ScreenDisplay</P>
<P>                Dim pPolygonMovePointFeeaback As IPolygonMovePointFeedback<BR>                pPolygonMovePointFeeaback = m_pDispFeed<BR>                pPolygonMovePointFeeaback.Start(pGeometry, lVerIndex, hitPt)</P>
<P>            ElseIf pGeometry.GeometryType = esriGeometryType.esriGeometryPolyline Then<BR>                m_pDispFeed = New LineMovePointFeedback<BR>                m_pDispFeed.Display = m_ActiveView.ScreenDisplay</P>
<P>                Dim pLineMovePointFeedback As ILineMovePointFeedback<BR>                pLineMovePointFeedback = m_pDispFeed<BR>                pLineMovePointFeedback.Start(pGeometry, lVerIndex, hitPt)<BR>            End If<BR>        End If<BR>    End Sub</P>
<P>    Public Sub MoveVertexMouseMove(ByVal movePoint As IPoint)<BR>        If Not m_pDispFeed Is Nothing Then<BR>            m_pDispFeed.MoveTo(movePoint)<BR>        End If<BR>    End Sub</P>
<P>   Public Sub MoveVertexMouseUp(ByVal endPoint As IPoint)<BR>        Dim pGeometryCollection As IGeometryCollection<BR>        Dim pPointCollection As IPointCollection<BR>        Dim pTrans2D As ITransform2D</P>
<P>        On Error GoTo err_Handle<BR>        If Not m_pDispFeed Is Nothing Then<BR>            If m_Geometry.GeometryType = esriGeometryType.esriGeometryPolygon Then<BR>                Dim pPolygonMovePointFeedback As IPolygonMovePointFeedback<BR>                pPolygonMovePointFeedback = m_pDispFeed<BR>                pPolygonMovePointFeedback.Stop()<BR>            ElseIf m_Geometry.GeometryType = esriGeometryType.esriGeometryPolyline Then<BR>                Dim pLineMovePointFeedback As ILineMovePointFeedback<BR>                pLineMovePointFeedback = m_pDispFeed<BR>                pLineMovePointFeedback.Stop()<BR>            End If<BR>            pGeometryCollection = m_Geometry<BR>            pPointCollection = pGeometryCollection.Geometry(m_PartIndex)<BR>            pTrans2D = pPointCollection.Point(m_HitIndex)<BR>            pTrans2D.Move(endPoint.X - m_StartPoint.X, endPoint.Y - m_StartPoint.Y)<BR>            pPointCollection.UpdatePoint(m_HitIndex, pTrans2D)<BR>            pGeometryCollection.GeometriesChanged()<BR>            m_ActiveView.Refresh()<BR>        End If<BR>        Exit Sub<BR>err_Handle:<BR>        MsgBox("err: " ; Err.Description)<BR>    End Sub</P>
<P>    Private Function HitTest(ByVal pFeature As IFeature, ByVal pInPt As IPoint, ByVal dSrchDis As Double, ByRef lPrtIdx As Long, ByRef lVertIdx As Long) As Boolean<BR>        '//根据指定半径查找与输入点最近的点<BR>        Dim pHtTest As IHitTest<BR>        Dim pGeoemtry As IGeometry<BR>        Dim bIsHit As Boolean<BR>        Dim dHitDis As Double<BR>        Dim bHitRight As Boolean = False</P>
<P>        pGeoemtry = pFeature.Shape<BR>        If pGeoemtry.GeometryType = esriGeometryType.esriGeometryPolygon Or pGeoemtry.GeometryType = esriGeometryType.esriGeometryPolyline Then<BR>            pHtTest = pGeoemtry<BR>            bIsHit = pHtTest.HitTest(pInPt, dSrchDis, esriGeometryHitPartType.esriGeometryPartVertex, Nothing, dHitDis, lPrtIdx, lVertIdx, bHitRight)<BR>        End If<BR>        Return bIsHit<BR>    End Function</P>
喜欢0 评分0
lovegismore
路人甲
路人甲
  • 注册日期2006-07-25
  • 发帖数21
  • QQ
  • 铜币210枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-05-31 09:53
I have solved the problem! It is need to append "m_Feature.Store()" after the "pGeometryCollection.GeometriesChanged()" in the MoveVertexMouseUp function
举报 回复(0) 喜欢(0)     评分
游客

返回顶部