Admin Production ni-theme
Current Publication

Drawing

LabWindows/CVI

Drawing Class Help

This class contains functions for drawing and manipulating shapes, text, and bitmap images on canvas controls.

The canvas has a built–in pixel–based Cartesian coordinate system, where (0,0) represents the top, left corner of the canvas. All drawing is specified relative to this coordinate system. This coordinate system can be modified using the following attributes:

ATTR_CANVAS_XCOORD_AT_ORIGIN
ATTR_CANVAS_YCOORD_AT_ORIGIN
ATTR_CANVAS_XSCALING
ATTR_CANVAS_YSCALING

Each canvas has an offscreen bitmap, which is used to restore the appearance of the canvas when the region is exposed.

Drawing is controlled by the value of the ATTR_DRAW_POLICY attribute, which can have one of the following values:

VAL_UPDATE_IMMEDIATELY

Drawing takes place offscreen. The bitmap section corresponding to the area of the drawing operation is then copied into the canvas display. This is the default value.

VAL_MARK_FOR_UPDATE

Drawing takes place offscreen. The area on the canvas corresponding to the area of the drawing operation is marked for update instead of being copied into the display. The new drawing becomes visible when draw events are processed.

VAL_DIRECT_TO_SCREEN

Drawing goes directly to the screen. The offscreen bitmap is not updated. Although this may result in a faster drawing time, whatever is drawn in this mode is lost when the canvas is redrawn.

Although the drawing functions can be called at any time, they are most efficient when called from within a batch drawing operation. A batch drawing operation consists of a call to CanvasStartBatchDraw, followed by one or more calls to the canvas drawing functions, followed by a call to CanvasEndBatchDraw.

For optimal performance, National Instruments recommends you include as many drawing primitives as possible within a batch drawing operation. When you call a drawing function outside of a batch operation, the function is implicitly surrounded by calls to CanvasStartBatchDraw and CanvasEndBatchDraw.

The drawing functions are constrained by the clipping set using CanvasSetClipRect. Any drawing outside the clipping rectangle is not rendered.

When the ATTR_PICT_BGCOLOR attribute is changed, the entire canvas area is cleared.

The ATTR_OVERLAP_POLICY attribute controls what occurs when you draw to a canvas that is overlapped by another control. You can specify one of the following values for this attribute:

VAL_DEFER_DRAWING

If the control is overlapped and the draw policy is VAL_UPDATE_IMMEDIATELY, new drawing does not become visible until draw events are processed (the same as VAL_MARK_FOR_UPDATE). If the draw policy is VAL_DIRECT_TO_SCREEN, no drawing takes place. This is the default value.

VAL_DRAW_ON_TOP

If the control is overlapped and the draw policy is not VAL_MARK_FOR_UPDATE, drawing occurs on top of the overlapping controls.

Library: User Interface Library