enhancing arcreader functionality with custom layers · esri.arcgis.display.idisplay, byval...
TRANSCRIPT
Enhancing ArcReader Enhancing ArcReader Functionality with Custom Functionality with Custom
LayersLayers
Mark CederholmMark CederholmUniSource Energy ServicesUniSource Energy Services
9:47 AM9:47 AM
ArcReader as a field appArcReader as a field app
CostCost--free deploymentfree deploymentArcMap quality map displayArcMap quality map displayDisconnectedDisconnectedLimited outLimited out--ofof--box functionalitybox functionalityArcReader control: weakArcReader control: weakSmall set of ArcObjectsSmall set of ArcObjectsNo access to feature geometry, No access to feature geometry, location, projections, etc.location, projections, etc.
9:47 AM9:47 AM
Custom layersCustom layers
Most ArcObjects availableMost ArcObjects availableFeature geometry, projections, Feature geometry, projections, geometry operations, editsgeometry operations, editsLimited access to application Limited access to application components: ScreenDisplay onlycomponents: ScreenDisplay onlyArcReaderArcReader--specific limitationsspecific limitations
9:47 AM9:47 AM
Implementing a custom layer: 1Implementing a custom layer: 19:47 AM9:47 AM
Implementing a custom layer: 2Implementing a custom layer: 29:47 AM9:47 AM
Implementing a custom layer: 3Implementing a custom layer: 39:47 AM9:47 AM
Implementing Visible(): 1Implementing Visible(): 1Public Property Visible() As Boolean Implements ESRI.ArcGIS.Carto.ILayer.Visible
GetReturn m_bVisible
End GetSet(ByVal value As Boolean)
m_bVisible = valueIf m_bVisible Then
If m_TestForm Is Nothing Thenm_TestForm = New TestForm
ElseIf Not m_TestForm.Created Thenm_TestForm = NothingGC.Collect()m_TestForm = New TestForm
End IfIf Not m_pDisplay Is Nothing Then
m_TestForm.SetScreenDisplay(m_pDisplay)End Ifm_TestForm.Show()…
9:47 AM9:47 AM
Implementing Visible(): 2Implementing Visible(): 2…Else
If Not m_TestForm Is Nothing Thenm_TestForm.ShutDown()If m_TestForm.Visible Then
m_TestForm.Hide()End Ifm_TestForm = NothingGC.Collect()
End IfEnd If
End SetEnd Property
9:47 AM9:47 AM
Implementing Draw()Implementing Draw()Public Sub Draw(ByVal DrawPhase As ESRI.ArcGIS.esriSystem.esriDrawPhase, ByVal Display As ESRI.ArcGIS.Display.IDisplay, ByVal TrackCancel As ESRI.ArcGIS.esriSystem.ITrackCancel) Implements ESRI.ArcGIS.Carto.ILayer.Draw
If Not Display Is m_pDisplay Thenm_pDisplay = DisplayIf Not m_TestForm Is Nothing Then
m_TestForm.SetScreenDisplay(Display)End If
End IfEnd Sub
9:47 AM9:47 AM
Interacting with the applicationInteracting with the application
What you get:What you get:IScreenDisplayIScreenDisplayIDisplayEventsIDisplayEvents
What you donWhat you don’’t get:t get:IApplicationIApplicationIMapIMapIPageLayoutIPageLayoutIActiveViewIActiveViewIActiveViewEventsIActiveViewEvents
9:47 AM9:47 AM
Assemblies Not Included with ArcReaderAssemblies Not Included with ArcReader
All UI classes except All UI classes except SystemUISystemUIArcCatalogArcCatalogArcGlobeArcGlobeArcMapArcMapArcScanArcScanArcSceneArcSceneCatalogCatalogEditorEditorEditorExtEditorExt
FrameworkFrameworkGeoprocessingGeoprocessingMilitaryAnalystMilitaryAnalystMOLEMOLEOutputExtensionsOutputExtensionsPublisherPublisherSpatialAnalystSpatialAnalystSurveyDataExtSurveyDataExtSurveyExtSurveyExtTrackingAnalystTrackingAnalyst
9:47 AM9:47 AM
Adding a Custom Layer (VBA)Adding a Custom Layer (VBA)Dim pDoc As IMxDocument, pMap As IMapDim pLayers As IEnumLayer, pLayer As ILayerDim pTestLayer As ILayer
Set pDoc = Application.DocumentSet pMap = pDoc.FocusMapSet pLayers = pMap.Layers(Nothing, True)pLayers.ResetDo
Set pLayer = pLayers.NextIf pLayer Is Nothing Then
Exit DoEnd IfIf TypeOf pLayer Is ITestLayer Then
MsgBox "Layer already added", vbExclamationExit Sub
End IfLoopSet pTestLayer = New TestLayerClasspMap.AddLayer pTestLayer
9:47 AM9:47 AM
Demo 1: GPS point displayDemo 1: GPS point display9:47 AM9:47 AM
Drawing the pointDrawing the point
Private Sub DrawPoint(ByVal pPoint As IPoint)With m_pSD ' IScreenDisplay
.StartDrawing(0, esriScreenCache.esriNoScreenCache)
.SetSymbol(m_pMapSymbol)
.DrawPoint(pPoint)
.FinishDrawing()End With
End Sub
9:47 AM9:47 AM
Undrawing the point: 1Undrawing the point: 1
' Calculate extent of symbol to invalidate
Dim pDisp As IDisplayTransformationDim dPtSize As Double, dRefScale As Double, dMapScale As Double
pDisp = m_pSD.DisplayTransformationdPtSize = m_dPtSizedRefScale = pDisp.ReferenceScaleIf dRefScale <> 0 Then
dMapScale = pDisp.ScaleRatiodPtSize = dPtSize * dRefScale / dMapScale
End IfdPtSize = dPtSize + 4
9:47 AM9:47 AM
Undrawing the point: 2Undrawing the point: 2
' Convert to map coordinates and build envelope
Dim dExt As Double, dX As Double, dY As DoubleDim pEnv As IEnvelope
dExt = pDisp.FromPoints(dPtSize)dX = pPoint.XdY = pPoint.YpEnv = New EnvelopepEnv.PutCoords(dX - dExt / 2, dY - dExt / 2, dX + dExt / 2, dY + dExt / 2)
' Invalidate
m_pSD.Invalidate(pEnv, False, esriScreenCache.esriNoScreenCache)
9:47 AM9:47 AM
Putting them togetherPutting them together
If Not m_pPrevPoint Is Nothing ThenUndrawPoint(m_pPrevPoint)m_pPrevPoint = NothingGC.Collect()Application.DoEvents() ' Allow the undraw to complete
End IfDrawPoint(m_pMapPoint)
9:47 AM9:47 AM
Display eventsDisplay eventsPrivate Sub m_pDisplayEvents_DisplayInvalidated…
m_bEnabled = FalseEnd SubPrivate Sub m_pDisplayEvents_DisplayScrolled…
m_bEnabled = FalseEnd SubPrivate Sub m_pDisplayEvents_DisplayStarted…
m_bEnabled = FalseEnd SubPrivate Sub m_pDisplayEvents_DisplayFinished…
m_bEnabled = TrueEnd Sub Private Sub FeedEvent()
If Not m_bEnabled ThenExit Sub
End Ifm_bEnabled = False…DrawGPSPoint(dLon, dLat)m_bEnabled = True
End Sub
9:47 AM9:47 AM
Demo 2: street intersection finderDemo 2: street intersection finder
9:47 AM9:47 AM
Get intersection pointGet intersection pointDim pTO As ITopologicalOperatorDim pIntShape As IGeometryDim pPoint As IPointDim pEnv As IEnvelope
pTO = pShape1pIntShape = pTO.Intersect(pShape2, _
esriGeometryDimension.esriGeometry0Dimension)If pIntShape.GeometryType = esriGeometryType.esriGeometryPoint Then
pPoint = pIntShapeElse
pEnv = pIntShape.EnvelopepPoint = New PointpPoint.X = (pEnv.XMin + pEnv.XMax) / 2pPoint.Y = (pEnv.YMin + pEnv.YMax) / 2
End If
9:47 AM9:47 AM
Pan if needed and flashPan if needed and flash
Dim fg As FlashGeometryClassDim pDT As IDisplayTransformation
fg = New FlashGeometryClasspDT = m_pScreenDisp.DisplayTransformationpEnv = pDT.FittedBoundsIf pPoint.X < pEnv.XMin Or pPoint.X > pEnv.XMax Or _
pPoint.Y < pEnv.YMin Or pPoint.Y > pEnv.YMax ThenpEnv = pDT.VisibleBoundspEnv.CenterAt(pPoint)pDT.VisibleBounds = pEnvm_pScreenDisp.Invalidate(Nothing, True, _
esriScreenCache.esriAllScreenCaches)Application.DoEvents() ' Allow draw to finish
End Iffg.FlashShape(m_pScreenDisp, pPoint)
9:47 AM9:47 AM
Demo 3: create new featuresDemo 3: create new features9:47 AM9:47 AM
Activating a toolActivating a tool
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As LongPrivate Declare Function ReleaseCapture Lib "user32" () As LongPrivate Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Sub btnAddLine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddLine.Click
Dim i As LongIf m_pScreenDisp Is Nothing Then
Exit SubEnd Ifm_bAddLine = Truei = SetCapture(Me.Handle)Me.Cursor = Windows.Forms.Cursors.Cross
End Sub
9:47 AM9:47 AM
Using IRubberBand for tool actionsUsing IRubberBand for tool actionsPrivate Sub TestForm_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
…ElseIf m_bAddLine Then
Dim pRubberline As IRubberBandDim pLine As IPolylinepRubberline = New RubberLinepLine = pRubberline.TrackNew(m_pScreenDisp, Nothing)If pLine Is Nothing Then
Exit SubEnd IfAddFeature(pLine, FeatureType.Line)m_bAddLine = False
End IfMe.Cursor = Windows.Forms.Cursors.Defaulti = ReleaseCapture()Application.DoEvents()i = SetForegroundWindow(Me.Handle)
End Sub
9:47 AM9:47 AM
ArcReader editing restrictionsArcReader editing restrictions
Supported:Supported:Simple featuresSimple featuresShapefilesShapefilesFile geodatabaseFile geodatabasePersonal gdbPersonal gdbArcSDE PersonalArcSDE Personal
Not supported:Not supported:Features requiring Features requiring an edit sessionan edit sessionTwoTwo--way replicasway replicas
9:47 AM9:47 AM
Demo 4: network analysisDemo 4: network analysis9:47 AM9:47 AM
Network analysis in ArcReaderNetwork analysis in ArcReader
The Bad News:The Bad News:Cannot use TraceFlowSolverCannot use TraceFlowSolver
The Good News:The Good News:Can use ForwardStarCan use ForwardStar
9:47 AM9:47 AM
Performance tip !!!Performance tip !!!
Avoid heavy use of fineAvoid heavy use of fine--grained grained ArcObjects in .NET applicationsArcObjects in .NET applicationsTo optimize performance, develop To optimize performance, develop coarsecoarse--grained objects in C++ for grained objects in C++ for .NET applications to consume.NET applications to consume
9:47 AM9:47 AM
SummarySummary
Custom layers implementing Custom layers implementing IPersistVariant can be published to a PMFIPersistVariant can be published to a PMFMost cocreatable ArcObjects installed with Most cocreatable ArcObjects installed with ArcReader may be usedArcReader may be usedApplication interaction is limited to Application interaction is limited to ScreenDisplay classScreenDisplay classSimple edits may be performed, but Simple edits may be performed, but geodatabase operations requiring edit geodatabase operations requiring edit sessions are not allowedsessions are not allowed
9:47 AM9:47 AM
Questions?Questions?
Mark CederholmMark [email protected]@uesaz.comThis presentation and sample code This presentation and sample code may be downloaded at:may be downloaded at:
http://www.pierssen.com/arcgis/misc.htmhttp://www.pierssen.com/arcgis/misc.htm
9:47 AM9:47 AM