chapter 12 making tools week 7 fall 2006. tools (events) besides click mousedown, mouseup, mousemove...

Post on 02-Jan-2016

212 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Chapter 12Making Tools

Week 7

Fall 2006

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

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

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”

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

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)

Code examples – create marker

• Fore example: create a marker to mark city location.– 1) Create a point

Dim pPoint As IPointSet pPoint = New PointpPoint.X = 0 ‘London, long and latpPoint.Y = 53.5

– 2) Create new marker elementDim pMarkerElement As IMarkerElementSet pMarkerElement = New MarkerElement

- 3) Associate the point with the marker elementDim pElement As IElement ‘Switch interfaces to IElement from

IMarkerElementSet pElement = pMarkerElementpElement.Geometry = pPoint

IContainer

- 4) Add to the IGraphicsContainerDim 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

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 graphicscontainerpGraphics.AddElement pElement, 0

Partial Refresh

• pActiveView.PartialRefresh _ esriViewGraphics, pElement, Nothing

Which caches are refreshedWhich layers/elements are refreshedWhich parts of the screen are refreshed (envelope)

Caches – screen capture of active view area

top related