Coin Logo http://www.sim.no/
http://www.coin3d.org/

SoTransformerDragger.h
1#ifndef COIN_SOTRANSFORMERDRAGGER_H
2#define COIN_SOTRANSFORMERDRAGGER_H
3
4/**************************************************************************\
5 *
6 * This file is part of the Coin 3D visualization library.
7 * Copyright (C) by Kongsberg Oil & Gas Technologies.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * ("GPL") version 2 as published by the Free Software Foundation.
12 * See the file LICENSE.GPL at the root directory of this source
13 * distribution for additional information about the GNU GPL.
14 *
15 * For using Coin with software that can not be combined with the GNU
16 * GPL, and for taking advantage of the additional benefits of our
17 * support services, please contact Kongsberg Oil & Gas Technologies
18 * about acquiring a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24 *
25\**************************************************************************/
26
28#include <Inventor/tools/SbPimplPtr.h>
29#include <Inventor/fields/SoSFRotation.h>
30#include <Inventor/fields/SoSFVec3f.h>
31#include <Inventor/fields/SoSFFloat.h>
32#include <Inventor/lists/SoNodeList.h>
33
34class SoSensor;
35class SoFieldSensor;
36class SoTransformerDraggerP;
37
38class COIN_DLL_API SoTransformerDragger : public SoDragger {
39 typedef SoDragger inherited;
40
41 SO_KIT_HEADER(SoTransformerDragger);
42
43 SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackLocation);
44 SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackSep);
45 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackAntiSquish);
46 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackSep);
47 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackTransform);
48 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackTransformSwitch);
49 SO_KIT_CATALOG_ENTRY_HEADER(negXRoundWallFeedback);
50 SO_KIT_CATALOG_ENTRY_HEADER(negXWallFeedback);
51 SO_KIT_CATALOG_ENTRY_HEADER(negXWallFeedbackSwitch);
52 SO_KIT_CATALOG_ENTRY_HEADER(negYRoundWallFeedback);
53 SO_KIT_CATALOG_ENTRY_HEADER(negYWallFeedback);
54 SO_KIT_CATALOG_ENTRY_HEADER(negYWallFeedbackSwitch);
55 SO_KIT_CATALOG_ENTRY_HEADER(negZRoundWallFeedback);
56 SO_KIT_CATALOG_ENTRY_HEADER(negZWallFeedback);
57 SO_KIT_CATALOG_ENTRY_HEADER(negZWallFeedbackSwitch);
58 SO_KIT_CATALOG_ENTRY_HEADER(overallStyle);
59 SO_KIT_CATALOG_ENTRY_HEADER(posXRoundWallFeedback);
60 SO_KIT_CATALOG_ENTRY_HEADER(posXWallFeedback);
61 SO_KIT_CATALOG_ENTRY_HEADER(posXWallFeedbackSwitch);
62 SO_KIT_CATALOG_ENTRY_HEADER(posYRoundWallFeedback);
63 SO_KIT_CATALOG_ENTRY_HEADER(posYWallFeedback);
64 SO_KIT_CATALOG_ENTRY_HEADER(posYWallFeedbackSwitch);
65 SO_KIT_CATALOG_ENTRY_HEADER(posZRoundWallFeedback);
66 SO_KIT_CATALOG_ENTRY_HEADER(posZWallFeedback);
67 SO_KIT_CATALOG_ENTRY_HEADER(posZWallFeedbackSwitch);
68 SO_KIT_CATALOG_ENTRY_HEADER(radialFeedback);
69 SO_KIT_CATALOG_ENTRY_HEADER(radialFeedbackSwitch);
70 SO_KIT_CATALOG_ENTRY_HEADER(rotator1);
71 SO_KIT_CATALOG_ENTRY_HEADER(rotator1Active);
72 SO_KIT_CATALOG_ENTRY_HEADER(rotator1LocateGroup);
73 SO_KIT_CATALOG_ENTRY_HEADER(rotator1Switch);
74 SO_KIT_CATALOG_ENTRY_HEADER(rotator2);
75 SO_KIT_CATALOG_ENTRY_HEADER(rotator2Active);
76 SO_KIT_CATALOG_ENTRY_HEADER(rotator2LocateGroup);
77 SO_KIT_CATALOG_ENTRY_HEADER(rotator2Switch);
78 SO_KIT_CATALOG_ENTRY_HEADER(rotator3);
79 SO_KIT_CATALOG_ENTRY_HEADER(rotator3Active);
80 SO_KIT_CATALOG_ENTRY_HEADER(rotator3LocateGroup);
81 SO_KIT_CATALOG_ENTRY_HEADER(rotator3Switch);
82 SO_KIT_CATALOG_ENTRY_HEADER(rotator4);
83 SO_KIT_CATALOG_ENTRY_HEADER(rotator4Active);
84 SO_KIT_CATALOG_ENTRY_HEADER(rotator4LocateGroup);
85 SO_KIT_CATALOG_ENTRY_HEADER(rotator4Switch);
86 SO_KIT_CATALOG_ENTRY_HEADER(rotator5);
87 SO_KIT_CATALOG_ENTRY_HEADER(rotator5Active);
88 SO_KIT_CATALOG_ENTRY_HEADER(rotator5LocateGroup);
89 SO_KIT_CATALOG_ENTRY_HEADER(rotator5Switch);
90 SO_KIT_CATALOG_ENTRY_HEADER(rotator6);
91 SO_KIT_CATALOG_ENTRY_HEADER(rotator6Active);
92 SO_KIT_CATALOG_ENTRY_HEADER(rotator6LocateGroup);
93 SO_KIT_CATALOG_ENTRY_HEADER(rotator6Switch);
94 SO_KIT_CATALOG_ENTRY_HEADER(rotatorSep);
95 SO_KIT_CATALOG_ENTRY_HEADER(scale1);
96 SO_KIT_CATALOG_ENTRY_HEADER(scale1Active);
97 SO_KIT_CATALOG_ENTRY_HEADER(scale1LocateGroup);
98 SO_KIT_CATALOG_ENTRY_HEADER(scale1Switch);
99 SO_KIT_CATALOG_ENTRY_HEADER(scale2);
100 SO_KIT_CATALOG_ENTRY_HEADER(scale2Active);
101 SO_KIT_CATALOG_ENTRY_HEADER(scale2LocateGroup);
102 SO_KIT_CATALOG_ENTRY_HEADER(scale2Switch);
103 SO_KIT_CATALOG_ENTRY_HEADER(scale3);
104 SO_KIT_CATALOG_ENTRY_HEADER(scale3Active);
105 SO_KIT_CATALOG_ENTRY_HEADER(scale3LocateGroup);
106 SO_KIT_CATALOG_ENTRY_HEADER(scale3Switch);
107 SO_KIT_CATALOG_ENTRY_HEADER(scale4);
108 SO_KIT_CATALOG_ENTRY_HEADER(scale4Active);
109 SO_KIT_CATALOG_ENTRY_HEADER(scale4LocateGroup);
110 SO_KIT_CATALOG_ENTRY_HEADER(scale4Switch);
111 SO_KIT_CATALOG_ENTRY_HEADER(scale5);
112 SO_KIT_CATALOG_ENTRY_HEADER(scale5Active);
113 SO_KIT_CATALOG_ENTRY_HEADER(scale5LocateGroup);
114 SO_KIT_CATALOG_ENTRY_HEADER(scale5Switch);
115 SO_KIT_CATALOG_ENTRY_HEADER(scale6);
116 SO_KIT_CATALOG_ENTRY_HEADER(scale6Active);
117 SO_KIT_CATALOG_ENTRY_HEADER(scale6LocateGroup);
118 SO_KIT_CATALOG_ENTRY_HEADER(scale6Switch);
119 SO_KIT_CATALOG_ENTRY_HEADER(scale7);
120 SO_KIT_CATALOG_ENTRY_HEADER(scale7Active);
121 SO_KIT_CATALOG_ENTRY_HEADER(scale7LocateGroup);
122 SO_KIT_CATALOG_ENTRY_HEADER(scale7Switch);
123 SO_KIT_CATALOG_ENTRY_HEADER(scale8);
124 SO_KIT_CATALOG_ENTRY_HEADER(scale8Active);
125 SO_KIT_CATALOG_ENTRY_HEADER(scale8LocateGroup);
126 SO_KIT_CATALOG_ENTRY_HEADER(scale8Switch);
127 SO_KIT_CATALOG_ENTRY_HEADER(scaleBoxFeedback);
128 SO_KIT_CATALOG_ENTRY_HEADER(scaleBoxFeedbackSwitch);
129 SO_KIT_CATALOG_ENTRY_HEADER(scaleSep);
130 SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
131 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedback);
132 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackRotation);
133 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackSep);
134 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackSwitch);
135 SO_KIT_CATALOG_ENTRY_HEADER(translator1);
136 SO_KIT_CATALOG_ENTRY_HEADER(translator1Active);
137 SO_KIT_CATALOG_ENTRY_HEADER(translator1LocateGroup);
138 SO_KIT_CATALOG_ENTRY_HEADER(translator1Switch);
139 SO_KIT_CATALOG_ENTRY_HEADER(translator2);
140 SO_KIT_CATALOG_ENTRY_HEADER(translator2Active);
141 SO_KIT_CATALOG_ENTRY_HEADER(translator2LocateGroup);
142 SO_KIT_CATALOG_ENTRY_HEADER(translator2Switch);
143 SO_KIT_CATALOG_ENTRY_HEADER(translator3);
144 SO_KIT_CATALOG_ENTRY_HEADER(translator3Active);
145 SO_KIT_CATALOG_ENTRY_HEADER(translator3LocateGroup);
146 SO_KIT_CATALOG_ENTRY_HEADER(translator3Switch);
147 SO_KIT_CATALOG_ENTRY_HEADER(translator4);
148 SO_KIT_CATALOG_ENTRY_HEADER(translator4Active);
149 SO_KIT_CATALOG_ENTRY_HEADER(translator4LocateGroup);
150 SO_KIT_CATALOG_ENTRY_HEADER(translator4Switch);
151 SO_KIT_CATALOG_ENTRY_HEADER(translator5);
152 SO_KIT_CATALOG_ENTRY_HEADER(translator5Active);
153 SO_KIT_CATALOG_ENTRY_HEADER(translator5LocateGroup);
154 SO_KIT_CATALOG_ENTRY_HEADER(translator5Switch);
155 SO_KIT_CATALOG_ENTRY_HEADER(translator6);
156 SO_KIT_CATALOG_ENTRY_HEADER(translator6Active);
157 SO_KIT_CATALOG_ENTRY_HEADER(translator6LocateGroup);
158 SO_KIT_CATALOG_ENTRY_HEADER(translator6Switch);
159 SO_KIT_CATALOG_ENTRY_HEADER(translatorSep);
160 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackActive);
161 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackSelect);
162 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackSwitch);
163 SO_KIT_CATALOG_ENTRY_HEADER(xCircleFeedback);
164 SO_KIT_CATALOG_ENTRY_HEADER(xCircleFeedbackSwitch);
165 SO_KIT_CATALOG_ENTRY_HEADER(xCrosshairFeedback);
166 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackActive);
167 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackSelect);
168 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackSwitch);
169 SO_KIT_CATALOG_ENTRY_HEADER(yCircleFeedback);
170 SO_KIT_CATALOG_ENTRY_HEADER(yCircleFeedbackSwitch);
171 SO_KIT_CATALOG_ENTRY_HEADER(yCrosshairFeedback);
172 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackActive);
173 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackSelect);
174 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackSwitch);
175 SO_KIT_CATALOG_ENTRY_HEADER(zCircleFeedback);
176 SO_KIT_CATALOG_ENTRY_HEADER(zCircleFeedbackSwitch);
177 SO_KIT_CATALOG_ENTRY_HEADER(zCrosshairFeedback);
178
179public:
180 static void initClass(void);
182
186 SoSFFloat minDiscRotDot;
187
188 enum State {
189 INACTIVE,
190
191 RIT_X_ROTATE,
192 TOP_Y_ROTATE,
193 FNT_Z_ROTATE,
194 LFT_X_ROTATE,
195 BOT_Y_ROTATE,
196 BAK_Z_ROTATE,
197
198 PX_PY_PZ_3D_SCALE,
199 PX_PY_NZ_3D_SCALE,
200 PX_NY_PZ_3D_SCALE,
201 PX_NY_NZ_3D_SCALE,
202 NX_PY_PZ_3D_SCALE,
203 NX_PY_NZ_3D_SCALE,
204 NX_NY_PZ_3D_SCALE,
205 NX_NY_NZ_3D_SCALE,
206
207 RIT_TRANSLATE,
208 TOP_TRANSLATE,
209 FNT_TRANSLATE,
210 LFT_TRANSLATE,
211 BOT_TRANSLATE,
212 BAK_TRANSLATE
213 };
214
215 State getCurrentState(void);
216
217 void unsquishKnobs(void);
218
219 SbBool isLocateHighlighting(void);
220 void setLocateHighlighting(SbBool onoff);
221
222 static void setColinearThreshold(int newval);
223 static int getColinearThreshold(void);
224
225 SbVec3f getBoxPointInWorldSpace(const SbVec3f & pointonunitbox);
226 SbVec3f getBoxDirInWorldSpace(const SbVec3f & dironunitbox);
227 SbVec3f getWorldPointInBoxSpace(const SbVec3f & pointinworldspace);
228 SbVec2f getWorldPointInPixelSpace(const SbVec3f & thepoint);
229
230 SbVec3f getInteractiveCenterInBoxSpace(void);
231
232protected:
233 virtual ~SoTransformerDragger(void);
234 virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE);
235 virtual void setDefaultOnNonWritingFields(void);
236
237 static void startCB(void * f, SoDragger * d);
238 static void motionCB(void * f, SoDragger * d);
239 static void finishCB(void * f, SoDragger * d);
240 static void metaKeyChangeCB(void *, SoDragger *);
241 static void fieldSensorCB(void * f, SoSensor * s);
242 static void valueChangedCB(void * f, SoDragger * d);
243
244 void dragStart(void);
245 void drag(void);
246 void dragFinish(void);
247
248 void updateAntiSquishList(void);
249 void setAllPartSwitches(int scalewhich, int rotatewhich, int translatewhich);
250 int getMouseGestureDirection(SbBool x_ok, SbBool y_ok, SbBool z_ok);
251 static int getIgnoreAxis(SbVec2f axis[3][2],
252 SbBool x_ok, SbBool y_ok, SbBool z_ok);
253 static void makeMinorAxisPerpendicularIfColinear(SbVec2f origin, SbVec2f axisends[3][2], int index_a, int index_b);
254 static SbBool isColinear(SbVec2f a1[2], SbVec2f a2[2], int pixels);
255
260
261private:
262 void getSurroundScaleMatrices(SbMatrix &matrix, SbMatrix &inv);
263 SoNode *getNodeFieldNode(const char *fieldname);
264
265 void build_catalog1(void);
266 void build_catalog2(void);
267 void build_catalog3(void);
268 void build_catalog4(void);
269 void build_catalog5(void);
270 void build_catalog6(void);
271
272 SbMatrix getWorkingToWorldMatrix(void);
273 SbMatrix getWorldToWorkingMatrix(void);
274 SbVec3f localToWorking(const SbVec3f &v);
275 SbVec3f workingToLocal(const SbVec3f &v);
276 SbVec3f calcCtrlOffset(const SbVec3f &startpt);
277 void setSwitchValue(const char *str, const int which);
278
279 SbBool setDynamicTranslatorSwitches(const SoEvent *event);
280 SbBool setDynamicRotatorSwitches(const SoEvent *event);
281 SbBool setDynamicScaleSwitches(const SoEvent *event);
282
283 void dragTranslate();
284 void dragScale();
285 void dragRotate();
286
287 class SbPlaneProjector *planeProj;
288 class SbLineProjector *lineProj;
289 class SbSphereProjector *sphereProj;
290 class SbCylinderProjector *cylProj;
291
292 State state;
293
294private:
295 SbPimplPtr<SoTransformerDraggerP> pimpl;
296 friend class SoTransformerDraggerP;
297
298 // NOT IMPLEMENTED:
300 SoTransformerDragger & operator = (const SoTransformerDragger & rhs);
301}; // SoTransformerDragger
302
303#endif // !COIN_SOTRANSFORMERDRAGGER_H
The SbCylinderProjector class is the abstract base class for mapping to cylindrical surfaces.
Definition SbCylinderProjector.h:30
The SbLineProjector class projects 2D points to 3D points along a line.
Definition SbLineProjector.h:32
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition SbMatrix.h:37
The SbPlaneProjector class projects 2D points to 3D points in a plane.
Definition SbPlaneProjector.h:31
The SbSphereProjector class is the abstract base class for mapping to spherical surfaces.
Definition SbSphereProjector.h:31
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition SbVec2f.h:39
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:40
The SoDragger class is the base class for all draggers.
Definition SoDragger.h:55
static void initClass(void)
Definition SoDragger.cpp:399
virtual void setDefaultOnNonWritingFields(void)
Definition SoDragger.cpp:1791
The SoEvent class is the base class for all Coin events.
Definition SoEvent.h:34
The SoFieldSensor class detects changes to a field.
Definition SoFieldSensor.h:29
static void fieldSensorCB(void *, SoSensor *)
Definition SoInteractionKit.cpp:742
virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways=FALSE)
Definition SoInteractionKit.cpp:665
static void setSwitchValue(SoNode *node, const int newVal)
Definition SoInteractionKit.cpp:375
The SoNodeList class is a container for pointers to SoNode objects.
Definition SoNodeList.h:31
The SoNode class is the base class for nodes used in scene graphs.
Definition SoNode.h:47
The SoSFFloat class is a container for a floating point value.
Definition SoSFFloat.h:30
The SoSFRotation class is a container for an SbRotation.
Definition SoSFRotation.h:31
The SoSFVec3f class is a container for an SbVec3f vector.
Definition SoSFVec3f.h:31
The SoSensor class is the abstract base class for all sensors.
Definition SoSensor.h:34
The SoTransformerDragger provides geometry for translation, scaling and rotations.
Definition SoTransformerDragger.h:38
SoFieldSensor * scaleFieldSensor
Definition SoTransformerDragger.h:257
SoSFVec3f translation
Definition SoTransformerDragger.h:184
SoNodeList antiSquishList
Definition SoTransformerDragger.h:259
State
Definition SoTransformerDragger.h:188
SoSFRotation rotation
Definition SoTransformerDragger.h:183
SoFieldSensor * translFieldSensor
Definition SoTransformerDragger.h:256
SoFieldSensor * rotateFieldSensor
Definition SoTransformerDragger.h:258
SoSFVec3f scaleFactor
Definition SoTransformerDragger.h:185

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Wed Jul 17 2024 for Coin by Doxygen 1.12.0.