summaryrefslogtreecommitdiffhomepage
path: root/gui/mapping-window.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-09 15:50:09 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-10 10:41:56 +0200
commit0eec855f4f5ac86f70525418918fd1ebb4d45e03 (patch)
treeb8014ad75774e00ba3c26f2b781d6ad0c6021c9a /gui/mapping-window.cpp
parentf56f30f1d076c8b48a0bd4ce47b26ede618d2880 (diff)
spline-widget, gui: rename mapping-related files and classes
Adjust usages.
Diffstat (limited to 'gui/mapping-window.cpp')
-rw-r--r--gui/mapping-window.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/gui/mapping-window.cpp b/gui/mapping-window.cpp
new file mode 100644
index 00000000..108e1354
--- /dev/null
+++ b/gui/mapping-window.cpp
@@ -0,0 +1,94 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
+#include "mapping-window.hpp"
+#include "opentrack-logic/main-settings.hpp"
+#include "spline-widget/spline-widget.hpp"
+MapWidget::MapWidget(Mappings& m) :
+ m(m)
+{
+ ui.setupUi(this);
+
+ m.load_mappings();
+
+ reload();
+
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
+
+ tie_setting(s.a_x.altp, ui.tx_altp);
+ tie_setting(s.a_y.altp, ui.ty_altp);
+ tie_setting(s.a_z.altp, ui.tz_altp);
+ tie_setting(s.a_yaw.altp, ui.rx_altp);
+ tie_setting(s.a_pitch.altp, ui.ry_altp);
+ tie_setting(s.a_roll.altp, ui.rz_altp);
+}
+
+void MapWidget::reload()
+{
+ {
+ struct {
+ spline_widget* qfc;
+ Axis axis;
+ QCheckBox* checkbox;
+ bool altp;
+ } qfcs[] =
+ {
+ { ui.rxconfig, Yaw, nullptr, false },
+ { ui.ryconfig, Pitch, nullptr, false },
+ { ui.rzconfig, Roll, nullptr, false },
+ { ui.txconfig, TX, nullptr, false },
+ { ui.tyconfig, TY, nullptr, false },
+ { ui.tzconfig, TZ, nullptr, false },
+
+ { ui.rxconfig_alt, Yaw, ui.rx_altp, true },
+ { ui.ryconfig_alt, Pitch, ui.ry_altp, true },
+ { ui.rzconfig_alt, Roll, ui.rz_altp, true },
+ { ui.txconfig_alt, TX, ui.tx_altp, true },
+ { ui.tyconfig_alt, TY, ui.ty_altp, true },
+ { ui.tzconfig_alt, TZ, ui.tz_altp, true },
+ { nullptr, Yaw, nullptr, false }
+ };
+
+ for (int i = 0; qfcs[i].qfc; i++)
+ {
+ const bool altp = qfcs[i].altp;
+ Map& axis = m(qfcs[i].axis);
+ spline* conf = altp ? &axis.spline_alt : &axis.spline_main;
+ const auto& name = qfcs[i].altp ? axis.name2 : axis.name1;
+ if (altp)
+ {
+ spline_widget& qfc = *qfcs[i].qfc;
+ connect(qfcs[i].checkbox, &QCheckBox::toggled,
+ this,
+ [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();});
+ qfc.setEnabled(qfcs[i].checkbox->isChecked());
+ qfc.force_redraw();
+ }
+
+ if (qfcs[i].axis >= 3)
+ qfcs[i].qfc->set_snap(1, 5);
+ else
+ qfcs[i].qfc->set_snap(1, 5);
+
+ qfcs[i].qfc->setConfig(conf, name);
+ }
+ }
+}
+
+void MapWidget::doOK()
+{
+ m.save_mappings();
+ close();
+}
+
+void MapWidget::doCancel()
+{
+ m.invalidate_unsaved();
+ close();
+}