<<< KID Rendering | Chapters | Fault Reporting in KID >>> |
Picking makes a connection between the KID object and the tag of the kernel item.
To pick an item from the screen, the command
pick
is used. Initially the user has to define the type of entity which is to be picked from the items displayed on the screen. The command:
> ( <entity> pick ) |
produces a cursor on the screen, which can then be positioned over the entity (face, edge, body, etc.) which is to be picked. Pressing an appropriate key records the tag or coordinates for the pick. In the case of topological items further calls to
( <entity> pick )
allow further entities of the same type to be picked and added to the tag list of
<entity>
.
> (b0 sketch) -- sketch the body > (define f1 face) -- define the object > (f1 pick) -- puts up the moveable crosswires - press any key to pick the item > (f1 sketch) -- now the object can be used |
pick
is also a function of
p_points
, and can be used to pick coordinate sets from the screen in image space, or directly by giving an optional argument of a set of coordinates. This is described in the section "Using p_points to create a p_profile". The function pick can pick indirectly from the screen when used with two optional arguments.
The pick can only be made from a graphics view, so that if a model is not drawn the pick cannot be made. The entity to be picked must first be defined.
To assist the above operations the commands pick2, and pick3 are used, these commands expect multiple picks from the screen to be made.
The primitive
p_points
can be used with the function "pick" to build a set of coordinates in the image plane. The
p_points
object must first be defined, and the cursor enabled by the "pick" function. A series of points can be picked in the image plane, by pressing an appropriate key, and the sequence terminated by picking a previously picked point. The item of class
p_points
can be used to create a body from a profile using
p_profile
, which in turn can be swept or swung to produce a new item.
The coordinates for b0 can also be given in either of the ways shown:
> (b1 coordinate (p1 coordinate)) -- implicit coordinate list > (b1 coordinate `( (1 2 3 ) (...))) -- explicit coordinate list > (b1 create) -- create kernel item (acorn, wire or sheet body) |
When "pick" is invoked with just one argument ( the position vector of the eye point in model space), the nearest entity to that point in the current view direction is picked. Only a face facing toward the
eye_point
would be picked, assuming a face had been defined.
When both arguments are given, the implicit current view direction is overwritten with the second argument, and entities are picked in an identical way. This mode of use could be applied when an eye point and view direction are already known, for example when taken directly from a journal file.
> (f1 pick `(200 200 200) `(1 1 1) ) |
Note: The "pick" command actually uses the graphics "drawing_list" to determine which entities have been selected. |
The "drawing_list" is not reset by the (graphics clear) command but needs to be reset independently:
> (graphics drawing_list nil) |
If the "drawing_list" is not reset then it is possible to pick from objects which no longer appear in the display. Conversely, if "pick" is being used with arguments then it is only necessary to add the entities to the drawing_list in order to pick from them - there is no actual need to display them:
Picking can be done without an image on the screen. This type of logical picking is achieved by successive qualification, for example by picking all the faces in a body, then selecting only those with specified geometric properties. Three functions can be used, "pick_from", "pick_using" and "pick_node".
"pick_from" collects all items of a particular type from an object below the entity class. The equivalent statement might be "all edges in the body". "pick_from" purges any duplicates from the resulting tag list. Unlike "pick", "pick_from" is not cumulative, and a further call to it replaces the tags collected previously with a new set.
"pick_using" filters a set of items using a function as a qualifying clause. This is equivalent to a statement such as "only those faces with spherical surfaces". If "pick_using" finds no items, an empty sublist is returned. A few examples of this are shown next.
"pick_node" uses the node identifier of an object to pick it from the body or KI assembly to which it belongs.
Assume a body b1 has been created with some toroidal faces. The example which follows shows how to find those faces which are toroidal and have a specific major radius.
The next example shows how the top face of a block can be picked without using the cursor, so that a new surface can be exchanged for this one using
tweak
.
If pick_using finds no items an error message is returned, e.g.
( error "f2; no match entity" ) |
and the existing list is left unaltered.
> ((define f0 face) pick_node 34 ´b0) > ((define f0 face) pick_node ´(34 45 56) ´b0) > ((define c0 curve) pick_node ´(21 23 25) ´b0) |
Some KID functions result in the tag property of an entity having a LISP list of tags. An example of this is the function
pick_from
. It is often possible to manipulate an object with a list of tags using the same functions as if it had a single tag. This facility is not provided by all KID functions.
A class
p_points
exists as a subclass of primitive. The class has a function "pick" which allows the user to give a list of vector points as its argument. These are held in the object's coordinate property. The user can either supply the list as an argument to pick, or can supply no argument and thus employ the cursor to select the vector points. Consider the following examples:
This then prompts the user to select the list of points by moving the cursor in the graphics frame with the arrow keys. Points are selected by moving to the desired location and striking any key, the list is terminated when a key is struck without the user having moved the cursor. The selected vector points are located on the graphics viewing plane. (The viewing plane is a plane perpendicular to the current view_direction passing through the current view_to point.)
No other functions are provided;
p_points
is intended only as a convenient location for storing a list of coordinates.
To pick from an assembly, first the assembly must be converted from a single layer assembly to a list of bodies (changes the type of entity from an assembly to a body).
> (a0 disassemble) -- unpacks bodies from instances and applies transforms; a0 is now a body > (graphics ske a0) > (define e0 edge) > (e0 pick) -- pick the edge from the body a0 using the cursor |
The inverse operation, to create the assembly, takes the part with one or more tags and makes each an instance in an assembly, which can then be transmitted as a single entity.
> (a0 tag) > (100 174 279 1000) > (a0 assemble) -- a0 is now an assembly > (a0 transmit "part_name") |
<<< KID Rendering | Chapters | Fault Reporting in KID >>> |