k_willow
路人甲
路人甲
  • 注册日期2005-01-27
  • 发帖数2
  • QQ
  • 铜币109枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1445回复:1

[求助]AO实现地图符号化!

楼主#
更多 发布于:2005-01-27 21:05
<P>请教各位高手IFeatureRenderer接口下 Draw方法该如何设置?语法如下:</P>
<P><I>object</I>.<B>Draw</B> <B>(</B><I>Cursor</I>, <I>drawPhase</I>, <I>Display</I>, <I>trackCancel</I><B> )</B></P>
<P><b>其中的</b><EM>Display是 IDisplay;</EM> <EM>trackCancel</EM><b> 是 </b><EM>IT</EM><EM>rackCancel</EM><B> </B></P>
<P><b>最近忙着做地图符号化,主要做饼图、柱状图。想只对选出来的要素做符号化,看帮助文档应该是用上述方法吧?请各位高手指点!先谢谢了!</b></P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2005-01-28 22:00
<PRE>你可以把你选择到的要素生成选择集来操作,</PRE><PRE> Private Sub IFeatureRenderer_Draw(ByVal Cursor As esriCore.IFeatureCursor, _
                                  ByVal drawPhase As esriCore.esriDrawPhase, _
                                  ByVal Display As esriCore.IDisplay, _
                                  ByVal trackCancel As esriCore.ITrackCancel)
    On Error GoTo ErrorHandler
    
    Dim dblLen As Double  'The length of the line
    Dim intI As Integer   'Used as a loop control
    Dim strTemp As String 'Used to collect feature information
    Dim pField As IField  'Used to loop through each feature's fields.
    
    'Required for drawing the feature
    Dim pF As IFeature
    Dim pFD As IFeatureDraw
    
    ' set display's symbol for drawing
    If Not Display Is Nothing Then Display.SetSymbol m_pSym
  
    ' loop through the features and draw them
    Set pF = Cursor.NextFeature
    Do While (Not pF Is Nothing) And trackCancel.Continue
        Set pFD = pF
        
        strTemp = ""
        'Get information about each field of the feature.
        For intI = 0 To pF.Fields.FieldCount - 1
            Set pField = pF.Fields.Field(intI)
            strTemp = strTemp ; "Field Index: " ; intI ; vbCrLf ; _
                       "Field Name:  " ; pField.Name ; vbCrLf ; _
                       "Field Type:  " ; pField.Type ; vbCrLf
                      
            If (pField.Type = esriFieldTypeGeometry) Then
                strTemp = strTemp ; "Field Value: Shape" ; vbCrLf ; vbCrLf
            ElseIf (pField.Type = esriFieldTypeBlob) Then
                strTemp = strTemp ; "Field Value: Blob" ; vbCrLf ; vbCrLf
            Else
             'This always displays the default value
                strTemp = strTemp ; "Field Value: " ; pF.Value(intI) ; vbCrLf ; vbCrLf
            End If
        Next intI
        MsgBox strTemp, vbInformation, "Current Feature Information"</PRE><PRE>        'Get the length from the feature.
        dblLen = CDbl(pF.Value(pF.Fields.FindField("LENGTH"))) 'Always returns zero
        
        'Decide how to render the feature
        If pF.Shape.GeometryType = esriGeometryPolyline Then
            If dblLen > 5 Then
                Display.SetSymbol m_pLSym
                pFD.Draw drawPhase, Display, m_pLSym2, True, Nothing, esriDSNormal
            Else
                Display.SetSymbol m_pLSym2
                pFD.Draw drawPhase, Display, m_pLSym2, True, Nothing, esriDSNormal
            End If
        Else
            Display.SetSymbol m_pSym
            pFD.Draw drawPhase, Display, m_pSym, True, Nothing, esriDSNormal
        End If
          
        Set pF = Cursor.NextFeature
    Loop
      
ErrorHandler_Exit:
    Set pF = Nothing
    Set pFD = Nothing
    Set pField = Nothing
  Exit Sub
ErrorHandler:
  HandleError True, "IFeatureRenderer_Draw " ; c_sModuleFileName ; " " ; _
              GetErrorLineNumberString(Erl), Err.Number, Err.Source, Err.Description, 4
  GoTo ErrorHandler_Exit
End Sub</PRE><PRE>
*******************************************</PRE><PRE>Private Sub IFeatureRenderer_PrepareFilter(ByVal fc As esriCore.IFeatureClass,
                                           ByVal QueryFilter As esriCore.IQueryFilter)
    Dim pFields As IFields
    Dim pField As IField
    Dim cnt As Integer, i As Integer
    
    ' Add all fields because one day we will render on any field
    Set pFields = fc.Fields
    cnt = pFields.FieldCount
    
    For i = 0 To cnt - 1
        Set pField = pFields.Field(i)
        If Not pField Is Nothing Then
            QueryFilter.AddField pField.Name
        End If
        Set pField = Nothing
    Next i
End Sub
</PRE>
[此贴子已经被作者于2005-1-28 22:02:50编辑过]
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部