SoDragger.h
#ifndef COIN_SODRAGGER_H
#define COIN_SODRAGGER_H
/**************************************************************************\
* Copyright (c) Kongsberg Oil & Gas Technologies AS
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/
#include <Inventor/nodekits/SoInteractionKit.h>
#include <Inventor/tools/SbPimplPtr.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/lists/SoCallbackList.h>
#include <Inventor/SbMatrix.h>
#include <Inventor/SbVec3f.h>
#include <Inventor/SbVec2s.h>
#include <Inventor/SbViewVolume.h>
#include <Inventor/SbViewportRegion.h>
#ifndef COIN_INTERNAL
// For Open Inventor compatibility.
#include <Inventor/nodes/SoScale.h>
#endif // !COIN_INTERNAL
class SbRotation;
class SbVec2f;
class SbVec2s;
class SbViewVolume;
class SbViewportRegion;
class SoDragger;
class SoEvent;
class SoPickedPoint;
class SoDraggerP;
typedef void SoDraggerCB(void * data, SoDragger * dragger);
class COIN_DLL_API SoDragger : public SoInteractionKit {
typedef SoInteractionKit inherited;
SO_KIT_HEADER(SoDragger);
SO_KIT_CATALOG_ENTRY_HEADER(motionMatrix);
public:
SoSFBool isActive;
enum ProjectorFrontSetting { FRONT, BACK, USE_PICK };
// override these in case we decide to do some extra work later
virtual void callback(SoCallbackAction * action);
virtual void GLRender(SoGLRenderAction * action);
virtual void getMatrix(SoGetMatrixAction * action);
virtual void rayPick(SoRayPickAction * action);
virtual void search(SoSearchAction * action);
virtual void write(SoWriteAction * action);
virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
void setProjectorEpsilon(const float epsilon);
float getProjectorEpsilon(void) const;
void addStartCallback(SoDraggerCB * func, void * data = NULL);
void removeStartCallback(SoDraggerCB * func, void * data = NULL);
void addMotionCallback(SoDraggerCB * func, void * data = NULL);
void removeMotionCallback(SoDraggerCB * func, void * data = NULL);
void addFinishCallback(SoDraggerCB * func, void * data = NULL);
void removeFinishCallback(SoDraggerCB * func, void * data = NULL);
void addValueChangedCallback(SoDraggerCB * func, void * data = NULL);
void removeValueChangedCallback(SoDraggerCB * func, void * data = NULL);
void setMinGesture(int pixels);
int getMinGesture(void) const;
SbBool enableValueChangedCallbacks(SbBool newval);
const SbMatrix & getMotionMatrix(void);
void addOtherEventCallback(SoDraggerCB * func, void * data = NULL);
void removeOtherEventCallback(SoDraggerCB * func, void * data = NULL);
void registerChildDragger(SoDragger * child);
void unregisterChildDragger(SoDragger * child);
void registerChildDraggerMovingIndependently(SoDragger * child);
void unregisterChildDraggerMovingIndependently(SoDragger * child);
SbMatrix getLocalToWorldMatrix(void);
SbMatrix getWorldToLocalMatrix(void);
SbVec3f getLocalStartingPoint(void);
SbVec3f getWorldStartingPoint(void);
void getPartToLocalMatrix(const SbName & partname, SbMatrix & parttolocalmatrix, SbMatrix & localtopartmatrix);
void transformMatrixLocalToWorld(const SbMatrix & frommatrix, SbMatrix & tomatrix);
void transformMatrixWorldToLocal(const SbMatrix & frommatrix, SbMatrix & tomatrix);
void transformMatrixToLocalSpace(const SbMatrix & frommatrix, SbMatrix & tomatrix, const SbName & fromspacepartname);
virtual void setMotionMatrix(const SbMatrix & newmatrix);
void valueChanged(void);
const SbMatrix & getStartMotionMatrix(void);
virtual void saveStartParameters(void);
const SoPath * getPickPath(void) const;
const SoEvent * getEvent(void) const;
SoPath * createPathToThis(void);
const SoPath * getSurrogatePartPickedOwner(void) const;
const SbName & getSurrogatePartPickedName(void) const;
const SoPath * getSurrogatePartPickedPath(void) const;
void setStartingPoint(const SoPickedPoint * newpoint);
void setStartingPoint(const SbVec3f & newpoint);
const SbViewVolume & getViewVolume(void);
void setViewVolume(const SbViewVolume & vol);
const SbViewportRegion & getViewportRegion(void);
void setViewportRegion(const SbViewportRegion & reg);
SoHandleEventAction * getHandleEventAction(void) const;
void setHandleEventAction(SoHandleEventAction * newAction);
void setTempPathToThis(const SoPath * somethingclose);
virtual void grabEventsSetup(void);
virtual void grabEventsCleanup(void);
void workFieldsIntoTransform(SbMatrix & mtx);
void setFrontOnProjector(ProjectorFrontSetting newval);
ProjectorFrontSetting getFrontOnProjector(void) const;
static void setMinScale(float newminscale);
static float getMinScale(void);
static void workValuesIntoTransform(SbMatrix & mtx, const SbVec3f * translationptr, const SbRotation * rotationptr, const SbVec3f * scalefactorptr, const SbRotation * scaleorientationptr, const SbVec3f * centerptr);
static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation, const SbVec3f & center);
static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation);
static SbMatrix appendTranslation(const SbMatrix & mtx, const SbVec3f & translation, const SbMatrix * conversion = NULL);
static SbMatrix appendScale(const SbMatrix & mtx, const SbVec3f & scale, const SbVec3f & scalecenter, const SbMatrix * conversion = NULL);
static SbMatrix appendRotation(const SbMatrix & mtx, const SbRotation & rot, const SbVec3f & rotcenter, const SbMatrix * conversion = NULL);
static void initClass(void);
static void initClasses(void);
protected:
SoDragger(void);
virtual ~SoDragger(void);
SbVec2f getNormalizedLocaterPosition(void);
SbVec2s getLocaterPosition(void);
SbVec2s getStartLocaterPosition(void) const;
void setStartLocaterPosition(SbVec2s p);
SbBool isAdequateConstraintMotion(void);
virtual SbBool shouldGrabBasedOnSurrogate(const SoPath * pickpath, const SoPath * surrogatepath);
void setCameraInfo(SoAction * action);
virtual void handleEvent(SoHandleEventAction * ha);
void transferMotion(SoDragger * child);
void setIgnoreInBbox(SbBool newval);
SbBool isIgnoreInBbox(void);
virtual void getBoundingBox(SoGetBoundingBoxAction * action);
void setActiveChildDragger(SoDragger * newchilddragger);
SoDragger * getActiveChildDragger(void) const;
virtual void setDefaultOnNonWritingFields(void);
static void childTransferMotionAndValueChangedCB(void *, SoDragger *);
static void childValueChangedCB(void *, SoDragger *);
static void childStartCB(void *, SoDragger *);
static void childMotionCB(void *, SoDragger *);
static void childFinishCB(void *, SoDragger *);
static void childOtherEventCB(void *, SoDragger *);
// This method is not present in Open Inventor. It was moved from
// being a private method to a protected method in Coin to make it
// possible to construct draggers which can handle Motion3 events.
void updateDraggerCache(const SoPath * path);
virtual const SoPickedPoint* getPickedPointForStart(SoHandleEventAction* action);
private:
void updateElements(class SoState * state);
SbBool isPicked(SoPath * path);
void eventHandled(const SoEvent * event, SoHandleEventAction * action);
static float minscale;
private:
SbPimplPtr<SoDraggerP> pimpl;
// NOT IMPLEMENTED:
SoDragger(const SoDragger & rhs);
SoDragger & operator = (const SoDragger & rhs);
}; // SoDragger
#endif // !COIN_SODRAGGER_H
SbMatrix
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition SbMatrix.h:47
SbName
The SbName class stores strings by reference.
Definition SbName.h:40
SbPimplPtr
Definition SbPimplPtr.h:55
SbRotation
The SbRotation class represents a rotation in 3D space.
Definition SbRotation.h:44
SbVec2f
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition SbVec2f.h:49
SbVec2s
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition SbVec2s.h:51
SbVec3f
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:51
SbViewVolume
The SbViewVolume class is a viewing volume in 3D space.
Definition SbViewVolume.h:50
SbViewportRegion
The SbViewportRegion class is a viewport within a full window.
Definition SbViewportRegion.h:40
SoAction
The SoAction class is the base class for all traversal actions.
Definition SoAction.h:77
SoBaseKit::write
virtual void write(SoWriteAction *action)
Definition SoBaseKit.cpp:1116
SoBaseKit::callback
virtual void callback(SoCallbackAction *action)
Definition SoBaseKit.cpp:1001
SoBaseKit::getBoundingBox
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
Definition SoBaseKit.cpp:1015
SoBaseKit::GLRender
virtual void GLRender(SoGLRenderAction *action)
Definition SoBaseKit.cpp:1008
SoBaseKit::rayPick
virtual void rayPick(SoRayPickAction *action)
Definition SoBaseKit.cpp:1067
SoBaseKit::getPrimitiveCount
virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action)
Definition SoBaseKit.cpp:1376
SoBaseKit::handleEvent
virtual void handleEvent(SoHandleEventAction *action)
Definition SoBaseKit.cpp:1060
SoBaseKit::getMatrix
virtual void getMatrix(SoGetMatrixAction *action)
Definition SoBaseKit.cpp:1038
SoBaseKit::search
virtual void search(SoSearchAction *action)
Definition SoBaseKit.cpp:1084
SoCallbackAction
The SoCallbackAction class invokes callbacks at specific nodes.
Definition SoCallbackAction.h:80
SoDragger
The SoDragger class is the base class for all draggers.
Definition SoDragger.h:62
SoDragger::isActive
SoSFBool isActive
Definition SoDragger.h:69
SoDragger::SoDragger
SoDragger(void)
Definition SoDragger.cpp:355
SoDragger::ProjectorFrontSetting
ProjectorFrontSetting
Definition SoDragger.h:71
SoDragger::BACK
@ BACK
Definition SoDragger.h:71
SoDragger::USE_PICK
@ USE_PICK
Definition SoDragger.h:71
SoDragger::FRONT
@ FRONT
Definition SoDragger.h:71
SoEvent
The SoEvent class is the base class for all Coin events.
Definition SoEvent.h:45
SoGLRenderAction
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition SoGLRenderAction.h:50
SoGetBoundingBoxAction
The SoGetBoundingBoxAction class calculates bounding boxes for nodes and subgraphs.
Definition SoGetBoundingBoxAction.h:45
SoGetMatrixAction
The SoGetMatrixAction class is an action for accumulating the transformation matrix of a subgraph.
Definition SoGetMatrixAction.h:46
SoGetPrimitiveCountAction
The SoGetPrimitiveCountAction class counts the primitives in a scene.
Definition SoGetPrimitiveCountAction.h:44
SoHandleEventAction
The SoHandleEventAction class distributes user events to the scene.
Definition SoHandleEventAction.h:46
SoInteractionKit::initClass
static void initClass(void)
Sets up initialization for data common to all instances of this class, like submitting necessary info...
Definition SoInteractionKit.cpp:266
SoInteractionKit::setDefaultOnNonWritingFields
virtual void setDefaultOnNonWritingFields()
Definition SoInteractionKit.cpp:716
SoInteractionKit::SoInteractionKit
SoInteractionKit(void)
Definition SoInteractionKit.cpp:218
SoNode::initClasses
static void initClasses(void)
Definition SoNode.cpp:604
SoNode::grabEventsCleanup
virtual void grabEventsCleanup(void)
Definition SoNode.cpp:1385
SoNode::grabEventsSetup
virtual void grabEventsSetup(void)
Definition SoNode.cpp:1376
SoPath
The SoPath class is a container class for traversal path descriptions.
Definition SoPath.h:52
SoPickedPoint
The SoPickedPoint class is used for specifying picked points.
Definition SoPickedPoint.h:48
SoRayPickAction
The SoRayPickAction class does ray intersection with scene graphs.
Definition SoRayPickAction.h:50
SoSFBool
The SoSFBool class is a container for an SbBool value.
Definition SoSFBool.h:39
SoSearchAction
The SoSearchAction class provides methods for searching through scene graphs.
Definition SoSearchAction.h:44
SoState
The SoState class manages the Coin scene graph traversal state data.
Definition SoState.h:44
SoWriteAction
The SoWriteAction class writes a scene graph to file.
Definition SoWriteAction.h:42