00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef _SO_TRANSFORMER_DRAGGER_
00051 #define _SO_TRANSFORMER_DRAGGER_
00052
00053 #include <Inventor/SoLists.h>
00054 #include <Inventor/draggers/SoDragger.h>
00055 #include <Inventor/fields/SoSFFloat.h>
00056 #include <Inventor/fields/SoSFRotation.h>
00057 #include <Inventor/fields/SoSFVec3f.h>
00058 #include <Inventor/sensors/SoSensor.h>
00059
00060 class SbDict;
00061 class SbPlaneProjector;
00062 class SbLineProjector;
00063 class SbSphereSectionProjector;
00064 class SbCylinderPlaneProjector;
00065 class SoFieldSensor;
00066
00068
00069
00070
00071
00072
00074
00688 class SoTransformerDragger : public SoDragger {
00689
00690 SO_KIT_HEADER(SoTransformerDragger);
00691
00692 SO_KIT_CATALOG_ENTRY_HEADER(overallStyle);
00693
00694
00695 SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
00696
00697 SO_KIT_CATALOG_ENTRY_HEADER(translatorSep);
00698 SO_KIT_CATALOG_ENTRY_HEADER(translator1Switch);
00699 SO_KIT_CATALOG_ENTRY_HEADER(translator1LocateGroup);
00700 SO_KIT_CATALOG_ENTRY_HEADER(translator1);
00701 SO_KIT_CATALOG_ENTRY_HEADER(translator1Active);
00702 SO_KIT_CATALOG_ENTRY_HEADER(translator2Switch);
00703 SO_KIT_CATALOG_ENTRY_HEADER(translator2LocateGroup);
00704 SO_KIT_CATALOG_ENTRY_HEADER(translator2);
00705 SO_KIT_CATALOG_ENTRY_HEADER(translator2Active);
00706 SO_KIT_CATALOG_ENTRY_HEADER(translator3Switch);
00707 SO_KIT_CATALOG_ENTRY_HEADER(translator3LocateGroup);
00708 SO_KIT_CATALOG_ENTRY_HEADER(translator3);
00709 SO_KIT_CATALOG_ENTRY_HEADER(translator3Active);
00710 SO_KIT_CATALOG_ENTRY_HEADER(translator4Switch);
00711 SO_KIT_CATALOG_ENTRY_HEADER(translator4LocateGroup);
00712 SO_KIT_CATALOG_ENTRY_HEADER(translator4);
00713 SO_KIT_CATALOG_ENTRY_HEADER(translator4Active);
00714 SO_KIT_CATALOG_ENTRY_HEADER(translator5Switch);
00715 SO_KIT_CATALOG_ENTRY_HEADER(translator5LocateGroup);
00716 SO_KIT_CATALOG_ENTRY_HEADER(translator5);
00717 SO_KIT_CATALOG_ENTRY_HEADER(translator5Active);
00718 SO_KIT_CATALOG_ENTRY_HEADER(translator6Switch);
00719 SO_KIT_CATALOG_ENTRY_HEADER(translator6LocateGroup);
00720 SO_KIT_CATALOG_ENTRY_HEADER(translator6);
00721 SO_KIT_CATALOG_ENTRY_HEADER(translator6Active);
00722
00723
00724 SO_KIT_CATALOG_ENTRY_HEADER(rotatorSep);
00725 SO_KIT_CATALOG_ENTRY_HEADER(rotator1Switch);
00726 SO_KIT_CATALOG_ENTRY_HEADER(rotator1LocateGroup);
00727 SO_KIT_CATALOG_ENTRY_HEADER(rotator1);
00728 SO_KIT_CATALOG_ENTRY_HEADER(rotator1Active);
00729 SO_KIT_CATALOG_ENTRY_HEADER(rotator2Switch);
00730 SO_KIT_CATALOG_ENTRY_HEADER(rotator2LocateGroup);
00731 SO_KIT_CATALOG_ENTRY_HEADER(rotator2);
00732 SO_KIT_CATALOG_ENTRY_HEADER(rotator2Active);
00733 SO_KIT_CATALOG_ENTRY_HEADER(rotator3Switch);
00734 SO_KIT_CATALOG_ENTRY_HEADER(rotator3LocateGroup);
00735 SO_KIT_CATALOG_ENTRY_HEADER(rotator3);
00736 SO_KIT_CATALOG_ENTRY_HEADER(rotator3Active);
00737 SO_KIT_CATALOG_ENTRY_HEADER(rotator4Switch);
00738 SO_KIT_CATALOG_ENTRY_HEADER(rotator4LocateGroup);
00739 SO_KIT_CATALOG_ENTRY_HEADER(rotator4);
00740 SO_KIT_CATALOG_ENTRY_HEADER(rotator4Active);
00741 SO_KIT_CATALOG_ENTRY_HEADER(rotator5Switch);
00742 SO_KIT_CATALOG_ENTRY_HEADER(rotator5LocateGroup);
00743 SO_KIT_CATALOG_ENTRY_HEADER(rotator5);
00744 SO_KIT_CATALOG_ENTRY_HEADER(rotator5Active);
00745 SO_KIT_CATALOG_ENTRY_HEADER(rotator6Switch);
00746 SO_KIT_CATALOG_ENTRY_HEADER(rotator6LocateGroup);
00747 SO_KIT_CATALOG_ENTRY_HEADER(rotator6);
00748 SO_KIT_CATALOG_ENTRY_HEADER(rotator6Active);
00749
00750 SO_KIT_CATALOG_ENTRY_HEADER(scaleSep);
00751 SO_KIT_CATALOG_ENTRY_HEADER(scale1Switch);
00752 SO_KIT_CATALOG_ENTRY_HEADER(scale1LocateGroup);
00753 SO_KIT_CATALOG_ENTRY_HEADER(scale1);
00754 SO_KIT_CATALOG_ENTRY_HEADER(scale1Active);
00755 SO_KIT_CATALOG_ENTRY_HEADER(scale2Switch);
00756 SO_KIT_CATALOG_ENTRY_HEADER(scale2LocateGroup);
00757 SO_KIT_CATALOG_ENTRY_HEADER(scale2);
00758 SO_KIT_CATALOG_ENTRY_HEADER(scale2Active);
00759 SO_KIT_CATALOG_ENTRY_HEADER(scale3Switch);
00760 SO_KIT_CATALOG_ENTRY_HEADER(scale3LocateGroup);
00761 SO_KIT_CATALOG_ENTRY_HEADER(scale3);
00762 SO_KIT_CATALOG_ENTRY_HEADER(scale3Active);
00763 SO_KIT_CATALOG_ENTRY_HEADER(scale4Switch);
00764 SO_KIT_CATALOG_ENTRY_HEADER(scale4LocateGroup);
00765 SO_KIT_CATALOG_ENTRY_HEADER(scale4);
00766 SO_KIT_CATALOG_ENTRY_HEADER(scale4Active);
00767 SO_KIT_CATALOG_ENTRY_HEADER(scale5Switch);
00768 SO_KIT_CATALOG_ENTRY_HEADER(scale5LocateGroup);
00769 SO_KIT_CATALOG_ENTRY_HEADER(scale5);
00770 SO_KIT_CATALOG_ENTRY_HEADER(scale5Active);
00771 SO_KIT_CATALOG_ENTRY_HEADER(scale6Switch);
00772 SO_KIT_CATALOG_ENTRY_HEADER(scale6LocateGroup);
00773 SO_KIT_CATALOG_ENTRY_HEADER(scale6);
00774 SO_KIT_CATALOG_ENTRY_HEADER(scale6Active);
00775 SO_KIT_CATALOG_ENTRY_HEADER(scale7Switch);
00776 SO_KIT_CATALOG_ENTRY_HEADER(scale7LocateGroup);
00777 SO_KIT_CATALOG_ENTRY_HEADER(scale7);
00778 SO_KIT_CATALOG_ENTRY_HEADER(scale7Active);
00779 SO_KIT_CATALOG_ENTRY_HEADER(scale8Switch);
00780 SO_KIT_CATALOG_ENTRY_HEADER(scale8LocateGroup);
00781 SO_KIT_CATALOG_ENTRY_HEADER(scale8);
00782 SO_KIT_CATALOG_ENTRY_HEADER(scale8Active);
00783
00784 SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackSep);
00785 SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackLocation);
00786 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackSwitch);
00787 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackActive);
00788 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackSelect);
00789 SO_KIT_CATALOG_ENTRY_HEADER(xCrosshairFeedback);
00790 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackSwitch);
00791 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackActive);
00792 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackSelect);
00793 SO_KIT_CATALOG_ENTRY_HEADER(yCrosshairFeedback);
00794 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackSwitch);
00795 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackActive);
00796 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackSelect);
00797 SO_KIT_CATALOG_ENTRY_HEADER(zCrosshairFeedback);
00798
00799 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackSep);
00800 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackSwitch);
00801 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackRotation);
00802 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedback);
00803
00804 SO_KIT_CATALOG_ENTRY_HEADER(scaleBoxFeedbackSwitch);
00805 SO_KIT_CATALOG_ENTRY_HEADER(scaleBoxFeedback);
00806
00807 SO_KIT_CATALOG_ENTRY_HEADER(posXWallFeedbackSwitch);
00808 SO_KIT_CATALOG_ENTRY_HEADER(posXWallFeedback);
00809 SO_KIT_CATALOG_ENTRY_HEADER(posXRoundWallFeedback);
00810 SO_KIT_CATALOG_ENTRY_HEADER(posYWallFeedbackSwitch);
00811 SO_KIT_CATALOG_ENTRY_HEADER(posYWallFeedback);
00812 SO_KIT_CATALOG_ENTRY_HEADER(posYRoundWallFeedback);
00813 SO_KIT_CATALOG_ENTRY_HEADER(posZWallFeedbackSwitch);
00814 SO_KIT_CATALOG_ENTRY_HEADER(posZWallFeedback);
00815 SO_KIT_CATALOG_ENTRY_HEADER(posZRoundWallFeedback);
00816 SO_KIT_CATALOG_ENTRY_HEADER(negXWallFeedbackSwitch);
00817 SO_KIT_CATALOG_ENTRY_HEADER(negXWallFeedback);
00818 SO_KIT_CATALOG_ENTRY_HEADER(negXRoundWallFeedback);
00819 SO_KIT_CATALOG_ENTRY_HEADER(negYWallFeedbackSwitch);
00820 SO_KIT_CATALOG_ENTRY_HEADER(negYWallFeedback);
00821 SO_KIT_CATALOG_ENTRY_HEADER(negYRoundWallFeedback);
00822 SO_KIT_CATALOG_ENTRY_HEADER(negZWallFeedbackSwitch);
00823 SO_KIT_CATALOG_ENTRY_HEADER(negZWallFeedback);
00824 SO_KIT_CATALOG_ENTRY_HEADER(negZRoundWallFeedback);
00825
00826 SO_KIT_CATALOG_ENTRY_HEADER(radialFeedbackSwitch);
00827 SO_KIT_CATALOG_ENTRY_HEADER(radialFeedback);
00828
00829 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackSep);
00830 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackTransformSwitch);
00831 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackAntiSquish);
00832 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackTransform);
00833 SO_KIT_CATALOG_ENTRY_HEADER(xCircleFeedbackSwitch);
00834 SO_KIT_CATALOG_ENTRY_HEADER(xCircleFeedback);
00835 SO_KIT_CATALOG_ENTRY_HEADER(yCircleFeedbackSwitch);
00836 SO_KIT_CATALOG_ENTRY_HEADER(yCircleFeedback);
00837 SO_KIT_CATALOG_ENTRY_HEADER(zCircleFeedbackSwitch);
00838 SO_KIT_CATALOG_ENTRY_HEADER(zCircleFeedback);
00839
00840
00841 public:
00845 SoTransformerDragger();
00846
00851 SoSFRotation rotation;
00856 SoSFVec3f translation;
00861 SoSFVec3f scaleFactor;
00869 SoSFFloat minDiscRotDot;
00870
00877 void unsquishKnobs();
00878
00882 SbBool isLocateHighlighting() { return locateHighlightOn; }
00890 void setLocateHighlighting( SbBool onOff );
00891
00899 static void setColinearThreshold(int newVal);
00904 static int getColinearThreshold();
00905
00906 private:
00907
00908
00909
00910 SbVec3f getBoxPointInWorldSpace( const SbVec3f &pointOnUnitBox );
00911 SbVec3f getBoxDirInWorldSpace( const SbVec3f &dirOnUnitBox );
00912 SbVec3f getWorldPointInBoxSpace( const SbVec3f &pointInWorldSpace );
00913 SbVec2f getWorldPointInPixelSpace( const SbVec3f &thePoint );
00914
00915
00916
00917
00918
00919
00920 SbVec3f getInteractiveCenterInBoxSpace()
00921 { return interactiveCenterInBoxSpace; }
00922
00923 private:
00924 static void initClass();
00925 static void exitClass();
00926
00927 enum State
00928 { INACTIVE,
00929 RIT_X_ROTATE, TOP_Y_ROTATE, FNT_Z_ROTATE,
00930 LFT_X_ROTATE, BOT_Y_ROTATE, BAK_Z_ROTATE,
00931
00932 PX_PY_PZ_3D_SCALE, PX_PY_NZ_3D_SCALE, PX_NY_PZ_3D_SCALE,
00933 PX_NY_NZ_3D_SCALE, NX_PY_PZ_3D_SCALE, NX_PY_NZ_3D_SCALE,
00934 NX_NY_PZ_3D_SCALE, NX_NY_NZ_3D_SCALE,
00935
00936 RIT_TRANSLATE, TOP_TRANSLATE, FNT_TRANSLATE,
00937 LFT_TRANSLATE, BOT_TRANSLATE, BAK_TRANSLATE };
00938
00939 State getCurrentState() { return currentState; }
00940
00941 private:
00942
00943
00944 static void startCB( void *, SoDragger * );
00945 static void motionCB( void *, SoDragger * );
00946 static void finishCB( void *, SoDragger * );
00947
00948 SoFieldSensor *translFieldSensor;
00949 SoFieldSensor *scaleFieldSensor;
00950 SoFieldSensor *rotateFieldSensor;
00951 static void fieldSensorCB( void *, SoSensor * );
00952 static void valueChangedCB( void *, SoDragger * );
00953
00954
00955 static void metaKeyChangeCB( void *, SoDragger *);
00956
00957
00958 void dragStart();
00959 void drag();
00960 void dragFinish();
00961
00962
00963
00964 void setAllPartSwitches( int scaleAssemblyWhich,
00965 int rotateAssemblyWhich,
00966 int translateAssemblyWhich );
00967
00968
00969
00970
00971
00972
00973
00974 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00975
00976 virtual void setDefaultOnNonWritingFields();
00977
00978 virtual ~SoTransformerDragger();
00979
00980
00981 void updateAntiSquishList();
00982
00983 SoNodeList antiSquishList;
00984
00985 int getMouseGestureDirection(SbBool xAllowed, SbBool yAllowed,
00986 SbBool zAllowed);
00987
00988 static int getIgnoreAxis(SbVec2f axis[3][2], SbBool xAllowed,
00989 SbBool yAllowed, SbBool zAllowed );
00990
00991 static void makeMinorAxisPerpendicularIfColinear( SbVec2f origin,
00992 SbVec2f axisEnds[3][2], int indexA, int indexB );
00993
00994 static SbBool isColinear(SbVec2f a1[2], SbVec2f a2[2], int pixels);
00995
00996 private:
00997
00998 State currentState;
00999 int currentDir;
01000
01001
01002
01003
01004 SbBool rotatingAsDisc;
01005
01006 SbPlaneProjector *planeProj;
01007 SbLineProjector *lineProj;
01008 SbSphereSectionProjector *sphereProj;
01009 SbCylinderPlaneProjector *cylProj;
01010
01011 State restartState;
01012 SbVec3f worldRestartPt;
01013
01014 SbMatrix prevMotionMatrix;
01015 SbVec3f prevWorldHitPt;
01016 SbVec3f interactiveCenterInBoxSpace;
01017
01018
01019
01020
01021 SbVec2f startNormalizedLocaterPosition;
01022
01023 SbBool altDown, ctlDown, shftDown;
01024
01025 SbBool constraining;
01026
01027
01028 void setHighlights();
01029 void setFeedback();
01030 void setFeedbackForTranslate();
01031 void setFeedbackForScale();
01032 void setFeedbackForRotate();
01033
01034 State getStateFromPick();
01035 SbBool translateInit();
01036 SbBool rotateInit();
01037 SbBool scaleInit();
01038
01039 SbBool translateDrag();
01040 SbBool scaleDrag();
01041
01042 SbBool rotateDrag();
01043 SbBool rotateConstrainedDrag();
01044 SbBool rotateConstrainedDiscDrag();
01045 SbBool rotateConstrainedCylindricalDrag();
01046
01047 void initSphereProjector();
01048 void initDiscProjector();
01049 void initCylinderProjector();
01050
01051 SbBool getShouldRotateAsDisc();
01052 int getConstrainedRotationAxis();
01053
01054
01055 static const char geomBuffer[];
01056
01057 void setAllDefaultParts();
01058
01059 SbBool locateHighlightOn;
01060
01061 static int colinearThreshold;
01062
01063
01064
01065
01066 void makeCatalog();
01067 void makeTranslaterCatalogParts();
01068 void makeRotaterCatalogParts();
01069 void makeScalerCatalogParts();
01070 void makeAxisFeedbackCatalogParts();
01071 void makeBoxFeedbackCatalogParts();
01072 void makeWallFeedbackCatalogParts();
01073 void makeRadialFeedbackCatalogParts();
01074 void makeCircleFeedbackCatalogParts();
01075
01076 };
01077
01078 #endif
01079
01080