VP03 1 Graphics
VP03 1 Graphics
Objectives
The student will correctly:
Create, manipulate, and clear static and interactive graphics on a
display
Render a graphic in the appropriate coordinate space
Create graphic collections and composite shapes, including tool
result graphics
1
Graphics
• Graphics in VisionPro can be either
– Static
• No updates made to the graphic once displayed
– Interactive
• The user may select and manipulate the graphic
• Graphic properties may be changed in code and automatically updated
Basic Steps
• For both static and interactive graphics, the basic steps for
creating and configuring are the same
2
Static Graphics
• First, determine the shape of your graphic:
– Circle (CogCircle class)
– Coordinate Axes (CogCoordinateAxes class)
– Ellipse (CogEllipse class)
– Line Segment (CogLineSegment class)
– Point Marker (CogPointMarker class)
– Rectangle (CogRectangle class)
– Rectangle Affine (CogRectangleAffine class)
– Polygon (CogPolygon class)
Static Graphics
• Create the shape:
3
Static Graphics
• Set the appropriate properties for the shape
• Properties vary by shape, but examples of the most commonly
used:
Rect.Color = CogColorConstants.Blue
Rect.SetXYWidthHeight(100, 200, 100, 50)
Rect.LineStyle =
CogGraphicLineStyleConstants.DashDot
Static Graphics
• Now add the shape to the display’s graphics collection
CogRecordDisplay1.StaticGraphics.Add(Rect,"group")
4
Interactive Graphics
• Interactive shapes are created the same way as static:
Interactive Graphics
• Next, set the properties of the shape:
Circ.Color = CogColorConstants.Magenta
Circ.SetCenterRadius(300, 300, 200)
Circ.LineStyle =
CogGraphicLineStyleConstants.Dash
10
5
Interactive Graphics
• A few special properties for interactive shapes:
• Make it interactive:
Circ.Interactive = True
11
Interactive Graphics
• Then add it to the display
CogRecordDisplay1.InteractiveGraphics.
Add(Circ, “group”, true)
12
6
Get Graphic Pose
• After a user interacts with a graphic, get the new position / orientation / size
of the graphic:
Private X As Double
Private Y As Double
Private Rad As Double
Circ.GetCenterRadius(X, Y, Rad)
13
Clearing Graphics
• The Clear method removes all static or interactive graphics from the
display
CogRecordDisplay1.InteractiveGraphics.Clear()
CogRecordDisplay1.StaticGraphics.Clear()
14
7
Drawing Text Graphics
• Text works very similarly to shapes:
15
16
8
Drawing Enabled
• If you have several graphics to add to a display, you may want
to set the DrawingEnabled property of the display to False to
postpone drawing until all the shapes are added to the display
CogRecordDisplay1.DrawingEnabled = False
17