Debian Codegraph @

src/Gui/Inventor/Draggers/SoLinearDragger.h

raw
1 /***************************************************************************
2 * Copyright (c) 2015 Thomas Anderson <blobfish[at]gmx.com> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23 #ifndef GUI_LINEAR_DRAGGER_H
24 #define GUI_LINEAR_DRAGGER_H
25
26 #include <Inventor/draggers/SoDragger.h>
27 #include <Inventor/fields/SoSFColor.h>
28 #include <Inventor/fields/SoSFDouble.h>
29 #include <Inventor/fields/SoSFFloat.h>
30 #include <Inventor/fields/SoSFInt32.h>
31 #include <Inventor/fields/SoSFRotation.h>
32 #include <Inventor/fields/SoSFString.h>
33 #include <Inventor/fields/SoSFVec3f.h>
34 #include <Inventor/projectors/SbLineProjector.h>
35
36 #include <FCGlobal.h>
37
38 class SoBaseColor;
39 class SoTransform;
40
41 namespace Gui
42 {
43 /*! @brief Translation Dragger.
44 *
45 * used for translating along axis. Set the
46 * translationIncrement to desired step. Use
47 * 'translationIncrementCount' multiplied with
48 * 'translationIncrement' for a full double
49 * precision vector scalar.
50 */
51 class GuiExport SoLinearDragger: public SoDragger
52 {
53 SO_KIT_HEADER(SoLinearDragger);
54 SO_KIT_CATALOG_ENTRY_HEADER(baseGeomSwitch);
55 SO_KIT_CATALOG_ENTRY_HEADER(baseGeom);
56 SO_KIT_CATALOG_ENTRY_HEADER(baseColor);
57 SO_KIT_CATALOG_ENTRY_HEADER(activeSwitch);
58 SO_KIT_CATALOG_ENTRY_HEADER(secondaryColor);
59 SO_KIT_CATALOG_ENTRY_HEADER(labelSwitch);
60 SO_KIT_CATALOG_ENTRY_HEADER(labelSeparator);
61 SO_KIT_CATALOG_ENTRY_HEADER(scale);
62 SO_KIT_CATALOG_ENTRY_HEADER(arrow);
63
64 public:
65 static void initClass();
66 SoLinearDragger();
67
68 SoSFString label; //!< set from outside and used to label
69 SoSFVec3f translation; //!< set from outside and used from outside for single precision.
70 SoSFDouble translationIncrement; //!< set from outside and used for rounding.
71 SoSFInt32 translationIncrementCount; //!< number of steps. used from outside.
72 SoSFFloat autoScaleResult; //!< set from parent dragger.
73 SoSFColor color; //!< colour of the dragger
74 SoSFColor activeColor; //!< colour of the dragger while being dragged
75 SoSFBool labelVisible; //!< controls the visibility of the dragger label
76 SoSFVec3f geometryScale; //!< the scale of the dragger geometry
77 SoSFBool active; //!< set when the dragger is being dragged
78 SoSFBool baseGeomVisible; //!< toggles if the dragger has a base geometry or not
79
80 void instantiateBaseGeometry();
81
82 protected:
83 ~SoLinearDragger() override;
84 SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE) override;
85
86 static void startCB(void*, SoDragger* d);
87 static void motionCB(void*, SoDragger* d);
88 static void finishCB(void*, SoDragger* d);
89 static void fieldSensorCB(void* f, SoSensor*);
90 static void valueChangedCB(void*, SoDragger* d);
91
92 void dragStart();
93 void drag();
94 void dragFinish();
95
96 SoFieldSensor fieldSensor;
97 SbLineProjector projector;
98
99 private:
100 SbVec3f roundTranslation(const SbVec3f& vecIn, float incrementIn);
101
102 SoSeparator* buildLabelGeometry();
103 SoBaseColor* buildActiveColor();
104 SoBaseColor* buildColor();
105
106 using inherited = SoDragger;
107 };
108
109 class GuiExport SoLinearDraggerContainer: public SoInteractionKit
110 {
111 SO_KIT_HEADER(SoLinearDraggerContainer);
112 SO_KIT_CATALOG_ENTRY_HEADER(draggerSwitch);
113 SO_KIT_CATALOG_ENTRY_HEADER(transform);
114 SO_KIT_CATALOG_ENTRY_HEADER(dragger);
115
116 public:
117 static void initClass();
118 SoLinearDraggerContainer();
119
120 SoSFRotation rotation;
121 SoSFColor color;
122 SoSFVec3f translation;
123 SoSFBool visible;
124
125 SbVec3f getPointerDirection();
126 void setPointerDirection(const SbVec3f& dir);
127
128 SoLinearDragger* getDragger();
129
130 private:
131 SoTransform* buildTransform();
132
133 using inherited = SoInteractionKit;
134 };
135
136 } // namespace Gui
137
138 #endif /* GUI_LINEAR_DRAGGER_H */