0% found this document useful (0 votes)
43 views

VP03 1 Graphics

The document discusses graphics in VisionPro software. It describes how to create both static and interactive graphics, set their properties, add them to a display, and clear them. Key steps include choosing a shape class, setting properties like color and position, and adding the graphic to the display's static or interactive graphics collection. Interactive graphics can also have their properties changed and positions retrieved after user manipulation.

Uploaded by

inigofet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

VP03 1 Graphics

The document discusses graphics in VisionPro software. It describes how to create both static and interactive graphics, set their properties, add them to a display, and clear them. Key steps include choosing a shape class, setting properties like color and position, and adding the graphic to the display's static or interactive graphics collection. Interactive graphics can also have their properties changed and positions retrieved after user manipulation.

Uploaded by

inigofet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

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

• Create the shape


• Set graphic properties
• Add graphics to the display

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)

• To use a combination of shapes that is treated as one graphical entity, use


Composite Shape (CogCompositeShape class)

Static Graphics
• Create the shape:

Private Rect As CogRectangle


Rect = New CogRectangle

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")

• The display maintains two lists of graphics:


– Static graphics list is for drawing graphics that will not change
– Interactive graphics list is for drawings graphics that the user can
manipulate or that will change

4
Interactive Graphics
• Interactive shapes are created the same way as static:

Private Circ As CogCircle


Circ = New CogCircle

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

• Enable manipulation of the shape:


Circ.GraphicDOFEnable =
CogCircleDOFConstants.Position

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)

• All shapes have similar “get” methods

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:

' Allocate the graphic and set its properties


Private cglCaption As New CogGraphicLabel
cglCaption.Text = "Cognex Display Control“

'.NET fonts are read only, so create a new font and


' then push this font object onto the Font property
' of the label
Dim myFont as Font
myFont = new Font("Comic Sans MS", 18, FontStyle.Bold)
cglCaption.Font = myFont

' Add it to the display


CogRecordDisplay1.StaticGraphics.Add(cglCaption, _
“group”)

15

Graphics and Coordinate Spaces


• To change the space in which a graphic is drawn, set its
SelectedSpaceName property

Circ.SelectedSpaceName = "standard space"

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

You might also like