Debian Codegraph @

src/Gui/Inventor/Draggers/SoPlanarDragger.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_PLANAR_DRAGGER_H
24 #define GUI_PLANAR_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/projectors/SbLineProjector.h>
34 #include <Inventor/projectors/SbPlaneProjector.h>
35 #include <Inventor/nodes/SoBaseColor.h>
36
37 namespace Gui
38 {
39 /*! @brief Planar Translation Dragger.
40 *
41 * used for translating on a plane. Set the
42 * translationIncrement to desired step. Use
43 * 'translationIncrementXCount' or
44 * 'translationIncrementYCount' multiplied with
45 * 'translationIncrement' for a full double
46 * precision vector scalar.
47 *
48 * @author qewer33
49 */
50 class SoPlanarDragger: public SoDragger
51 {
52 SO_KIT_HEADER(SoLinearDragger);
53 SO_KIT_CATALOG_ENTRY_HEADER(planarTranslatorSwitch);
54 SO_KIT_CATALOG_ENTRY_HEADER(planarTranslator);
55 SO_KIT_CATALOG_ENTRY_HEADER(planarTranslatorActive);
56
57 public:
58 static void initClass();
59 SoPlanarDragger();
60 SoSFVec3f translation; //!< set from outside and used from outside for single precision.
61 SoSFDouble translationIncrement; //!< set from outside and used for rounding.
62 SoSFInt32 translationIncrementXCount; //!< number of steps. used from outside.
63 SoSFInt32 translationIncrementYCount; //!< number of steps. used from outside.
64 SoSFFloat autoScaleResult; //!< set from parent dragger.
65
66 protected:
67 ~SoPlanarDragger() override;
68 SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE) override;
69
70 static void startCB(void*, SoDragger* d);
71 static void motionCB(void*, SoDragger* d);
72 static void finishCB(void*, SoDragger* d);
73 static void fieldSensorCB(void* f, SoSensor*);
74 static void valueChangedCB(void*, SoDragger* d);
75
76 void dragStart();
77 void drag();
78 void dragFinish();
79
80 SoFieldSensor fieldSensor;
81 SbPlaneProjector projector;
82
83 private:
84 void buildFirstInstance();
85 SbVec3f roundTranslation(const SbVec3f& vecIn, float incrementIn);
86 SoGroup* buildGeometry();
87 using inherited = SoDragger;
88 };
89
90 } // namespace Gui
91
92 #endif /* GUI_PLANAR_DRAGGER_H */