diff options
-rw-r--r-- | tracker-test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tracker-test/test.cpp | 83 | ||||
-rw-r--r-- | tracker-test/test.h | 44 | ||||
-rw-r--r-- | tracker-test/test.ui | 59 | ||||
-rw-r--r-- | tracker-test/test_dialog.cpp | 3 |
5 files changed, 193 insertions, 0 deletions
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 <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 "test.h" +#include "opentrack/plugin-api.hpp" +#include <cmath> + +#include <QDebug> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>test_ui</class> + <widget class="QWidget" name="test_ui"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>352</width> + <height>224</height> + </rect> + </property> + <property name="windowTitle"> + <string>Sine wave</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>../gui/images/facetracknoir.png</normaloff>../gui/images/facetracknoir.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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" + |