Open Inventor Reference
|
Box-like object you scale, rotate, and translate by dragging with the mouse. More...
#include <Inventor/draggers/SoTransformerDragger.h>
Public Types | |
enum | State { INACTIVE, RIT_X_ROTATE, TOP_Y_ROTATE, FNT_Z_ROTATE, LFT_X_ROTATE, BOT_Y_ROTATE, BAK_Z_ROTATE, PX_PY_PZ_3D_SCALE, PX_PY_NZ_3D_SCALE, PX_NY_PZ_3D_SCALE, PX_NY_NZ_3D_SCALE, NX_PY_PZ_3D_SCALE, NX_PY_NZ_3D_SCALE, NX_NY_PZ_3D_SCALE, NX_NY_NZ_3D_SCALE, RIT_TRANSLATE, TOP_TRANSLATE, FNT_TRANSLATE, LFT_TRANSLATE, BOT_TRANSLATE, BAK_TRANSLATE } |
Public Member Functions | |
SoTransformerDragger () | |
Constructor. | |
void | unsquishKnobs () |
Tells the dragger to unsquish its rotation and scale knobs during the next traversal. | |
SbBool | isLocateHighlighting () |
Controls whether or not locate highlighting is used. | |
void | setLocateHighlighting (SbBool onOff) |
Controls whether or not locate highlighting is used. | |
SbVec3f | getBoxPointInWorldSpace (const SbVec3f &pointOnUnitBox) |
These convert points and directions from the space of the unit box to world space. | |
SbVec3f | getBoxDirInWorldSpace (const SbVec3f &dirOnUnitBox) |
SbVec3f | getWorldPointInBoxSpace (const SbVec3f &pointInWorldSpace) |
SbVec2f | getWorldPointInPixelSpace (const SbVec3f &thePoint) |
SbVec3f | getInteractiveCenterInBoxSpace () |
Callbacks would like to know this sometimes. | |
State | getCurrentState () |
Static Public Member Functions | |
static void | setColinearThreshold (int newVal) |
static int | getColinearThreshold () |
When picking a direction for constraining based on gesture, this paramater determines how many pixels must separate two axes before they are regarded as distinct. | |
static void | initClass () |
initialize the class | |
Public Attributes | |
SoSFRotation | rotation |
SoSFVec3f | translation |
SoSFVec3f | scaleFactor |
SoSFFloat | minDiscRotDot |
0-1, specifies minimum dot product | |
Protected Member Functions | |
void | dragStart () |
These really do the work during startCB, motionCB, and finishCB. | |
void | drag () |
void | dragFinish () |
void | setAllPartSwitches (int scaleAssemblyWhich, int rotateAssemblyWhich, int translateAssemblyWhich) |
Sets switch values for all parts in the scale, rotate, and translate assemblies. | |
virtual SbBool | setUpConnections (SbBool onOff, SbBool doItAlways=FALSE) |
detach/attach any sensors, callbacks, and/or field connections. | |
virtual void | setDefaultOnNonWritingFields () |
Called by the SoBaseKit::write() method. | |
virtual | ~SoTransformerDragger () |
void | updateAntiSquishList () |
Finds all SoAntiSquish nodes in subgraph and puts them in list. | |
int | getMouseGestureDirection (SbBool xAllowed, SbBool yAllowed, SbBool zAllowed) |
Static Protected Member Functions | |
static void | startCB (void *, SoDragger *) |
Callbacks for drag start, motion, and finish. | |
static void | motionCB (void *, SoDragger *) |
static void | finishCB (void *, SoDragger *) |
static void | fieldSensorCB (void *, SoSensor *) |
static void | valueChangedCB (void *, SoDragger *) |
static void | metaKeyChangeCB (void *, SoDragger *) |
Callbacks for pressing and releasing the meta keys. | |
static int | getIgnoreAxis (SbVec2f axis[3][2], SbBool xAllowed, SbBool yAllowed, SbBool zAllowed) |
static void | makeMinorAxisPerpendicularIfColinear (SbVec2f origin, SbVec2f axisEnds[3][2], int indexA, int indexB) |
static SbBool | isColinear (SbVec2f a1[2], SbVec2f a2[2], int pixels) |
Protected Attributes | |
SoFieldSensor * | translFieldSensor |
SoFieldSensor * | scaleFieldSensor |
SoFieldSensor * | rotateFieldSensor |
SoNodeList | antiSquishList |
Tells all nodes in the antiSquishList to recalculate next time through. |
SoTransformerDragger is a dragger shaped like a box. It has small cubes at the corners and small balls sticking out of the middle of each face. Click and drag any face of the box for 2D translation in the plane of that face. Drag any corner-cube to scale the box uniformly. Pick any of the mid-face balls to rotate the whole dragger about its center.
The SoTransformerDragger uses locate highlighting, so you can tell which part you are about to select before pressing the mouse button. By default, the locate highlight color is gold.
Click-drag any face to translate the dragger within the plane of that face. The face you selected will highlight in yellow. While you drag, yellow feedback arrows display the two directions of motion. Press the <Shift>
key and the arrows turn orange; you may now pick between these two directions to constrain the motion. The direction you move the cursor in will determine which direction is chosen. Press the <Control>
key and the dragger will translate perpendicular to that plane. The translation field is modified as the face is dragged.
Click a corner to scale the dragger. The corner you selected will turn yellow and radial lines will indicate that you may move toward and away from the center of the box. Drag radially and you will perform uniform scale. Press the <Control>
key to scale about the opposite corner instead of the center of the box.
To stretch the dragger non-uniformly, press <Shift>
when you drag the corner cube. Now you will see three orange arrows indicating that your gesture will determine which direction to choose. Move the cursor and the selected arrow will turn yellow while the others disappear. Now the dragger will stretch only in the direction you selected. Pressing <Control>
at the same time as <Shift>
allows you to stretch the dragger while keeping the opposite side pinned in place. When you drag a corner, this modifies the scaleFactor and possibly the translation field of the dragger.
Click one of the spherical knobs to rotate the dragger. When you first click, you'll see two orange lines and two purple circles. The purple circles indicate the two ways you can rotate. The orange lines are, once again, the two choices for your mouse gesture. Each line begins you moving around one of the two circles. Once you move the cursor far enough, the selected line turns yellow and you begin rotating the dragger about the selected circle. The other circle and line will disappear.
To perform unconstrained ("free") rotation, just press <Shift>
while you drag the spherical knob. There will be no choices; instead all three purple circles will be displayed, forming a ball that you can roll around. Regardless of how you rotate, dragging the spherical knobs will modify the rotatation field of the dragger. Depending on how it is centered and what transforms precede it in the scene graph, rotation is likely to affect the translation and scaleFactor fields as well.
Pressing the <Control>
key will change the center of rotation in both the constrained and unconstrained (<Shift>
) case. By default, rotation occurs about the center of the bounding box. With <Control>
depressed, rotation occurs about the middle of the opposite side of the bounding box. The purple feedback will change to illustrate this; the feedback circles increase in size and purple crosshairs sprout at the new rotational center.
Ordinarily, the knobs of the dragger are unsquished upon readin from file and when the mouse button is released at the end of a drag. If you want this to happen more often, then you should call the method unsquishKnobs.
As with all draggers, if you change the fields the dragger will move to match the new settings.
Remember:
This is not an SoTransform!. If you want to move other objects with this dragger, you can either:
[a] Use an SoTransformerManip, which is subclassed from SoTransform. It creates one of these draggers and uses it as the interface to change its fields. (see the SoTransformerManip man page).
[b] Use field-to-field connections to connect the fields of this dragger to those of any SoTransformation node.
You can change the parts in any instance of this dragger using setPart(). The default part geometries are defined as resources for this SoTransformerDragger class. They are detailed in the Dragger Resources section of the online reference page for this class. You can make your program use different default resources for the parts by copying the file /usr/share/data/draggerDefaults/transformerDragger.iv into your own directory, editing the file, and then setting the environment variable SO_DRAGGER_DIR to be a path to that directory.
TransformerDragger { renderCaching AUTO boundingBoxCaching AUTO renderCulling AUTO pickCulling AUTO isActive FALSE translation 0 0 0 scaleFactor 1 1 1 rotation 0 0 1 0 minDiscRotDot 0.025 }
Definition at line 284 of file SoTransformerDragger.h.
Definition at line 489 of file SoTransformerDragger.h.
SoTransformerDragger::SoTransformerDragger | ( | ) |
virtual SoTransformerDragger::~SoTransformerDragger | ( | ) | [protected, virtual] |
void SoTransformerDragger::drag | ( | ) | [protected] |
void SoTransformerDragger::dragFinish | ( | ) | [protected] |
void SoTransformerDragger::dragStart | ( | ) | [protected] |
static void SoTransformerDragger::fieldSensorCB | ( | void * | , |
SoSensor * | |||
) | [static, protected] |
Reimplemented from SoInteractionKit.
static void SoTransformerDragger::finishCB | ( | void * | , |
SoDragger * | |||
) | [static, protected] |
Can be useful during callbacks.
static int SoTransformerDragger::getColinearThreshold | ( | ) | [inline, static] |
If they are deemed "the same" then the shorter of the two will be discarded.
Definition at line 467 of file SoTransformerDragger.h.
State SoTransformerDragger::getCurrentState | ( | ) | [inline] |
Definition at line 501 of file SoTransformerDragger.h.
static int SoTransformerDragger::getIgnoreAxis | ( | SbVec2f | axis[3][2], |
SbBool | xAllowed, | ||
SbBool | yAllowed, | ||
SbBool | zAllowed | ||
) | [static, protected] |
SbVec3f SoTransformerDragger::getInteractiveCenterInBoxSpace | ( | ) | [inline] |
It's the location in bbox space of the point about which the transformer is rotating or scaling. It's different depending on which part is picked (determined by getCurrentState()) and which modifier keys are down.
Definition at line 483 of file SoTransformerDragger.h.
int SoTransformerDragger::getMouseGestureDirection | ( | SbBool | xAllowed, |
SbBool | yAllowed, | ||
SbBool | zAllowed | ||
) | [protected] |
static void SoTransformerDragger::initClass | ( | ) | [static] |
Reimplemented from SoDragger.
static SbBool SoTransformerDragger::isColinear | ( | SbVec2f | a1[2], |
SbVec2f | a2[2], | ||
int | pixels | ||
) | [static, protected] |
SbBool SoTransformerDragger::isLocateHighlighting | ( | ) | [inline] |
Default is TRUE.
Definition at line 456 of file SoTransformerDragger.h.
static void SoTransformerDragger::makeMinorAxisPerpendicularIfColinear | ( | SbVec2f | origin, |
SbVec2f | axisEnds[3][2], | ||
int | indexA, | ||
int | indexB | ||
) | [static, protected] |
static void SoTransformerDragger::metaKeyChangeCB | ( | void * | , |
SoDragger * | |||
) | [static, protected] |
static void SoTransformerDragger::motionCB | ( | void * | , |
SoDragger * | |||
) | [static, protected] |
void SoTransformerDragger::setAllPartSwitches | ( | int | scaleAssemblyWhich, |
int | rotateAssemblyWhich, | ||
int | translateAssemblyWhich | ||
) | [protected] |
static void SoTransformerDragger::setColinearThreshold | ( | int | newVal | ) | [inline, static] |
Definition at line 462 of file SoTransformerDragger.h.
virtual void SoTransformerDragger::setDefaultOnNonWritingFields | ( | ) | [protected, virtual] |
Draggers don't want to write out fields if they have default vals.
sets isActive to default if default and not connected.
Looks for fields named: 'rotation' with value SbRotation::identity() 'translation' with value (0,0,0) 'center' with value (0,0,0) 'scaleFactor' with value (1,1,1) and sets them to default if they are not connected from a field. (most draggers are missing at least some of these, but thats okay)
Then calls the method for SoInteractionKit.
NOTE: Parts which are set to default may still wind up writing to file if, for example, they lie on a path.
Reimplemented from SoDragger.
void SoTransformerDragger::setLocateHighlighting | ( | SbBool | onOff | ) |
Default is TRUE.
virtual SbBool SoTransformerDragger::setUpConnections | ( | SbBool | onOff, |
SbBool | doItAlways = FALSE |
||
) | [protected, virtual] |
Called by: start/end of SoBaseKit::readInstance and on new copy by: start/end of SoBaseKit::copy. Classes that redefine must call setUpConnections(TRUE,TRUE) at end of constructor. Returns the state of the node when this was called.
Reimplemented from SoInteractionKit.
static void SoTransformerDragger::startCB | ( | void * | , |
SoDragger * | |||
) | [static, protected] |
void SoTransformerDragger::unsquishKnobs | ( | ) |
Ordinarily, the knobs are only unsquished upon readin from file and when the mouse button is released at the end of a drag. If you want this to happen more often, then you should call this method.
void SoTransformerDragger::updateAntiSquishList | ( | ) | [protected] |
static void SoTransformerDragger::valueChangedCB | ( | void * | , |
SoDragger * | |||
) | [static, protected] |
SoNodeList SoTransformerDragger::antiSquishList [protected] |
Definition at line 545 of file SoTransformerDragger.h.
Definition at line 445 of file SoTransformerDragger.h.
SoFieldSensor* SoTransformerDragger::rotateFieldSensor [protected] |
Definition at line 512 of file SoTransformerDragger.h.
Definition at line 442 of file SoTransformerDragger.h.
Definition at line 444 of file SoTransformerDragger.h.
SoFieldSensor* SoTransformerDragger::scaleFieldSensor [protected] |
Definition at line 511 of file SoTransformerDragger.h.
Definition at line 443 of file SoTransformerDragger.h.
SoFieldSensor* SoTransformerDragger::translFieldSensor [protected] |
Definition at line 510 of file SoTransformerDragger.h.