| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * Further, this software is distributed without any warranty that it is |
| 16 | * free of the rightful claim of any third person regarding infringement |
| 17 | * or the like. Any license provided herein, whether implied or |
| 18 | * otherwise, applies only to this software file. Patent licenses, if |
| 19 | * any, provided herein do not apply to combinations of this program with |
| 20 | * other software, or any other product whatsoever. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 | * Mountain View, CA 94043, or: |
| 28 | * |
| 29 | * http://www.sgi.com |
| 30 | * |
| 31 | * For further information regarding this notice, see: |
| 32 | * |
| 33 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | /* |
| 38 | * Copyright (C) 1990,91 Silicon Graphics, Inc. |
| 39 | * |
| 40 | _______________________________________________________________________ |
| 41 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 42 | | |
| 43 | | $Revision: 1.1.1.1 $ |
| 44 | | |
| 45 | | Classes: |
| 46 | | SoRotateCylindricalDragger |
| 47 | | |
| 48 | | Author(s): Paul Isaacs, Howard Look |
| 49 | | |
| 50 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 51 | _______________________________________________________________________ |
| 52 | */ |
| 53 | |
| 54 | |
| 55 | #include <cstdio> |
| 56 | #include <Inventor/SbLinear.h>cxx . . $ `<file>/lib/database/include/Inventor/SbLinear.h`/ |
| 57 | #include <Inventor/SoDB.h>cxx . . $ `<file>/lib/database/include/Inventor/SoDB.h`/ |
| 58 | #include <Inventor/sensors/SoFieldSensor.h>cxx . . $ `<file>/lib/database/include/Inventor/sensors/SoFieldSensor.h`/ |
| 59 | #include <Inventor/SoInput.h>cxx . . $ `<file>/lib/database/include/Inventor/SoInput.h`/ |
| 60 | #include <Inventor/SoPath.h>cxx . . $ `<file>/lib/database/include/Inventor/SoPath.h`/ |
| 61 | #include <Inventor/projectors/SbCylinderPlaneProjector.h>cxx . . $ `<file>/lib/database/include/Inventor/projectors/SbCylinderPlaneProjector.h`/ |
| 62 | #include <Inventor/draggers/SoRotateCylindricalDragger.h>cxx . . $ `<file>/lib/interaction/include/Inventor/draggers/SoRotateCylindricalDragger.h`/ |
| 63 | #include <Inventor/nodes/SoSeparator.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSeparator.h`/ |
| 64 | #include <Inventor/nodes/SoSwitch.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSwitch.h`/ |
| 65 | |
| 66 | #include "geom/SoRotateCylindricalDraggerGeom.h"cxx . . $ `<file>/lib/interaction/src/draggers/geom/SoRotateCylindricalDraggerGeom.h`/ |
| 67 | |
| 68 | |
| 69 | SO_KIT_SOURCEcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:194:9`!(SoRotateCylindricalDragger); |
| 70 | |
| 71 | |
| 72 | //////////////////////////////////////////////////////////////////////// |
| 73 | // |
| 74 | // Description: |
| 75 | // Constructor |
| 76 | // |
| 77 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#SoRotateCylindricalDragger(49f6e7a06ebc5aa8).() |
| 78 | // |
| 79 | //////////////////////////////////////////////////////////////////////// |
| 80 | { |
| 81 | SO_KIT_CONSTRUCTORcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:254:9`!(SoRotateCylindricalDragger); |
| 82 | |
| 83 | isBuiltIncxx . . $ SoFieldContainer#isBuiltIn. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 84 | |
| 85 | // Put this stuff under the geomSeparator so it will draw more |
| 86 | // efficiently. |
| 87 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(rotatorSwitch, SoSwitch, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, |
| 88 | geomSeparator, ,FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 89 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(rotator, SoSeparator, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, |
| 90 | rotatorSwitch, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 91 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(rotatorActive, SoSeparator, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, |
| 92 | rotatorSwitch, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 93 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(feedbackSwitch, SoSwitch, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, |
| 94 | geomSeparator, ,FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 95 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(feedback, SoSeparator, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, |
| 96 | feedbackSwitch, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 97 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(feedbackActive, SoSeparator, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, |
| 98 | feedbackSwitch, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 99 | |
| 100 | // read geometry for shared parts |
| 101 | if (SO_KIT_IS_FIRST_INSTANCEcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:258:9`!()) |
| 102 | readDefaultPartscxx . . $ SoInteractionKit#readDefaultParts(5e891a9f77bb0eff).("rotateCylindricalDragger.iv", geomBuffercxx . . $ SoRotateCylindricalDragger#geomBuffer., sizeof(geomBuffercxx . . $ SoRotateCylindricalDragger#geomBuffer.) ); |
| 103 | |
| 104 | SO_KIT_ADD_FIELDcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:261:9`!(rotation, (0.0, 0.0, 0.0, 1.0)); |
| 105 | |
| 106 | SO_KIT_INIT_INSTANCEcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:546:9`!(); |
| 107 | |
| 108 | // create the parts... |
| 109 | setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("rotator"cxx . . $ SbName#SbName(85c52e162fed56f9)., "rotateCylindricalRotator"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 110 | setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("rotatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., |
| 111 | "rotateCylindricalRotatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 112 | setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("feedback"cxx . . $ SbName#SbName(85c52e162fed56f9)., "rotateCylindricalFeedback"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 113 | setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("feedbackActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., |
| 114 | "rotateCylindricalFeedbackActive"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 115 | |
| 116 | // Set the switches to 0... |
| 117 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).( rotatorSwitchcxx . . $ SoRotateCylindricalDragger#rotatorSwitch..getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).(), 0 ); |
| 118 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).( feedbackSwitchcxx . . $ SoRotateCylindricalDragger#feedbackSwitch..getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).(), 0 ); |
| 119 | |
| 120 | // start with our own default projector |
| 121 | // the user can replace if they want |
| 122 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. = new SbCylinderPlaneProjectorcxx . . $ SbCylinderPlaneProjector#(); |
| 123 | userProjcxx . . $ SoRotateCylindricalDragger#userProj. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 124 | |
| 125 | // add the callbacks to perform the dragging |
| 126 | addStartCallbackcxx . . $ SoDragger#addStartCallback(5d3f11b67c4aec04).( &SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::startCBcxx . . $ SoRotateCylindricalDragger#startCB(7027446dc0b7318f). ); |
| 127 | addMotionCallbackcxx . . $ SoDragger#addMotionCallback(5d3f11b67c4aec04).( &SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::motionCBcxx . . $ SoRotateCylindricalDragger#motionCB(7027446dc0b7318f). ); |
| 128 | addFinishCallbackcxx . . $ SoDragger#addFinishCallback(5d3f11b67c4aec04).( &SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::doneCBcxx . . $ SoRotateCylindricalDragger#doneCB(7027446dc0b7318f). ); |
| 129 | |
| 130 | // Updates the scaleFactor field when the motionMatrix is set. |
| 131 | addValueChangedCallbackcxx . . $ SoDragger#addValueChangedCallback(5d3f11b67c4aec04).( &SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::valueChangedCBcxx . . $ SoRotateCylindricalDragger#valueChangedCB(7027446dc0b7318f). ); |
| 132 | |
| 133 | // Updates the motionMatrix when the scaleFactor field is set. |
| 134 | fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor. |
| 135 | = new SoFieldSensorcxx . . $ SoFieldSensor#(&SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::fieldSensorCBcxx . . $ SoRotateCylindricalDragger#fieldSensorCB(c8d298b3e215c027)., this); |
| 136 | fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor.->setPrioritycxx . . $ SoDelayQueueSensor#setPriority(cb2f890c2fdad230).( 0 ); |
| 137 | |
| 138 | setUpConnectionscxx . . $ SoRotateCylindricalDragger#setUpConnections(9b79fb6aee4c0440).( TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`! ); |
| 139 | } |
| 140 | |
| 141 | //////////////////////////////////////////////////////////////////////// |
| 142 | // |
| 143 | // Description: |
| 144 | // Destructor |
| 145 | // |
| 146 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::~cxx . . $ SoRotateCylindricalDragger#`~SoRotateCylindricalDragger`(49f6e7a06ebc5aa8).SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#() |
| 147 | // |
| 148 | //////////////////////////////////////////////////////////////////////// |
| 149 | { |
| 150 | if ( cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. ) |
| 151 | delete cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.; |
| 152 | if (fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor. ) |
| 153 | delete fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor.; |
| 154 | } |
| 155 | |
| 156 | //////////////////////////////////////////////////////////////////////// |
| 157 | // |
| 158 | // Description: |
| 159 | // Redefines this to also copy the projector. |
| 160 | // |
| 161 | // Use: protected, virtual |
| 162 | |
| 163 | void |
| 164 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::copyContentscxx . . $ SoRotateCylindricalDragger#copyContents(502fcadd2953076).(const SoFieldContainercxx . . $ SoFieldContainer# *fromFC, |
| 165 | SbBoolcxx . . $ SbBool# copyConnections) |
| 166 | // |
| 167 | //////////////////////////////////////////////////////////////////////// |
| 168 | { |
| 169 | // Do the usual stuff |
| 170 | SoDraggercxx . . $ SoDragger#::copyContentscxx . . $ SoInteractionKit#copyContents(502fcadd2953076).(fromFC, copyConnections); |
| 171 | |
| 172 | // Now, copy the projector variables... |
| 173 | |
| 174 | const SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *origDragger = |
| 175 | (const SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *) fromFC; |
| 176 | |
| 177 | if ( cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. ) |
| 178 | delete cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.; |
| 179 | |
| 180 | if ( origDragger->cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. ) |
| 181 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. = (SbCylinderProjectorcxx . . $ SbCylinderProjector# *) |
| 182 | origDragger->cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->copycxx . . $ SbProjector#copy(8f29d50edcefcf8d).(); |
| 183 | else |
| 184 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 185 | |
| 186 | userProjcxx . . $ SoRotateCylindricalDragger#userProj. = origDragger->userProjcxx . . $ SoRotateCylindricalDragger#userProj.; |
| 187 | } |
| 188 | |
| 189 | // detach/attach any sensors, callbacks, and/or field connections. |
| 190 | // Called by: start/end of SoBaseKit::readInstance |
| 191 | // and on new copy by: start/end of SoBaseKit::copy. |
| 192 | // Classes that redefine must call setUpConnections(TRUE,TRUE) |
| 193 | // at end of constructor. |
| 194 | // Returns the state of the node when this was called. |
| 195 | SbBoolcxx . . $ SbBool# |
| 196 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::setUpConnectionscxx . . $ SoRotateCylindricalDragger#setUpConnections(9b79fb6aee4c0440).( SbBoolcxx . . $ SbBool# onOff, SbBoolcxx . . $ SbBool# doItAlways ) |
| 197 | { |
| 198 | if ( !doItAlways && connectionsSetUpcxx . . $ SoBaseKit#connectionsSetUp. == onOff) |
| 199 | return onOff; |
| 200 | |
| 201 | if ( onOff ) { |
| 202 | |
| 203 | // We connect AFTER base class. |
| 204 | SoDraggercxx . . $ SoDragger#::setUpConnectionscxx . . $ SoInteractionKit#setUpConnections(9b79fb6aee4c0440).( onOff, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 205 | |
| 206 | // Call the sensor CBs to make things are up-to-date. |
| 207 | fieldSensorCBcxx . . $ SoRotateCylindricalDragger#fieldSensorCB(c8d298b3e215c027).( this, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ); |
| 208 | |
| 209 | // Connect the field sensors |
| 210 | if (fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor.->getAttachedFieldcxx . . $ SoFieldSensor#getAttachedField(c4a4d937024b6702).() != &rotationcxx . . $ SoRotateCylindricalDragger#rotation.) |
| 211 | fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &rotationcxx . . $ SoRotateCylindricalDragger#rotation. ); |
| 212 | } |
| 213 | else { |
| 214 | |
| 215 | // We disconnect BEFORE base class. |
| 216 | |
| 217 | // Disconnect the field sensors. |
| 218 | if (fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor.->getAttachedFieldcxx . . $ SoFieldSensor#getAttachedField(c4a4d937024b6702).()) |
| 219 | fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); |
| 220 | |
| 221 | SoDraggercxx . . $ SoDragger#::setUpConnectionscxx . . $ SoInteractionKit#setUpConnections(9b79fb6aee4c0440).( onOff, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 222 | } |
| 223 | |
| 224 | return !(connectionsSetUpcxx . . $ SoBaseKit#connectionsSetUp. = onOff); |
| 225 | } |
| 226 | |
| 227 | //////////////////////////////////////////////////////////////////////// |
| 228 | // |
| 229 | // Description: |
| 230 | // Set the cylinder projector back to the default or to something |
| 231 | // new. |
| 232 | // |
| 233 | // Use: public |
| 234 | // |
| 235 | void |
| 236 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::setProjectorcxx . . $ SoRotateCylindricalDragger#setProjector(442b9a623d78f843).(SbCylinderProjectorcxx . . $ SbCylinderProjector# *proj) |
| 237 | // |
| 238 | //////////////////////////////////////////////////////////////////////// |
| 239 | { |
| 240 | if ( cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. ) |
| 241 | delete cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.; |
| 242 | |
| 243 | if (proj == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 244 | // passing in null resets the projector to the default |
| 245 | userProjcxx . . $ SoRotateCylindricalDragger#userProj. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 246 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. = new SbCylinderPlaneProjectorcxx . . $ SbCylinderPlaneProjector#(); |
| 247 | } |
| 248 | else { |
| 249 | // use the projector passed in |
| 250 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj. = proj; |
| 251 | userProjcxx . . $ SoRotateCylindricalDragger#userProj. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | //////////////////////////////////////////////////////////////////////// |
| 256 | // |
| 257 | // Description: |
| 258 | // Rotate the rotateCylindricalDragger based on mouse motion. |
| 259 | // |
| 260 | // Use: private |
| 261 | // |
| 262 | void |
| 263 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::dragStartcxx . . $ SoRotateCylindricalDragger#dragStart(49f6e7a06ebc5aa8).() |
| 264 | // |
| 265 | //////////////////////////////////////////////////////////////////////// |
| 266 | { |
| 267 | // Set the switches to 1... |
| 268 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).( rotatorSwitchcxx . . $ SoRotateCylindricalDragger#rotatorSwitch..getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).(), 1 ); |
| 269 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).( feedbackSwitchcxx . . $ SoRotateCylindricalDragger#feedbackSwitch..getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).(), 1 ); |
| 270 | |
| 271 | // Establish the projector cylinder in working space. |
| 272 | // Working space is space at end of motion matrix. |
| 273 | // translate direction is defined as (1,0,0) in local space. |
| 274 | // The axis in working space is the Y axis. |
| 275 | SbLinecxx . . $ SbLine# wsAxiscxx . . $ SbLine#SbLine(d696704770a33d8f).(SbVec3fcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,0), SbVec3fcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,1,0)); |
| 276 | |
| 277 | SbVec3fcxx . . $ SbVec3f# startLocalHitPt = getLocalStartingPointcxx . . $ SoDragger#getLocalStartingPoint(42d43ea8522fe3bf).(); |
| 278 | float rad = (startLocalHitPt |
| 279 | -cxx . . $ operator-(af63bf8d0639b76b). wsAxis.getClosestPointcxx . . $ SbLine#getClosestPoint(d67ad7d0c0b29ebb).(startLocalHitPt)).lengthcxx . . $ SbVec3f#length(5036dfe8d4170af2).(); |
| 280 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->setCylindercxx . . $ SbCylinderProjector#setCylinder(c58b45a4694d5726).( SbCylindercxx . . $ SbCylinder#SbCylinder(cdf826ac23993467).(wsAxis, rad) ); |
| 281 | |
| 282 | // If the hit point is on the near side of the center from where |
| 283 | // the eye is, then tell the projector to intersect front. |
| 284 | // Else, tell it to intersect back. |
| 285 | SbMatrixcxx . . $ SbMatrix# lclToWld = getLocalToWorldMatrixcxx . . $ SoDragger#getLocalToWorldMatrix(2db31fc6bbb60646).(); |
| 286 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->setViewVolumecxx . . $ SbProjector#setViewVolume(187982bfa537c808).( getViewVolumecxx . . $ SoDragger#getViewVolume(ee52a61c9e3934e6).() ); |
| 287 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->setWorkingSpacecxx . . $ SbCylinderProjector#setWorkingSpace(37d2f951b3ffd7a6).( lclToWld ); |
| 288 | if (getFrontOnProjectorcxx . . $ SoDragger#getFrontOnProjector(f2ba4169cfff313c).() == USE_PICKcxx . . $ SoDragger#USE_PICK. ) |
| 289 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->setFrontcxx . . $ SbCylinderProjector#setFront(d4f767463ce0a6b3).(cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->isPointInFrontcxx . . $ SbCylinderProjector#isPointInFront(66e1d16e2771ff3b).(startLocalHitPt)); |
| 290 | else if (getFrontOnProjectorcxx . . $ SoDragger#getFrontOnProjector(f2ba4169cfff313c).() == FRONTcxx . . $ SoDragger#FRONT. ) |
| 291 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->setFrontcxx . . $ SbCylinderProjector#setFront(d4f767463ce0a6b3).( TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`! ); |
| 292 | else |
| 293 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->setFrontcxx . . $ SbCylinderProjector#setFront(d4f767463ce0a6b3).( FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 294 | |
| 295 | // The cylindrical (and spherical) projectors are sort of weird in |
| 296 | // that the initial hit defines the projector, but may not actually lie |
| 297 | // on the cylinder or sphere selected. |
| 298 | // This happens when the inital hit is too close to the edge to fit within |
| 299 | // 'tolerance.' |
| 300 | // So, to be sure that we get accurate performance, we need to |
| 301 | // project the mouse onto the projector once it is defined in order to |
| 302 | // get our starting point. |
| 303 | SbVec3fcxx . . $ SbVec3f# localProjectPtcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8)., worldProjectPtcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 304 | localProjectPt =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->projectcxx . . $ SbCylinderProjector#project(52e93d88cc4c3965).( getNormalizedLocaterPositioncxx . . $ SoDragger#getNormalizedLocaterPosition(e67d94fc922bbbd4).()); |
| 305 | lclToWld.multVecMatrixcxx . . $ SbMatrix#multVecMatrix(f4e74898890c8c54).( localProjectPt, worldProjectPt ); |
| 306 | setStartingPointcxx . . $ SoDragger#setStartingPoint(65a601b9d70571d6).( worldProjectPt ); |
| 307 | } |
| 308 | |
| 309 | //////////////////////////////////////////////////////////////////////// |
| 310 | // |
| 311 | // Description: |
| 312 | // Rotate the rotateCylindricalDragger based on mouse motion. |
| 313 | // |
| 314 | // Use: private |
| 315 | // |
| 316 | void |
| 317 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::dragcxx . . $ SoRotateCylindricalDragger#drag(49f6e7a06ebc5aa8).() |
| 318 | // |
| 319 | //////////////////////////////////////////////////////////////////////// |
| 320 | { |
| 321 | // Set up the projector space and view. |
| 322 | // Working space is space at end of motion matrix. |
| 323 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->setViewVolumecxx . . $ SbProjector#setViewVolume(187982bfa537c808).( getViewVolumecxx . . $ SoDragger#getViewVolume(ee52a61c9e3934e6).() ); |
| 324 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->setWorkingSpacecxx . . $ SbCylinderProjector#setWorkingSpace(37d2f951b3ffd7a6).( getLocalToWorldMatrixcxx . . $ SoDragger#getLocalToWorldMatrix(2db31fc6bbb60646).() ); |
| 325 | |
| 326 | // Get newHitPt and startHitPt in workspace. |
| 327 | SbVec3fcxx . . $ SbVec3f# newHitPt |
| 328 | = cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->projectcxx . . $ SbCylinderProjector#project(52e93d88cc4c3965).( getNormalizedLocaterPositioncxx . . $ SoDragger#getNormalizedLocaterPosition(e67d94fc922bbbd4).()); |
| 329 | SbVec3fcxx . . $ SbVec3f# startHitPt = getLocalStartingPointcxx . . $ SoDragger#getLocalStartingPoint(42d43ea8522fe3bf).(); |
| 330 | |
| 331 | // deltaRot is how much we rotated since the mouse button went down. |
| 332 | SbRotationcxx . . $ SbRotation# deltaRot = |
| 333 | cylinderProjcxx . . $ SoRotateCylindricalDragger#cylinderProj.->getRotationcxx . . $ SbCylinderProjector#getRotation(64a7df9701b866d).( startHitPt, newHitPt ); |
| 334 | |
| 335 | // Append this to the startMotionMatrix, which we saved at the beginning |
| 336 | // of the drag, to find the current motion matrix. |
| 337 | setMotionMatrixcxx . . $ SoDragger#setMotionMatrix(37d2f951b3ffd7a6).( |
| 338 | appendRotationcxx . . $ SoDragger#appendRotation(55735ba517c4d581).( getStartMotionMatrixcxx . . $ SoDragger#getStartMotionMatrix(c49c36ee78b0a89e).(), deltaRot, SbVec3fcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,0))); |
| 339 | } |
| 340 | |
| 341 | //////////////////////////////////////////////////////////////////////// |
| 342 | // |
| 343 | // Description: |
| 344 | // Rotate the rotateCylindricalDragger based on mouse motion. |
| 345 | // |
| 346 | // Use: private |
| 347 | // |
| 348 | void |
| 349 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::dragFinishcxx . . $ SoRotateCylindricalDragger#dragFinish(49f6e7a06ebc5aa8).() |
| 350 | // |
| 351 | //////////////////////////////////////////////////////////////////////// |
| 352 | { |
| 353 | // Set the switches to 0... |
| 354 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).( rotatorSwitchcxx . . $ SoRotateCylindricalDragger#rotatorSwitch..getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).(), 0 ); |
| 355 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).( feedbackSwitchcxx . . $ SoRotateCylindricalDragger#feedbackSwitch..getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).(), 0 ); |
| 356 | } |
| 357 | |
| 358 | //////////////////////////////////////////////////////////////////// |
| 359 | // Stubs for callbacks |
| 360 | //////////////////////////////////////////////////////////////////// |
| 361 | void |
| 362 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::startCBcxx . . $ SoRotateCylindricalDragger#startCB(7027446dc0b7318f).( void *, SoDraggercxx . . $ SoDragger# *inDragger ) |
| 363 | { |
| 364 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *dl = (SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *) inDragger; |
| 365 | dl->dragStartcxx . . $ SoRotateCylindricalDragger#dragStart(49f6e7a06ebc5aa8).(); |
| 366 | } |
| 367 | |
| 368 | void |
| 369 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::motionCBcxx . . $ SoRotateCylindricalDragger#motionCB(7027446dc0b7318f).( void *, SoDraggercxx . . $ SoDragger# *inDragger ) |
| 370 | { |
| 371 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *dl = (SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *) inDragger; |
| 372 | dl->dragcxx . . $ SoRotateCylindricalDragger#drag(49f6e7a06ebc5aa8).(); |
| 373 | } |
| 374 | |
| 375 | void |
| 376 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::doneCBcxx . . $ SoRotateCylindricalDragger#doneCB(7027446dc0b7318f).( void *, SoDraggercxx . . $ SoDragger# *inDragger ) |
| 377 | { |
| 378 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *dl = (SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *) inDragger; |
| 379 | dl->dragFinishcxx . . $ SoRotateCylindricalDragger#dragFinish(49f6e7a06ebc5aa8).(); |
| 380 | } |
| 381 | |
| 382 | void |
| 383 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::valueChangedCBcxx . . $ SoRotateCylindricalDragger#valueChangedCB(7027446dc0b7318f).( void *, SoDraggercxx . . $ SoDragger# *inDragger ) |
| 384 | { |
| 385 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *m = (SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *) inDragger; |
| 386 | SbMatrixcxx . . $ SbMatrix# motMat = m->getMotionMatrixcxx . . $ SoDragger#getMotionMatrix(c49c36ee78b0a89e).(); |
| 387 | |
| 388 | SbVec3fcxx . . $ SbVec3f# transcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8)., scalecxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 389 | SbRotationcxx . . $ SbRotation# rotcxx . . $ SbRotation#SbRotation(49f6e7a06ebc5aa8)., scaleOrientcxx . . $ SbRotation#SbRotation(49f6e7a06ebc5aa8).; |
| 390 | getTransformFastcxx . . $ SoDragger#getTransformFast(87c9df4114162fa2).( motMat, trans, rot, scale, scaleOrient ); |
| 391 | |
| 392 | // Disconnect the field sensor |
| 393 | m->fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); |
| 394 | |
| 395 | if ( m->rotationcxx . . $ SoRotateCylindricalDragger#rotation..getValuecxx . . $ SoSFRotation#getValue(cd68af149be99fa7).() !=cxx . . $ `operator!=`(63a2304dedfd8e48). rot ) |
| 396 | m->rotationcxx . . $ SoRotateCylindricalDragger#rotation. =cxx . . $ SoSFRotation#`operator=`(a110af7e76887ee8). rot; |
| 397 | |
| 398 | // Reconnect the field sensor |
| 399 | m->fieldSensorcxx . . $ SoRotateCylindricalDragger#fieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &(m->rotationcxx . . $ SoRotateCylindricalDragger#rotation.) ); |
| 400 | } |
| 401 | |
| 402 | void |
| 403 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger#::fieldSensorCBcxx . . $ SoRotateCylindricalDragger#fieldSensorCB(c8d298b3e215c027).( void *inDragger, SoSensorcxx . . $ SoSensor# * ) |
| 404 | { |
| 405 | SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *dragger |
| 406 | = (SoRotateCylindricalDraggercxx . . $ SoRotateCylindricalDragger# *) inDragger; |
| 407 | |
| 408 | // Incorporate the new field value into the matrix... |
| 409 | SbMatrixcxx . . $ SbMatrix# motMat = dragger->getMotionMatrixcxx . . $ SoDragger#getMotionMatrix(c49c36ee78b0a89e).(); |
| 410 | dragger->workFieldsIntoTransformcxx . . $ SoDragger#workFieldsIntoTransform(ab60305a37435a6f).( motMat ); |
| 411 | |
| 412 | dragger->setMotionMatrixcxx . . $ SoDragger#setMotionMatrix(37d2f951b3ffd7a6).( motMat ); |
| 413 | } |