From 251d2c45a37da6fed01c1f37529c3cd899b434e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jun 2016 16:58:28 +0200 Subject: tracker/test: sine wave test tracker --- tracker-test/CMakeLists.txt | 4 +++ tracker-test/test.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++ tracker-test/test.h | 44 +++++++++++++++++++++++ tracker-test/test.ui | 59 +++++++++++++++++++++++++++++++ tracker-test/test_dialog.cpp | 3 ++ 5 files changed, 193 insertions(+) create mode 100644 tracker-test/CMakeLists.txt create mode 100644 tracker-test/test.cpp create mode 100644 tracker-test/test.h create mode 100644 tracker-test/test.ui create mode 100644 tracker-test/test_dialog.cpp diff --git a/tracker-test/CMakeLists.txt b/tracker-test/CMakeLists.txt new file mode 100644 index 00000000..81fcf667 --- /dev/null +++ b/tracker-test/CMakeLists.txt @@ -0,0 +1,4 @@ +set(SDK_TEST_TRACKER FALSE CACHE BOOL "sine wave test tracker") +if(SDK_TEST_TRACKER) + opentrack_boilerplate(opentrack-tracker-test) +endif() diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp new file mode 100644 index 00000000..b9376c98 --- /dev/null +++ b/tracker-test/test.cpp @@ -0,0 +1,83 @@ +/* Copyright (c) 2014, 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 "test.h" +#include "opentrack/plugin-api.hpp" +#include + +#include + +const double FTNoIR_Tracker::incr[6] = +{ + 2, 3, 4, + 70, 5, 3 +}; + +FTNoIR_Tracker::FTNoIR_Tracker() : + last_x { 0, 0, 0, 0, 0, 0 } +{ +} + +FTNoIR_Tracker::~FTNoIR_Tracker() +{ +} + +void FTNoIR_Tracker::start_tracker(QFrame*) +{ + t.start(); +} + +void FTNoIR_Tracker::data(double *data) +{ + using std::fmod; + using std::sin; + using std::fabs; + using std::copysign; + + const double dt = t.elapsed_seconds(); + t.start(); + + for (int i = 0; i < 6; i++) + { + double x = last_x[i] + incr[i] * d2r * dt; + + x = fmod(x , 2 * pi); + + last_x[i] = x; + + if (x > pi + pi/2) + { + x -= pi; + } + + double ret = sin(x) * 180; + + data[i] = ret; + } +} + +TrackerControls::TrackerControls() +{ + ui.setupUi(this); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); +} + +void TrackerControls::doOK() +{ + //s.b->save(); + close(); +} + +void TrackerControls::doCancel() +{ + close(); +} + +OPENTRACK_DECLARE_TRACKER(FTNoIR_Tracker, TrackerControls, FTNoIR_TrackerDll) diff --git a/tracker-test/test.h b/tracker-test/test.h new file mode 100644 index 00000000..500b28f4 --- /dev/null +++ b/tracker-test/test.h @@ -0,0 +1,44 @@ +#pragma once +#include "ui_test.h" +#include "opentrack/plugin-api.hpp" +#include "opentrack-compat/timer.hpp" + +class FTNoIR_Tracker : public ITracker +{ +public: + FTNoIR_Tracker(); + ~FTNoIR_Tracker() override; + void start_tracker(QFrame *) override; + void data(double *data) override; + +private: + static constexpr double pi = 3.14159265358979323846; + static constexpr double r2d = 180 / pi; + static constexpr double d2r = pi / 180; + + static const double incr[6]; + double last_x[6]; + Timer t; +}; + +class TrackerControls: public ITrackerDialog +{ + Q_OBJECT + + Ui::test_ui ui; +public: + TrackerControls(); + void register_tracker(ITracker *) override {} + void unregister_tracker() override {} +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_TrackerDll : public Metadata +{ +public: + QString name() { return QString("Testing - sine wave"); } + QIcon icon() { return QIcon(":/images/facetracknoir.png"); } +}; + diff --git a/tracker-test/test.ui b/tracker-test/test.ui new file mode 100644 index 00000000..2b33524f --- /dev/null +++ b/tracker-test/test.ui @@ -0,0 +1,59 @@ + + + test_ui + + + Qt::NonModal + + + + 0 + 0 + 352 + 224 + + + + Sine wave + + + + ../gui/images/facetracknoir.png../gui/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/tracker-test/test_dialog.cpp b/tracker-test/test_dialog.cpp new file mode 100644 index 00000000..38578ffc --- /dev/null +++ b/tracker-test/test_dialog.cpp @@ -0,0 +1,3 @@ +#include "test.h" +#include "opentrack/plugin-api.hpp" + -- cgit v1.2.3