--- a/nbproject/configurations.xml Wed Mar 06 16:21:18 2019 +0100
+++ b/nbproject/configurations.xml Thu Mar 14 00:23:34 2019 +0100
@@ -58,6 +58,8 @@
</df>
</df>
<df name="src">
+ <in>SimulatorWindow.cpp</in>
+ <in>SimulatorWindow.h</in>
<in>spacenav-simulator-qt.cpp</in>
</df>
</df>
@@ -142,6 +144,10 @@
</incDir>
</ccTool>
</folder>
+ <item path="src/SimulatorWindow.cpp" ex="false" tool="1" flavor2="8">
+ <ccTool flags="0">
+ </ccTool>
+ </item>
<item path="src/spacenav-simulator-qt.cpp" ex="false" tool="1" flavor2="8">
<ccTool flags="0">
</ccTool>
@@ -215,6 +221,10 @@
</incDir>
</ccTool>
</folder>
+ <item path="src/SimulatorWindow.cpp" ex="false" tool="1" flavor2="0">
+ </item>
+ <item path="src/SimulatorWindow.h" ex="false" tool="3" flavor2="0">
+ </item>
<item path="src/spacenav-simulator-qt.cpp" ex="false" tool="1" flavor2="8">
<ccTool flags="0">
</ccTool>
--- a/src/CMakeLists.txt Wed Mar 06 16:21:18 2019 +0100
+++ b/src/CMakeLists.txt Thu Mar 14 00:23:34 2019 +0100
@@ -32,6 +32,8 @@
add_executable(
${EXECUTABLE_FILE}
# QObjects must be listed here (including them from other files is not enough)
+ SimulatorWindow.h
+ SimulatorWindow.cpp
spacenav-simulator-qt.cpp
)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SimulatorWindow.cpp Thu Mar 14 00:23:34 2019 +0100
@@ -0,0 +1,93 @@
+/**
+ * Spacenav Simulator Qt
+ * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QtWidgets/QFormLayout>
+#include <QtWidgets/QLabel>
+#include <QtWidgets/QGridLayout>
+#include <qt5/QtCore/qobject.h>
+
+#include "SimulatorWindow.h"
+
+SimulatorWindow::SimulatorWindow() {
+ resize(640, 480);
+ setWindowTitle("Spacenav Simulator");
+
+ QWidget* centralwidget = new QWidget(this);
+ QFormLayout* formLayout = new QFormLayout(centralwidget);
+
+ int f = 0;
+
+ formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Buttons:", centralwidget));
+ std::vector<QString> buttonLabels = {"0", "1"};
+
+ for (QString b : buttonLabels) {
+ QCheckBox* button = new QCheckBox(centralwidget);
+ buttons.push_back(button);
+ formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(b, centralwidget));
+ formLayout->setWidget(f++, QFormLayout::FieldRole, button);
+ }
+
+ std::vector<QString> axisLabels = {"X", "Y", "Z"};
+
+ formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Motion:", centralwidget));
+ for (QString a : axisLabels) {
+ QSlider* slider = createSlider(centralwidget);
+ motions.push_back(slider);
+ formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(a, centralwidget));
+ formLayout->setWidget(f++, QFormLayout::FieldRole, slider);
+ }
+
+
+ formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Rotation:", centralwidget));
+ for (QString a : axisLabels) {
+ QSlider* slider = createSlider(centralwidget);
+ rotations.push_back(slider);
+ formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(a, centralwidget));
+ formLayout->setWidget(f++, QFormLayout::FieldRole, slider);
+ }
+
+ formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Actions:", centralwidget));
+ centerButton = new QPushButton("Center all", centralwidget);
+ connect(centerButton, &QPushButton::clicked, this, &SimulatorWindow::centerAll);
+ formLayout->setWidget(f++, QFormLayout::FieldRole, centerButton);
+
+
+ setCentralWidget(centralwidget);
+}
+
+SimulatorWindow::SimulatorWindow(const SimulatorWindow& orig) {
+}
+
+SimulatorWindow::~SimulatorWindow() {
+}
+
+QSlider* SimulatorWindow::createSlider(QWidget* parent) {
+ QSlider* slider = new QSlider(Qt::Orientation::Horizontal, parent);
+ rotations.push_back(slider);
+ slider->setRange(-500, 500);
+ slider->setValue(0);
+ slider->setTickPosition(QSlider::TicksBelow);
+ slider->setTickInterval(100);
+ slider->setSingleStep(1);
+ return slider;
+}
+
+void SimulatorWindow::centerAll() {
+ for (QSlider* s : motions) s->setValue(0);
+ for (QSlider* s : rotations) s->setValue(0);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SimulatorWindow.h Thu Mar 14 00:23:34 2019 +0100
@@ -0,0 +1,41 @@
+/**
+ * Spacenav Simulator Qt
+ * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <vector>
+#include <QtWidgets/QMainWindow>
+#include <QtWidgets/QCheckBox>
+#include <QtWidgets/QSlider>
+#include <QtWidgets/QPushButton>
+
+class SimulatorWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ SimulatorWindow();
+ SimulatorWindow(const SimulatorWindow& orig);
+ virtual ~SimulatorWindow();
+private:
+ std::vector<QCheckBox*> buttons;
+ std::vector<QSlider*> motions;
+ std::vector<QSlider*> rotations;
+ QPushButton* centerButton;
+ QSlider* createSlider(QWidget* parent);
+
+private slots:
+ void centerAll();
+};
--- a/src/spacenav-simulator-qt.cpp Wed Mar 06 16:21:18 2019 +0100
+++ b/src/spacenav-simulator-qt.cpp Thu Mar 14 00:23:34 2019 +0100
@@ -20,14 +20,16 @@
#include <QApplication>
#include <QThread>
-#include <stdlib.h>
-#include <signal.h>
-#include <X11/Xlib.h>
-#include <spnav.h>
+#include "SimulatorWindow.h"
int main(int argc, char**argv) {
setlocale(LC_ALL, "");
QApplication app(argc, argv);
- return 0;
+ SimulatorWindow w;
+ w.show();
+
+ int qtResultCode = app.exec();
+
+ return qtResultCode;
}