author | František Kučera <franta-hg@frantovo.cz> |
Thu, 24 Oct 2019 21:49:24 +0200 | |
branch | v_0 |
changeset 11 | aaa89fe98b63 |
parent 9 | d3716f03efcd |
permissions | -rw-r--r-- |
5 | 1 |
/** |
2 |
* Spacenav Demo Qt |
|
3 |
* Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
|
4 |
* |
|
5 |
* This program is free software: you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
11
aaa89fe98b63
fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
5 | 8 |
* |
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 |
||
18 |
#include "SpacenavWindow.h" |
|
19 |
||
20 |
SpacenavWindow::SpacenavWindow() { |
|
21 |
widget.setupUi(this); |
|
6
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
22 |
resize(640, 480); |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
23 |
setWindowTitle("Spacenav Demo"); |
7
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
24 |
|
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
25 |
std::vector<QCheckBox*> buttons{ widget.button0, widget.button1}; |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
26 |
for (QCheckBox* b : buttons) b->setEnabled(false); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
27 |
|
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
28 |
std::vector<QProgressBar*> motions{ |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
29 |
widget.motionX, widget.motionY, widget.motionZ, |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
30 |
widget.rotationX, widget.rotationY, widget.rotationZ |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
31 |
}; |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
32 |
|
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
33 |
for (QProgressBar* m : motions) { |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
34 |
m->setMinimum(-500); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
35 |
m->setMaximum(500); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
36 |
m->setValue(0); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
37 |
m->setFormat("%v"); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
38 |
} |
8 | 39 |
|
40 |
widget.period->setMinimum(0); |
|
41 |
widget.period->setMaximum(100); |
|
42 |
widget.period->setValue(0); |
|
43 |
widget.period->setFormat("%v ms"); |
|
44 |
widget.period->setToolTip("duration in milliseconds from the last change"); |
|
5 | 45 |
} |
46 |
||
47 |
SpacenavWindow::~SpacenavWindow() { |
|
48 |
} |
|
49 |
||
6
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
50 |
void SpacenavWindow::spacenavMotionEvent(SpacenavWrapper::Event::MotionEvent e) { |
7
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
51 |
widget.motionX->setValue(e.x); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
52 |
widget.motionY->setValue(e.y); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
53 |
widget.motionZ->setValue(e.z); |
8 | 54 |
|
7
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
55 |
widget.rotationX->setValue(e.rx); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
56 |
widget.rotationY->setValue(e.ry); |
b6c0e1574a8b
display buttons, motions and rotations of all axes
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
57 |
widget.rotationZ->setValue(e.rz); |
8 | 58 |
|
59 |
widget.period->setValue(e.period); |
|
60 |
// std::wcerr << L"period: " << e.period << std::endl; |
|
5 | 61 |
} |
6
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
62 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
63 |
void SpacenavWindow::spacenavButtonEvent(SpacenavWrapper::Event::ButtonEvent e) { |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
64 |
if (e.number == 0) widget.button0->setChecked(e.pressed); |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
65 |
if (e.number == 1) widget.button1->setChecked(e.pressed); |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
66 |
} |
9
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
67 |
|
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
68 |
void SpacenavWindow::spacenavConnectionStatus(SpacenavWrapper::ConnectionStatus s) { |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
69 |
if (s == SpacenavWrapper::ConnectionStatus::DOMAIN_SOCKET) widget.connection->setText("connected through: domain socket"); |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
70 |
if (s == SpacenavWrapper::ConnectionStatus::X11) widget.connection->setText("connected through: X11"); |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
71 |
} |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
72 |