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. --- filter-accela/ftnoir_filter_accela.cpp | 2 +- filter-accela/ftnoir_filter_accela.h | 2 +- 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 --------------------------------- opentrack-logic/main-settings.hpp | 15 +- opentrack-logic/mappings.hpp | 46 ++-- opentrack-logic/tracker.cpp | 12 +- opentrack-logic/tracker.h | 2 +- spline-widget/spline-widget.cpp | 34 +-- spline-widget/spline-widget.hpp | 10 +- spline-widget/spline.cpp | 42 ++-- spline-widget/spline.hpp | 6 +- 17 files changed, 608 insertions(+), 607 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 diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 24287e48..b165a56d 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -84,7 +84,7 @@ void FTNoIR_Filter::filter(const double* input, double *output) for (int i = 0; i < 6; i++) { - Map& m = i >= 3 ? rot : trans; + spline& m = i >= 3 ? rot : trans; smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; diff --git a/filter-accela/ftnoir_filter_accela.h b/filter-accela/ftnoir_filter_accela.h index 7eda8c9e..eb1a30a4 100644 --- a/filter-accela/ftnoir_filter_accela.h +++ b/filter-accela/ftnoir_filter_accela.h @@ -43,7 +43,7 @@ public: FTNoIR_Filter(); void filter(const double* input, double *output) override; void center() override { first_run = true; } - Map rot, trans; + spline rot, trans; private: settings_accela s; bool first_run; 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() - -
diff --git a/opentrack-logic/main-settings.hpp b/opentrack-logic/main-settings.hpp index 81eb99cf..29f7f62c 100644 --- a/opentrack-logic/main-settings.hpp +++ b/opentrack-logic/main-settings.hpp @@ -62,7 +62,7 @@ struct module_settings struct main_settings { - pbundle b; + pbundle b, b_map; axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll; value tcomp_p, tcomp_tz; value tray_enabled; @@ -77,12 +77,13 @@ struct main_settings value tracklogging_filename; main_settings() : b(bundle("opentrack-ui")), - a_x(b, "x", TX), - a_y(b, "y", TY), - a_z(b, "z", TZ), - a_yaw(b, "yaw", Yaw), - a_pitch(b, "pitch", Pitch), - a_roll(b, "roll", Roll), + b_map(bundle("opentrack-mappings")), + a_x(b_map, "x", TX), + a_y(b_map, "y", TY), + a_z(b_map, "z", TZ), + a_yaw(b_map, "yaw", Yaw), + a_pitch(b_map, "pitch", Pitch), + a_roll(b_map, "roll", Roll), tcomp_p(b, "compensate-translation", true), tcomp_tz(b, "compensate-translation-disable-z-axis", false), tray_enabled(b, "use-system-tray", false), diff --git a/opentrack-logic/mappings.hpp b/opentrack-logic/mappings.hpp index 9475ecb4..3e396980 100644 --- a/opentrack-logic/mappings.hpp +++ b/opentrack-logic/mappings.hpp @@ -13,46 +13,46 @@ using namespace options; #include "spline-widget/spline.hpp" #include "main-settings.hpp" -class Mapping { +class Map { public: - Mapping(QString primary, + Map(QString primary, QString secondary, int max_x, int max_y, axis_opts& opts) : - curve(max_x, max_y), - curveAlt(max_x, max_y), + spline_main(max_x, max_y), + spline_alt(max_x, max_y), opts(opts), name1(primary), name2(secondary) { mem iniFile = group::ini_file(); - curve.loadSettings(*iniFile, primary); - curveAlt.loadSettings(*iniFile, secondary); + spline_main.loadSettings(*iniFile, primary); + spline_alt.loadSettings(*iniFile, secondary); } - Map curve; - Map curveAlt; + spline spline_main; + spline spline_alt; axis_opts& opts; QString name1, name2; }; class Mappings { private: - Mapping axes[6]; + Map axes[6]; public: Mappings(std::vector opts) : axes { - Mapping("tx","tx_alt", 30, 75, *opts[TX]), - Mapping("ty","ty_alt", 30, 75, *opts[TY]), - Mapping("tz","tz_alt", 30, 75, *opts[TZ]), - Mapping("rx", "rx_alt", 180, 180, *opts[Yaw]), - Mapping("ry", "ry_alt", 180, 180, *opts[Pitch]), - Mapping("rz", "rz_alt", 180, 180, *opts[Roll]) + Map("tx","tx_alt", 30, 75, *opts[TX]), + Map("ty","ty_alt", 30, 75, *opts[TY]), + Map("tz","tz_alt", 30, 75, *opts[TZ]), + Map("rx", "rx_alt", 180, 180, *opts[Yaw]), + Map("ry", "ry_alt", 180, 180, *opts[Pitch]), + Map("rz", "rz_alt", 180, 180, *opts[Roll]) } {} - inline Mapping& operator()(int i) { return axes[i]; } - inline const Mapping& operator()(int i) const { return axes[i]; } + inline Map& operator()(int i) { return axes[i]; } + inline const Map& operator()(int i) const { return axes[i]; } void load_mappings() { @@ -60,8 +60,8 @@ public: for (int i = 0; i < 6; i++) { - axes[i].curve.loadSettings(*iniFile, axes[i].name1); - axes[i].curveAlt.loadSettings(*iniFile, axes[i].name2); + axes[i].spline_main.loadSettings(*iniFile, axes[i].name1); + axes[i].spline_alt.loadSettings(*iniFile, axes[i].name2); axes[i].opts.b->reload(); } } @@ -71,8 +71,8 @@ public: for (int i = 0; i < 6; i++) { - axes[i].curve.saveSettings(*iniFile, axes[i].name1); - axes[i].curveAlt.saveSettings(*iniFile, axes[i].name2); + axes[i].spline_main.saveSettings(*iniFile, axes[i].name1); + axes[i].spline_alt.saveSettings(*iniFile, axes[i].name2); axes[i].opts.b->save(); } } @@ -81,8 +81,8 @@ public: { for (int i = 0; i < 6; i++) { - axes[i].curve.invalidate_unsaved_settings(); - axes[i].curveAlt.invalidate_unsaved_settings(); + axes[i].spline_main.invalidate_unsaved_settings(); + axes[i].spline_alt.invalidate_unsaved_settings(); axes[i].opts.b->reload(); } } diff --git a/opentrack-logic/tracker.cpp b/opentrack-logic/tracker.cpp index 746a29f4..ab1a7406 100644 --- a/opentrack-logic/tracker.cpp +++ b/opentrack-logic/tracker.cpp @@ -54,12 +54,12 @@ Tracker::rmat Tracker::get_camera_offset_matrix(double c) return euler::euler_to_rmat(off); } -double Tracker::map(double pos, Mapping& axis) +double Tracker::map(double pos, Map& axis) { bool altp = (pos < 0) && axis.opts.altp; - axis.curve.setTrackingActive( !altp ); - axis.curveAlt.setTrackingActive( altp ); - auto& fc = altp ? axis.curveAlt : axis.curve; + axis.spline_main.setTrackingActive( !altp ); + axis.spline_alt.setTrackingActive( altp ); + auto& fc = altp ? axis.spline_alt : axis.spline_main; return fc.getValue(pos); } @@ -355,8 +355,8 @@ void Tracker::run() for (int i = 0; i < 6; i++) { - m(i).curve.setTrackingActive(false); - m(i).curveAlt.setTrackingActive(false); + m(i).spline_main.setTrackingActive(false); + m(i).spline_alt.setTrackingActive(false); } } diff --git a/opentrack-logic/tracker.h b/opentrack-logic/tracker.h index 91ac3f2f..2153f7c0 100644 --- a/opentrack-logic/tracker.h +++ b/opentrack-logic/tracker.h @@ -57,7 +57,7 @@ private: rmat r_b, r_b_real; double t_b[3]; - double map(double pos, Mapping& axis); + double map(double pos, Map& axis); void logic(); void t_compensate(const rmat& rmat, const euler_t& ypr, euler_t& output, bool rz); void run() override; diff --git a/spline-widget/spline-widget.cpp b/spline-widget/spline-widget.cpp index ee2e3c73..17dbe31d 100644 --- a/spline-widget/spline-widget.cpp +++ b/spline-widget/spline-widget.cpp @@ -15,7 +15,7 @@ using namespace options; #include #include -QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) : +spline_widget::spline_widget(QWidget *parent) : QWidget(parent), _config(nullptr), moving_control_point_idx(-1), @@ -28,7 +28,7 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) : setMouseTracking(true); } -void QFunctionConfigurator::setConfig(Map* config, const QString& name) +void spline_widget::setConfig(spline* config, const QString& name) { mem iniFile = group::ini_file(); if (name != "") @@ -39,17 +39,17 @@ void QFunctionConfigurator::setConfig(Map* config, const QString& name) update(); } -void QFunctionConfigurator::set_preview_only(bool val) +void spline_widget::set_preview_only(bool val) { _preview_only = val; } -bool QFunctionConfigurator::is_preview_only() const +bool spline_widget::is_preview_only() const { return _preview_only; } -void QFunctionConfigurator::drawBackground() +void spline_widget::drawBackground() { if (!_config) return; @@ -111,7 +111,7 @@ void QFunctionConfigurator::drawBackground() } } -void QFunctionConfigurator::drawFunction() +void spline_widget::drawFunction() { if (!_config) return; @@ -173,7 +173,7 @@ void QFunctionConfigurator::drawFunction() painter.restore(); } -void QFunctionConfigurator::paintEvent(QPaintEvent *e) +void spline_widget::paintEvent(QPaintEvent *e) { QPainter p(this); @@ -221,7 +221,7 @@ void QFunctionConfigurator::paintEvent(QPaintEvent *e) } } -void QFunctionConfigurator::drawPoint(QPainter *painter, const QPointF &pos, QColor colBG, QColor border) +void spline_widget::drawPoint(QPainter *painter, const QPointF &pos, QColor colBG, QColor border) { painter->save(); painter->setPen(border); @@ -232,7 +232,7 @@ void QFunctionConfigurator::drawPoint(QPainter *painter, const QPointF &pos, QCo painter->restore(); } -void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen &pen) +void spline_widget::drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen &pen) { painter->save(); painter->setPen(pen); @@ -241,7 +241,7 @@ void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, co painter->restore(); } -void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) +void spline_widget::mousePressEvent(QMouseEvent *e) { if (!_config || !isEnabled()) return; @@ -308,7 +308,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) update(); } -void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) +void spline_widget::mouseMoveEvent(QMouseEvent *e) { if (!_config || !isEnabled()) return; @@ -390,7 +390,7 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) } } -void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) +void spline_widget::mouseReleaseEvent(QMouseEvent *e) { if (!_config || !isEnabled()) return; @@ -406,7 +406,7 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) } } -void QFunctionConfigurator::update_range() +void spline_widget::update_range() { if (!_config) return; @@ -425,13 +425,13 @@ void QFunctionConfigurator::update_range() update(); } -bool QFunctionConfigurator::point_within_pixel(const QPointF &pt, const QPointF &pixel) +bool spline_widget::point_within_pixel(const QPointF &pt, const QPointF &pixel) { QPointF tmp = pixel - point_to_pixel(pt); return sqrt(QPointF::dotProduct(tmp, tmp)) < point_size; } -QPointF QFunctionConfigurator::pixel_coord_to_point(const QPointF& point) +QPointF spline_widget::pixel_coord_to_point(const QPointF& point) { if (!_config) return QPointF(-1, -1); @@ -459,13 +459,13 @@ QPointF QFunctionConfigurator::pixel_coord_to_point(const QPointF& point) return QPointF(x, y); } -QPointF QFunctionConfigurator::point_to_pixel(const QPointF& point) +QPointF spline_widget::point_to_pixel(const QPointF& point) { return QPointF(pixel_bounds.x() + point.x() * c.x(), pixel_bounds.y() + pixel_bounds.height() - point.y() * c.y()); } -void QFunctionConfigurator::resizeEvent(QResizeEvent *) +void spline_widget::resizeEvent(QResizeEvent *) { update_range(); } diff --git a/spline-widget/spline-widget.hpp b/spline-widget/spline-widget.hpp index cc416b60..577e6f7f 100644 --- a/spline-widget/spline-widget.hpp +++ b/spline-widget/spline-widget.hpp @@ -15,16 +15,16 @@ #include "spline.hpp" #include "opentrack/plugin-api.hpp" -class SPLINE_WIDGET_EXPORT QFunctionConfigurator : public QWidget +class SPLINE_WIDGET_EXPORT spline_widget : public QWidget { Q_OBJECT Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier) Q_PROPERTY(bool is_preview_only READ is_preview_only WRITE set_preview_only) public: - QFunctionConfigurator(QWidget *parent = 0); + spline_widget(QWidget *parent = 0); - Map* config(); - void setConfig(Map* config, const QString &name); + spline* config(); + void setConfig(spline* config, const QString &name); QColor colorBezier() const { @@ -63,7 +63,7 @@ private: QPointF pixel_coord_to_point (const QPointF& point); QPointF point_to_pixel(const QPointF& point); - Map* _config; + spline* _config; // bounds of the rectangle user can interact with QRectF pixel_bounds; diff --git a/spline-widget/spline.cpp b/spline-widget/spline.cpp index 7bac6b78..48b508ef 100644 --- a/spline-widget/spline.cpp +++ b/spline-widget/spline.cpp @@ -21,47 +21,47 @@ #include -void Map::setTrackingActive(bool blnActive) +void spline::setTrackingActive(bool blnActive) { activep = blnActive; } -Map::Map() : Map(0, 0) +spline::spline() : spline(0, 0) { } -void Map::removeAllPoints() +void spline::removeAllPoints() { QMutexLocker foo(&_mutex); cur.input.clear(); reload(); } -void Map::setMaxInput(qreal max_input) +void spline::setMaxInput(qreal max_input) { QMutexLocker l(&_mutex); max_x = max_input; } -void Map::setMaxOutput(qreal max_output) +void spline::setMaxOutput(qreal max_output) { QMutexLocker l(&_mutex); max_y = max_output; } -qreal Map::maxInput() const +qreal spline::maxInput() const { QMutexLocker l(&_mutex); return max_x; } -qreal Map::maxOutput() const +qreal spline::maxOutput() const { QMutexLocker l(&_mutex); return max_y; } -Map::Map(qreal maxx, qreal maxy) : +spline::spline(qreal maxx, qreal maxy) : _mutex(QMutex::Recursive), max_x(0), max_y(0), @@ -74,7 +74,7 @@ Map::Map(qreal maxx, qreal maxy) : reload(); } -float Map::getValue(float x) +float spline::getValue(float x) { QMutexLocker foo(&_mutex); float q = x * precision(); @@ -88,14 +88,14 @@ float Map::getValue(float x) return ret; } -bool Map::getLastPoint(QPointF& point ) +bool spline::getLastPoint(QPointF& point ) { QMutexLocker foo(&_mutex); point = last_input_value; return activep; } -float Map::getValueInternal(int x) +float spline::getValueInternal(int x) { float sign = x < 0 ? -1 : 1; x = abs(x); @@ -123,7 +123,7 @@ static bool sortFn(const QPointF& one, const QPointF& two) return one.x() < two.x(); } -void Map::reload() +void spline::reload() { if (cur.input.size()) { @@ -202,7 +202,7 @@ void Map::reload() cur.data.clear(); } -void Map::removePoint(int i) +void spline::removePoint(int i) { QMutexLocker foo(&_mutex); if (i >= 0 && i < cur.input.size()) @@ -212,7 +212,7 @@ void Map::removePoint(int i) } } -void Map::addPoint(QPointF pt) +void spline::addPoint(QPointF pt) { QMutexLocker foo(&_mutex); cur.input.append(pt); @@ -220,7 +220,7 @@ void Map::addPoint(QPointF pt) std::stable_sort(cur.input.begin(), cur.input.end(), sortFn); } -void Map::movePoint(int idx, QPointF pt) +void spline::movePoint(int idx, QPointF pt) { QMutexLocker foo(&_mutex); if (idx >= 0 && idx < cur.input.size()) @@ -232,20 +232,20 @@ void Map::movePoint(int idx, QPointF pt) } } -const QList Map::getPoints() +const QList spline::getPoints() { QMutexLocker foo(&_mutex); return cur.input; } -void Map::invalidate_unsaved_settings() +void spline::invalidate_unsaved_settings() { QMutexLocker foo(&_mutex); cur = saved; reload(); } -void Map::loadSettings(QSettings& settings, const QString& title) +void spline::loadSettings(QSettings& settings, const QString& title) { QMutexLocker foo(&_mutex); QPointF newPoint; @@ -275,7 +275,7 @@ void Map::loadSettings(QSettings& settings, const QString& title) saved = cur; } -bool Map::State::operator==(const State& other) const +bool spline::State::operator==(const State& other) const { if (input.size() != other.input.size()) return false; @@ -297,7 +297,7 @@ bool Map::State::operator==(const State& other) const return true; } -void Map::saveSettings(QSettings& settings, const QString& title) +void spline::saveSettings(QSettings& settings, const QString& title) { QMutexLocker foo(&_mutex); @@ -335,7 +335,7 @@ void Map::saveSettings(QSettings& settings, const QString& title) } -int Map::precision() const +int spline::precision() const { if (cur.input.size()) return (value_count-1) / std::max(1.f, (cur.input[cur.input.size() - 1].x())); diff --git a/spline-widget/spline.hpp b/spline-widget/spline.hpp index 5d83aefd..6387c87a 100644 --- a/spline-widget/spline.hpp +++ b/spline-widget/spline.hpp @@ -24,7 +24,7 @@ # define SPLINE_WIDGET_EXPORT Q_DECL_IMPORT #endif -class SPLINE_WIDGET_EXPORT Map +class SPLINE_WIDGET_EXPORT spline { private: int precision() const; @@ -48,8 +48,8 @@ private: public: qreal maxInput() const; qreal maxOutput() const; - Map(); - Map(qreal maxx, qreal maxy); + spline(); + spline(qreal maxx, qreal maxy); float getValue(float x); bool getLastPoint(QPointF& point); -- cgit v1.2.3