next up previous contents index
Next: Graphics Up: Main Functions 1 Previous: Annotation   Contents   Index

Ghost Rendering

The PushGhost/PopGhost functions are useful in scripts where an object is created, and the user must click to place the object. The object's outline can be drawn and attached to the pointer, facilitating placement. Example:

array[2000]
# create some shape in array, nverts is actual size
...
ShowPrompt("Click to locate new object");
xy[2]
PushGhost(array, nverts)
ShowGhost(8)
if !Point(xy)
    Exit()
end
ShowGhost(0)
PopGhost()
# use xy to create object in database

(int) PushGhost(array, numpts)
This function allows a polygon to be added to the list of polygons used for dynamic highlighting with the ShowGhost function. The outline of the polygon will be ``attached'' to the mouse pointer. The return value is the number of polygons in the list, after the present one is added. The array is an array of x-y values forming the polygon. The numpts value is the number of x-y pairs that constitute the polygon. If this value is less than 2 or greater than the real size of the array, the real size of the array will be assumed. The second argument is useful when the polygon data do not entirely fill the array, and can be set to 0 otherwise.

(int) PushGhostBox(left, bottom, right, top)
This function is similar to PushGhost. It allows a box outline to be added to the list of polygons used for ghosting with the ShowGhost function. The outline of the box will be ``attached'' to the mouse pointer. The return value is the number of polygons in the list, after the present one is added. The arguments are the coordinates of the lower left and upper right corners of the box, where ``0'' is the point attached to the mouse pointer. The PopGhost function is used to remove the most recently added object from the list.

(int) PushGhostH(object_handle, all)
Push the outline of the figure referenced by the handle onto the ghost list. If boolean all is true, push all objects in the list represented by the handle, otherwise push the single object at the head of the list. The return value is an integer count of the number of outlines added to the ghost list.

(int) PopGhost()
This function removes the last ghosting polygon passed to PushGhost or PushGhostBox from the internal list, and returns the number of polygons remaining in the list.

(int) ShowGhost(type)
Show dynamic highlighting. This function turns on/off the ghosting, i.e., the display of certain features which are ``attached'' to the mouse pointer. The argument is one of the numeric codes from the table below.

0 Turn off ghosting
1 full-screen horiz line, snapped to grid
2 full-screen vert line, snapped to grid
3 full-screen horiz line, not snapped
4 full-screen vert line, not snapped
5 vector from last point location to pointer
6 box, snapped to grid
7 box, not snapped
8 display polygon list from PushGhost
9 vector from last point location to pointer
10 vector from last point location to pointer
11 vector from last point location to pointer

The modes 5, 9, 10, and 11 draw a vector from the last button 1 down location to the pointer. Mode 5 snaps to the grid, and snaps the angle to multiples of 45 degrees when the angle is close. If the Constrain45 variable is set, the angle is strictly constrained to multiples of 45 degrees. Mode 9 is similar, but does not snap to grid. Mode 10 is similar, but there are no angle constraints, except that implicit in snapping to the grid. Mode 11 is similar, but there are no angle constraints and no grid snapping.

With the ghosting enabled, the Point function returns coordinates that are snapped to grid or not depending on the mode passed to ShowGhost. Modes 1, 2, 5, 6, 8, and 10 are snapped to grid.

If the UseTransform function has been called to enable use of the current transform, the current transform will be applied to the displayed objects when using mode 8. The translation supplied to UseTransform is ignored (the translation tracks the mouse pointer).


next up previous contents index
Next: Graphics Up: Main Functions 1 Previous: Annotation   Contents   Index
Stephen R. Whiteley 2022-05-28