Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoTransformerDragger.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul Isaacs (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2019 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_TRANSFORMER_DRAGGER_
51#define _SO_TRANSFORMER_DRAGGER_
52
53#include <Inventor/SoLists.h>
59
60class SbDict;
62class SbLineProjector;
65class SoFieldSensor;
66
68//
69// Class: SoTransformerDragger
70//
71// SoTransformerDragger - allows user to transform objects.
72//
74
689
691
692 SO_KIT_CATALOG_ENTRY_HEADER(overallStyle);
693
694 // For making the dragger surround what lies above it.
695 SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
696
697 SO_KIT_CATALOG_ENTRY_HEADER(translatorSep);
698 SO_KIT_CATALOG_ENTRY_HEADER(translator1Switch);
699 SO_KIT_CATALOG_ENTRY_HEADER(translator1LocateGroup);
700 SO_KIT_CATALOG_ENTRY_HEADER(translator1);
701 SO_KIT_CATALOG_ENTRY_HEADER(translator1Active);
702 SO_KIT_CATALOG_ENTRY_HEADER(translator2Switch);
703 SO_KIT_CATALOG_ENTRY_HEADER(translator2LocateGroup);
704 SO_KIT_CATALOG_ENTRY_HEADER(translator2);
705 SO_KIT_CATALOG_ENTRY_HEADER(translator2Active);
706 SO_KIT_CATALOG_ENTRY_HEADER(translator3Switch);
707 SO_KIT_CATALOG_ENTRY_HEADER(translator3LocateGroup);
708 SO_KIT_CATALOG_ENTRY_HEADER(translator3);
709 SO_KIT_CATALOG_ENTRY_HEADER(translator3Active);
710 SO_KIT_CATALOG_ENTRY_HEADER(translator4Switch);
711 SO_KIT_CATALOG_ENTRY_HEADER(translator4LocateGroup);
712 SO_KIT_CATALOG_ENTRY_HEADER(translator4);
713 SO_KIT_CATALOG_ENTRY_HEADER(translator4Active);
714 SO_KIT_CATALOG_ENTRY_HEADER(translator5Switch);
715 SO_KIT_CATALOG_ENTRY_HEADER(translator5LocateGroup);
716 SO_KIT_CATALOG_ENTRY_HEADER(translator5);
717 SO_KIT_CATALOG_ENTRY_HEADER(translator5Active);
718 SO_KIT_CATALOG_ENTRY_HEADER(translator6Switch);
719 SO_KIT_CATALOG_ENTRY_HEADER(translator6LocateGroup);
720 SO_KIT_CATALOG_ENTRY_HEADER(translator6);
721 SO_KIT_CATALOG_ENTRY_HEADER(translator6Active);
722
723
724 SO_KIT_CATALOG_ENTRY_HEADER(rotatorSep);
725 SO_KIT_CATALOG_ENTRY_HEADER(rotator1Switch);
726 SO_KIT_CATALOG_ENTRY_HEADER(rotator1LocateGroup);
728 SO_KIT_CATALOG_ENTRY_HEADER(rotator1Active);
729 SO_KIT_CATALOG_ENTRY_HEADER(rotator2Switch);
730 SO_KIT_CATALOG_ENTRY_HEADER(rotator2LocateGroup);
732 SO_KIT_CATALOG_ENTRY_HEADER(rotator2Active);
733 SO_KIT_CATALOG_ENTRY_HEADER(rotator3Switch);
734 SO_KIT_CATALOG_ENTRY_HEADER(rotator3LocateGroup);
736 SO_KIT_CATALOG_ENTRY_HEADER(rotator3Active);
737 SO_KIT_CATALOG_ENTRY_HEADER(rotator4Switch);
738 SO_KIT_CATALOG_ENTRY_HEADER(rotator4LocateGroup);
740 SO_KIT_CATALOG_ENTRY_HEADER(rotator4Active);
741 SO_KIT_CATALOG_ENTRY_HEADER(rotator5Switch);
742 SO_KIT_CATALOG_ENTRY_HEADER(rotator5LocateGroup);
744 SO_KIT_CATALOG_ENTRY_HEADER(rotator5Active);
745 SO_KIT_CATALOG_ENTRY_HEADER(rotator6Switch);
746 SO_KIT_CATALOG_ENTRY_HEADER(rotator6LocateGroup);
748 SO_KIT_CATALOG_ENTRY_HEADER(rotator6Active);
749
751 SO_KIT_CATALOG_ENTRY_HEADER(scale1Switch);
752 SO_KIT_CATALOG_ENTRY_HEADER(scale1LocateGroup);
754 SO_KIT_CATALOG_ENTRY_HEADER(scale1Active);
755 SO_KIT_CATALOG_ENTRY_HEADER(scale2Switch);
756 SO_KIT_CATALOG_ENTRY_HEADER(scale2LocateGroup);
758 SO_KIT_CATALOG_ENTRY_HEADER(scale2Active);
759 SO_KIT_CATALOG_ENTRY_HEADER(scale3Switch);
760 SO_KIT_CATALOG_ENTRY_HEADER(scale3LocateGroup);
762 SO_KIT_CATALOG_ENTRY_HEADER(scale3Active);
763 SO_KIT_CATALOG_ENTRY_HEADER(scale4Switch);
764 SO_KIT_CATALOG_ENTRY_HEADER(scale4LocateGroup);
766 SO_KIT_CATALOG_ENTRY_HEADER(scale4Active);
767 SO_KIT_CATALOG_ENTRY_HEADER(scale5Switch);
768 SO_KIT_CATALOG_ENTRY_HEADER(scale5LocateGroup);
770 SO_KIT_CATALOG_ENTRY_HEADER(scale5Active);
771 SO_KIT_CATALOG_ENTRY_HEADER(scale6Switch);
772 SO_KIT_CATALOG_ENTRY_HEADER(scale6LocateGroup);
774 SO_KIT_CATALOG_ENTRY_HEADER(scale6Active);
775 SO_KIT_CATALOG_ENTRY_HEADER(scale7Switch);
776 SO_KIT_CATALOG_ENTRY_HEADER(scale7LocateGroup);
778 SO_KIT_CATALOG_ENTRY_HEADER(scale7Active);
779 SO_KIT_CATALOG_ENTRY_HEADER(scale8Switch);
780 SO_KIT_CATALOG_ENTRY_HEADER(scale8LocateGroup);
782 SO_KIT_CATALOG_ENTRY_HEADER(scale8Active);
783
784 SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackSep);
785 SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackLocation);
786 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackSwitch);
787 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackActive);
788 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedbackSelect);
789 SO_KIT_CATALOG_ENTRY_HEADER(xCrosshairFeedback);
790 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackSwitch);
791 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackActive);
792 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedbackSelect);
793 SO_KIT_CATALOG_ENTRY_HEADER(yCrosshairFeedback);
794 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackSwitch);
795 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackActive);
796 SO_KIT_CATALOG_ENTRY_HEADER(zAxisFeedbackSelect);
797 SO_KIT_CATALOG_ENTRY_HEADER(zCrosshairFeedback);
798
799 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackSep);
800 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackSwitch);
801 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedbackRotation);
802 SO_KIT_CATALOG_ENTRY_HEADER(translateBoxFeedback);
803
804 SO_KIT_CATALOG_ENTRY_HEADER(scaleBoxFeedbackSwitch);
805 SO_KIT_CATALOG_ENTRY_HEADER(scaleBoxFeedback);
806
807 SO_KIT_CATALOG_ENTRY_HEADER(posXWallFeedbackSwitch);
808 SO_KIT_CATALOG_ENTRY_HEADER(posXWallFeedback);
809 SO_KIT_CATALOG_ENTRY_HEADER(posXRoundWallFeedback);
810 SO_KIT_CATALOG_ENTRY_HEADER(posYWallFeedbackSwitch);
811 SO_KIT_CATALOG_ENTRY_HEADER(posYWallFeedback);
812 SO_KIT_CATALOG_ENTRY_HEADER(posYRoundWallFeedback);
813 SO_KIT_CATALOG_ENTRY_HEADER(posZWallFeedbackSwitch);
814 SO_KIT_CATALOG_ENTRY_HEADER(posZWallFeedback);
815 SO_KIT_CATALOG_ENTRY_HEADER(posZRoundWallFeedback);
816 SO_KIT_CATALOG_ENTRY_HEADER(negXWallFeedbackSwitch);
817 SO_KIT_CATALOG_ENTRY_HEADER(negXWallFeedback);
818 SO_KIT_CATALOG_ENTRY_HEADER(negXRoundWallFeedback);
819 SO_KIT_CATALOG_ENTRY_HEADER(negYWallFeedbackSwitch);
820 SO_KIT_CATALOG_ENTRY_HEADER(negYWallFeedback);
821 SO_KIT_CATALOG_ENTRY_HEADER(negYRoundWallFeedback);
822 SO_KIT_CATALOG_ENTRY_HEADER(negZWallFeedbackSwitch);
823 SO_KIT_CATALOG_ENTRY_HEADER(negZWallFeedback);
824 SO_KIT_CATALOG_ENTRY_HEADER(negZRoundWallFeedback);
825
826 SO_KIT_CATALOG_ENTRY_HEADER(radialFeedbackSwitch);
827 SO_KIT_CATALOG_ENTRY_HEADER(radialFeedback);
828
829 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackSep);
830 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackTransformSwitch);
831 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackAntiSquish);
832 SO_KIT_CATALOG_ENTRY_HEADER(circleFeedbackTransform);
833 SO_KIT_CATALOG_ENTRY_HEADER(xCircleFeedbackSwitch);
834 SO_KIT_CATALOG_ENTRY_HEADER(xCircleFeedback);
835 SO_KIT_CATALOG_ENTRY_HEADER(yCircleFeedbackSwitch);
836 SO_KIT_CATALOG_ENTRY_HEADER(yCircleFeedback);
837 SO_KIT_CATALOG_ENTRY_HEADER(zCircleFeedbackSwitch);
838 SO_KIT_CATALOG_ENTRY_HEADER(zCircleFeedback);
839
840
841 public:
846
870
878
882 SbBool isLocateHighlighting() { return locateHighlightOn; }
891
899 static void setColinearThreshold(int newVal);
905
906 private:
907
908 // These convert points and directions from the space of the unit
909 // box to world space. Can be useful during callbacks.
910 SbVec3f getBoxPointInWorldSpace( const SbVec3f &pointOnUnitBox );
911 SbVec3f getBoxDirInWorldSpace( const SbVec3f &dirOnUnitBox );
912 SbVec3f getWorldPointInBoxSpace( const SbVec3f &pointInWorldSpace );
913 SbVec2f getWorldPointInPixelSpace( const SbVec3f &thePoint );
914
915 // Callbacks would like to know this sometimes.
916 // It's the location in bbox space of the point about which the
917 // transformer is rotating or scaling. It's different depending on
918 // which part is picked (determined by getCurrentState()) and
919 // which modifier keys are down.
920 SbVec3f getInteractiveCenterInBoxSpace()
921 { return interactiveCenterInBoxSpace; }
922
923 private:
924 static void initClass(); // initialize the class
925 static void exitClass();
926
927 enum State
928 { INACTIVE,
929 RIT_X_ROTATE, TOP_Y_ROTATE, FNT_Z_ROTATE,
930 LFT_X_ROTATE, BOT_Y_ROTATE, BAK_Z_ROTATE,
931
932 PX_PY_PZ_3D_SCALE, PX_PY_NZ_3D_SCALE, PX_NY_PZ_3D_SCALE,
933 PX_NY_NZ_3D_SCALE, NX_PY_PZ_3D_SCALE, NX_PY_NZ_3D_SCALE,
934 NX_NY_PZ_3D_SCALE, NX_NY_NZ_3D_SCALE,
935
936 RIT_TRANSLATE, TOP_TRANSLATE, FNT_TRANSLATE,
937 LFT_TRANSLATE, BOT_TRANSLATE, BAK_TRANSLATE };
938
939 State getCurrentState() { return currentState; }
940
941 private:
942
943 // Callbacks for drag start, motion, and finish
944 static void startCB( void *, SoDragger * );
945 static void motionCB( void *, SoDragger * );
946 static void finishCB( void *, SoDragger * );
947
948 SoFieldSensor *translFieldSensor;
949 SoFieldSensor *scaleFieldSensor;
950 SoFieldSensor *rotateFieldSensor;
951 static void fieldSensorCB( void *, SoSensor * );
952 static void valueChangedCB( void *, SoDragger * );
953
954 // Callbacks for pressing and releasing the meta keys
955 static void metaKeyChangeCB( void *, SoDragger *);
956
957 // These really do the work during startCB, motionCB, and finishCB
958 void dragStart();
959 void drag();
960 void dragFinish();
961
962 // Sets switch values for all parts in the scale, rotate, and translate
963 // assemblies.
964 void setAllPartSwitches( int scaleAssemblyWhich,
965 int rotateAssemblyWhich,
966 int translateAssemblyWhich );
967
968 // detach/attach any sensors, callbacks, and/or field connections.
969 // Called by: start/end of SoBaseKit::readInstance
970 // and on new copy by: start/end of SoBaseKit::copy.
971 // Classes that redefine must call setUpConnections(TRUE,TRUE)
972 // at end of constructor.
973 // Returns the state of the node when this was called.
974 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
975
976 virtual void setDefaultOnNonWritingFields();
977
978 virtual ~SoTransformerDragger();
979
980 // Finds all SoAntiSquish nodes in subgraph and puts them in list.
981 void updateAntiSquishList();
982 // Tells all nodes in the antiSquishList to recalculate next time through.
983 SoNodeList antiSquishList;
984
985 int getMouseGestureDirection(SbBool xAllowed, SbBool yAllowed,
986 SbBool zAllowed);
987
988 static int getIgnoreAxis(SbVec2f axis[3][2], SbBool xAllowed,
989 SbBool yAllowed, SbBool zAllowed );
990
991 static void makeMinorAxisPerpendicularIfColinear( SbVec2f origin,
992 SbVec2f axisEnds[3][2], int indexA, int indexB );
993
994 static SbBool isColinear(SbVec2f a1[2], SbVec2f a2[2], int pixels);
995
996 private:
997
998 State currentState;
999 int currentDir; // Used for 1-D operations,
1000 // this variable records the current
1001 // axis being used.
1002 // when doing 1-D rot, can rotate as disc (like spinning a turntable) or
1003 // cylinder (like rolling a rolling pin). This flag says which.
1004 SbBool rotatingAsDisc;
1005
1006 SbPlaneProjector *planeProj;
1007 SbLineProjector *lineProj;
1008 SbSphereSectionProjector *sphereProj;
1009 SbCylinderPlaneProjector *cylProj;
1010
1011 State restartState; // used by meta callback.
1012 SbVec3f worldRestartPt; // used during interaction
1013
1014 SbMatrix prevMotionMatrix; // used during rotate interaction
1015 SbVec3f prevWorldHitPt; // used during rotate and translate interaction
1016 SbVec3f interactiveCenterInBoxSpace; // used during rotations.
1017
1018 // used to reset prevWorldHitPt after initializing the cylinder projector.
1019 // Need to store during rotateInit() since SoDragger provides no method
1020 // to retrieve.
1021 SbVec2f startNormalizedLocaterPosition;
1022
1023 SbBool altDown, ctlDown, shftDown; // used to keep track of
1024 // which meta keys were down.
1025 SbBool constraining; // Depends on state of shftDown and which part picked.
1026
1027 // functions which do all the work
1028 void setHighlights();
1029 void setFeedback();
1030 void setFeedbackForTranslate();
1031 void setFeedbackForScale();
1032 void setFeedbackForRotate();
1033
1034 State getStateFromPick();
1035 SbBool translateInit();
1036 SbBool rotateInit();
1037 SbBool scaleInit();
1038
1039 SbBool translateDrag();
1040 SbBool scaleDrag();
1041
1042 SbBool rotateDrag();
1043 SbBool rotateConstrainedDrag();
1044 SbBool rotateConstrainedDiscDrag();
1045 SbBool rotateConstrainedCylindricalDrag();
1046
1047 void initSphereProjector();
1048 void initDiscProjector();
1049 void initCylinderProjector();
1050
1051 SbBool getShouldRotateAsDisc();
1052 int getConstrainedRotationAxis();
1053
1054 // character strings from which the shared geometry is read
1055 static const char geomBuffer[];
1056
1057 void setAllDefaultParts();
1058
1059 SbBool locateHighlightOn;
1060
1061 static int colinearThreshold;
1062
1063 // These subroutines construct the catalog. They normally would just
1064 // sit in the constructor, but the compiler doesn't like such huge
1065 // methods so we broke it up into small chunks.
1066 void makeCatalog();
1067 void makeTranslaterCatalogParts();
1068 void makeRotaterCatalogParts();
1069 void makeScalerCatalogParts();
1070 void makeAxisFeedbackCatalogParts();
1071 void makeBoxFeedbackCatalogParts();
1072 void makeWallFeedbackCatalogParts();
1073 void makeRadialFeedbackCatalogParts();
1074 void makeCircleFeedbackCatalogParts();
1075
1076};
1077
1078#endif /* _SO_TRANSFORMER_DRAGGER_ */
1079
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
#define SO_KIT_CATALOG_ENTRY_HEADER(partName)
Definition SoSubKit.h:107
#define SO_KIT_HEADER(className)
Definition SoSubKit.h:91
Cylinder-plane projector.
Line projector.
4x4 matrix class.
Definition SbMatrix.h:309
Plane projector.
Sphere-section projector.
2D vector class.
Definition SbVec.h:76
3D vector class.
Definition SbVec.h:932
Base class for nodekits that move in response to click-drag-release mouse events.
Definition SoDragger.h:534
Sensor class that can be attached to Open Inventor fields.
Maintains a list of pointers to nodes.
Definition SoNodeList.h:74
Field containing a floating-point value.
Definition SoSFFloat.h:78
Field containing a rotation.
Field containing a three-dimensional vector.
Definition SoSFVec3f.h:80
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:97
Box-like object you scale, rotate, and translate by dragging with the mouse.
SoSFFloat minDiscRotDot
Specifies the minimum dot product between eyeDir and rotPlane normal before switching from record...
SoTransformerDragger()
Constructor.
void setLocateHighlighting(SbBool onOff)
Sets whether or not locate highlighting is used.
void unsquishKnobs()
Tells the dragger to unsquish its rotation and scale knobs during the next traversal.
static void setColinearThreshold(int newVal)
Sets the colinear threshold.
SoSFVec3f translation
Position of the dragger.
SoSFRotation rotation
Orientation of the dragger.
SoSFVec3f scaleFactor
Scale of the dragger.
static int getColinearThreshold()
Returns the colinear threshold.
SbBool isLocateHighlighting()
Returns whether or not locate highlighting is used.
int SbBool
Boolean type.
Definition SbBase.h:87