Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SoTransformerDragger.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2002 by Systems in Motion. All rights reserved.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public License
00008  *  version 2.1 as published by the Free Software Foundation. See the
00009  *  file LICENSE.LGPL at the root directory of the distribution for
00010  *  more details.
00011  *
00012  *  If you want to use Coin for applications not compatible with the
00013  *  LGPL, please contact SIM to acquire a Professional Edition license.
00014  *
00015  *  Systems in Motion, Prof Brochs gate 6, 7030 Trondheim, NORWAY
00016  *  http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097
00017  *
00018 \**************************************************************************/
00019 
00020 #ifndef COIN_SOTRANSFORMERDRAGGER_H
00021 #define COIN_SOTRANSFORMERDRAGGER_H
00022 
00023 #include <Inventor/draggers/SoDragger.h>
00024 #include <Inventor/fields/SoSFRotation.h>
00025 #include <Inventor/fields/SoSFVec3f.h>
00026 #include <Inventor/fields/SoSFFloat.h>
00027 #include <Inventor/lists/SoNodeList.h>
00028 
00029 class SoSensor;
00030 class SoFieldSensor;
00031 
00032 
00033 class COIN_DLL_API SoTransformerDragger : public SoDragger {
00034   typedef SoDragger inherited;
00035 
00036   SO_KIT_HEADER(SoTransformerDragger);
00037 
00038   SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackLocation);
00039   SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackSep);
00040   SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackAntiSquish);
00041   SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackSep);
00042   SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackTransform);
00043   SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackTransformSwitch);
00044   SO_KIT_CATALOG_ENTRY_HEADER(negXRoundWallFeedback);
00045   SO_KIT_CATALOG_ENTRY_HEADER(negXWallFeedback);
00046   SO_KIT_CATALOG_ENTRY_HEADER(negXWallFeedbackSwitch);
00047   SO_KIT_CATALOG_ENTRY_HEADER(negYRoundWallFeedback);
00048   SO_KIT_CATALOG_ENTRY_HEADER(negYWallFeedback);
00049   SO_KIT_CATALOG_ENTRY_HEADER(negYWallFeedbackSwitch);
00050   SO_KIT_CATALOG_ENTRY_HEADER(negZRoundWallFeedback);
00051   SO_KIT_CATALOG_ENTRY_HEADER(negZWallFeedback);
00052   SO_KIT_CATALOG_ENTRY_HEADER(negZWallFeedbackSwitch);
00053   SO_KIT_CATALOG_ENTRY_HEADER(overallStyle);
00054   SO_KIT_CATALOG_ENTRY_HEADER(posXRoundWallFeedback);
00055   SO_KIT_CATALOG_ENTRY_HEADER(posXWallFeedback);
00056   SO_KIT_CATALOG_ENTRY_HEADER(posXWallFeedbackSwitch);
00057   SO_KIT_CATALOG_ENTRY_HEADER(posYRoundWallFeedback);
00058   SO_KIT_CATALOG_ENTRY_HEADER(posYWallFeedback);
00059   SO_KIT_CATALOG_ENTRY_HEADER(posYWallFeedbackSwitch);
00060   SO_KIT_CATALOG_ENTRY_HEADER(posZRoundWallFeedback);
00061   SO_KIT_CATALOG_ENTRY_HEADER(posZWallFeedback);
00062   SO_KIT_CATALOG_ENTRY_HEADER(posZWallFeedbackSwitch);
00063   SO_KIT_CATALOG_ENTRY_HEADER(radialFeedback);
00064   SO_KIT_CATALOG_ENTRY_HEADER(radialFeedbackSwitch);
00065   SO_KIT_CATALOG_ENTRY_HEADER(rotator1);
00066   SO_KIT_CATALOG_ENTRY_HEADER(rotator1Active);
00067   SO_KIT_CATALOG_ENTRY_HEADER(rotator1LocateGroup);
00068   SO_KIT_CATALOG_ENTRY_HEADER(rotator1Switch);
00069   SO_KIT_CATALOG_ENTRY_HEADER(rotator2);
00070   SO_KIT_CATALOG_ENTRY_HEADER(rotator2Active);
00071   SO_KIT_CATALOG_ENTRY_HEADER(rotator2LocateGroup);
00072   SO_KIT_CATALOG_ENTRY_HEADER(rotator2Switch);
00073   SO_KIT_CATALOG_ENTRY_HEADER(rotator3);
00074   SO_KIT_CATALOG_ENTRY_HEADER(rotator3Active);
00075   SO_KIT_CATALOG_ENTRY_HEADER(rotator3LocateGroup);
00076   SO_KIT_CATALOG_ENTRY_HEADER(rotator3Switch);
00077   SO_KIT_CATALOG_ENTRY_HEADER(rotator4);
00078   SO_KIT_CATALOG_ENTRY_HEADER(rotator4Active);
00079   SO_KIT_CATALOG_ENTRY_HEADER(rotator4LocateGroup);
00080   SO_KIT_CATALOG_ENTRY_HEADER(rotator4Switch);
00081   SO_KIT_CATALOG_ENTRY_HEADER(rotator5);
00082   SO_KIT_CATALOG_ENTRY_HEADER(rotator5Active);
00083   SO_KIT_CATALOG_ENTRY_HEADER(rotator5LocateGroup);
00084   SO_KIT_CATALOG_ENTRY_HEADER(rotator5Switch);
00085   SO_KIT_CATALOG_ENTRY_HEADER(rotator6);
00086   SO_KIT_CATALOG_ENTRY_HEADER(rotator6Active);
00087   SO_KIT_CATALOG_ENTRY_HEADER(rotator6LocateGroup);
00088   SO_KIT_CATALOG_ENTRY_HEADER(rotator6Switch);
00089   SO_KIT_CATALOG_ENTRY_HEADER(rotatorSep);
00090   SO_KIT_CATALOG_ENTRY_HEADER(scale1);
00091   SO_KIT_CATALOG_ENTRY_HEADER(scale1Active);
00092   SO_KIT_CATALOG_ENTRY_HEADER(scale1LocateGroup);
00093   SO_KIT_CATALOG_ENTRY_HEADER(scale1Switch);
00094   SO_KIT_CATALOG_ENTRY_HEADER(scale2);
00095   SO_KIT_CATALOG_ENTRY_HEADER(scale2Active);
00096   SO_KIT_CATALOG_ENTRY_HEADER(scale2LocateGroup);
00097   SO_KIT_CATALOG_ENTRY_HEADER(scale2Switch);
00098   SO_KIT_CATALOG_ENTRY_HEADER(scale3);
00099   SO_KIT_CATALOG_ENTRY_HEADER(scale3Active);
00100   SO_KIT_CATALOG_ENTRY_HEADER(scale3LocateGroup);
00101   SO_KIT_CATALOG_ENTRY_HEADER(scale3Switch);
00102   SO_KIT_CATALOG_ENTRY_HEADER(scale4);
00103   SO_KIT_CATALOG_ENTRY_HEADER(scale4Active);
00104   SO_KIT_CATALOG_ENTRY_HEADER(scale4LocateGroup);
00105   SO_KIT_CATALOG_ENTRY_HEADER(scale4Switch);
00106   SO_KIT_CATALOG_ENTRY_HEADER(scale5);
00107   SO_KIT_CATALOG_ENTRY_HEADER(scale5Active);
00108   SO_KIT_CATALOG_ENTRY_HEADER(scale5LocateGroup);
00109   SO_KIT_CATALOG_ENTRY_HEADER(scale5Switch);
00110   SO_KIT_CATALOG_ENTRY_HEADER(scale6);
00111   SO_KIT_CATALOG_ENTRY_HEADER(scale6Active);
00112   SO_KIT_CATALOG_ENTRY_HEADER(scale6LocateGroup);
00113   SO_KIT_CATALOG_ENTRY_HEADER(scale6Switch);
00114   SO_KIT_CATALOG_ENTRY_HEADER(scale7);
00115   SO_KIT_CATALOG_ENTRY_HEADER(scale7Active);
00116   SO_KIT_CATALOG_ENTRY_HEADER(scale7LocateGroup);
00117   SO_KIT_CATALOG_ENTRY_HEADER(scale7Switch);
00118   SO_KIT_CATALOG_ENTRY_HEADER(scale8);
00119   SO_KIT_CATALOG_ENTRY_HEADER(scale8Active);
00120   SO_KIT_CATALOG_ENTRY_HEADER(scale8LocateGroup);
00121   SO_KIT_CATALOG_ENTRY_HEADER(scale8Switch);
00122   SO_KIT_CATALOG_ENTRY_HEADER(scaleBoxFeedback);
00123   SO_KIT_CATALOG_ENTRY_HEADER(scaleBoxFeedbackSwitch);
00124   SO_KIT_CATALOG_ENTRY_HEADER(scaleSep);
00125   SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
00126   SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedback);
00127   SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackRotation);
00128   SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackSep);
00129   SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackSwitch);
00130   SO_KIT_CATALOG_ENTRY_HEADER(translator1);
00131   SO_KIT_CATALOG_ENTRY_HEADER(translator1Active);
00132   SO_KIT_CATALOG_ENTRY_HEADER(translator1LocateGroup);
00133   SO_KIT_CATALOG_ENTRY_HEADER(translator1Switch);
00134   SO_KIT_CATALOG_ENTRY_HEADER(translator2);
00135   SO_KIT_CATALOG_ENTRY_HEADER(translator2Active);
00136   SO_KIT_CATALOG_ENTRY_HEADER(translator2LocateGroup);
00137   SO_KIT_CATALOG_ENTRY_HEADER(translator2Switch);
00138   SO_KIT_CATALOG_ENTRY_HEADER(translator3);
00139   SO_KIT_CATALOG_ENTRY_HEADER(translator3Active);
00140   SO_KIT_CATALOG_ENTRY_HEADER(translator3LocateGroup);
00141   SO_KIT_CATALOG_ENTRY_HEADER(translator3Switch);
00142   SO_KIT_CATALOG_ENTRY_HEADER(translator4);
00143   SO_KIT_CATALOG_ENTRY_HEADER(translator4Active);
00144   SO_KIT_CATALOG_ENTRY_HEADER(translator4LocateGroup);
00145   SO_KIT_CATALOG_ENTRY_HEADER(translator4Switch);
00146   SO_KIT_CATALOG_ENTRY_HEADER(translator5);
00147   SO_KIT_CATALOG_ENTRY_HEADER(translator5Active);
00148   SO_KIT_CATALOG_ENTRY_HEADER(translator5LocateGroup);
00149   SO_KIT_CATALOG_ENTRY_HEADER(translator5Switch);
00150   SO_KIT_CATALOG_ENTRY_HEADER(translator6);
00151   SO_KIT_CATALOG_ENTRY_HEADER(translator6Active);
00152   SO_KIT_CATALOG_ENTRY_HEADER(translator6LocateGroup);
00153   SO_KIT_CATALOG_ENTRY_HEADER(translator6Switch);
00154   SO_KIT_CATALOG_ENTRY_HEADER(translatorSep);
00155   SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackActive);
00156   SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackSelect);
00157   SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackSwitch);
00158   SO_KIT_CATALOG_ENTRY_HEADER(xCircleFeedback);
00159   SO_KIT_CATALOG_ENTRY_HEADER(xCircleFeedbackSwitch);
00160   SO_KIT_CATALOG_ENTRY_HEADER(xCrosshairFeedback);
00161   SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackActive);
00162   SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackSelect);
00163   SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackSwitch);
00164   SO_KIT_CATALOG_ENTRY_HEADER(yCircleFeedback);
00165   SO_KIT_CATALOG_ENTRY_HEADER(yCircleFeedbackSwitch);
00166   SO_KIT_CATALOG_ENTRY_HEADER(yCrosshairFeedback);
00167   SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackActive);
00168   SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackSelect);
00169   SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackSwitch);
00170   SO_KIT_CATALOG_ENTRY_HEADER(zCircleFeedback);
00171   SO_KIT_CATALOG_ENTRY_HEADER(zCircleFeedbackSwitch);
00172   SO_KIT_CATALOG_ENTRY_HEADER(zCrosshairFeedback);
00173 
00174 
00175 public:
00176   static void initClass(void);
00177   SoTransformerDragger(void);
00178 
00179   SoSFRotation rotation;
00180   SoSFVec3f translation;
00181   SoSFVec3f scaleFactor;
00182   SoSFFloat minDiscRotDot;
00183 
00184   enum State {
00185     INACTIVE,
00186 
00187     RIT_X_ROTATE,
00188     TOP_Y_ROTATE,
00189     FNT_Z_ROTATE,
00190     LFT_X_ROTATE,
00191     BOT_Y_ROTATE,
00192     BAK_Z_ROTATE,
00193 
00194     PX_PY_PZ_3D_SCALE,
00195     PX_PY_NZ_3D_SCALE,
00196     PX_NY_PZ_3D_SCALE,
00197     PX_NY_NZ_3D_SCALE,
00198     NX_PY_PZ_3D_SCALE,
00199     NX_PY_NZ_3D_SCALE,
00200     NX_NY_PZ_3D_SCALE,
00201     NX_NY_NZ_3D_SCALE,
00202 
00203     RIT_TRANSLATE,
00204     TOP_TRANSLATE,
00205     FNT_TRANSLATE,
00206     LFT_TRANSLATE,
00207     BOT_TRANSLATE,
00208     BAK_TRANSLATE
00209   };
00210 
00211   State getCurrentState(void);
00212 
00213   void unsquishKnobs(void);
00214 
00215   SbBool isLocateHighlighting(void);
00216   void setLocateHighlighting(SbBool onoff);
00217 
00218   static void setColinearThreshold(int newval);
00219   static int getColinearThreshold(void);
00220 
00221   SbVec3f getBoxPointInWorldSpace(const SbVec3f & pointonunitbox);
00222   SbVec3f getBoxDirInWorldSpace(const SbVec3f & dironunitbox);
00223   SbVec3f getWorldPointInBoxSpace(const SbVec3f & pointinworldspace);
00224   SbVec2f getWorldPointInPixelSpace(const SbVec3f & thepoint);
00225 
00226   SbVec3f getInteractiveCenterInBoxSpace(void);
00227 
00228 protected:
00229   ~SoTransformerDragger();
00230   virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE);
00231   virtual void setDefaultOnNonWritingFields(void);
00232 
00233   static void startCB(void * f, SoDragger * d);
00234   static void motionCB(void * f, SoDragger * d);
00235   static void finishCB(void * f, SoDragger * d);
00236   static void metaKeyChangeCB(void *, SoDragger *);
00237   static void fieldSensorCB(void * f, SoSensor * s);
00238   static void valueChangedCB(void * f, SoDragger * d);
00239 
00240   void dragStart(void);
00241   void drag(void);
00242   void dragFinish(void);
00243 
00244   void updateAntiSquishList(void);
00245   void setAllPartSwitches(int scalewhich, int rotatewhich, int translatewhich);
00246   int getMouseGestureDirection(SbBool x_ok, SbBool y_ok, SbBool z_ok);
00247   static int getIgnoreAxis(SbVec2f axis[3][2],
00248                            SbBool x_ok, SbBool y_ok, SbBool z_ok);
00249   static void makeMinorAxisPerpendicularIfColinear(SbVec2f origin, SbVec2f axisends[3][2], int index_a, int index_b);
00250   static SbBool isColinear(SbVec2f a1[2], SbVec2f a2[2], int pixels);
00251 
00252   SoFieldSensor * translFieldSensor;
00253   SoFieldSensor * scaleFieldSensor;
00254   SoFieldSensor * rotateFieldSensor;
00255   SoNodeList antiSquishList;
00256 
00257 private:
00258   void getSurroundScaleMatrices(SbMatrix &matrix, SbMatrix &inv);
00259   SoNode *getNodeFieldNode(const char *fieldname);
00260 
00261   void build_catalog1(void);
00262   void build_catalog2(void);
00263   void build_catalog3(void);
00264   void build_catalog4(void);
00265   void build_catalog5(void);
00266   void build_catalog6(void);
00267 
00268   SbMatrix getWorkingToWorldMatrix(void);
00269   SbMatrix getWorldToWorkingMatrix(void);
00270   SbVec3f localToWorking(const SbVec3f &v);
00271   SbVec3f workingToLocal(const SbVec3f &v);
00272   SbVec3f calcCtrlOffset(const SbVec3f &startpt);
00273   void setSwitchValue(const char *str, const int which);
00274 
00275   SbBool setDynamicTranslatorSwitches(const SoEvent *event);
00276   SbBool setDynamicRotatorSwitches(const SoEvent *event);
00277   SbBool setDynamicScaleSwitches(const SoEvent *event);
00278 
00279   void dragTranslate();
00280   void dragScale();
00281   void dragRotate();
00282 
00283   class SbPlaneProjector *planeProj;
00284   class SbLineProjector *lineProj;
00285   class SbSphereProjector *sphereProj;
00286   class SbCylinderProjector *cylProj;
00287 
00288   State state;
00289 
00290   class SoTransformerDraggerP * pimpl;
00291   friend class SoTransformerDraggerP;
00292 };
00293 
00294 #endif // !COIN_SOTRANSFORMERDRAGGER_H

Generated at Tue Mar 5 03:31:20 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001