00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COIN_SODRAGGER_H
00021 #define COIN_SODRAGGER_H
00022
00023 #include <Inventor/nodekits/SoInteractionKit.h>
00024 #include <Inventor/fields/SoSFBool.h>
00025 #include <Inventor/lists/SoCallbackList.h>
00026 #include <Inventor/SbMatrix.h>
00027 #include <Inventor/SbVec3f.h>
00028 #include <Inventor/SbVec2s.h>
00029 #include <Inventor/SbViewVolume.h>
00030 #include <Inventor/SbViewportRegion.h>
00031 #ifndef COIN_INTERNAL
00032
00033 #include <Inventor/nodes/SoScale.h>
00034 #endif // COIN_INTERNAL
00035
00036
00037 class SbRotation;
00038 class SbVec2f;
00039 class SbVec2s;
00040 class SbViewVolume;
00041 class SbViewportRegion;
00042 class SoDragger;
00043 class SoEvent;
00044 class SoPickedPoint;
00045
00046 typedef void SoDraggerCB(void * data, SoDragger * dragger);
00047
00048
00049 class COIN_DLL_API SoDragger : public SoInteractionKit {
00050 typedef SoInteractionKit inherited;
00051
00052 SO_KIT_HEADER(SoDragger);
00053
00054 SO_KIT_CATALOG_ENTRY_HEADER(motionMatrix);
00055
00056 public:
00057 SoSFBool isActive;
00058
00059 enum ProjectorFrontSetting { FRONT, BACK, USE_PICK };
00060
00061
00062 virtual void callback(SoCallbackAction * action);
00063 virtual void GLRender(SoGLRenderAction * action);
00064 virtual void getMatrix(SoGetMatrixAction * action);
00065 virtual void rayPick(SoRayPickAction * action);
00066 virtual void search(SoSearchAction * action);
00067 virtual void write(SoWriteAction * action);
00068 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00069
00070 void addStartCallback(SoDraggerCB * func, void * data = NULL);
00071 void removeStartCallback(SoDraggerCB * func, void * data = NULL);
00072 void addMotionCallback(SoDraggerCB * func, void * data = NULL);
00073 void removeMotionCallback(SoDraggerCB * func, void * data = NULL);
00074 void addFinishCallback(SoDraggerCB * func, void * data = NULL);
00075 void removeFinishCallback(SoDraggerCB * func, void * data = NULL);
00076 void addValueChangedCallback(SoDraggerCB * func, void * data = NULL);
00077 void removeValueChangedCallback(SoDraggerCB * func, void * data = NULL);
00078 void setMinGesture(int pixels);
00079 int getMinGesture(void) const;
00080 SbBool enableValueChangedCallbacks(SbBool newval);
00081 const SbMatrix & getMotionMatrix(void);
00082 void addOtherEventCallback(SoDraggerCB * func, void * data = NULL);
00083 void removeOtherEventCallback(SoDraggerCB * func, void * data = NULL);
00084 void registerChildDragger(SoDragger * child);
00085 void unregisterChildDragger(SoDragger * child);
00086 void registerChildDraggerMovingIndependently(SoDragger * child);
00087 void unregisterChildDraggerMovingIndependently(SoDragger * child);
00088 SbMatrix getLocalToWorldMatrix(void);
00089 SbMatrix getWorldToLocalMatrix(void);
00090 SbVec3f getLocalStartingPoint(void);
00091 SbVec3f getWorldStartingPoint(void);
00092 void getPartToLocalMatrix(const SbName & partname, SbMatrix & parttolocalmatrix, SbMatrix & localtopartmatrix);
00093 void transformMatrixLocalToWorld(const SbMatrix & frommatrix, SbMatrix & tomatrix);
00094 void transformMatrixWorldToLocal(const SbMatrix & frommatrix, SbMatrix & tomatrix);
00095 void transformMatrixToLocalSpace(const SbMatrix & frommatrix, SbMatrix & tomatrix, const SbName & fromspacepartname);
00096 void setMotionMatrix(const SbMatrix & newmatrix);
00097 void valueChanged(void);
00098 const SbMatrix & getStartMotionMatrix(void);
00099 virtual void saveStartParameters(void);
00100 const SoPath * getPickPath(void) const;
00101 const SoEvent * getEvent(void) const;
00102 SoPath * createPathToThis(void);
00103 const SoPath * getSurrogatePartPickedOwner(void) const;
00104 const SbName & getSurrogatePartPickedName(void) const;
00105 const SoPath * getSurrogatePartPickedPath(void) const;
00106 void setStartingPoint(const SoPickedPoint * newpoint);
00107 void setStartingPoint(const SbVec3f & newpoint);
00108 const SbViewVolume & getViewVolume(void);
00109 void setViewVolume(const SbViewVolume & vol);
00110 const SbViewportRegion & getViewportRegion(void);
00111 void setViewportRegion(const SbViewportRegion & reg);
00112 SoHandleEventAction * getHandleEventAction(void) const;
00113 void setHandleEventAction(SoHandleEventAction * newAction);
00114 void setTempPathToThis(const SoPath * somethingclose);
00115 virtual void grabEventsSetup(void);
00116 virtual void grabEventsCleanup(void);
00117 void workFieldsIntoTransform(SbMatrix & mtx);
00118 void setFrontOnProjector(ProjectorFrontSetting newval);
00119 ProjectorFrontSetting getFrontOnProjector(void) const;
00120
00121 static void setMinScale(float newminscale);
00122 static float getMinScale(void);
00123 static void workValuesIntoTransform(SbMatrix & mtx, const SbVec3f * translationptr, const SbRotation * rotationptr, const SbVec3f * scalefactorptr, const SbRotation * scaleorientationptr, const SbVec3f * centerptr);
00124 static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation, const SbVec3f & center);
00125 static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation);
00126 static SbMatrix appendTranslation(const SbMatrix & mtx, const SbVec3f & translation, const SbMatrix * conversion = NULL);
00127 static SbMatrix appendScale(const SbMatrix & mtx, const SbVec3f & scale, const SbVec3f & scalecenter, const SbMatrix * conversion = NULL);
00128 static SbMatrix appendRotation(const SbMatrix & mtx, const SbRotation & rot, const SbVec3f & rotcenter, const SbMatrix * conversion = NULL);
00129 static void initClass(void);
00130 static void initClasses(void);
00131
00132 protected:
00133 SoDragger(void);
00134 virtual ~SoDragger();
00135
00136 SbVec2f getNormalizedLocaterPosition(void);
00137 SbVec2s getLocaterPosition(void);
00138 SbVec2s getStartLocaterPosition(void) const;
00139 void setStartLocaterPosition(SbVec2s p);
00140 SbBool isAdequateConstraintMotion(void);
00141 virtual SbBool shouldGrabBasedOnSurrogate(const SoPath * pickpath, const SoPath * surrogatepath);
00142 void setCameraInfo(SoAction * action);
00143 virtual void handleEvent(SoHandleEventAction * ha);
00144 void transferMotion(SoDragger * child);
00145 void setIgnoreInBbox(SbBool newval);
00146 SbBool isIgnoreInBbox(void);
00147 virtual void getBoundingBox(SoGetBoundingBoxAction * action);
00148 void setActiveChildDragger(SoDragger * newchilddragger);
00149 SoDragger * getActiveChildDragger(void) const;
00150 virtual void setDefaultOnNonWritingFields(void);
00151
00152 static void childTransferMotionAndValueChangedCB(void *, SoDragger *);
00153 static void childValueChangedCB(void *, SoDragger *);
00154 static void childStartCB(void *, SoDragger *);
00155 static void childMotionCB(void *, SoDragger *);
00156 static void childFinishCB(void *, SoDragger *);
00157 static void childOtherEventCB(void *, SoDragger *);
00158
00159
00160
00161
00162 void updateDraggerCache(const SoPath * path);
00163
00164 private:
00165 void updateElements(class SoState * state);
00166 SbBool isPicked(SoPath * path);
00167 void eventHandled(const SoEvent * event, SoHandleEventAction * action);
00168 static float minscale;
00169
00170 class SoDraggerP * pimpl;
00171 };
00172
00173 #endif // !COIN_SODRAGGER_H