|
阅读:1194回复:1
请教一个engine中实现捕捉功能的问题
<P>各位,请教一个engine中实现捕捉功能的问题。</P>
<P>我现在通过hittest已经得到了捕捉点,我想像arcmap的sketch工具一样,通过一个小圆圈表示当前捕捉到的点。</P> <P>请问通过什么方法绘制这个小圆圈比较好? 多谢!</P> <P>我现在是通过element来绘制的,但对鼠标轨迹的擦除不是很好,总是有些痕迹的残留。代码如下:</P> <P>捕捉鼠标绘制<BR>Dim pCurrentSymbol As ISimpleMarkerSymbol<BR>pCurrentSymbol = New SimpleMarkerSymbol<BR>With pCurrentSymbol<BR> .Outline = True<BR> .OutlineSize = 0.2<BR> .OutlineColor = GetRGBColor(0, 0, 0)<BR> .Color = GetRGBColor(0, 200, 240, 0)<BR> .Style = esriSimpleMarkerStyle.esriSMSSquare<BR> .Size = 6<BR>End With</P> <P>Dim pPointGeo As IGeometry<BR>pPointGeo = m_pPoint 'm_pPoint是捕捉到的点,从窗体传入类中的<BR>Dim pElement As IElement<BR>Dim pME As IMarkerElement<BR>pME = New MarkerElement<BR>pElement = pME<BR>pElement.Geometry = pPointGeo<BR>pME.Symbol = pCurrentSymbol</P> <P>Dim pGraphicsContainer As IGraphicsContainer<BR>pGraphicsContainer = GetMap()<BR>pGraphicsContainer.DeleteAllElements()<BR>pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, Nothing)<BR>pGraphicsContainer.AddElement(pElement, 0)</P> <P>Dim pEnve As IEnvelope ’用于擦除鼠标轨迹的矩形区域<BR>If m_pOldPoint Is Nothing Then <BR> m_pOldPoint.PutCoords(m_pPoint.X, m_pPoint.Y)<BR>End If<BR>pEnve = m_pOldPoint.Envelope<BR>pEnve.Height = 10<BR>pEnve.Width = 10<BR>pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, pEnve)</P> <P>pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, Nothing)</P> <P>m_pOldPoint = m_pPoint</P> |
|
|
1楼#
发布于:2006-06-29 18:06
Public Sub SnapAfterDraw(iViewDrawPhase As Long)<BR>On Error GoTo SnapAfterDraw_Err<BR> Dim pScreenDisplay As IScreenDisplay<BR> Dim iHDC As Long<BR> <BR> If iViewDrawPhase = esriViewForeground Then<BR> <BR> If Not m_SnapGeometry Is Nothing Then<BR> <BR> Set pScreenDisplay = m_pActvieView.ScreenDisplay<BR> iHDC = pScreenDisplay.hDC<BR> <BR> If m_SnapSymbol Is Nothing Then SetSnapSymbol<BR> <BR> pScreenDisplay.StartDrawing iHDC, -1<BR> pScreenDisplay.SetSymbol m_SnapSymbol<BR> pScreenDisplay.DrawPoint m_SnapGeometry<BR> pScreenDisplay.FinishDrawing<BR> <BR> Set m_SnapGeometry = Nothing<BR> <BR> End If<BR> <BR> End If<BR> <BR> Exit Sub<BR>SnapAfterDraw_Err:<BR> MsgBox Err.Description, vbInformation, "系统消息"<BR>End Sub
|
|