AE two-dimensional map Selection Range, added to the three-dimensional arcscene control display, rendering

Source: Internet
Author: User

How to select a range for a two-dimensional map and add it to the three-dimensional arcscene Control for display and rendering (source code)

1. Add the following in the arcmapcontrol_onmousedown event:
Dim objenvelope as ienvelope
Dim pscreendisplay as idisplay
Dim prubberband as irubberband
Set m_pactiveview = arcmapcontrol. activeview. focusmap
Set pscreendisplay = arcmapcontrol. activeview. screendisplay
Set prubberband = new rubberenvelope
Set objenvelope = prubberband. tracknew (pscreendisplay, nothing)

If objenvelope is nothing then
Call msgbox ("envelope is empty", vbexclamation)
Exit sub
End if
Call frmmap3d. INIT (objenvelope)
Ii. Elements in Initialization selection:
Public sub loadscenelayers ()
On Error goto errorhandler
'
Dim pmap as IMAP
Dim player as ilayer
Dim pcompositelayer as icompositelayer
Dim ppriority as long
Dim pindex1 as long
Dim pindex2 as long
'
Set mscenegraph = frmmap3d. arcscenecontrol. scenegraph 'sceneviewerctrl1. scenegraph
Set mscenegraphevents = mscenegraph

Set pmap = frmmapcontrol. arcmapcontrol. activeview. focusmap
Ppriority = 0
'
For pindex1 = 0 to pmap. layercount-1 step 1
Set player = pmap. layer (pindex1)
If player. Visible = true then
If typeof player is igrouplayer then
Set pcompositelayer = player
For pindex2 = 0 to pcompositelayer. Count-1 step 1
Ppriority = ppriority + 1
Call loadscenelayers2 (pcompositelayer. layer (pindex2), ppriority)
Next pindex2
Else
Ppriority = ppriority + 1
Call loadscenelayers2 (player, ppriority)
End if
End if
Next pindex1
Exit sub
Errorhandler:
Msgbox "loadscenelayers"
'Call handleerror (false, "loadscenelayers" & module_name & "(" & CSTR (ERL) & ")", Err. Number, Err. Source, Err. description)
End sub

Private sub loadscenelayers2 (byval playermx as ilayer ,_
Byref ppriority as long)
On Error goto errorhandler
'
Dim pfeatureselection as ifeatureselection
Dim pspatialfilter as ispatialfilter
Dim pfeaturelayerdefinition as ifeaturelayerdefinition

Dim pfeaturelayermx as ifeaturelayer
Dim pfeaturelayersx as ifeaturelayer

Dim p3dproperties as i3dproperties

Dim pgeofeaturelayermx as igeofeaturelayer
Dim pgeofeaturelayersx as igeofeaturelayer

Dim playersx as ilayer
Dim pcolor as icolor
Dim psymbol as isymbol
Dim pobjectcopy as iobjectcopy 'esricontrolssupport. iobjectcopy
'
Dim plistitems as mscomctllib. listitems
Dim plistitem as mscomctllib. listitem

'------------------------------------------------------
'Select features that pass through the current extent
'------------------------------------------------------
Set playersx = nothing
If typeof playermx is ifeaturelayer then
Set pfeaturelayermx = playermx
If pfeaturelayermx. featureclass. featuretype = esriftsimple then
Set pspatialfilter = new spatialfilter
Set pspatialfilter. Geometry = menvelope
'
'Pspatialfilter. geometryfield = pfeaturelayermx. featureclass. shapefieldname
Pspatialfilter. spatialrel = esrispatialrelintersects
'
Set pfeatureselection = pfeaturelayermx
Call pfeatureselection. selectfeatures (pspatialfilter, esriselectionresultnew, false)
'
Set pfeaturelayerdefinition = pfeaturelayermx
Set pfeaturelayersx = pfeaturelayerdefinition. createselectionlayer (pfeaturelayermx. Name, true ,"","")
Pfeaturelayersx. Visible = pfeaturelayermx. Visible
'
Call pfeatureselection. Clear
'
Set pgeofeaturelayermx = pfeaturelayermx
Set pgeofeaturelayersx = pfeaturelayersx
Set pobjectcopy = new objectcopy
Set pgeofeaturelayersx. Renderer = pobjectcopy. Copy (pgeofeaturelayermx. Renderer)
'
Set playersx = pfeaturelayersx
End if
Else
If typeof playermx is irasterlayer then
Dim prasterlayermx as irasterlayer
Set prasterlayermx = playermx
Prasterlayermx. visibleextent = menvelope
Set playersx = prasterlayermx

End if
End if
'-----------------------
'Add layer to arcscene
'-----------------------
Call mscenegraph. Scene. addlayer (playersx, false)
'---------------------------------
'Update 3D properties of sxlayer
'---------------------------------
Set p3dproperties = get3dpropertiesfromlayer (playersx)
If not (p3dproperties is nothing) then
'P3dproperties. baseexpressi
'P3dproperties. baseoption = esribaseshape
P3dproperties. depthpriorityvalue = ppriority
'P3dproperties. extrusi
'P3dproperties. extrusiontype = esriextrusionnone
'P3dproperties. faceculling = esrifacecullingnone
'P3dproperties. Illuminate = true
'P3dproperties. offsetexpressi
'P3dproperties. rendermode = esrirendercache
'P3dproperties. renderrefreshrate = 0.75
'P3dproperties. rendervisibility = esrirenderalways
'P3dproperties. smoothshading = true
'P3dproperties. zfactor = 1
'
Call p3dproperties. apply3dproperties (playersx)
End if
'End if
'
Exit sub
Errorhandler:
Msgbox "loadscenelayers2"
'Call handleerror (false, "loadscenelayers2" & module_name & "(" & CSTR (ERL) & ")", Err. Number, Err. Source, Err. description)
End sub
3. Perform symbol Rendering

Public sub symbolinit ()
On Error goto errh
'Readini
Dim prEN as isimplerenderer
Dim pgeofeatlyr as igeofeaturelayer

Dim I as integer

For I = 0 to frmmap3d. arcscenecontrol. Scene. layercount-1
If frmmap3d. arcscenecontrol. Scene. layer (I). name like "*" & "L" then
Set pgeofeatlyr = frmmap3d. arcscenecontrol. Scene. layer (I)
Set prEN = pgeofeatlyr. Renderer

'Dim psimplerenderer as isimplerenderer
Dim pline3dsymbol as ilinesymbol
Dim psimplelinesymbol as isimpleline3dsymbol
Set psimplelinesymbol = new simpleline3dsymbol
Psimplelinesymbol. Style = esris3dlstube
Set pline3dsymbol = psimplelinesymbol
Pline3dsymbol. width = 2
Dim prgbcolor as irgbcolor
Set prgbcolor = new rgbcolor
Prgbcolor. red= 255

Pline3dsymbol. Color = prgbcolor
Exitloop:

Set Pren. symbol = pline3dsymbol
Frmmap3d. arcscenecontrol. Scene. scenegraph. invalidate pgeofeatlyr, true, true
Frmmap3d. arcscenecontrol. Scene. scenegraph. refreshviewers
End if
Next
Frmtreetoc3dcontrol. arctoccontrol. Update
Errh:
If err. Number <> 0 then
Msgbox err. Number & err. Description, vbokonly + vbinformation & "2"
End if

End sub

Private function get3dpropertiesfromlayer (player as ilayer) as i3dproperties
On Error goto errorhandler
'
Dim pindex as integer
Dim playerextensions as ilayerextensions
Dim p3dproperties as i3dproperties
'
Set playerextensions = player
Set p3dproperties = nothing
'
If not (playerextensions is nothing) then
For pindex = 0 to playerextensions. extensioncount-1 step 1
If typeof playerextensions. Extension (pindex) is i3dproperties then
Set p3dproperties = playerextensions. Extension (pindex)
Exit
End if
Next pindex
End if
'
Set get3dpropertiesfromlayer = p3dproperties
'
Exit Function
Errorhandler:
Msgbox "get3dpropsfromlayer"
'Call handleerror (false, "get3dpropsfromlayer" & module_name & "(" & CSTR (ERL) & ")", Err. Number, Err. Source, Err. description)
End Function

Public sub univaluesymbol ()
Dim puniquevaluerenderer as iuniquevaluerenderer
Dim psym as isimplelinesymbol 'ifillsymbol
Dim pcolor as icolor
Dim pnextuniquecolor as icolor
Dim penumramp as ienumcolors
Dim ptable as itable
Dim fieldnumberds as long
Dim fieldnumberwidth as long
Dim fieldnumberheight as long
Dim pnextrow as irow
Dim pnextrowbuffer as irowbuffer
Dim pcursor as icursor
Dim pqueryfilter as iqueryfilter
Dim dbl_dsvalue as Variant
'''''''''''''''''''''''''''''''''''''''' '''
Dim pline3dsymbol as ilinesymbol
Dim psimplelinesymbol as isimpleline3dsymbol
'''''''''''''''''''''''''''''''''''''''' '''
Set puniquevaluerenderer = new uniquevaluerenderer
Dim pgeofeatlyr as igeofeaturelayer
Dim I as integer
For I = 0 to frmmap3d. arcscenecontrol. Scene. layercount-1
Set pgeofeatlyr = frmmap3d. arcscenecontrol. Scene. layer (I)
If pgeofeatlyr. featureclass. shapetype = esrigeometryline or pgeofeatlyr. featureclass. shapetype = esrigeometrypolyline then
Fieldnumberds = pgeofeatlyr. featureclass. findfield ("D_S ")
Fieldnumberwidth = pgeofeatlyr. featureclass. findfield ("width ")
Fieldnumberheight = pgeofeatlyr. featureclass. findfield ("height ")
If fieldnumberds =-1 and fieldnumberwidth =-1 then
Goto nextiiii
End if
Puniquevaluerenderer. fieldcount = 1
Set pqueryfilter = new queryfilter
If fieldnumberds <>-1 then
Puniquevaluerenderer. Field (0) = con_d_s
Pqueryfilter. addfield con_d_s
Else
Puniquevaluerenderer. Field (0) = "width"
Pqueryfilter. addfield "width"
End if
'Set up the color ramp, this came from looking at arcmaps color Ramp
'Properties for pastels.
'
Dim pcolorramp as irandomcolorramp
Set pcolorramp = new randomcolorramp
Pcolorramp. starthue = 0
Pcolorramp. minvalue = 99
Pcolorramp. minsaturation = 15
Pcolorramp. endhue = 360
Pcolorramp. maxvalue = 100.
Pcolorramp. maxsaturation = 30
Pcolorramp. size = 100
Pcolorramp. createramp true
Set penumramp = pcolorramp. colors
Set pnextuniquecolor = nothing

'Get a Enumerator on the first row of the Layer'
Set pcursor = pgeofeatlyr. Search (pqueryfilter, true)
Set pnextrow = pcursor. nextrow
Do while not pnextrow is nothing
Set pnextrowbuffer = pnextrow
Set psimplelinesymbol = new simpleline3dsymbol
Psimplelinesymbol. Style = esris3dlstube
If fieldnumberds <>-1 then
Dbl_dsvalue = pnextrowbuffer. Value (fieldnumberds)
Psimplelinesymbol. resolutionquality = 1 #
Else
Dbl_dsvalue = pnextrowbuffer. Value (fieldnumberwidth)
Psimplelinesymbol. resolutionquality = 0 #
End if
Set pnextuniquecolor = penumramp. Next
If pnextuniquecolor is nothing then
Penumramp. Reset
Set pnextuniquecolor = penumramp. Next
End if
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''
Dim symbolwith as double
Symbolwith = cdbl (dbl_dsvalue)
Symbolwith = symbolwith/1000
Set pline3dsymbol = psimplelinesymbol
Pline3dsymbol. width = symbolwith
Pline3dsymbol. Color = pnextuniquecolor
Puniquevaluerenderer. addvalue dbl_dsvalue, dbl_dsvalue, pline3dsymbol
Set pnextrow = pcursor. nextrow
Loop
Set pgeofeatlyr. Renderer = puniquevaluerenderer
Frmmap3d. arcscenecontrol. Scene. scenegraph. invalidate pgeofeatlyr, true, true
Frmmap3d. arcscenecontrol. Scene. scenegraph. refreshviewers
End if
Nextiiii:
Next
Frmtreetoc3dcontrol. arctoccontrol. Update
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.