Coin Logo http://www.coin3d.org/
http://www.kongsberg.com/kogt/

SoDragger.h
Go to the documentation of this file.
1 #ifndef COIN_SODRAGGER_H
2 #define COIN_SODRAGGER_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 
36 #include <Inventor/nodekits/SoInteractionKit.h>
37 #include <Inventor/tools/SbPimplPtr.h>
38 #include <Inventor/fields/SoSFBool.h>
40 #include <Inventor/SbMatrix.h>
41 #include <Inventor/SbVec3f.h>
42 #include <Inventor/SbVec2s.h>
43 #include <Inventor/SbViewVolume.h>
44 #include <Inventor/SbViewportRegion.h>
45 #ifndef COIN_INTERNAL
46 // For Open Inventor compatibility.
47 #include <Inventor/nodes/SoScale.h>
48 #endif // !COIN_INTERNAL
49 
51 class SbRotation;
52 class SbVec2f;
53 class SbVec2s;
54 class SbViewVolume;
55 class SbViewportRegion;
56 class SoDragger;
57 class SoEvent;
58 class SoPickedPoint;
59 class SoDraggerP;
60 
62 typedef void SoDraggerCB(void * data, SoDragger * dragger);
63 
64 class COIN_DLL_API SoDragger : public SoInteractionKit {
66 
67  SO_KIT_HEADER(SoDragger);
68  SO_KIT_CATALOG_ENTRY_HEADER(motionMatrix);
69 
70 public:
72 
73  enum ProjectorFrontSetting { FRONT, BACK, USE_PICK };
74 
75  // override these in case we decide to do some extra work later
76  virtual void callback(SoCallbackAction * action);
77  virtual void GLRender(SoGLRenderAction * action);
78  virtual void getMatrix(SoGetMatrixAction * action);
79  virtual void rayPick(SoRayPickAction * action);
80  virtual void search(SoSearchAction * action);
81  virtual void write(SoWriteAction * action);
82  virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
83 
84  void setProjectorEpsilon(const float epsilon);
85  float getProjectorEpsilon(void) const;
86 
87  void addStartCallback(SoDraggerCB * func, void * data = NULL);
88  void removeStartCallback(SoDraggerCB * func, void * data = NULL);
89  void addMotionCallback(SoDraggerCB * func, void * data = NULL);
90  void removeMotionCallback(SoDraggerCB * func, void * data = NULL);
91  void addFinishCallback(SoDraggerCB * func, void * data = NULL);
92  void removeFinishCallback(SoDraggerCB * func, void * data = NULL);
93  void addValueChangedCallback(SoDraggerCB * func, void * data = NULL);
94  void removeValueChangedCallback(SoDraggerCB * func, void * data = NULL);
95  void setMinGesture(int pixels);
96  int getMinGesture(void) const;
97  SbBool enableValueChangedCallbacks(SbBool newval);
98  const SbMatrix & getMotionMatrix(void);
99  void addOtherEventCallback(SoDraggerCB * func, void * data = NULL);
100  void removeOtherEventCallback(SoDraggerCB * func, void * data = NULL);
101  void registerChildDragger(SoDragger * child);
102  void unregisterChildDragger(SoDragger * child);
103  void registerChildDraggerMovingIndependently(SoDragger * child);
104  void unregisterChildDraggerMovingIndependently(SoDragger * child);
105  SbMatrix getLocalToWorldMatrix(void);
106  SbMatrix getWorldToLocalMatrix(void);
107  SbVec3f getLocalStartingPoint(void);
108  SbVec3f getWorldStartingPoint(void);
109  void getPartToLocalMatrix(const SbName & partname, SbMatrix & parttolocalmatrix, SbMatrix & localtopartmatrix);
110  void transformMatrixLocalToWorld(const SbMatrix & frommatrix, SbMatrix & tomatrix);
111  void transformMatrixWorldToLocal(const SbMatrix & frommatrix, SbMatrix & tomatrix);
112  void transformMatrixToLocalSpace(const SbMatrix & frommatrix, SbMatrix & tomatrix, const SbName & fromspacepartname);
113  virtual void setMotionMatrix(const SbMatrix & newmatrix);
114  void valueChanged(void);
115  const SbMatrix & getStartMotionMatrix(void);
116  virtual void saveStartParameters(void);
117  const SoPath * getPickPath(void) const;
118  const SoEvent * getEvent(void) const;
119  SoPath * createPathToThis(void);
120  const SoPath * getSurrogatePartPickedOwner(void) const;
121  const SbName & getSurrogatePartPickedName(void) const;
122  const SoPath * getSurrogatePartPickedPath(void) const;
123  void setStartingPoint(const SoPickedPoint * newpoint);
124  void setStartingPoint(const SbVec3f & newpoint);
125  const SbViewVolume & getViewVolume(void);
126  void setViewVolume(const SbViewVolume & vol);
127  const SbViewportRegion & getViewportRegion(void);
128  void setViewportRegion(const SbViewportRegion & reg);
129  SoHandleEventAction * getHandleEventAction(void) const;
130  void setHandleEventAction(SoHandleEventAction * newAction);
131  void setTempPathToThis(const SoPath * somethingclose);
132  virtual void grabEventsSetup(void);
133  virtual void grabEventsCleanup(void);
134  void workFieldsIntoTransform(SbMatrix & mtx);
135  void setFrontOnProjector(ProjectorFrontSetting newval);
136  ProjectorFrontSetting getFrontOnProjector(void) const;
137 
138  static void setMinScale(float newminscale);
139  static float getMinScale(void);
140  static void workValuesIntoTransform(SbMatrix & mtx, const SbVec3f * translationptr, const SbRotation * rotationptr, const SbVec3f * scalefactorptr, const SbRotation * scaleorientationptr, const SbVec3f * centerptr);
141  static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation, const SbVec3f & center);
142  static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation);
143  static SbMatrix appendTranslation(const SbMatrix & mtx, const SbVec3f & translation, const SbMatrix * conversion = NULL);
144  static SbMatrix appendScale(const SbMatrix & mtx, const SbVec3f & scale, const SbVec3f & scalecenter, const SbMatrix * conversion = NULL);
145  static SbMatrix appendRotation(const SbMatrix & mtx, const SbRotation & rot, const SbVec3f & rotcenter, const SbMatrix * conversion = NULL);
146  static void initClass(void);
147  static void initClasses(void);
148 
149 protected:
150  SoDragger(void);
151  virtual ~SoDragger(void);
152 
153  SbVec2f getNormalizedLocaterPosition(void);
154  SbVec2s getLocaterPosition(void);
155  SbVec2s getStartLocaterPosition(void) const;
156  void setStartLocaterPosition(SbVec2s p);
157  SbBool isAdequateConstraintMotion(void);
158  virtual SbBool shouldGrabBasedOnSurrogate(const SoPath * pickpath, const SoPath * surrogatepath);
159  void setCameraInfo(SoAction * action);
160  virtual void handleEvent(SoHandleEventAction * ha);
161  void transferMotion(SoDragger * child);
162  void setIgnoreInBbox(SbBool newval);
163  SbBool isIgnoreInBbox(void);
164  virtual void getBoundingBox(SoGetBoundingBoxAction * action);
165  void setActiveChildDragger(SoDragger * newchilddragger);
166  SoDragger * getActiveChildDragger(void) const;
167  virtual void setDefaultOnNonWritingFields(void);
168 
169  static void childTransferMotionAndValueChangedCB(void *, SoDragger *);
170  static void childValueChangedCB(void *, SoDragger *);
171  static void childStartCB(void *, SoDragger *);
172  static void childMotionCB(void *, SoDragger *);
173  static void childFinishCB(void *, SoDragger *);
174  static void childOtherEventCB(void *, SoDragger *);
175 
176  // This method is not present in Open Inventor. It was moved from
177  // being a private method to a protected method in Coin to make it
178  // possible to construct draggers which can handle Motion3 events.
179  void updateDraggerCache(const SoPath * path);
180 
181 private:
182  void updateElements(class SoState * state);
183  SbBool isPicked(SoPath * path);
184  void eventHandled(const SoEvent * event, SoHandleEventAction * action);
185  static float minscale;
186 
187 private:
188  SbPimplPtr<SoDraggerP> pimpl;
189 
190  // NOT IMPLEMENTED:
191  SoDragger(const SoDragger & rhs);
192  SoDragger & operator = (const SoDragger & rhs);
193 }; // SoDragger
194 
195 #endif // !COIN_SODRAGGER_H

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

Generated on Sat Oct 26 2013 19:06:29 for Coin by Doxygen 1.8.4.