Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoHandleBoxDragger.h
1 #ifndef COIN_SOHANDLEBOXDRAGGER_H
2 #define COIN_SOHANDLEBOXDRAGGER_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
37 #include <Inventor/tools/SbLazyPimplPtr.h>
38 #include <Inventor/fields/SoSFVec3f.h>
39 
40 class SoSensor;
41 class SoFieldSensor;
42 class SbPlaneProjector;
43 class SbLineProjector;
44 class SoHandleBoxDraggerP;
45 
46 class COIN_DLL_API SoHandleBoxDragger : public SoDragger {
47  typedef SoDragger inherited;
48 
49  SO_KIT_HEADER(SoHandleBoxDragger);
50  SO_KIT_CATALOG_ENTRY_HEADER(arrow1);
51  SO_KIT_CATALOG_ENTRY_HEADER(arrow1Switch);
52  SO_KIT_CATALOG_ENTRY_HEADER(arrow2);
53  SO_KIT_CATALOG_ENTRY_HEADER(arrow2Switch);
54  SO_KIT_CATALOG_ENTRY_HEADER(arrow3);
55  SO_KIT_CATALOG_ENTRY_HEADER(arrow3Switch);
56  SO_KIT_CATALOG_ENTRY_HEADER(arrow4);
57  SO_KIT_CATALOG_ENTRY_HEADER(arrow4Switch);
58  SO_KIT_CATALOG_ENTRY_HEADER(arrow5);
59  SO_KIT_CATALOG_ENTRY_HEADER(arrow5Switch);
60  SO_KIT_CATALOG_ENTRY_HEADER(arrow6);
61  SO_KIT_CATALOG_ENTRY_HEADER(arrow6Switch);
62  SO_KIT_CATALOG_ENTRY_HEADER(arrowTranslation);
63  SO_KIT_CATALOG_ENTRY_HEADER(drawStyle);
64  SO_KIT_CATALOG_ENTRY_HEADER(extruder1);
65  SO_KIT_CATALOG_ENTRY_HEADER(extruder1Active);
66  SO_KIT_CATALOG_ENTRY_HEADER(extruder1Switch);
67  SO_KIT_CATALOG_ENTRY_HEADER(extruder2);
68  SO_KIT_CATALOG_ENTRY_HEADER(extruder2Active);
69  SO_KIT_CATALOG_ENTRY_HEADER(extruder2Switch);
70  SO_KIT_CATALOG_ENTRY_HEADER(extruder3);
71  SO_KIT_CATALOG_ENTRY_HEADER(extruder3Active);
72  SO_KIT_CATALOG_ENTRY_HEADER(extruder3Switch);
73  SO_KIT_CATALOG_ENTRY_HEADER(extruder4);
74  SO_KIT_CATALOG_ENTRY_HEADER(extruder4Active);
75  SO_KIT_CATALOG_ENTRY_HEADER(extruder4Switch);
76  SO_KIT_CATALOG_ENTRY_HEADER(extruder5);
77  SO_KIT_CATALOG_ENTRY_HEADER(extruder5Active);
78  SO_KIT_CATALOG_ENTRY_HEADER(extruder5Switch);
79  SO_KIT_CATALOG_ENTRY_HEADER(extruder6);
80  SO_KIT_CATALOG_ENTRY_HEADER(extruder6Active);
81  SO_KIT_CATALOG_ENTRY_HEADER(extruder6Switch);
82  SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
83  SO_KIT_CATALOG_ENTRY_HEADER(translator1);
84  SO_KIT_CATALOG_ENTRY_HEADER(translator1Active);
85  SO_KIT_CATALOG_ENTRY_HEADER(translator1Switch);
86  SO_KIT_CATALOG_ENTRY_HEADER(translator2);
87  SO_KIT_CATALOG_ENTRY_HEADER(translator2Active);
88  SO_KIT_CATALOG_ENTRY_HEADER(translator2Switch);
89  SO_KIT_CATALOG_ENTRY_HEADER(translator3);
90  SO_KIT_CATALOG_ENTRY_HEADER(translator3Active);
91  SO_KIT_CATALOG_ENTRY_HEADER(translator3Switch);
92  SO_KIT_CATALOG_ENTRY_HEADER(translator4);
93  SO_KIT_CATALOG_ENTRY_HEADER(translator4Active);
94  SO_KIT_CATALOG_ENTRY_HEADER(translator4Switch);
95  SO_KIT_CATALOG_ENTRY_HEADER(translator5);
96  SO_KIT_CATALOG_ENTRY_HEADER(translator5Active);
97  SO_KIT_CATALOG_ENTRY_HEADER(translator5Switch);
98  SO_KIT_CATALOG_ENTRY_HEADER(translator6);
99  SO_KIT_CATALOG_ENTRY_HEADER(translator6Active);
100  SO_KIT_CATALOG_ENTRY_HEADER(translator6Switch);
101  SO_KIT_CATALOG_ENTRY_HEADER(uniform1);
102  SO_KIT_CATALOG_ENTRY_HEADER(uniform1Active);
103  SO_KIT_CATALOG_ENTRY_HEADER(uniform1Switch);
104  SO_KIT_CATALOG_ENTRY_HEADER(uniform2);
105  SO_KIT_CATALOG_ENTRY_HEADER(uniform2Active);
106  SO_KIT_CATALOG_ENTRY_HEADER(uniform2Switch);
107  SO_KIT_CATALOG_ENTRY_HEADER(uniform3);
108  SO_KIT_CATALOG_ENTRY_HEADER(uniform3Active);
109  SO_KIT_CATALOG_ENTRY_HEADER(uniform3Switch);
110  SO_KIT_CATALOG_ENTRY_HEADER(uniform4);
111  SO_KIT_CATALOG_ENTRY_HEADER(uniform4Active);
112  SO_KIT_CATALOG_ENTRY_HEADER(uniform4Switch);
113  SO_KIT_CATALOG_ENTRY_HEADER(uniform5);
114  SO_KIT_CATALOG_ENTRY_HEADER(uniform5Active);
115  SO_KIT_CATALOG_ENTRY_HEADER(uniform5Switch);
116  SO_KIT_CATALOG_ENTRY_HEADER(uniform6);
117  SO_KIT_CATALOG_ENTRY_HEADER(uniform6Active);
118  SO_KIT_CATALOG_ENTRY_HEADER(uniform6Switch);
119  SO_KIT_CATALOG_ENTRY_HEADER(uniform7);
120  SO_KIT_CATALOG_ENTRY_HEADER(uniform7Active);
121  SO_KIT_CATALOG_ENTRY_HEADER(uniform7Switch);
122  SO_KIT_CATALOG_ENTRY_HEADER(uniform8);
123  SO_KIT_CATALOG_ENTRY_HEADER(uniform8Active);
124  SO_KIT_CATALOG_ENTRY_HEADER(uniform8Switch);
125 
126 public:
127  static void initClass(void);
128  SoHandleBoxDragger(void);
129 
132 
133 protected:
134  virtual ~SoHandleBoxDragger(void);
135  virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE);
136  virtual void setDefaultOnNonWritingFields(void);
137 
138  static void startCB(void * f, SoDragger * d);
139  static void motionCB(void * f, SoDragger * d);
140  static void finishCB(void * f, SoDragger * d);
141  static void metaKeyChangeCB(void * f, SoDragger * d);
142  static void fieldSensorCB(void * f, SoSensor * s);
143  static void valueChangedCB(void * f, SoDragger * d);
144 
145  void dragStart(void);
146  void drag(void);
147  void dragFinish(void);
148  void setAllPartsActive(SbBool onoroff);
149 
152 
153 private:
154  void updateSwitches();
155  void updateArrows();
156  SoNode *getNodeFieldNode(const char *fieldname);
157  SbPlaneProjector *planeProj;
158  SbLineProjector *lineProj;
159  int whatkind;
160  int whatnum;
161  int constraintState;
162  SbBool ctrlDown;
163  SbVec3f worldRestartPt;
164  SbVec3f ctrlOffset;
165 
166  void getSurroundScaleMatrices(SbMatrix &matrix, SbMatrix &inv);
167  SbVec3f getDraggerCenter();
168  SbVec3f calcCtrlOffset(const SbVec3f startpt);
169 
170 private:
172 
173  // NOT IMPLEMENTED:
175  SoHandleBoxDragger & operator = (const SoHandleBoxDragger & rhs);
176 }; // SoHandleBoxDragger
177 
178 #endif // !COIN_SOHANDLEBOXDRAGGER_H
SoFieldSensor * translFieldSensor
Definition: SoHandleBoxDragger.h:150
static void fieldSensorCB(void *, SoSensor *)
Definition: SoInteractionKit.cpp:752
SoSFVec3f scaleFactor
Definition: SoHandleBoxDragger.h:130
The SoHandleBoxDragger class provides support for interactive scaling and translation.
Definition: SoHandleBoxDragger.h:46
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
The SoInteractionKit class is a base class for draggers.
Definition: SoInteractionKit.h:50
The SoDragger class is the base class for all draggers.
Definition: SoDragger.h:64
The SoSensor class is the abstract base class for all sensors.
Definition: SoSensor.h:43
static void initClass(void)
Definition: SoDragger.cpp:409
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:51
SoFieldSensor * scaleFieldSensor
Definition: SoHandleBoxDragger.h:151
The SoFieldSensor class detects changes to a field.
Definition: SoFieldSensor.h:38
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition: SbMatrix.h:47
The SbPlaneProjector class projects 2D points to 3D points in a plane.
Definition: SbPlaneProjector.h:40
The SoSFVec3f class is a container for an SbVec3f vector.
Definition: SoSFVec3f.h:40
SoSFVec3f translation
Definition: SoHandleBoxDragger.h:131
The SbLineProjector class projects 2D points to 3D points along a line.
Definition: SbLineProjector.h:41
virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways=FALSE)
Definition: SoInteractionKit.cpp:675
virtual void setDefaultOnNonWritingFields(void)
Definition: SoDragger.cpp:1829