Download presentation
Presentation is loading. Please wait.
Published byDarcy Thornton Modified over 9 years ago
1
Chapter 12 Making Tools Week 7 Fall 2006
2
Tools (events) besides Click MouseDown, MouseUp, MouseMove CursorID defines mouse appearance Eabled to disable tool when necessary MouseDown events(x/y are pixel locations, not coordinates, you need to use IMxDocument.CuurentLocation to obtain them) Private Sub UIToolControl_MouseDown ( _ button As Long, shift As Long, x As Long, y As Long) MsgBox “X: “ & x & “, Y: “ & y End Sub Button=1 – holding down the left button, =2, right button Shift=0, not depressed, 1 : depressed
3
IPoint IMxDocument: CurrentLocaiton: IPoint. –pMxDoc.CurrentLocation will return an IPoint object, from which X and Y can be determined From IPoint, X,Y return current location: For example: Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Dim pPoint As IPoint Set pPoint = pMxDoc.CurrentLocation MsgBox “Longitude: “ & pPoint.X & “, Latitude: “ & pPoint.Y
4
Status Bar IApplication.StatusBar returns an object of IStatusBar (for example: Dim pStatus As IStatusBar Set pStatus = Application.StatusBar 4 panels of message bars, starting from 0. pStatus.Message(0) = “Lat: “ & pPoint.y… pStatus.Message(1) = “Hello, this is message is from Adv GIS”
5
Drawing graphics Graphics on map – follow map units Graphics on layout – follow inches or cm Graphics belong to abstract class called Element (p. 212) Map and PageLayout have Element. Create objects out of GraphicElement coclass which include LineElement, TextElement and MarkerElement Element is associated with geometry objects – point, line and polygon Geometry is the starting point to create graphic elements
6
MarkerElement MarkerElement is the point’s visual representation, required…. Otherwise, your point is just an abstract identity… Once created, MarkerElement must be associated with your existing point. QI is shown in these steps (next slide)
7
Code examples – create marker Fore example: create a marker to mark city location. –1) Create a point Dim pPoint As IPoint Set pPoint = New Point pPoint.X = 0 ‘London, long and lat pPoint.Y = 53.5 –2) Create new marker element Dim pMarkerElement As IMarkerElement Set pMarkerElement = New MarkerElement -3) Associate the point with the marker element Dim pElement As IElement ‘Switch interfaces to IElement from IMarkerElement Set pElement = pMarkerElement pElement.Geometry = pPoint
8
IContainer -4) Add to the IGraphicsContainer Dim pMap As IMap ‘FocusMap return IMap, switch to IGraphicsContainer Set pMap = pMxDoc.FocusMap Dim pGraphics As IGraphicsContainer Set pGraphics = pMap -Always take 4 lines to get the interface you need. Two to declare and set the interface you don’t need and two more to declare and set the interface variable that you want. For a shortcut example, see next slide
9
To save two steps If you don’t need IMap object, then simply use pMxDoc.FocusMap to get IMap object, instead of declare one. Dim pGraphics As IGraphicsContainer Set pGraphics = pMxDoc.FocusMap Next, add graphics into graphicscontainer pGraphics.AddElement pElement, 0
10
Partial Refresh pActiveView.PartialRefresh _ esriViewGraphics, pElement, Nothing Which caches are refreshed Which layers/elements are refreshed Which parts of the screen are refreshed (envelope) Caches – screen capture of active view area
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.