Viewing Environment and Definition
<<< KID Graphics: Overview | Chapters | KID Rendering >>> |
These properties allow the user to define how the model is viewed. Examples of the use of these properties, and their default values, are given below:
If
graphics perspective
is
nil
(the default), then,
If
graphics perspective
is
t
, then'
The following pre-defined view directions can be set using their associated commands:
Windowing defines that area of the model image which is in view. The "view_window_" functions are the most basic ones. There default settings are:
> (graphics view_window_xmin -100) > (graphics view_window_xmax 100) > (graphics view_window_ymin -100) > (graphics view_window_ymax 100) |
The following functions provide an easier way to redefine the window by using the cursor.
When a picture has been drawn, "pick_window" enables the cursor for two picks, to define a window diagonal.
> (graphics sketch ´b0) > (graphics pick_window ) -- cursor enabled for two picks > (graphics redraw ) |
pick_centre
enables the cursor for a pick which defines the centre of the new window. If more detail of the new window centre is required this operation can be followed by a "zoom". Be careful not to use "autowindow" immediately after these commands, unless the new window is to be purposely overwritten.
> (graphics sketch ´b0) > (graphics pick_centre) > (graphics zoom 2) > (graphics redraw) |
It is possible to "autowindow" the view so that the window is set to the smallest size possible for the objects which are currently drawn.
"redraw" clears the screen and draws the current GRA graphics data structure. This means that if the graphics drawing list is altered, followed by a "redraw", the GRA graphics data is output, not reflecting the change in the drawing list.
"ar" is the combination of an "autowindow" and a "redraw".
> (graphics sketch ´b0) -- b0 sketched with current view > (graphics autowindow) -- no visible change > (graphics redraw) -- sketch of b0 with smallest possible window |
> (graphics ar) -- autowindow and redraw > (graphics drawing_list ´( b0 b1)) -- drawing list changed > (graphics redraw) -- but only b0 will be drawn |
Note: Using "autowindow" on its own does not have any visible effect, although it does altered the GRA viewing environment. Its effect is only visible after a "redraw". |
The "centre" function uses a model space pointer to specify the centre of the current view window. To refresh the view, and therefore see the view in relation to the specified "centre", it is necessary to do a "redraw".
> ( graphics ske ´b0 ) > ( graphics centre ´( 0 0 10 ); redraw ) |
The "zoom" function takes a real number as its argument. It changes the current window sizes so that the image is magnified or reduced about the "centre" of the current view window.
A factor greater than 1.0 magnifies the image on the screen.
To see the zoomed image it is necessary to refresh the screen using "redraw".
> ( graphics zoom <factor> ) > ( graphics redraw ) |
It is possible to change the view definition by altering the properties previously described. However, a number of functions are provided to allow easy manipulation of the view. The pan functions take a real number as their argument. The effect is to move the edges of the window by the given distance in the given direction.
> (graphics pan_left <distance>) > (graphics pan_right <distance>) > (graphics pan_up <distance>) > (graphics pan_down <distance>) |
The rotate functions also take a real number as their argument. They rotate the viewing direction and the 'from point' about the image by the given amount. The angle is specified in degrees.
> (graphics rotate_left <angle>) > (graphics rotate_right <angle>) > (graphics rotate_up <angle>) > (graphics rotate_down <angle>) |
Only one view or graphics subclass can be active at a time, and all graphics output are sent to that view until another one is selected. The view must first be defined, then this view can be selected:
> (define view_x graphics) > (view_x select) |
Note: Selecting a view does not clear the screen, or draw the frame and axes. |
The function
clear
clears the graphics screen of the terminal, and empty the GRA stream(s) used by the current view:
> (graphics clear) |
In addition to the
clear
function, use of the abbreviated forms of
sketch
and
hidden
clear the screen before drawing the entity.
> (graphics ske ´b0) > (graphics hid ´b0) |
To display the limits of the current view on the screen, the "frame" function is provided, "axes" draws axes in the current view.
> (graphics frame [<t or nil>]) > (graphics axes [<t or nil>]) |
Using these functions without any arguments draws a frame or axes in the view. If an argument is given, this is interpreted as a logical value (t or nil). If the value given is
t
(i.e. anything but nil) a frame or axes are automatically drawn when ever the view is redrawn.
Each view has a drawing list property, e.g.
view_1 drawing_list
. This is used to contain a list of the objects which have been drawn in this particular view. Initially, the drawing list is empty, but when objects are rendered their names are added to this list.
Some functions redraw all the items in the drawing list. If the view has no drawing list itself, they look up the class tree until a non empty drawing list is found. Therefore, one class may be used to hold the drawing list and its subclasses may be views which are used to render the objects.
It is possible to add items to the drawing list without rendering them. This could be used to create a sketch of a number of objects.
> (define my_view graphics) > (my_view select) > (my_view drawing_list ´(b0 e1 f2)) > (my_view sketch) -- objects b0, e1 and f2 will now be drawn |
Note: 1) The object which is the argument should be a list of KID objects, which represent kernel items with tags, and it must be quoted (') to avoid it being evaluated. 2)
graphics clear
does not clear the
drawing_list
which is used for "Picking". Therefore, it is possible to pick objects from what appears to be a clear display. The
drawing_list
must be reset independently. |
> (graphics drawing_list ´(b0))-- drawing_list only contains b0 > (graphics drawing_list nil) -- empty the drawing_list |
It is possible to enquire about a view:
> (view_x enquire) -- prints information about the view |
<<< KID Graphics: Overview | Chapters | KID Rendering >>> |