diff options
-rw-r--r-- | api/plugin-api.hpp | 2 | ||||
-rw-r--r-- | spline/axis-opts.cpp | 2 | ||||
-rw-r--r-- | spline/axis-opts.hpp | 3 | ||||
-rw-r--r-- | spline/spline.cpp | 15 | ||||
-rw-r--r-- | spline/spline.hpp | 25 |
5 files changed, 22 insertions, 25 deletions
diff --git a/api/plugin-api.hpp b/api/plugin-api.hpp index 76dc34af..29f678f3 100644 --- a/api/plugin-api.hpp +++ b/api/plugin-api.hpp @@ -22,6 +22,8 @@ using Pose = Mat<double, 6, 1>; enum Axis { TX, TY, TZ, Yaw, Pitch, Roll, + + NonAxis = -1, }; namespace plugin_api { diff --git a/spline/axis-opts.cpp b/spline/axis-opts.cpp index 52fe20f5..d7616939 100644 --- a/spline/axis-opts.cpp +++ b/spline/axis-opts.cpp @@ -25,8 +25,6 @@ static max_clamp get_max_y(Axis k) } axis_opts::axis_opts(QString pfx, Axis idx) : - b_settings_window(make_bundle("opentrack-ui")), - b_mapping_window(make_bundle("opentrack-mappings")), zero(b_settings_window, n(pfx, "zero-pos"), 0), src(b_settings_window, n(pfx, "source-index"), idx), invert(b_settings_window, n(pfx, "invert-sign"), false), diff --git a/spline/axis-opts.hpp b/spline/axis-opts.hpp index ad94236c..5581f569 100644 --- a/spline/axis-opts.hpp +++ b/spline/axis-opts.hpp @@ -34,7 +34,8 @@ struct OTR_SPLINE_EXPORT axis_opts final }; // note, these two bundles can be the same value with no issues - bundle b_settings_window, b_mapping_window; + bundle b_settings_window = make_bundle("opentrack-ui"); + bundle b_mapping_window = make_bundle("opentrack-mappings"); value<double> zero; value<int> src; value<bool> invert, altp; diff --git a/spline/spline.cpp b/spline/spline.cpp index 2e29997a..e3cd2d6f 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -24,16 +24,13 @@ #include <QDebug> -constexpr int spline::value_count; +using namespace spline_detail; + +constexpr std::size_t spline::value_count; spline::spline(const QString& name, const QString& axis_name, Axis axis) : - s(nullptr), - data(value_count, -16), - _mutex(QMutex::Recursive), ctx(std::make_shared<QObject>()), - axis(axis), - activep(false), - validp(false) + axis(axis) { set_bundle(options::make_bundle(name), axis_name, axis); } @@ -460,13 +457,13 @@ void spline::ensure_valid(QList<QPointF>& the_points) } // the return value is only safe to use with no spline::set_bundle calls -std::shared_ptr<spline::settings> spline::get_settings() +std::shared_ptr<settings> spline::get_settings() { QMutexLocker foo(&_mutex); return s; } -std::shared_ptr<const spline::settings> spline::get_settings() const +std::shared_ptr<const settings> spline::get_settings() const { QMutexLocker foo(&_mutex); return s; diff --git a/spline/spline.hpp b/spline/spline.hpp index defa80fc..54c53767 100644 --- a/spline/spline.hpp +++ b/spline/spline.hpp @@ -43,7 +43,7 @@ signals: void recomputed() const; }; -} +} // ns spline_detail class OTR_SPLINE_EXPORT spline final { @@ -60,23 +60,20 @@ class OTR_SPLINE_EXPORT spline final std::shared_ptr<spline_detail::settings> s; QMetaObject::Connection connection, conn_maxx, conn_maxy; - std::vector<float> data; - using interp_data_t = decltype(data); + static constexpr std::size_t value_count = 4096; - static constexpr int value_count = 4096; + std::vector<float> data = std::vector<float>(value_count, float(-16)); - MyMutex _mutex; + mutex _mutex { mutex::recursive }; QPointF last_input_value; - std::shared_ptr<QObject> ctx; + std::shared_ptr<QObject> ctx { std::make_shared<QObject>() }; - Axis axis; + Axis axis = NonAxis; - bool activep; - bool validp; + bool activep = false; + bool validp = false; public: - using settings = spline_detail::settings; - void invalidate_settings(); void reload(); @@ -108,9 +105,11 @@ public: bundle get_bundle(); void ensure_valid(QList<QPointF>& the_points); - std::shared_ptr<settings> get_settings(); - std::shared_ptr<const settings> get_settings() const; + std::shared_ptr<spline_detail::settings> get_settings(); + std::shared_ptr<const spline_detail::settings> get_settings() const; using points_t = decltype(s->points()); int get_point_count() const; + + using settings = spline_detail::settings; }; |