summaryrefslogtreecommitdiffhomepage
path: root/tracker-test
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-test')
-rw-r--r--tracker-test/CMakeLists.txt5
-rw-r--r--tracker-test/lang/de_DE.ts22
-rw-r--r--tracker-test/lang/nl_NL.ts8
-rw-r--r--tracker-test/lang/ru_RU.ts8
-rw-r--r--tracker-test/lang/stub.ts8
-rw-r--r--tracker-test/lang/zh_CN.ts22
-rw-r--r--tracker-test/test.cpp75
-rw-r--r--tracker-test/test.h12
-rw-r--r--tracker-test/test.ui27
9 files changed, 117 insertions, 70 deletions
diff --git a/tracker-test/CMakeLists.txt b/tracker-test/CMakeLists.txt
index 334aa38e..e300c83c 100644
--- a/tracker-test/CMakeLists.txt
+++ b/tracker-test/CMakeLists.txt
@@ -1,4 +1 @@
-set(SDK_TEST_TRACKER FALSE CACHE BOOL "sine wave test tracker")
-if(SDK_TEST_TRACKER)
- otr_module(tracker-test)
-endif()
+otr_module(tracker-test)
diff --git a/tracker-test/lang/de_DE.ts b/tracker-test/lang/de_DE.ts
new file mode 100644
index 00000000..e11372b6
--- /dev/null
+++ b/tracker-test/lang/de_DE.ts
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="de_DE">
+<context>
+ <name>test_metadata</name>
+ <message>
+ <source>Test tracker</source>
+ <translation>Test-Tracker</translation>
+ </message>
+</context>
+<context>
+ <name>test_ui</name>
+ <message>
+ <source>Sine wave</source>
+ <translation>Sinus-Welle</translation>
+ </message>
+ <message>
+ <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <translation>Beim Klick auf „Abbrechen“ wird die Anwendung sofort abstürzen.</translation>
+ </message>
+</context>
+</TS>
diff --git a/tracker-test/lang/nl_NL.ts b/tracker-test/lang/nl_NL.ts
index a136c79e..b4150273 100644
--- a/tracker-test/lang/nl_NL.ts
+++ b/tracker-test/lang/nl_NL.ts
@@ -4,17 +4,19 @@
<context>
<name>test_metadata</name>
<message>
- <location filename="../test.h" line="+39"/>
- <source>Testing - sine wave</source>
+ <source>Test tracker</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>test_ui</name>
<message>
- <location filename="../test.ui" line="+17"/>
<source>Sine wave</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
</TS>
diff --git a/tracker-test/lang/ru_RU.ts b/tracker-test/lang/ru_RU.ts
index 30cda523..c69b3728 100644
--- a/tracker-test/lang/ru_RU.ts
+++ b/tracker-test/lang/ru_RU.ts
@@ -4,17 +4,19 @@
<context>
<name>test_metadata</name>
<message>
- <location filename="../test.h" line="+39"/>
- <source>Testing - sine wave</source>
+ <source>Test tracker</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>test_ui</name>
<message>
- <location filename="../test.ui" line="+17"/>
<source>Sine wave</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
</TS>
diff --git a/tracker-test/lang/stub.ts b/tracker-test/lang/stub.ts
index 12952b2a..78f647f5 100644
--- a/tracker-test/lang/stub.ts
+++ b/tracker-test/lang/stub.ts
@@ -4,17 +4,19 @@
<context>
<name>test_metadata</name>
<message>
- <location filename="../test.h" line="+39"/>
- <source>Testing - sine wave</source>
+ <source>Test tracker</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>test_ui</name>
<message>
- <location filename="../test.ui" line="+17"/>
<source>Sine wave</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
</TS>
diff --git a/tracker-test/lang/zh_CN.ts b/tracker-test/lang/zh_CN.ts
new file mode 100644
index 00000000..5df28f2f
--- /dev/null
+++ b/tracker-test/lang/zh_CN.ts
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="zh_CN">
+<context>
+ <name>test_metadata</name>
+ <message>
+ <source>Test tracker</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>test_ui</name>
+ <message>
+ <source>Sine wave</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp
index 06a4f1f2..3ca47ae1 100644
--- a/tracker-test/test.cpp
+++ b/tracker-test/test.cpp
@@ -8,77 +8,58 @@
#include "test.h"
#include "api/plugin-api.hpp"
-#include <cmath>
+#include "compat/math-imports.hpp"
+
+#include <QPushButton>
+#include <cmath>
#include <QDebug>
-const double test_tracker::incr[6] =
+static const double incr[3] =
{
- 50, 40, 80,
- 70, 5, 3
+ 10, 5, 3
};
-test_tracker::test_tracker() :
- last_x { 0, 0, 0, 0, 0, 0 }
-{
-}
+static const double max_values[3] = {
+ 180, 2, 3,
+};
-test_tracker::~test_tracker()
-{
-}
+test_tracker::test_tracker() = default;
+test_tracker::~test_tracker() = default;
-void test_tracker::start_tracker(QFrame*)
+module_status test_tracker::start_tracker(QFrame*)
{
t.start();
+ return {};
}
-#ifdef EMIT_NAN
-# include <cstdlib>
-#endif
-
void test_tracker::data(double *data)
{
- using std::fmod;
- using std::sin;
- using std::fabs;
- using std::copysign;
-
const double dt = t.elapsed_seconds();
t.start();
-#ifdef EMIT_NAN
- if ((rand()%4) == 0)
+ for (int i = 0; i < 3; i++)
{
- for (int i = 0; i < 6; i++)
- data[i] = 0./0.;
+ double last_ = last[i];
+ double max = max_values[i] * 2;
+ double incr_ = incr[i];
+ double x = fmod(last_ + incr_ * dt, max);
+ last[i] = x;
+ if (x > max_values[i])
+ x = -max + x;
+ data[i+3] = x;
}
- else
-#endif
- for (int i = 0; i < 6; i++)
- {
- double x = last_x[i] + incr[i] * dt;
- if (x > 180)
- x = -360 + x;
- else if (x < -180)
- x = 360 + x;
- x = copysign(fmod(fabs(x), 360), x);
- last_x[i] = x;
-
- if (i >= 3)
- {
- data[i] = x;
- }
- else
- {
- data[i] = x * 100/180.;
- }
- }
}
-test_dialog::test_dialog()
+test_dialog::test_dialog() // NOLINT(cppcoreguidelines-pro-type-member-init)
{
ui.setupUi(this);
+ connect(ui.buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* btn) {
+ if (btn == ui.buttonBox->button(QDialogButtonBox::Abort))
+ *(volatile int*)nullptr /*NOLINT*/ = 0;
+ });
+
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
}
diff --git a/tracker-test/test.h b/tracker-test/test.h
index 01133617..320145ad 100644
--- a/tracker-test/test.h
+++ b/tracker-test/test.h
@@ -10,12 +10,11 @@ class test_tracker : public ITracker
public:
test_tracker();
~test_tracker() override;
- void start_tracker(QFrame *) override;
+ module_status start_tracker(QFrame *) override;
void data(double *data) override;
private:
- static const double incr[6];
- double last_x[6];
+ double last[6] {};
Timer t;
};
@@ -35,8 +34,9 @@ private slots:
class test_metadata : public Metadata
{
-public:
- QString name() { return QString(QCoreApplication::translate("test_metadata", "Testing - sine wave")); }
- QIcon icon() { return QIcon(":/images/facetracknoir.png"); }
+ Q_OBJECT
+
+ QString name() override { return tr("Test tracker"); }
+ QIcon icon() override { return QIcon(":/images/opentrack.png"); }
};
diff --git a/tracker-test/test.ui b/tracker-test/test.ui
index 1141d584..509eb819 100644
--- a/tracker-test/test.ui
+++ b/tracker-test/test.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>184</width>
- <height>39</height>
+ <width>278</width>
+ <height>58</height>
</rect>
</property>
<property name="windowTitle">
@@ -18,7 +18,7 @@
</property>
<property name="windowIcon">
<iconset>
- <normaloff>../gui/images/facetracknoir.png</normaloff>../gui/images/facetracknoir.png</iconset>
+ <normaloff>../gui/images/opentrack.png</normaloff>../gui/images/opentrack.png</iconset>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
@@ -28,9 +28,28 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Pressing &quot;Abort&quot; will immediately crash the application.</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ <set>QDialogButtonBox::Abort|QDialogButtonBox::Close</set>
</property>
</widget>
</item>