Debian Codegraph @

src/Gui/SpaceballEvent.h

raw
1 /***************************************************************************
2 * Copyright (c) 2010 Thomas Anderson <ta@nextgenengineering> *
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 SPACEBALLEVENT_H
24 #define SPACEBALLEVENT_H
25
26 #include <QInputEvent>
27
28 namespace Spaceball
29 {
30 enum ButtonStateType
31 {
32 BUTTON_NONE = 0,
33 BUTTON_PRESSED,
34 BUTTON_RELEASED
35 };
36
37 class EventBase: public QInputEvent
38 {
39 public:
40 bool isHandled()
41 {
42 return handled;
43 }
44 void setHandled(bool sig)
45 {
46 handled = sig;
47 }
48
49 protected:
50 explicit EventBase(QEvent::Type event);
51 bool handled {false};
52 };
53
54 class MotionEvent: public EventBase
55 {
56 public:
57 MotionEvent();
58 MotionEvent(const MotionEvent& in);
59 MotionEvent& operator=(const MotionEvent& in);
60 void translations(int& xTransOut, int& yTransOut, int& zTransOut);
61 void setTranslations(const int& xTransIn, const int& yTransIn, const int& zTransIn);
62 int translationX()
63 {
64 return xTrans;
65 }
66 int translationY()
67 {
68 return yTrans;
69 }
70 int translationZ()
71 {
72 return zTrans;
73 }
74
75 void rotations(int& xRotOut, int& yRotOut, int& zRotOut);
76 void setRotations(const int& xRotIn, const int& yRotIn, const int& zRotIn);
77 int rotationX()
78 {
79 return xRot;
80 }
81 int rotationY()
82 {
83 return yRot;
84 }
85 int rotationZ()
86 {
87 return zRot;
88 }
89
90 static int MotionEventType;
91
92 private:
93 int xTrans {0};
94 int yTrans {0};
95 int zTrans {0};
96 int xRot {0};
97 int yRot {0};
98 int zRot {0};
99 };
100
101 class ButtonEvent: public EventBase
102 {
103 public:
104 ButtonEvent();
105 ButtonEvent(const ButtonEvent& in);
106 ButtonEvent& operator=(const ButtonEvent& in);
107 ButtonStateType buttonStatus();
108 void setButtonStatus(const ButtonStateType& buttonStatusIn);
109 int buttonNumber();
110 void setButtonNumber(const int& buttonNumberIn);
111
112 static int ButtonEventType;
113
114 private:
115 ButtonStateType buttonState;
116 int button;
117 };
118 } // namespace Spaceball
119 #endif // SPACEBALLEVENT_H