From 0eec855f4f5ac86f70525418918fd1ebb4d45e03 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 9 Aug 2016 15:50:09 +0200 Subject: spline-widget, gui: rename mapping-related files and classes Adjust usages. --- gui/curve-config.cpp | 94 ------------ gui/curve-config.h | 21 --- gui/main-window.hpp | 2 +- gui/mapping-window.cpp | 94 ++++++++++++ gui/mapping-window.hpp | 21 +++ gui/mapping-window.ui | 406 +++++++++++++++++++++++++++++++++++++++++++++++++ gui/mapping.ui | 406 ------------------------------------------------- 7 files changed, 522 insertions(+), 522 deletions(-) delete mode 100644 gui/curve-config.cpp delete mode 100644 gui/curve-config.h create mode 100644 gui/mapping-window.cpp create mode 100644 gui/mapping-window.hpp create mode 100644 gui/mapping-window.ui delete mode 100644 gui/mapping.ui (limited to 'gui') diff --git a/gui/curve-config.cpp b/gui/curve-config.cpp deleted file mode 100644 index 3e262c48..00000000 --- a/gui/curve-config.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (c) 2014-2015, Stanislaw Halik - - * 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 "curve-config.h" -#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 { - QFunctionConfigurator* 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; - Mapping& axis = m(qfcs[i].axis); - Map* conf = altp ? &axis.curveAlt : &axis.curve; - const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; - if (altp) - { - QFunctionConfigurator& 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(); -} diff --git a/gui/curve-config.h b/gui/curve-config.h deleted file mode 100644 index 2124aa81..00000000 --- a/gui/curve-config.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include -#include "opentrack-logic/mappings.hpp" -#include "ui_mapping.h" - -class MapWidget final : public QWidget -{ - Q_OBJECT -public: - MapWidget(Mappings &m); - void reload(); -private: - Ui::UICCurveConfigurationDialog ui; - Mappings& m; - main_settings s; - - void closeEvent(QCloseEvent *) override { doCancel(); } -private slots: - void doOK(); - void doCancel(); -}; diff --git a/gui/main-window.hpp b/gui/main-window.hpp index 66852e6f..14c7cf0d 100644 --- a/gui/main-window.hpp +++ b/gui/main-window.hpp @@ -30,7 +30,7 @@ #include "opentrack-logic/shortcuts.h" #include "opentrack-logic/work.hpp" #include "opentrack-logic/state.hpp" -#include "curve-config.h" +#include "mapping-window.hpp" #include "options-dialog.hpp" #include "process_detector.h" 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 + + * 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(); +} diff --git a/gui/mapping-window.hpp b/gui/mapping-window.hpp new file mode 100644 index 00000000..e70a27c6 --- /dev/null +++ b/gui/mapping-window.hpp @@ -0,0 +1,21 @@ +#pragma once +#include +#include "opentrack-logic/mappings.hpp" +#include "ui_mapping-window.h" + +class MapWidget final : public QWidget +{ + Q_OBJECT +public: + MapWidget(Mappings& m); + void reload(); +private: + Ui::mapping_window ui; + Mappings& m; + main_settings s; + + void closeEvent(QCloseEvent *) override { doCancel(); } +private slots: + void doOK(); + void doCancel(); +}; diff --git a/gui/mapping-window.ui b/gui/mapping-window.ui new file mode 100644 index 00000000..877feed4 --- /dev/null +++ b/gui/mapping-window.ui @@ -0,0 +1,406 @@ + + + mapping_window + + + + 0 + 0 + 970 + 664 + + + + + 0 + 0 + + + + + 970 + 664 + + + + + 970 + 664 + + + + Mapping properties + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + + + + + + + QTabWidget::North + + + 0 + + + + background-color: #ccc; + + + Yaw + + + + + + + 255 + 0 + 0 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 0 + 0 + + + + + 255 + 255 + 255 + + + + + + + + + background-color: #ccc; + + + Pitch + + + + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + + + background-color: #ccc; + + + Roll + + + + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + + + background-color: #ccc; + + + X + + + + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + + + background-color: #ccc; + + + Y + + + + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + + + background-color: #ccc; + + + Z + + + + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + spline_widget + QWidget +
spline-widget/spline-widget.hpp
+
+
+ + ry_altp + rz_altp + tx_altp + ty_altp + tz_altp + tabWidget + buttonBox + rx_altp + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/gui/mapping.ui b/gui/mapping.ui deleted file mode 100644 index 3e3a54ff..00000000 --- a/gui/mapping.ui +++ /dev/null @@ -1,406 +0,0 @@ - - - UICCurveConfigurationDialog - - - - 0 - 0 - 970 - 664 - - - - - 0 - 0 - - - - - 970 - 664 - - - - - 970 - 664 - - - - Mapping properties - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - - - - - - - QTabWidget::North - - - 0 - - - - background-color: #ccc; - - - Yaw - - - - - - - 255 - 0 - 0 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 0 - 0 - - - - - 255 - 255 - 255 - - - - - - - - - background-color: #ccc; - - - Pitch - - - - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - - - background-color: #ccc; - - - Roll - - - - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - - - background-color: #ccc; - - - X - - - - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - - - background-color: #ccc; - - - Y - - - - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - - - background-color: #ccc; - - - Z - - - - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - QFunctionConfigurator - QWidget -
spline-widget/spline-widget.hpp
-
-
- - ry_altp - rz_altp - tx_altp - ty_altp - tz_altp - tabWidget - buttonBox - rx_altp - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
-- cgit v1.2.3