public class SoDragger extends SoInteractionKit
SoDragger
is the base class for all nodekits you move by using the mouse to click-drag-and-release. More specifically, they are operated by a start (mouse button 1 pressed over dragger to pick it), followed by dragging (mouse motion events are interpreted by the dragger and result in some form of motion and/or change to a field), followed by finish (mouse up).
Each dragger has a different paradigm for interpreting mouse motion and changing its fields as a result. Draggers map 2D mouse motion into motion of a point on 3D lines, planes, spheres, or cylinders. (See the SbProjector
reference pages.) Then they react to this motion of a point through 3-space by scaling, translating, or rotating. For example, SoTranslate2Dragger
maps mouse motion onto a 3D plane, then translates to follow the cursor as it moves within that plane.
Beginning with version 3.0, draggers also respond to tracked input device events (see SoControllerButtonEvent
and SoTrackerEvent
) in order to support immersive VR devices like a wand. Interaction is started by pressing wand button 1 when the tracker "ray" intersects the dragger's geometry. Analogous to 2D, in which the interaction is driven by tracking the ray from the 2D mouse cursor, in 3D the interaction is driven by tracking the ray emanating from the tracking device.
Beginning with version 5.0, draggers can also take position and orientation changes directly from the tracker's position and orientation. Specifically the difference between the tracker's current values and the values at the start of the interaction is applied as an incremental change to the dragger. In general this is a more natural way to manipulate objects in an immersive environment. You can use the setTrackerDirectMode
method to enable this behavior.
Every dragger has fields that describe its current state. Scaling draggers have a scaleFactor field, rotational draggers have a rotation field, etc. All draggers have the isActive
field, defined in this class. It is true while the dragger is being dragged, false otherwise.
Draggers that have only one part to pick and one motion field are called simple draggers. Examples are the SoRotateDiscDragger
, SoScale1Dragger
, and SoTranslate2Dragger
.
Draggers that create assemblies out of other draggers and then orchestrate the motion of the whole assembly are called composite draggers. SoTransformBoxDragger
is a composite dragger made entirely of simple draggers. SoDirectionalLightDragger
contains both a simple dragger (SoRotateSphericalDragger
) and a composite dragger (SoDragPointDragger
) When using a composite dragger, the fields of the composite dragger are the ones you should work with. Draggers lower down in the assemblage usually have zeroed out values. For example, when you drag the face of a transformBox, an SoTranslate2Dragger
, the transformBox "steals" the translation from the child dragger and transfers it up to the top of the composite dragger, where it effects all pieces of the assemblage.
Using draggers:
Draggers always keep their fields up to date, including while they are being dragged. So you can use field-to-field connections and engines to connect dragger values to other parts of your scene graph. Hence draggers can be easily utilized as input devices for mouse-driven 3D interface elements. You can also register value-changed callbacks, which are called whenever any of the fields is changed. See example below.
This makes it easy to constrain draggers to keep their fields within certain limits: if the limit is exceeded, just set it back to the exceeded maximum or minimum. You can do this even as the dragger is in use, by constraining the field value within a value-changed callback that you add with addValueChangedCallback(). In this case, be sure to temporarily disable the other value-changed callbacks using enableValueChangedCallbacks()
. Doing this will prevent infinite-looping. See example below.
Also, if you set the field of a dragger through some method other than dragging, (by calling setValue(), for example), the dragger's internal SoFieldSensor
will sense this and the dragger will move to satisfy that new value. This is useful to set the initial position (orientation, etc) of the dragger.
Draggers have a fixed orientation with respect to their local coordinate system. For example the SoTranslate1Dragger
drags along its local X axis, the SoTranslate2Dragger
drags in its local XY plane, etc. Some draggers, for example SoTrackballDragger
, have a built-in rotation field that allows modifying the dragger's initial orientation. For other draggers you can put the dragger and a transform node under an SoSeparator
and use the transform node to change the dragger's orientation. For example, rotate an SoTranslate1Dragger
so it effectively drags along the world coordinate Y axis.
Draggers can have zero or more of the following callbacks: - Start: called when manipulation starts
Draggers vs Manipulators:
When you drag a dragger, the dragger only moves itself. Draggers do not change the state or affect objects that follow in the scene graph. For example a dragger does not ever behave like an SoTransform
and change the current transformation matrix. Draggers are not transforms, even if they have field names like translation, rotation, scaleFactor. The application must connect the dragger to a transform node or use a callback to update some other object in the scene graph (see example below).
However many draggers, such as SoTrackballDragger
, have a corresponding SoTransformManip
, in this case SoTrackballManip
. The manipulator is a subclass of SoTransform
, and affects other objects in the scene; it uses a trackball dragger to provide its user interface. In this way, draggers are employed extensively by manipulators. The dragger notifies its employer of start, motion, finish, and value changes. (See the various reference pages for more details on specific draggers and manipulators).
Customizing draggers:
All draggers are nodekits. However, draggers do not list their parts in the Parts section of the reference page. Instead, there is a section called Dragger Resources, more suited to describe the parts made available to the programmer. Each dragger has some parts you can pick on, and other parts that replace them when they are active or moving. These active parts are often just the same geometry in another color. Draggers also have parts for displaying feedback. Each of these parts has a default scene graph, as well as a special function within the dragger. Each part also has a resource name. All this information is contained in the DRAGGER RESOURCES section.
Since draggers are nodekits, you can change a part in a dragger that has already been built using the SO_DRAGGER_DIR
When a dragger builds a part, it looks in the global dictionary (i.e. calls Proxy geometry:
The WYSIWYG Draggers:
Some of the default Open Inventor draggers have behaviors based on invisible geometry. For example, dragging a sphere by clicking on the surface of an invisible sphere. These behaviors may be unintuitive for some users. So Open Inventor also provides an alternative set of "WYSIWYG" draggers with semi-transparent handles in place of invisible geometry. For example, the To quickly enable these draggers set the environment variable SO_DRAGGER_DIR to "$OIVHOME/data/draggerWysiwyg" (for example using
Event handling
When a dragger activates as a result of a mouse button press, it will handle the button down event ( However, when the dragger de-activates as a result of releasing the mouse button, other nodes
will see this event ( Create a simple dragger and add a valueChanged callback that will be called when the dragger has changed one of its fields.
Implementation of a simple valueChanged callback that limits the range of the dragger.
File format/default:
Dragger {
All Parts
Extra Information for List Parts from Above Table
See also:
setPart()
method. For example, to change the "rotator" part of an SoTrackballDragger
:
But draggers also give each part a resource name. The default part geometries are defined as resources for each class, and each class has a file you can change to alter the defaults. The files are listed in each dragger's reference page. For example, the SoCenterballDragger
loads the file "centerballDragger.iv". You can make your program use different default resources for the parts by copying the listed file from the directory $OIVHOME/data/draggerDefaults into your own directory, editing the file, and then setting the environment variable SO_DRAGGER_DIR to be a path to that directory. In general applications should not directly modify files in the Open Inventor SDK directories.
SoInput
's default directory separator rules apply, i.e. the default directory separator is ":;" (
either colon or semicolon). Unfortunately this means that, on Microsoft Windows, the string "C:/myDir" will be interpreted as TWO separate directories "C/" and "/myDir".
SoNode.getByName()
) for a node whose name is resourceName. For example the SoCenterballDragger
lists a resource named "centerballRotator", therefore the scene graph for this dragger contains an SoSeparator
named "centerballRotator". By putting a new entry in the dictionary (creating a node with this name), you can override the default geometry. However note two things: First, Open Inventor allows multiple nodes to have the same name and in this case getByName()
returns the
most recently named node. Second, when the first instance of a dragger class is created, the constructor automatically creates the default dragger geometry (either from the compiled-in scene graph or from the geometry file in SO_DRAGGER_DIR). Therefore to override default geometry using named nodes, the application must first create an instance of the dragger class, then create and name the replacement geometry. Subsequently created draggers will now use the replacement geometry.
SoInteractionKit
method setPartAsPath()
provides support for creating "stand-in" objects for parts in the interaction kit. The "stand-in", or "surrogate" part, is a path to an object that lies somewhere else in the scene graph. This could be used, for example, with an SoTranslate1Dragger
to allow the user to click on some geometry and directly drag it (without displaying any separate dragger geometry). This technique is used, for example, in SoOrthoSliceDragger
.
SoCenterballDragger
shown below.
SoPreferences
). Applications that plan to use these draggers should make a local copy of this directory and set SO_DRAGGER_DIR to the local directory. This directory should be distributed with the application. For example:
By default the WYSIWYG dragger geometry contains an
Default SoCenterballDragger
WYSIWYG
SoCenterballDragger
SoTransparencyType
node that sets the transparency type for the dragger to SCREEN_DOOR. This setting overrides the tranparency type set on the viewer or RenderAction. To render the dragger with a different transparency type there are several options:
This is the simplest and cleanest solution.
(In general you should not directly modify the contents of the SDK directories.)
SoPreferences
)
SoTransparencyType
node, or
SoTransparencyType
node
(allowing the transparency type to be inherited as usual)
SoTransparencyType
node to the scene graph before the dragger
setOverride()
method with true
SoMouseButtonEvent
) and subsequent mouse move events (SoLocation2Event
). Other nodes in the scene graph will not see these events. Even nodes traversed before the dragger node will not see the mouse move events, because the dragger calls setGrabber() on the SoHandleEventAction
.
SoMouseButtonEvent
), because the dragger does
not call setHandled(). This potentially includes nodes above the dragger, such as SoSelection
, which defer event handling until after traversing their children. This is not a problem for the standard SoSelection
node because it ignores the button up event if it did not previously see the matching button down event. However custom node classes that process events should be aware of this behavior.
Or... Connect a simple dragger directly to a transform node:
Note: To avoid recursive calls, always disable the valueChanged callback before modifying the fields of the dragger.
}
renderCaching AUTO
boundingBoxCaching AUTO
renderCulling AUTO
pickCulling AUTO
isActive false
callbackList NULL
Part Name Part Type Default Type NULL Default
callbackList NodeKitListPart yes
Part Name Container Type Possible Types
callbackList Separator Callback, EventCallback
SoInteractionKit
, SoCenterballDragger
, SoDirectionalLightDragger
, SoDragPointDragger
, SoHandleBoxDragger
, SoJackDragger
, SoPointLightDragger
, SoRotateCylindricalDragger
, SoRotateDiscDragger
, SoRotateSphericalDragger
, SoScale1Dragger
, SoScale2Dragger
, SoScale2UniformDragger
, SoScaleUniformDragger
, SoSpotLightDragger
, SoTabBoxDragger
, SoTabPlaneDragger
, SoEllipsoidDragger
, SoTrackballDragger
, SoTransformBoxDragger
, SoTransformerDragger
, SoTranslate1Dragger
, SoTranslate2Dragger
Modifier and Type | Class and Description |
---|---|
static class |
SoDragger.TrackerDirectModes
Tracker direct mode.
|
SoInteractionKit.Cachings
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT
Deprecated.
Use
SoDragger.TrackerDirectModes.DEFAULT instead. |
SoSFBool |
enableCallbacks
If set to false, motion, start and finish callbacks are disabled.
|
static int |
FREE
Deprecated.
Use
SoDragger.TrackerDirectModes.FREE instead. |
SoSFBool |
isActive
true when mouse is down and dragging, else false.
|
static int |
MOVE
Deprecated.
Use
SoDragger.TrackerDirectModes.MOVE instead. |
static int |
NONE
Deprecated.
Use
SoDragger.TrackerDirectModes.NONE instead. |
static int |
ROTATE
Deprecated.
Use
SoDragger.TrackerDirectModes.ROTATE instead. |
AUTO, boundingBoxCaching, OFF, ON, pickCulling, renderCaching, renderCulling
boundingBoxIgnoring
VERBOSE_LEVEL, ZeroHandle
Modifier and Type | Method and Description |
---|---|
void |
addFinishCallback(SoDraggerCB cb,
java.lang.Object userData)
Adds finish callback.
|
void |
addMotionCallback(SoDraggerCB cb,
java.lang.Object userData)
Adds motion callback.
|
void |
addStartCallback(SoDraggerCB cb,
java.lang.Object userData)
Adds start callback.
|
void |
addValueChangedCallback(SoDraggerCB cb,
java.lang.Object userData)
Adds value-changed callback.
|
boolean |
enableValueChangedCallbacks(boolean newVal)
You can temporarily disable a dragger's valueChangedCallbacks.
|
static SoNodekitCatalog |
getClassNodekitCatalog()
Returns the
SoNodekitCatalog for this class. |
static SoDragger.TrackerDirectModes |
getInitialTrackerDirectMode()
Get the initial tracker direct mode.
|
int |
getMinGesture()
Gets the number of pixels of movement required to initiate a constraint gesture.
|
float |
getMinGestureFloat()
Float version of
getMinGesture . |
static float |
getMinScale()
Gets the smallest scale that any dragger will write.
|
SbMatrix |
getMotionMatrix()
Get the motion matrix.
|
SoDragger.TrackerDirectModes |
getTrackerDirectMode()
Get the current tracker direct mode for this dragger.
|
void |
removeFinishCallback(SoDraggerCB cb,
java.lang.Object userData)
Removes finish callback.
|
void |
removeMotionCallback(SoDraggerCB cb,
java.lang.Object userData)
Removes motion callback.
|
void |
removeStartCallback(SoDraggerCB cb,
java.lang.Object userData)
Removes start callback.
|
void |
removeValueChangedCallback(SoDraggerCB cb,
java.lang.Object userData)
Removes value-changed callback.
|
static void |
setInitialTrackerDirectMode()
Calls setInitialTrackerDirectMode(SoDragger.TrackerDirectModes.valueOf( SoDragger.TrackerDirectModes.DEFAULT.getValue() )).
|
static void |
setInitialTrackerDirectMode(SoDragger.TrackerDirectModes mode)
Set the initial tracker direct mode for draggers not yet created.
|
void |
setMinGesture(float pixels)
Float version of
setMinGesture . |
void |
setMinGesture(int pixels)
Sets the number of pixels of movement required to initiate a constraint gesture.
|
static void |
setMinScale(float newMinScale)
Sets the smallest scale that any dragger will write.
|
void |
setMotionMatrix(SbMatrix newMatrix)
Set the motion matrix.
|
void |
setTrackerDirectMode()
Calls setTrackerDirectMode(SoDragger.TrackerDirectModes.valueOf( SoDragger.TrackerDirectModes.DEFAULT.getValue() )).
|
void |
setTrackerDirectMode(SoDragger.TrackerDirectModes mode)
Sets the tracker direct mode for this dragger (see description above).
|
setPartAsPath
getNodekitCatalog, getPart, getPart, getPartString, getViewportIsEnabled, getViewportOrigin, getViewportSize, isSearchingChildren, set, set, setPart, setSearchingChildren
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, setToDefaults
dispose, getEXTERNPROTO, getName, getPROTO, isDisposable, isSynchronizable, setName, setSynchronizable
getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int NONE
SoDragger.TrackerDirectModes.NONE
instead.@Deprecated public static final int MOVE
SoDragger.TrackerDirectModes.MOVE
instead.@Deprecated public static final int ROTATE
SoDragger.TrackerDirectModes.ROTATE
instead.@Deprecated public static final int FREE
SoDragger.TrackerDirectModes.FREE
instead.@Deprecated public static final int DEFAULT
SoDragger.TrackerDirectModes.DEFAULT
instead.public final SoSFBool isActive
public final SoSFBool enableCallbacks
enableValueChangedCallbacks
method.
public void addValueChangedCallback(SoDraggerCB cb, java.lang.Object userData)
enableValueChangedCallbacks(boolean)
.public void removeValueChangedCallback(SoDraggerCB cb, java.lang.Object userData)
public void addStartCallback(SoDraggerCB cb, java.lang.Object userData)
public void removeStartCallback(SoDraggerCB cb, java.lang.Object userData)
public void addMotionCallback(SoDraggerCB cb, java.lang.Object userData)
public void removeMotionCallback(SoDraggerCB cb, java.lang.Object userData)
public void addFinishCallback(SoDraggerCB cb, java.lang.Object userData)
public void removeFinishCallback(SoDraggerCB cb, java.lang.Object userData)
public static void setInitialTrackerDirectMode()
public void setTrackerDirectMode()
public static void setMinScale(float newMinScale)
public static float getMinScale()
public static void setInitialTrackerDirectMode(SoDragger.TrackerDirectModes mode)
public SbMatrix getMotionMatrix()
Generally, it is better to look in a dragger's fields to find out about its state. For example, looking at the 'translation' field of an SoTranslate1Dragger
is easier than extracting the translation from its motion matrix. However for some complex draggers, e.g. SoCenterballDragger
, it is not possible to reconstruct the internal matrix from the external fields. This method is useful in that case.
public SoDragger.TrackerDirectModes getTrackerDirectMode()
public static SoNodekitCatalog getClassNodekitCatalog()
SoNodekitCatalog
for this class.public void setMotionMatrix(SbMatrix newMatrix)
Triggers value changed callbacks, but only if newMatrix != the current motionMatrix. Value changed callbacks can be disabled using the enableValueChangedCallbacks
method.
public int getMinGesture()
public float getMinGestureFloat()
getMinGesture
.
It can be used when a desktop is magnified on a wall of screens using ScaleViz with a tracker device calibrated for this wall.public boolean enableValueChangedCallbacks(boolean newVal)
public void setMinGesture(float pixels)
setMinGesture
.
It can be used when a desktop is magnified on a wall of screens using ScaleViz with a tracker device calibrated for this wall.public static SoDragger.TrackerDirectModes getInitialTrackerDirectMode()
public void setTrackerDirectMode(SoDragger.TrackerDirectModes mode)
public void setMinGesture(int pixels)
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com