| 1 |
NAME SoDragger SoDrag "" { base class for nodekits that move in response to click-drag-release mouse events } |
| 2 |
|
| 3 |
INCLUDE draggers/SoDragger.h |
| 4 |
|
| 5 |
TYPEDEF void SoDraggerCB "(void *userData, SoDragger *dragger)" |
| 6 |
|
| 7 |
DESC { \cSoDragger\. |
| 8 |
is the base class for all nodekits you move by using the mouse to |
| 9 |
click-drag-and-release. More specifically, |
| 10 |
they are operated by a start (mouse button 1 pressed over dragger to pick it), |
| 11 |
followed by dragging (mouse motion events are interpreted by the dragger |
| 12 |
and result in some form of motion and/or change to a field), |
| 13 |
followed by finish (mouse up). |
| 14 |
\p |
| 15 |
Each dragger has a different paradigm for interpreting mouse motion and |
| 16 |
changing its fields as a result. |
| 17 |
Draggers map 2D mouse motion into motion of a point on 3D lines, planes, |
| 18 |
spheres or cylinders. (See the \cSbProjector\. reference pages.) |
| 19 |
Then they react to this motion of a point through 3-space by scaling, |
| 20 |
translating, or rotating. |
| 21 |
For example, \cSoTranslate2Dragger\. maps mouse motion onto a |
| 22 |
3D plane, then translates to follow the cursor as it moves within that plane. |
| 23 |
\p |
| 24 |
Every dragger has \efields\. that describe its current state. |
| 25 |
Scaling draggers have a \vscaleFactor\. field, rotational draggers have |
| 26 |
a \vrotation\. field, etc. |
| 27 |
All draggers have the \visActive\. field, defined in this class. |
| 28 |
It is TRUE while the dragger is being dragged, FALSE otherwise. |
| 29 |
\p |
| 30 |
Draggers that have only one part to pick and one motion field are called |
| 31 |
\esimple draggers\.. Examples are the \cSoRotateDiscDragger\., |
| 32 |
\cSoScale1Dragger\., and \cSoTranslate2Dragger\.. |
| 33 |
\p |
| 34 |
Draggers that create assemblies out of other draggers and then orchestrate |
| 35 |
the motion of the whole assembly are call \ecomposite draggers\.. |
| 36 |
\cSoTransformBoxDragger\. is a composite dragger made entirely of simple |
| 37 |
draggers. \cSoDirectionalLightDragger\. contains both a simple dragger |
| 38 |
(\cSoRotateSphericalDragger\.) and a composite dragger (\cSoDragPointDragger\.) |
| 39 |
When using a composite dragger, the fields of the composite dragger |
| 40 |
are the ones you should work with. Draggers |
| 41 |
lower down in the assemblage usually have zeroed out values. |
| 42 |
For example, when you drag the face |
| 43 |
of a transformBox, an \cSoTranslate2Dragger\., the transformBox "steals" |
| 44 |
the translation from the child dragger and transfers it up to the top of the |
| 45 |
composite dragger, where it effects all pieces of the assemblage. |
| 46 |
\p |
| 47 |
Draggers always keep their fields up to date, including while they are |
| 48 |
being dragged. So you can use field-to-field connections and engines to |
| 49 |
connect dragger values to other parts of your scene graph. |
| 50 |
Hence draggers can be easily utilized as input devices for |
| 51 |
mouse-driven 3D interface elements. |
| 52 |
You can also register value-changed callbacks, which are called whenever any |
| 53 |
of the fields is changed. |
| 54 |
\p |
| 55 |
Also, if you set the field of a dragger through some method other than dragging, |
| 56 |
(by calling \m\+setValue()\.\-SoFieldSetValue()\.\., for example), |
| 57 |
the dragger's internal \cSoFieldSensor\. will sense this and the dragger |
| 58 |
will move to satisfy that new value. |
| 59 |
\p |
| 60 |
This makes it easy to constrain draggers to keep their fields within certain |
| 61 |
limits: if the limit is exceeded, just set it back to the exceeded maximum or |
| 62 |
minimum. You can do this even as the dragger is in use, by constraining the |
| 63 |
field value within a value-changed callback that you add with |
| 64 |
\m\+addValueChangedCallback()\.\-SoDraggerAddValueChangedCB\.\.. In this |
| 65 |
case, be sure to temporarily disable the other value-changed callbacks using |
| 66 |
\m\+enableValueChangedCallbacks()\.\-SoDraggerEnableValueChangedCBs\.\.. |
| 67 |
Doing this will prevent infinite-looping; changing the value followed |
| 68 |
by calling the callbacks which change the value ad infinitum. |
| 69 |
\p |
| 70 |
When you drag a dragger, the dragger only moves itself. |
| 71 |
Draggers do not change the state or affect objects that follow in the scene |
| 72 |
graph. |
| 73 |
For example a dragger does not ever behave like an \cSoTransform\. and |
| 74 |
change the current transformation matrix. |
| 75 |
Draggers are not transforms, even if they have field names like |
| 76 |
translation, rotation, scaleFactor. Many draggers, such |
| 77 |
as \cSoTrackballDragger\., have a corresponding \cSoTransformManip\., in |
| 78 |
this case \cSoTrackballManip\.. The manipulator is a subclass of \cSoTransform\., |
| 79 |
and affects other objects in the scene; it uses a trackball \edragger\. to |
| 80 |
provide its user interface. |
| 81 |
In this way, draggers are employed extensively by manipulators. |
| 82 |
Callback functions on the dragger allow its employer to be |
| 83 |
notified of start, motion, finish, and value changes. |
| 84 |
In all cases, the callback function is passed a pointer to the |
| 85 |
dragger which initiated the callback. |
| 86 |
(See the various man pages for more details on specific draggers and |
| 87 |
manipulators). |
| 88 |
\p |
| 89 |
All draggers are nodekits. |
| 90 |
However, draggers do not list their parts in the Parts section of the |
| 91 |
reference page. Instead, there is a section called Dragger Resources, |
| 92 |
more suited to describe the parts made available to the programmer. |
| 93 |
Because of space limitations, the Dragger Resources section only |
| 94 |
appears in the online versions of the reference pages. |
| 95 |
Each dragger has some parts you can pick on, and other parts that replace |
| 96 |
them when they are \eactive\. or moving. These active parts are often |
| 97 |
just the same geometry in another color. |
| 98 |
Draggers also have pieces for displaying feedback. |
| 99 |
Each of these pieces has a default scene graph, as well as a special |
| 100 |
function within the dragger. Each part also has a \kresource name\.. |
| 101 |
All this information is contained in the \kDRAGGER RESOURCES\. section. |
| 102 |
\p |
| 103 |
Since draggers are nodekits, you can set the parts in any instance of a dragger using |
| 104 |
\m\+setPart()\.\-SoDraggerSetPart()\.\.. |
| 105 |
\p |
| 106 |
But draggers also give each part a \eresource name\.. |
| 107 |
When a dragger builds a part, it looks in the global dictionary for the |
| 108 |
node with that \vresourceName\.. By putting a new entry in the dictionary, |
| 109 |
you can override that default. |
| 110 |
The default part geometries are defined as resources for each class, |
| 111 |
and each class has a file you can change to alter the defaults. |
| 112 |
The files are listed in each dragger's man page. |
| 113 |
You can make your program use different default resources for the parts |
| 114 |
by copying the listed file from the directory |
| 115 |
\v/usr/share/data/draggerDefaults\. |
| 116 |
into your own directory, editing the file, and then |
| 117 |
setting the environment variable \vSO_DRAGGER_DIR\. to be a path to that directory. |
| 118 |
} |
| 119 |
|
| 120 |
FIELD isActive { TRUE when mouse is down and dragging, else FALSE. } |
| 121 |
|
| 122 |
METHOD "addStartCB" void addStartCallback(SoDraggerCB *f, void *userData = NULL) {} |
| 123 |
METHOD "removeStartCB" void removeStartCallback(SoDraggerCB *f, void *userData = NULL) { |
| 124 |
Start callbacks are made after the mouse button 1 goes down and the |
| 125 |
dragger determines that it has been picked. If it is going to begin dragging, |
| 126 |
it grabs events and invokes the startCallbacks. |
| 127 |
} |
| 128 |
|
| 129 |
METHOD "addMotionCB" void addMotionCallback(SoDraggerCB *f, void *userData = NULL) {} |
| 130 |
METHOD "removeMotionCB" void removeMotionCallback(SoDraggerCB *f, void *userData = NULL) { |
| 131 |
Motion callbacks are called after each movement of the mouse |
| 132 |
during dragging. |
| 133 |
} |
| 134 |
|
| 135 |
METHOD "addFinishCB" void addFinishCallback(SoDraggerCB *f, void *userData = NULL) {} |
| 136 |
METHOD "removeFinishCB" void removeFinishCallback(SoDraggerCB *f, void *userData = NULL) { |
| 137 |
Finish callbacks are made after dragging ends and the dragger has |
| 138 |
stopped grabbing events. |
| 139 |
} |
| 140 |
|
| 141 |
METHOD "addValueChangedCB" void addValueChangedCallback(SoDraggerCB *f, void *userData = NULL) {} |
| 142 |
METHOD "removeValueChangedCB" void removeValueChangedCallback(SoDraggerCB *f, void *userData = NULL) { |
| 143 |
Value-changed callbacks are made after a dragger changes any of its fields. |
| 144 |
This does not include changes to the \visActive\. field. |
| 145 |
See also \m\+enableValueChangedCallbacks\.\-SoDraggerEnableValueChangedCBs\.\.. |
| 146 |
} |
| 147 |
|
| 148 |
METHOD "enableValueChangedCBs" SbBool enableValueChangedCallbacks() { |
| 149 |
You can temporarily disable a dragger's valueChangedCallbacks. |
| 150 |
The method returns a value that tells you if callbacks were already |
| 151 |
enabled. Use this method if you write a valueChanged callback of your |
| 152 |
own and you change one of the dragger's fields within the callback. |
| 153 |
(For example, when writing a callback to constrain your dragger). |
| 154 |
Disable first, then change the field, then re-enable the callbacks (if they |
| 155 |
were enabled to start with). |
| 156 |
All this prevents you from entering an infinite loop of changing values, |
| 157 |
calling callbacks which change values, etc. |
| 158 |
} |
| 159 |
|
| 160 |
METHOD "" void setMinGesture(int pixels) {} |
| 161 |
METHOD "" int getMinGesture() const { |
| 162 |
Set and get the number of pixels of movement required to |
| 163 |
initiate a constraint gesture. Default is 8. |
| 164 |
} |
| 165 |
|
| 166 |
METHOD "" static void setMinScale(float newMinScale) { } |
| 167 |
METHOD "" static float getMinScale() { |
| 168 |
The smallest scale that any dragger will write. If the user attempts |
| 169 |
to go below this amount, the dragger will set it to this minimum. |
| 170 |
Default is .001 |
| 171 |
} |
| 172 |
|
| 173 |
METHOD getClassNkitCat static |
| 174 |
const SoNodekitCatalog *getClassNodekitCatalog() const |
| 175 |
{ Returns an \cSoNodekitCatalog\. for this class. } |
| 176 |
|
| 177 |
METHOD "" static SoType getClassTypeId() { |
| 178 |
Returns type identifier for this class. |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
ALSO { |
| 183 |
SoInteractionKit, |
| 184 |
SoCenterballDragger, |
| 185 |
SoDirectionalLightDragger, |
| 186 |
SoDragPointDragger, |
| 187 |
SoHandleBoxDragger, |
| 188 |
SoJackDragger, |
| 189 |
SoPointLightDragger, |
| 190 |
SoRotateCylindricalDragger, |
| 191 |
SoRotateDiscDragger, |
| 192 |
SoRotateSphericalDragger, |
| 193 |
SoScale1Dragger, |
| 194 |
SoScale2Dragger, |
| 195 |
SoScale2UniformDragger, |
| 196 |
SoScaleUniformDragger, |
| 197 |
SoSpotLightDragger, |
| 198 |
SoTabBoxDragger, |
| 199 |
SoTabPlaneDragger, |
| 200 |
SoTrackballDragger, |
| 201 |
SoTransformBoxDragger, |
| 202 |
SoTransformerDragger, |
| 203 |
SoTranslate1Dragger, |
| 204 |
SoTranslate2Dragger |
| 205 |
} |