8.4 SNAPPING
A big part of manipulation is assembling objects together to form a larger whole, and
a big part of assembly is getting objects together at the right place in the correct orientation.
Doing this manually requires orienting the objects and then sliding them
together so they are flush and evenly aligned. A better approach is to build some
smarts into the system so objects "know" where to go and how to orient themselves.
This aspect of manipulation is called snapping. Snapping often also implies attachment,
which will be covered in a section 8. 5. Essentially, snapping gets the objects
together, and, if needed, attachment makes them stay together.
8.4.1 Explicit versus implicit
Explicit snapping requires that objects be marked with snap elements so that the user
clearly sees where and how objects can be connected together. For example, snap elements
might correspond to actual mechanical attachment points on the real objects
represented by the virtual ones. Alternatively, the system could automatically place
snap elements at strategic positions on objects, such as their bounding-box corners,
whether or not they correspond to mechanically accurate attachment points.
Implicit snapping involves the system automatically determining spatial relation-ships
that are deemed significant to the user, and causing the objects to align accordingly.
For example, objects might snap so their faces are evenly aligned or flush against
one another. For implicit snapping to be effective, good heuristics consistent with the
user's task are needed, which require that the designer have a good understanding of
the user tasks and data objects involved. Explicit snapping, on the other hand, better
lends itself to generalization.
Figure 8. 14 Direct snapping via mouse dragging, and indirect snapping via menu selection
8.4.2 Snap operations
An explicit snap operation involves two or more objects, each with a selected snap
element. When the snap occurs, the objects jump together and position themselves so
that the selected snap points are touching. Such snap operations are not immediately
obvious or intuitive to the user because snapping is an artificial activity not often
found in the real world. However, if the user is provided with adequate feedback, as
with any good idiom, he should get the hang of it rather quickly. A snap operation
seems straightforward, but is it? How are the snap elements selected? When the snap
occurs, which objects move and which ones stay in place?
Snap movement
Starting with the question of object movement, one approach is to let all the objects
move at once. This, however, can result in a 3D version of anarchy. For example, the
user may have a partial assembly nicely arranged and positioned in the world. Trying
to snap a new piece to it can result in the assembly coming apart if its pieces are not
firmly attached; or, if its pieces are attached, the whole assembly can end up moving
toward the single piece. In any case, this approach can seem counterintuitive and even
counterproductive to the user. A more useful approach is to designate one object in
the operation as the target object and the others as source objects. Then, when the
snap occurs, the source objects jump over to the target object and position them-selves.
This works well as long as it's clear to the user which object is the target and
which are the sources. But how are the source and target objects chosen?
Snap operations can occur directly as a result of dragging an object, or indirectly
as a result of commanding the snap to occur, such as with a third-person control but-ton
or menu item. Both forms are shown in figure 8. 14. In the case of dragging,
because the user has already decided to move an object, the most intuitive approach
is to designate it as the snap source object. You saw this in the case of PTF snap drag:
When the drag ends, the dragged object— the snap source— jumps into place. In the
case of an indirect snap operation, the choices for designating objects are not so obvious.
Order of selection can be a good criterion, with the first selected object designated
as the snap target, and all subsequently selected objects designated as snap sources.
Other possibilities include using menu selection or tool modes to designate the
selected object as being a source or a target, but these approaches are less desirable
because setting up the snap operation may seem like more trouble than it is worth to
the user.
Snap selection
A snap operation requires selection of a snap element on each source and target
object. A good way to classify snap element selection is by the degree of manual selection
involved, which is shown in figure 8. 15.
The first approach is "no selection," where the system performs all snap element
selections automatically. Typically, proximity is used as the selection criterion with the
closest snap elements between two objects being selected. For example, during a drag,
the system would determine the snap element on the source object— the one being
dragged— that is closest to a snap element on a neighboring object. The system would
autoselect these snap elements and designate the neighboring object as the target of the
snap operation. Something similar can be done for indirect snapping, but with the
currently selected object designated as the snap source. The no-selection approach is
very easy to use because all the user does is select or drag an object: All snap element
and target object selection is automatic. Unfortunately, it lacks a degree of control that
many assembly tasks require.
The next possibility is "partial selection," where the user selects a snap element
on an object and then drags either that object or another nearby object. As before, the
dragged object is the snap source object and distance is the criterion for snap element
selection. The closest snap element to the manually selected one, whether on the
dragged object or a neighboring one, is autoselected as the mate. Indirect snapping
would work the same, but the host object of the manually selected snap element would
be designated as the source object. The partial selection approach is a little harder for
the user to perform because it requires a selection and then a drag, but it can often provide
a satisfactory level of control over the snapping.
The final approach, which offers the most control, is "full selection." In this
approach, the user selects a snap element on both the source and target snap objects.
In this case, indirect snapping may seem like the only alternative, with the user commanding
the snap to happen: A drag may seem superfluous, but it is not. Dragging
Figure 8. 15 Different approaches to snap point selection, which involve varying degrees of
manual selection
one object or the other after selecting the snap elements could be a simple way to designate
which one is the snap source. Also, as you'll see in later sections, snapping and
attachment do not have to affect the complete geometry of the participants, in which
case a drag could still influence the final outcome geometry of the snap operation.
8.4.3 Snap typing
A snap element on one object can be connected to any snap element on another
object. Sometimes, however, it is helpful to the user if the designer imposes constraints
on how objects can be snapped together. With snap typing, a snap type is
assigned to the snaps, which allows only snaps of matching or complementary types
to be snapped together. For example, top surface snaps on furniture might assist the
user in aligning work surfaces so they are all at the same height, bookshelf snaps on a
bookcase, however, might prevent the user from attaching a light fixture where only a
movable bookshelf should go. Complementary male-female snaps on opposite sides
of furniture might constrain rows of furniture items to all face in one direction. The
possibilities for snap typing are endless.
8.4.4 Snap geometry
In many applications, snapping implies only a jump in position, with orientation
being unaffected. A variation on snap typing is snap orientation, with the mating
snap elements imposing a particular orientation between the snapped objects. For
example, when assembling modular furniture, often the pieces can go together only
with a certain geometry. The user should only have to indicate where to connect two
furniture pieces and the snap point orientation would take care of the rest. In this
example, the orientation might be fully constrained, but in other situations you want
the snap orientation to be partially constrained. For example, snapping two snap
edges together might force the edges to be colinear, but the relative orientation of the
host objects about the colinear edges would remain the same. Limiting the snap's
effect on the resulting geometry configuration can also apply to position. For example,
snapping two faces together might assure that they are coplanar, thereby making
them flush or at least even, but it wouldn't necessarily cause the faces to overlap.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|