Debian Codegraph @

src/Gui/SpaceballEvent.cpp

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
24 #include "SpaceballEvent.h"
25
26
27 using namespace Spaceball;
28
29 int MotionEvent::MotionEventType = -1;
30 int ButtonEvent::ButtonEventType = -1;
31
32 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
33 EventBase::EventBase(QEvent::Type event)
34 : QInputEvent(static_cast<QEvent::Type>(event))
35 #else
36 EventBase::EventBase(QEvent::Type event)
37 : QInputEvent(static_cast<QEvent::Type>(event), QPointingDevice::primaryPointingDevice())
38 #endif
39 {}
40
41 MotionEvent::MotionEvent()
42 : EventBase(static_cast<QEvent::Type>(MotionEventType))
43 {}
44
45 MotionEvent::MotionEvent(const MotionEvent& in)
46 : EventBase(static_cast<QEvent::Type>(MotionEventType))
47 {
48 xTrans = in.xTrans;
49 yTrans = in.yTrans;
50 zTrans = in.zTrans;
51 xRot = in.xRot;
52 yRot = in.yRot;
53 zRot = in.zRot;
54 handled = in.handled;
55 }
56
57 MotionEvent& MotionEvent::operator=(const MotionEvent& in)
58 {
59 if (this == &in) {
60 return *this;
61 }
62
63 xTrans = in.xTrans;
64 yTrans = in.yTrans;
65 zTrans = in.zTrans;
66 xRot = in.xRot;
67 yRot = in.yRot;
68 zRot = in.zRot;
69 handled = in.handled;
70 return *this;
71 }
72
73 void MotionEvent::translations(int& xTransOut, int& yTransOut, int& zTransOut)
74 {
75 xTransOut = xTrans;
76 yTransOut = yTrans;
77 zTransOut = zTrans;
78 }
79
80 void MotionEvent::setTranslations(const int& xTransIn, const int& yTransIn, const int& zTransIn)
81 {
82 xTrans = xTransIn;
83 yTrans = yTransIn;
84 zTrans = zTransIn;
85 }
86
87 void MotionEvent::rotations(int& xRotOut, int& yRotOut, int& zRotOut)
88 {
89 xRotOut = xRot;
90 yRotOut = yRot;
91 zRotOut = zRot;
92 }
93
94 void MotionEvent::setRotations(const int& xRotIn, const int& yRotIn, const int& zRotIn)
95 {
96 xRot = xRotIn;
97 yRot = yRotIn;
98 zRot = zRotIn;
99 }
100
101
102 ButtonEvent::ButtonEvent()
103 : EventBase(static_cast<QEvent::Type>(ButtonEventType))
104 , buttonState(BUTTON_NONE)
105 , button(0)
106 {}
107
108 ButtonEvent::ButtonEvent(const ButtonEvent& in)
109 : EventBase(static_cast<QEvent::Type>(ButtonEventType))
110 {
111 buttonState = in.buttonState;
112 button = in.button;
113 handled = in.handled;
114 }
115
116 ButtonEvent& ButtonEvent::operator=(const ButtonEvent& in)
117 {
118 if (this == &in) {
119 return *this;
120 }
121
122 buttonState = in.buttonState;
123 button = in.button;
124 handled = in.handled;
125 return *this;
126 }
127
128 ButtonStateType ButtonEvent::buttonStatus()
129 {
130 return buttonState;
131 }
132
133 void ButtonEvent::setButtonStatus(const ButtonStateType& buttonStatusIn)
134 {
135 buttonState = buttonStatusIn;
136 }
137
138 int ButtonEvent::buttonNumber()
139 {
140 return button;
141 }
142
143 void ButtonEvent::setButtonNumber(const int& buttonNumberIn)
144 {
145 button = buttonNumberIn;
146 }