![]() |
http://www.sim.no/ http://www.coin3d.org/ |
00001 #ifndef COIN_SODRAGGER_H 00002 #define COIN_SODRAGGER_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) by Kongsberg Oil & Gas Technologies. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Kongsberg Oil & Gas Technologies 00018 * about acquiring a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #include <Inventor/nodekits/SoInteractionKit.h> 00028 #include <Inventor/tools/SbPimplPtr.h> 00029 #include <Inventor/fields/SoSFBool.h> 00030 #include <Inventor/lists/SoCallbackList.h> 00031 #include <Inventor/SbMatrix.h> 00032 #include <Inventor/SbVec3f.h> 00033 #include <Inventor/SbVec2s.h> 00034 #include <Inventor/SbViewVolume.h> 00035 #include <Inventor/SbViewportRegion.h> 00036 #ifndef COIN_INTERNAL 00037 // For Open Inventor compatibility. 00038 #include <Inventor/nodes/SoScale.h> 00039 #endif // !COIN_INTERNAL 00040 00042 class SbRotation; 00043 class SbVec2f; 00044 class SbVec2s; 00045 class SbViewVolume; 00046 class SbViewportRegion; 00047 class SoDragger; 00048 class SoEvent; 00049 class SoPickedPoint; 00050 class SoDraggerP; 00051 00053 typedef void SoDraggerCB(void * data, SoDragger * dragger); 00054 00055 class COIN_DLL_API SoDragger : public SoInteractionKit { 00056 typedef SoInteractionKit inherited; 00057 00058 SO_KIT_HEADER(SoDragger); 00059 SO_KIT_CATALOG_ENTRY_HEADER(motionMatrix); 00060 00061 public: 00062 SoSFBool isActive; 00063 00064 enum ProjectorFrontSetting { FRONT, BACK, USE_PICK }; 00065 00066 // override these in case we decide to do some extra work later 00067 virtual void callback(SoCallbackAction * action); 00068 virtual void GLRender(SoGLRenderAction * action); 00069 virtual void getMatrix(SoGetMatrixAction * action); 00070 virtual void rayPick(SoRayPickAction * action); 00071 virtual void search(SoSearchAction * action); 00072 virtual void write(SoWriteAction * action); 00073 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action); 00074 00075 void setProjectorEpsilon(const float epsilon); 00076 float getProjectorEpsilon(void) const; 00077 00078 void addStartCallback(SoDraggerCB * func, void * data = NULL); 00079 void removeStartCallback(SoDraggerCB * func, void * data = NULL); 00080 void addMotionCallback(SoDraggerCB * func, void * data = NULL); 00081 void removeMotionCallback(SoDraggerCB * func, void * data = NULL); 00082 void addFinishCallback(SoDraggerCB * func, void * data = NULL); 00083 void removeFinishCallback(SoDraggerCB * func, void * data = NULL); 00084 void addValueChangedCallback(SoDraggerCB * func, void * data = NULL); 00085 void removeValueChangedCallback(SoDraggerCB * func, void * data = NULL); 00086 void setMinGesture(int pixels); 00087 int getMinGesture(void) const; 00088 SbBool enableValueChangedCallbacks(SbBool newval); 00089 const SbMatrix & getMotionMatrix(void); 00090 void addOtherEventCallback(SoDraggerCB * func, void * data = NULL); 00091 void removeOtherEventCallback(SoDraggerCB * func, void * data = NULL); 00092 void registerChildDragger(SoDragger * child); 00093 void unregisterChildDragger(SoDragger * child); 00094 void registerChildDraggerMovingIndependently(SoDragger * child); 00095 void unregisterChildDraggerMovingIndependently(SoDragger * child); 00096 SbMatrix getLocalToWorldMatrix(void); 00097 SbMatrix getWorldToLocalMatrix(void); 00098 SbVec3f getLocalStartingPoint(void); 00099 SbVec3f getWorldStartingPoint(void); 00100 void getPartToLocalMatrix(const SbName & partname, SbMatrix & parttolocalmatrix, SbMatrix & localtopartmatrix); 00101 void transformMatrixLocalToWorld(const SbMatrix & frommatrix, SbMatrix & tomatrix); 00102 void transformMatrixWorldToLocal(const SbMatrix & frommatrix, SbMatrix & tomatrix); 00103 void transformMatrixToLocalSpace(const SbMatrix & frommatrix, SbMatrix & tomatrix, const SbName & fromspacepartname); 00104 virtual void setMotionMatrix(const SbMatrix & newmatrix); 00105 void valueChanged(void); 00106 const SbMatrix & getStartMotionMatrix(void); 00107 virtual void saveStartParameters(void); 00108 const SoPath * getPickPath(void) const; 00109 const SoEvent * getEvent(void) const; 00110 SoPath * createPathToThis(void); 00111 const SoPath * getSurrogatePartPickedOwner(void) const; 00112 const SbName & getSurrogatePartPickedName(void) const; 00113 const SoPath * getSurrogatePartPickedPath(void) const; 00114 void setStartingPoint(const SoPickedPoint * newpoint); 00115 void setStartingPoint(const SbVec3f & newpoint); 00116 const SbViewVolume & getViewVolume(void); 00117 void setViewVolume(const SbViewVolume & vol); 00118 const SbViewportRegion & getViewportRegion(void); 00119 void setViewportRegion(const SbViewportRegion & reg); 00120 SoHandleEventAction * getHandleEventAction(void) const; 00121 void setHandleEventAction(SoHandleEventAction * newAction); 00122 void setTempPathToThis(const SoPath * somethingclose); 00123 virtual void grabEventsSetup(void); 00124 virtual void grabEventsCleanup(void); 00125 void workFieldsIntoTransform(SbMatrix & mtx); 00126 void setFrontOnProjector(ProjectorFrontSetting newval); 00127 ProjectorFrontSetting getFrontOnProjector(void) const; 00128 00129 static void setMinScale(float newminscale); 00130 static float getMinScale(void); 00131 static void workValuesIntoTransform(SbMatrix & mtx, const SbVec3f * translationptr, const SbRotation * rotationptr, const SbVec3f * scalefactorptr, const SbRotation * scaleorientationptr, const SbVec3f * centerptr); 00132 static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation, const SbVec3f & center); 00133 static void getTransformFast(SbMatrix & mtx, SbVec3f & translation, SbRotation & rotation, SbVec3f & scalefactor, SbRotation & scaleorientation); 00134 static SbMatrix appendTranslation(const SbMatrix & mtx, const SbVec3f & translation, const SbMatrix * conversion = NULL); 00135 static SbMatrix appendScale(const SbMatrix & mtx, const SbVec3f & scale, const SbVec3f & scalecenter, const SbMatrix * conversion = NULL); 00136 static SbMatrix appendRotation(const SbMatrix & mtx, const SbRotation & rot, const SbVec3f & rotcenter, const SbMatrix * conversion = NULL); 00137 static void initClass(void); 00138 static void initClasses(void); 00139 00140 protected: 00141 SoDragger(void); 00142 virtual ~SoDragger(void); 00143 00144 SbVec2f getNormalizedLocaterPosition(void); 00145 SbVec2s getLocaterPosition(void); 00146 SbVec2s getStartLocaterPosition(void) const; 00147 void setStartLocaterPosition(SbVec2s p); 00148 SbBool isAdequateConstraintMotion(void); 00149 virtual SbBool shouldGrabBasedOnSurrogate(const SoPath * pickpath, const SoPath * surrogatepath); 00150 void setCameraInfo(SoAction * action); 00151 virtual void handleEvent(SoHandleEventAction * ha); 00152 void transferMotion(SoDragger * child); 00153 void setIgnoreInBbox(SbBool newval); 00154 SbBool isIgnoreInBbox(void); 00155 virtual void getBoundingBox(SoGetBoundingBoxAction * action); 00156 void setActiveChildDragger(SoDragger * newchilddragger); 00157 SoDragger * getActiveChildDragger(void) const; 00158 virtual void setDefaultOnNonWritingFields(void); 00159 00160 static void childTransferMotionAndValueChangedCB(void *, SoDragger *); 00161 static void childValueChangedCB(void *, SoDragger *); 00162 static void childStartCB(void *, SoDragger *); 00163 static void childMotionCB(void *, SoDragger *); 00164 static void childFinishCB(void *, SoDragger *); 00165 static void childOtherEventCB(void *, SoDragger *); 00166 00167 // This method is not present in Open Inventor. It was moved from 00168 // being a private method to a protected method in Coin to make it 00169 // possible to construct draggers which can handle Motion3 events. 00170 void updateDraggerCache(const SoPath * path); 00171 00172 private: 00173 void updateElements(class SoState * state); 00174 SbBool isPicked(SoPath * path); 00175 void eventHandled(const SoEvent * event, SoHandleEventAction * action); 00176 static float minscale; 00177 00178 private: 00179 SbPimplPtr<SoDraggerP> pimpl; 00180 00181 // NOT IMPLEMENTED: 00182 SoDragger(const SoDragger & rhs); 00183 SoDragger & operator = (const SoDragger & rhs); 00184 }; // SoDragger 00185 00186 #endif // !COIN_SODRAGGER_H
Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.
Generated for Coin by Doxygen 1.7.5.1.