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

SoDragger.h
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) 1998-2007 by Systems in Motion. All rights reserved.
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 Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, 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/fields/SoSFBool.h>
29 #include <Inventor/lists/SoCallbackList.h>
30 #include <Inventor/SbMatrix.h>
31 #include <Inventor/SbVec3f.h>
32 #include <Inventor/SbVec2s.h>
33 #include <Inventor/SbViewVolume.h>
34 #include <Inventor/SbViewportRegion.h>
35 #ifndef COIN_INTERNAL
36  // For Open Inventor compatibility.
37  #include <Inventor/nodes/SoScale.h>
38 #endif // COIN_INTERNAL
39 
40 
41 class SbRotation;
42 class SbVec2f;
43 class SbVec2s;
44 class SbViewVolume;
45 class SbViewportRegion;
46 class SoDragger;
47 class SoEvent;
48 class SoPickedPoint;
49 
50 typedef void SoDraggerCB(void * data, SoDragger * dragger);
51 
52 
53 class COIN_DLL_API SoDragger : public SoInteractionKit {
55 
56  SO_KIT_HEADER(SoDragger);
57 
58  SO_KIT_CATALOG_ENTRY_HEADER(motionMatrix);
59 
60 public:
62 
63  enum ProjectorFrontSetting { FRONT, BACK, USE_PICK };
64 
65  // override these in case we decide to do some extra work later
66  virtual void callback(SoCallbackAction * action);
67  virtual void GLRender(SoGLRenderAction * action);
68  virtual void getMatrix(SoGetMatrixAction * action);
69  virtual void rayPick(SoRayPickAction * action);
70  virtual void search(SoSearchAction * action);
71  virtual void write(SoWriteAction * action);
72  virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
73 
74  void addStartCallback(SoDraggerCB * func, void * data = NULL);
75  void removeStartCallback(SoDraggerCB * func, void * data = NULL);
76  void addMotionCallback(SoDraggerCB * func, void * data = NULL);
77  void removeMotionCallback(SoDraggerCB * func, void * data = NULL);
78  void addFinishCallback(SoDraggerCB * func, void * data = NULL);
79  void removeFinishCallback(SoDraggerCB * func, void * data = NULL);
80  void addValueChangedCallback(SoDraggerCB * func, void * data = NULL);
81  void removeValueChangedCallback(SoDraggerCB * func, void * data = NULL);
82  void setMinGesture(int pixels);
83  int getMinGesture(void) const;
84  SbBool enableValueChangedCallbacks(SbBool newval);
85  const SbMatrix & getMotionMatrix(void);
86  void addOtherEventCallback(SoDraggerCB * func, void * data = NULL);
87  void removeOtherEventCallback(SoDraggerCB * func, void * data = NULL);
88  void registerChildDragger(SoDragger * child);
89  void unregisterChildDragger(SoDragger * child);
90  void registerChildDraggerMovingIndependently(SoDragger * child);
91  void unregisterChildDraggerMovingIndependently(SoDragger * child);
92  SbMatrix getLocalToWorldMatrix(void);
93  SbMatrix getWorldToLocalMatrix(void);
94  SbVec3f getLocalStartingPoint(void);
95  SbVec3f getWorldStartingPoint(void);
96  void getPartToLocalMatrix(const SbName & partname, SbMatrix & parttolocalmatrix, SbMatrix & localtopartmatrix);
97  void transformMatrixLocalToWorld(const SbMatrix & frommatrix, SbMatrix & tomatrix);
98  void transformMatrixWorldToLocal(const SbMatrix & frommatrix, SbMatrix & tomatrix);
99  void transformMatrixToLocalSpace(const SbMatrix & frommatrix, SbMatrix & tomatrix, const SbName & fromspacepartname);
100  void setMotionMatrix(const SbMatrix & newmatrix);
101  void valueChanged(void);
102  const SbMatrix & getStartMotionMatrix(void);
103  virtual void saveStartParameters(void);
104  const SoPath * getPickPath(void) const;
105  const SoEvent * getEvent(void) const;
106  SoPath * createPathToThis(void);
107  const SoPath * getSurrogatePartPickedOwner(void) const;
108  const SbName & getSurrogatePartPickedName(void) const;
109  const SoPath * getSurrogatePartPickedPath(void) const;
110  void setStartingPoint(const SoPickedPoint * newpoint);
111  void setStartingPoint(const SbVec3f & newpoint);
112  const SbViewVolume & getViewVolume(void);
113  void setViewVolume(const SbViewVolume & vol);
114  const SbViewportRegion & getViewportRegion(void);
115  void setViewportRegion(const SbViewportRegion & reg);
116  SoHandleEventAction * getHandleEventAction(void) const;
117  void setHandleEventAction(SoHandleEventAction * newAction);
118  void setTempPathToThis(const SoPath * somethingclose);
119  virtual void grabEventsSetup(void);
120  virtual void grabEventsCleanup(void);
121  void workFieldsIntoTransform(SbMatrix & mtx);
122  void setFrontOnProjector(ProjectorFrontSetting newval);
123  ProjectorFrontSetting getFrontOnProjector(void) const;
124 
125  static void setMinScale(float newminscale);
126  static float getMinScale(void);
127  static void workValuesIntoTransform(SbMatrix & mtx, const SbVec3f * translationptr, const SbRotation * rotationptr, const SbVec3f * scalefactorptr, const SbRotation * scaleorientationptr, const SbVec3f * centerptr);
128  static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation, const SbVec3f & center);
129  static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation);
130  static SbMatrix appendTranslation(const SbMatrix & mtx, const SbVec3f & translation, const SbMatrix * conversion = NULL);
131  static SbMatrix appendScale(const SbMatrix & mtx, const SbVec3f & scale, const SbVec3f & scalecenter, const SbMatrix * conversion = NULL);
132  static SbMatrix appendRotation(const SbMatrix & mtx, const SbRotation & rot, const SbVec3f & rotcenter, const SbMatrix * conversion = NULL);
133  static void initClass(void);
134  static void initClasses(void);
135 
136 protected:
137  SoDragger(void);
138  virtual ~SoDragger();
139 
140  SbVec2f getNormalizedLocaterPosition(void);
141  SbVec2s getLocaterPosition(void);
142  SbVec2s getStartLocaterPosition(void) const;
143  void setStartLocaterPosition(SbVec2s p);
144  SbBool isAdequateConstraintMotion(void);
145  virtual SbBool shouldGrabBasedOnSurrogate(const SoPath * pickpath, const SoPath * surrogatepath);
146  void setCameraInfo(SoAction * action);
147  virtual void handleEvent(SoHandleEventAction * ha);
148  void transferMotion(SoDragger * child);
149  void setIgnoreInBbox(SbBool newval);
150  SbBool isIgnoreInBbox(void);
151  virtual void getBoundingBox(SoGetBoundingBoxAction * action);
152  void setActiveChildDragger(SoDragger * newchilddragger);
153  SoDragger * getActiveChildDragger(void) const;
154  virtual void setDefaultOnNonWritingFields(void);
155 
156  static void childTransferMotionAndValueChangedCB(void *, SoDragger *);
157  static void childValueChangedCB(void *, SoDragger *);
158  static void childStartCB(void *, SoDragger *);
159  static void childMotionCB(void *, SoDragger *);
160  static void childFinishCB(void *, SoDragger *);
161  static void childOtherEventCB(void *, SoDragger *);
162 
163  // This method is not present in Open Inventor. It was moved from
164  // being a private method to a protected method in Coin to make it
165  // possible to construct draggers which can handle Motion3 events.
166  void updateDraggerCache(const SoPath * path);
167 
168 private:
169  void updateElements(class SoState * state);
170  SbBool isPicked(SoPath * path);
171  void eventHandled(const SoEvent * event, SoHandleEventAction * action);
172  static float minscale;
173 
174  class SoDraggerP * pimpl;
175 };
176 
177 #endif // !COIN_SODRAGGER_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:36
virtual void search(SoSearchAction *action)
Definition: SoBaseKit.cpp:1083
SoSFBool isActive
Definition: SoDragger.h:61
The SoRayPickAction class does ray intersection with scene graphs.For interaction with the scene grap...
Definition: SoRayPickAction.h:40
The SoGetMatrixAction class is an action for accumulating the transformation matrix of a subgraph...
Definition: SoGetMatrixAction.h:35
The SoSearchAction class provides methods for searching through scene graphs.Nodes can be searched fo...
Definition: SoSearchAction.h:32
virtual void handleEvent(SoHandleEventAction *action)
Definition: SoBaseKit.cpp:1059
static void initClasses(void)
Definition: SoNode.cpp:519
virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action)
Definition: SoBaseKit.cpp:1375
The SoState class manages the Coin scenegraph traversal state data.The SoState class is used by actio...
Definition: SoState.h:35
The SoInteractionKit class is a base class for draggers.This nodekit class makes it possible to set s...
Definition: SoInteractionKit.h:41
The SoSFBool class is a container for an SbBool value.This field is used where nodes, engines or other field containers needs to store a boolean on/off or TRUE/FALSE value, like for instance as the "on" field of the SoPointLight, SoSpotLight and SoDirectionalLight node classes.
Definition: SoSFBool.h:30
The SoPath class is a container class for traversal path descriptions.SoPath objects contain a list o...
Definition: SoPath.h:43
virtual void getMatrix(SoGetMatrixAction *action)
Definition: SoBaseKit.cpp:1037
The SoDragger class is the base class for all draggers.Draggers is a mechanism used for letting the e...
Definition: SoDragger.h:53
The SbRotation class represents a rotation in 3D space.SbRotation is used extensively throughout the ...
Definition: SbRotation.h:33
virtual void GLRender(SoGLRenderAction *action)
Definition: SoBaseKit.cpp:1007
The SoAction class is the base class for all traversal actions.Applying actions is the basic mechanis...
Definition: SoAction.h:67
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:37
The SbMatrix class is a 4x4 dimensional representation of a matrix.SbMatrix is used by many other cla...
Definition: SbMatrix.h:37
The SoHandleEventAction class distributes user events to the scene.This is the action used by the GUI...
Definition: SoHandleEventAction.h:36
ProjectorFrontSetting
Definition: SoDragger.h:63
The SoGetPrimitiveCountAction class counts the primitives in a scene.Apply this action to a scene if ...
Definition: SoGetPrimitiveCountAction.h:32
The SoGetBoundingBoxAction class calculates bounding boxes for nodes and subgraphs.If this action is applied to a path or scene graph root, it will calculate the bounding box and the center point of the geometry contained within the scene.
Definition: SoGetBoundingBoxAction.h:34
The SbViewVolume class is a viewing volume in 3D space.This class contains the necessary information ...
Definition: SbViewVolume.h:41
The SoPickedPoint class is used for specifying picked points.It holds miscellaneous information about...
Definition: SoPickedPoint.h:39
The SoCallbackAction class invokes callbacks at specific nodes.This action has mechanisms for trackin...
Definition: SoCallbackAction.h:70
The SoWriteAction class writes a scene graph to file.When applied to a scene, this action writes its ...
Definition: SoWriteAction.h:31
The SoEvent class is the base class for all Coin events.Coin contains its own set of event classes...
Definition: SoEvent.h:34
virtual void callback(SoCallbackAction *action)
Definition: SoBaseKit.cpp:1000
virtual void grabEventsSetup(void)
Definition: SoNode.cpp:1275
virtual void grabEventsCleanup(void)
Definition: SoNode.cpp:1284
The SbViewportRegion class is a viewport within a full window.The SbViewportRegion class contains inf...
Definition: SbViewportRegion.h:31
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
Definition: SoBaseKit.cpp:1014
virtual void write(SoWriteAction *action)
Definition: SoBaseKit.cpp:1115
virtual void rayPick(SoRayPickAction *action)
Definition: SoBaseKit.cpp:1066
virtual void setDefaultOnNonWritingFields()
Definition: SoInteractionKit.cpp:687
The SbVec2s class is a 2 dimensional vector with short integer coordinates.This vector class is used ...
Definition: SbVec2s.h:37
The SbName class stores strings by reference.The class is used by Coin for storing keywords...
Definition: SbName.h:31
The SoGLRenderAction class renders the scene graph with OpenGL calls.Applying this method at a root n...
Definition: SoGLRenderAction.h:39

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Fri Feb 17 2017 for Coin by Doxygen. 1.8.13