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

SoDragger.h
Go to the documentation of this file.
1#ifndef COIN_SODRAGGER_H
2#define COIN_SODRAGGER_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
27#include <Inventor/nodekits/SoInteractionKit.h>
28#include <Inventor/tools/SbPimplPtr.h>
29#include <Inventor/fields/SoSFBool.h>
30#include <Inventor/lists/SoCallbackList.h>
31#include <Inventor/SbMatrix.h>
32#include <Inventor/SbVec3f.h>
33#include <Inventor/SbVec2s.h>
34#include <Inventor/SbViewVolume.h>
35#include <Inventor/SbViewportRegion.h>
36#ifndef COIN_INTERNAL
37// For Open Inventor compatibility.
38#include <Inventor/nodes/SoScale.h>
39#endif // !COIN_INTERNAL
42class SbRotation;
43class SbVec2f;
44class SbVec2s;
45class SbViewVolume;
47class SoDragger;
48class SoEvent;
49class SoPickedPoint;
50class SoDraggerP;
51
53typedef void SoDraggerCB(void * data, SoDragger * dragger);
54
55class COIN_DLL_API SoDragger : public SoInteractionKit {
57
58 SO_KIT_HEADER(SoDragger);
59 SO_KIT_CATALOG_ENTRY_HEADER(motionMatrix);
60
61public:
63
64 enum ProjectorFrontSetting { FRONT, BACK, USE_PICK };
65
66 // override these in case we decide to do some extra work later
67 virtual void callback(SoCallbackAction * action);
68 virtual void GLRender(SoGLRenderAction * action);
69 virtual void getMatrix(SoGetMatrixAction * action);
70 virtual void rayPick(SoRayPickAction * action);
71 virtual void search(SoSearchAction * action);
72 virtual void write(SoWriteAction * action);
73 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
74
75 void setProjectorEpsilon(const float epsilon);
76 float getProjectorEpsilon(void) const;
77
78 void addStartCallback(SoDraggerCB * func, void * data = NULL);
79 void removeStartCallback(SoDraggerCB * func, void * data = NULL);
80 void addMotionCallback(SoDraggerCB * func, void * data = NULL);
81 void removeMotionCallback(SoDraggerCB * func, void * data = NULL);
82 void addFinishCallback(SoDraggerCB * func, void * data = NULL);
83 void removeFinishCallback(SoDraggerCB * func, void * data = NULL);
84 void addValueChangedCallback(SoDraggerCB * func, void * data = NULL);
85 void removeValueChangedCallback(SoDraggerCB * func, void * data = NULL);
86 void setMinGesture(int pixels);
87 int getMinGesture(void) const;
88 SbBool enableValueChangedCallbacks(SbBool newval);
89 const SbMatrix & getMotionMatrix(void);
90 void addOtherEventCallback(SoDraggerCB * func, void * data = NULL);
91 void removeOtherEventCallback(SoDraggerCB * func, void * data = NULL);
92 void registerChildDragger(SoDragger * child);
93 void unregisterChildDragger(SoDragger * child);
94 void registerChildDraggerMovingIndependently(SoDragger * child);
95 void unregisterChildDraggerMovingIndependently(SoDragger * child);
96 SbMatrix getLocalToWorldMatrix(void);
97 SbMatrix getWorldToLocalMatrix(void);
98 SbVec3f getLocalStartingPoint(void);
99 SbVec3f getWorldStartingPoint(void);
100 void getPartToLocalMatrix(const SbName & partname, SbMatrix & parttolocalmatrix, SbMatrix & localtopartmatrix);
101 void transformMatrixLocalToWorld(const SbMatrix & frommatrix, SbMatrix & tomatrix);
102 void transformMatrixWorldToLocal(const SbMatrix & frommatrix, SbMatrix & tomatrix);
103 void transformMatrixToLocalSpace(const SbMatrix & frommatrix, SbMatrix & tomatrix, const SbName & fromspacepartname);
104 virtual void setMotionMatrix(const SbMatrix & newmatrix);
105 void valueChanged(void);
106 const SbMatrix & getStartMotionMatrix(void);
107 virtual void saveStartParameters(void);
108 const SoPath * getPickPath(void) const;
109 const SoEvent * getEvent(void) const;
110 SoPath * createPathToThis(void);
111 const SoPath * getSurrogatePartPickedOwner(void) const;
112 const SbName & getSurrogatePartPickedName(void) const;
113 const SoPath * getSurrogatePartPickedPath(void) const;
114 void setStartingPoint(const SoPickedPoint * newpoint);
115 void setStartingPoint(const SbVec3f & newpoint);
116 const SbViewVolume & getViewVolume(void);
117 void setViewVolume(const SbViewVolume & vol);
118 const SbViewportRegion & getViewportRegion(void);
119 void setViewportRegion(const SbViewportRegion & reg);
120 SoHandleEventAction * getHandleEventAction(void) const;
121 void setHandleEventAction(SoHandleEventAction * newAction);
122 void setTempPathToThis(const SoPath * somethingclose);
123 virtual void grabEventsSetup(void);
124 virtual void grabEventsCleanup(void);
125 void workFieldsIntoTransform(SbMatrix & mtx);
126 void setFrontOnProjector(ProjectorFrontSetting newval);
127 ProjectorFrontSetting getFrontOnProjector(void) const;
128
129 static void setMinScale(float newminscale);
130 static float getMinScale(void);
131 static void workValuesIntoTransform(SbMatrix & mtx, const SbVec3f * translationptr, const SbRotation * rotationptr, const SbVec3f * scalefactorptr, const SbRotation * scaleorientationptr, const SbVec3f * centerptr);
132 static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation, const SbVec3f & center);
133 static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation);
134 static SbMatrix appendTranslation(const SbMatrix & mtx, const SbVec3f & translation, const SbMatrix * conversion = NULL);
135 static SbMatrix appendScale(const SbMatrix & mtx, const SbVec3f & scale, const SbVec3f & scalecenter, const SbMatrix * conversion = NULL);
136 static SbMatrix appendRotation(const SbMatrix & mtx, const SbRotation & rot, const SbVec3f & rotcenter, const SbMatrix * conversion = NULL);
137 static void initClass(void);
138 static void initClasses(void);
139
140protected:
141 SoDragger(void);
142 virtual ~SoDragger(void);
143
144 SbVec2f getNormalizedLocaterPosition(void);
145 SbVec2s getLocaterPosition(void);
146 SbVec2s getStartLocaterPosition(void) const;
147 void setStartLocaterPosition(SbVec2s p);
148 SbBool isAdequateConstraintMotion(void);
149 virtual SbBool shouldGrabBasedOnSurrogate(const SoPath * pickpath, const SoPath * surrogatepath);
150 void setCameraInfo(SoAction * action);
151 virtual void handleEvent(SoHandleEventAction * ha);
152 void transferMotion(SoDragger * child);
153 void setIgnoreInBbox(SbBool newval);
154 SbBool isIgnoreInBbox(void);
155 virtual void getBoundingBox(SoGetBoundingBoxAction * action);
156 void setActiveChildDragger(SoDragger * newchilddragger);
157 SoDragger * getActiveChildDragger(void) const;
158 virtual void setDefaultOnNonWritingFields(void);
159
160 static void childTransferMotionAndValueChangedCB(void *, SoDragger *);
161 static void childValueChangedCB(void *, SoDragger *);
162 static void childStartCB(void *, SoDragger *);
163 static void childMotionCB(void *, SoDragger *);
164 static void childFinishCB(void *, SoDragger *);
165 static void childOtherEventCB(void *, SoDragger *);
166
167 // This method is not present in Open Inventor. It was moved from
168 // being a private method to a protected method in Coin to make it
169 // possible to construct draggers which can handle Motion3 events.
170 void updateDraggerCache(const SoPath * path);
171
172private:
173 void updateElements(class SoState * state);
174 SbBool isPicked(SoPath * path);
175 void eventHandled(const SoEvent * event, SoHandleEventAction * action);
176 static float minscale;
177
178private:
179 SbPimplPtr<SoDraggerP> pimpl;
180
181 // NOT IMPLEMENTED:
182 SoDragger(const SoDragger & rhs);
183 SoDragger & operator = (const SoDragger & rhs);
184}; // SoDragger
185
186#endif // !COIN_SODRAGGER_H
void SoDraggerCB(void *data, SoDragger *dragger)
Definition SoDragger.h:53
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition SbMatrix.h:37
The SbName class stores strings by reference.
Definition SbName.h:31
The SbRotation class represents a rotation in 3D space.
Definition SbRotation.h:33
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition SbVec2f.h:39
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition SbVec2s.h:41
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:40
The SbViewVolume class is a viewing volume in 3D space.
Definition SbViewVolume.h:41
The SbViewportRegion class is a viewport within a full window.
Definition SbViewportRegion.h:31
The SoAction class is the base class for all traversal actions.
Definition SoAction.h:68
virtual void write(SoWriteAction *action)
Definition SoBaseKit.cpp:1121
virtual void callback(SoCallbackAction *action)
Definition SoBaseKit.cpp:1006
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
Definition SoBaseKit.cpp:1020
virtual void GLRender(SoGLRenderAction *action)
Definition SoBaseKit.cpp:1013
virtual void rayPick(SoRayPickAction *action)
Definition SoBaseKit.cpp:1072
virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action)
Definition SoBaseKit.cpp:1381
virtual void handleEvent(SoHandleEventAction *action)
Definition SoBaseKit.cpp:1065
virtual void getMatrix(SoGetMatrixAction *action)
Definition SoBaseKit.cpp:1043
virtual void search(SoSearchAction *action)
Definition SoBaseKit.cpp:1089
The SoCallbackAction class invokes callbacks at specific nodes.
Definition SoCallbackAction.h:71
The SoDragger class is the base class for all draggers.
Definition SoDragger.h:55
SoSFBool isActive
Definition SoDragger.h:62
ProjectorFrontSetting
Definition SoDragger.h:64
@ BACK
Definition SoDragger.h:64
The SoEvent class is the base class for all Coin events.
Definition SoEvent.h:34
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition SoGLRenderAction.h:41
The SoGetBoundingBoxAction class calculates bounding boxes for nodes and subgraphs.
Definition SoGetBoundingBoxAction.h:36
The SoGetMatrixAction class is an action for accumulating the transformation matrix of a subgraph.
Definition SoGetMatrixAction.h:37
The SoGetPrimitiveCountAction class counts the primitives in a scene.
Definition SoGetPrimitiveCountAction.h:34
The SoHandleEventAction class distributes user events to the scene.
Definition SoHandleEventAction.h:37
The SoInteractionKit class is a base class for draggers.
Definition SoInteractionKit.h:41
virtual void setDefaultOnNonWritingFields()
Definition SoInteractionKit.cpp:704
static void initClasses(void)
Definition SoNode.cpp:533
virtual void grabEventsCleanup(void)
Definition SoNode.cpp:1312
virtual void grabEventsSetup(void)
Definition SoNode.cpp:1303
The SoPath class is a container class for traversal path descriptions.
Definition SoPath.h:43
The SoPickedPoint class is used for specifying picked points.
Definition SoPickedPoint.h:39
The SoRayPickAction class does ray intersection with scene graphs.
Definition SoRayPickAction.h:41
The SoSFBool class is a container for an SbBool value.
Definition SoSFBool.h:30
The SoSearchAction class provides methods for searching through scene graphs.
Definition SoSearchAction.h:35
The SoState class manages the Coin scenegraph traversal state data.
Definition SoState.h:35
The SoWriteAction class writes a scene graph to file.
Definition SoWriteAction.h:33

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

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