diff options
Diffstat (limited to 'tracker-fusion')
| -rw-r--r-- | tracker-fusion/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | tracker-fusion/fusion-tracker-logo.png | bin | 0 -> 1985 bytes | |||
| -rw-r--r-- | tracker-fusion/fusion.cpp | 200 | ||||
| -rw-r--r-- | tracker-fusion/fusion.h | 62 | ||||
| -rw-r--r-- | tracker-fusion/fusion.qrc | 5 | ||||
| -rw-r--r-- | tracker-fusion/fusion.ui | 180 | ||||
| -rw-r--r-- | tracker-fusion/fusion_dialog.cpp | 2 | ||||
| -rw-r--r-- | tracker-fusion/lang/de_DE.ts | 56 | ||||
| -rw-r--r-- | tracker-fusion/lang/nl_NL.ts | 56 | ||||
| -rw-r--r-- | tracker-fusion/lang/ru_RU.ts | 56 | ||||
| -rw-r--r-- | tracker-fusion/lang/stub.ts | 56 | ||||
| -rw-r--r-- | tracker-fusion/lang/zh_CN.ts | 56 |
12 files changed, 730 insertions, 0 deletions
diff --git a/tracker-fusion/CMakeLists.txt b/tracker-fusion/CMakeLists.txt new file mode 100644 index 00000000..4125d630 --- /dev/null +++ b/tracker-fusion/CMakeLists.txt @@ -0,0 +1 @@ +otr_module(tracker-fusion) diff --git a/tracker-fusion/fusion-tracker-logo.png b/tracker-fusion/fusion-tracker-logo.png Binary files differnew file mode 100644 index 00000000..63d541e1 --- /dev/null +++ b/tracker-fusion/fusion-tracker-logo.png diff --git a/tracker-fusion/fusion.cpp b/tracker-fusion/fusion.cpp new file mode 100644 index 00000000..fba38d3d --- /dev/null +++ b/tracker-fusion/fusion.cpp @@ -0,0 +1,200 @@ +/* Copyright (c) 2017 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. + */ + +#undef NDEBUG + +#include "fusion.h" +#include "compat/library-path.hpp" + +#include <QDebug> +#include <QMessageBox> +#include <QApplication> +#include <cassert> + +static const char* own_name = "fusion"; + +static auto get_modules() +{ + return Modules(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH, dylib_load_quiet); +} + +fusion_tracker::fusion_tracker() = default; + +fusion_tracker::~fusion_tracker() +{ + // CAVEAT order matters + rot_tracker = nullptr; + pos_tracker = nullptr; + + rot_dylib = nullptr; + pos_dylib = nullptr; +} + +const QString& fusion_tracker::caption() +{ + static const QString caption = tr("Fusion tracker"); + return caption; +} + +module_status fusion_tracker::start_tracker(QFrame* frame) +{ + assert(!rot_tracker && !pos_tracker); + assert(!rot_dylib && !pos_dylib); + + QString err; + module_status status; + + fusion_settings s; + const QString rot_tracker_name = s.rot_tracker_name().toString(); + const QString pos_tracker_name = s.pos_tracker_name().toString(); + + assert(rot_tracker_name != own_name); + assert(pos_tracker_name != own_name); + + if (rot_tracker_name.isEmpty() || pos_tracker_name.isEmpty()) + { + err = tr("Trackers not selected."); + goto end; + } + + if (rot_tracker_name == pos_tracker_name) + { + err = tr("Select different trackers for rotation and position."); + goto end; + } + + { + Modules libs = get_modules(); + + for (auto& t : libs.trackers()) + { + if (t->module_name == rot_tracker_name) + { + assert(!rot_dylib); + rot_dylib = t; + } + + if (t->module_name == pos_tracker_name) + { + assert(!pos_dylib); + pos_dylib = t; + } + } + } + + if (!rot_dylib || !pos_dylib) + goto end; + + rot_tracker = make_dylib_instance<ITracker>(rot_dylib); + pos_tracker = make_dylib_instance<ITracker>(pos_dylib); + + status = pos_tracker->start_tracker(frame); + + if (!status.is_ok()) + { + err = pos_dylib->name + QStringLiteral(":\n ") + status.error; + goto end; + } + + if (frame->layout() == nullptr) + { + status = rot_tracker->start_tracker(frame); + if (!status.is_ok()) + { + err = rot_dylib->name + QStringLiteral(":\n ") + status.error; + goto end; + } + } + else + { + other_frame->setFixedSize(320, 240); // XXX magic frame size + other_frame->setVisible(false); + + rot_tracker->start_tracker(&*other_frame); + } + +end: + if (!err.isEmpty()) + return error(err); + else + return status_ok(); +} + +void fusion_tracker::data(double *data) +{ + if (pos_tracker && rot_tracker) + { + rot_tracker->data(rot_tracker_data); + pos_tracker->data(pos_tracker_data); + + for (unsigned k = 0; k < 3; k++) + data[k] = pos_tracker_data[k]; + for (unsigned k = 3; k < 6; k++) + data[k] = rot_tracker_data[k]; + } +} + +fusion_dialog::fusion_dialog() +{ + ui.setupUi(this); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + ui.rot_tracker->addItem({}); + ui.pos_tracker->addItem({}); + + Modules libs = get_modules(); + + for (auto& m : libs.trackers()) + { + if (m->module_name == own_name) + continue; + + ui.rot_tracker->addItem(m->icon, m->name, QVariant(m->module_name)); + ui.pos_tracker->addItem(m->icon, m->name, QVariant(m->module_name)); + } + + ui.rot_tracker->setCurrentIndex(0); + ui.pos_tracker->setCurrentIndex(0); + + tie_setting(s.rot_tracker_name, ui.rot_tracker); + tie_setting(s.pos_tracker_name, ui.pos_tracker); +} + +void fusion_dialog::doOK() +{ + const int rot_idx = ui.rot_tracker->currentIndex() - 1; + const int pos_idx = ui.pos_tracker->currentIndex() - 1; + + if (rot_idx == -1 || pos_idx == -1 || rot_idx == pos_idx) + { + QMessageBox::warning(this, + fusion_tracker::caption(), + tr("Fusion tracker only works when distinct trackers are selected " + "for rotation and position."), + QMessageBox::Close); + } + + s.b->save(); + close(); +} + +void fusion_dialog::doCancel() +{ + close(); +} + +fusion_settings::fusion_settings() : + opts("fusion-tracker"), + rot_tracker_name(b, "rot-tracker", ""), + pos_tracker_name(b, "pos-tracker", "") +{ +} + +OPENTRACK_DECLARE_TRACKER(fusion_tracker, fusion_dialog, fusion_metadata) diff --git a/tracker-fusion/fusion.h b/tracker-fusion/fusion.h new file mode 100644 index 00000000..daadf27d --- /dev/null +++ b/tracker-fusion/fusion.h @@ -0,0 +1,62 @@ +#pragma once + +#include "api/plugin-api.hpp" +#include "api/plugin-support.hpp" +#include "options/options.hpp" +using namespace options; + +#include <memory> + +#include <QObject> +#include <QFrame> +#include <QCoreApplication> + +struct fusion_settings final : opts +{ + value<QVariant> rot_tracker_name, pos_tracker_name; + + fusion_settings(); +}; + +class fusion_tracker : public QObject, public ITracker +{ + Q_OBJECT + + double rot_tracker_data[6] {}, pos_tracker_data[6] {}; + + std::unique_ptr<QFrame> other_frame { std::make_unique<QFrame>() }; + std::shared_ptr<dylib> rot_dylib, pos_dylib; + std::shared_ptr<ITracker> rot_tracker, pos_tracker; + +public: + fusion_tracker(); + ~fusion_tracker() override; + module_status start_tracker(QFrame*) override; + void data(double* data) override; + + static const QString& caption(); +}; + +#include "ui_fusion.h" + +class fusion_dialog : public ITrackerDialog +{ + Q_OBJECT + + fusion_settings s; + Ui::fusion_ui ui; +public: + fusion_dialog(); +private slots: + void doOK(); + void doCancel(); +}; + +class fusion_metadata : public Metadata +{ + Q_OBJECT + + QString name() { return tr("Fusion"); } + QIcon icon() { return QIcon(":/images/fusion-tracker-logo.png"); } +}; + diff --git a/tracker-fusion/fusion.qrc b/tracker-fusion/fusion.qrc new file mode 100644 index 00000000..32a5913e --- /dev/null +++ b/tracker-fusion/fusion.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/images"> + <file>fusion-tracker-logo.png</file> + </qresource> +</RCC> diff --git a/tracker-fusion/fusion.ui b/tracker-fusion/fusion.ui new file mode 100644 index 00000000..1eb8992e --- /dev/null +++ b/tracker-fusion/fusion.ui @@ -0,0 +1,180 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>fusion_ui</class> + <widget class="QWidget" name="fusion_ui"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>397</width> + <height>180</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Fusion</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>:/fusion-tracker-logo.png</normaloff>:/fusion-tracker-logo.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QFrame" name="frame_2"> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <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>Set distinct trackers for rotation and position input.</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Configure the trackers on the main window. It's required that they're both distinct, and both are set to something.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QFrame" name="frame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>89</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Rotation</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="rot_tracker"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>3</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>266</width> + <height>0</height> + </size> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>89</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Position</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="pos_tracker"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>3</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>266</width> + <height>0</height> + </size> + </property> + </widget> + </item> + </layout> + </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::Save</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="fusion.qrc"/> + </resources> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> diff --git a/tracker-fusion/fusion_dialog.cpp b/tracker-fusion/fusion_dialog.cpp new file mode 100644 index 00000000..ca05531a --- /dev/null +++ b/tracker-fusion/fusion_dialog.cpp @@ -0,0 +1,2 @@ +#include "fusion.h" + diff --git a/tracker-fusion/lang/de_DE.ts b/tracker-fusion/lang/de_DE.ts new file mode 100644 index 00000000..3019b655 --- /dev/null +++ b/tracker-fusion/lang/de_DE.ts @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +<context> + <name>fusion_dialog</name> + <message> + <source>Fusion tracker only works when distinct trackers are selected for rotation and position.</source> + <translation>Der Fusion-Tracker funktioniert nur, wenn für Rotation und Position unterschiedliche Tracker ausgewählt wurden.</translation> + </message> +</context> +<context> + <name>fusion_metadata</name> + <message> + <source>Fusion</source> + <translation>Fusion</translation> + </message> +</context> +<context> + <name>fusion_tracker</name> + <message> + <source>Fusion tracker</source> + <translation>Fusion-Tracker</translation> + </message> + <message> + <source>Trackers not selected.</source> + <translation>Keine Tracker ausgewählt.</translation> + </message> + <message> + <source>Select different trackers for rotation and position.</source> + <translation>Wähle unterschiedliche Tracker für Rotation und Position.</translation> + </message> +</context> +<context> + <name>fusion_ui</name> + <message> + <source>Fusion</source> + <translation>Fusion</translation> + </message> + <message> + <source>Set distinct trackers for rotation and position input.</source> + <translation>Wähle unterschiedliche Tracker für Rotations- und Positionseingabe.</translation> + </message> + <message> + <source>Configure the trackers on the main window. It's required that they're both distinct, and both are set to something.</source> + <translation>Konfiguriere die Tracker im Hauptfenster. Es ist unbedingt erforderlich, dass zwei unterschiedliche Tracker ausgewählt werden, und beides zumindest irgendeinen Tracker auswählt.</translation> + </message> + <message> + <source>Rotation</source> + <translation>Rotation</translation> + </message> + <message> + <source>Position</source> + <translation>Position</translation> + </message> +</context> +</TS> diff --git a/tracker-fusion/lang/nl_NL.ts b/tracker-fusion/lang/nl_NL.ts new file mode 100644 index 00000000..3ad3efec --- /dev/null +++ b/tracker-fusion/lang/nl_NL.ts @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="nl_NL"> +<context> + <name>fusion_dialog</name> + <message> + <source>Fusion tracker only works when distinct trackers are selected for rotation and position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_metadata</name> + <message> + <source>Fusion</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_tracker</name> + <message> + <source>Fusion tracker</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Trackers not selected.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Select different trackers for rotation and position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_ui</name> + <message> + <source>Fusion</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Set distinct trackers for rotation and position input.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Configure the trackers on the main window. It's required that they're both distinct, and both are set to something.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Rotation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Position</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tracker-fusion/lang/ru_RU.ts b/tracker-fusion/lang/ru_RU.ts new file mode 100644 index 00000000..9453b167 --- /dev/null +++ b/tracker-fusion/lang/ru_RU.ts @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="ru_RU"> +<context> + <name>fusion_dialog</name> + <message> + <source>Fusion tracker only works when distinct trackers are selected for rotation and position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_metadata</name> + <message> + <source>Fusion</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_tracker</name> + <message> + <source>Fusion tracker</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Trackers not selected.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Select different trackers for rotation and position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_ui</name> + <message> + <source>Fusion</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Set distinct trackers for rotation and position input.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Configure the trackers on the main window. It's required that they're both distinct, and both are set to something.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Rotation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Position</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tracker-fusion/lang/stub.ts b/tracker-fusion/lang/stub.ts new file mode 100644 index 00000000..7aed6201 --- /dev/null +++ b/tracker-fusion/lang/stub.ts @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1"> +<context> + <name>fusion_dialog</name> + <message> + <source>Fusion tracker only works when distinct trackers are selected for rotation and position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_metadata</name> + <message> + <source>Fusion</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_tracker</name> + <message> + <source>Fusion tracker</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Trackers not selected.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Select different trackers for rotation and position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_ui</name> + <message> + <source>Fusion</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Set distinct trackers for rotation and position input.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Configure the trackers on the main window. It's required that they're both distinct, and both are set to something.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Rotation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Position</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tracker-fusion/lang/zh_CN.ts b/tracker-fusion/lang/zh_CN.ts new file mode 100644 index 00000000..e1345e4c --- /dev/null +++ b/tracker-fusion/lang/zh_CN.ts @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="zh_CN"> +<context> + <name>fusion_dialog</name> + <message> + <source>Fusion tracker only works when distinct trackers are selected for rotation and position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_metadata</name> + <message> + <source>Fusion</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_tracker</name> + <message> + <source>Fusion tracker</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Trackers not selected.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Select different trackers for rotation and position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>fusion_ui</name> + <message> + <source>Fusion</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Set distinct trackers for rotation and position input.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Configure the trackers on the main window. It's required that they're both distinct, and both are set to something.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Rotation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Position</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> |
