From 1863f330b2b366f504a8b510d282163737d9f715 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 28 Oct 2014 09:06:15 +0100 Subject: rename --- facetracknoir/curve-config.cpp | 1 - facetracknoir/curve-config.h | 2 +- facetracknoir/facetracknoir.cpp | 408 ------------ facetracknoir/facetracknoir.h | 117 ---- facetracknoir/facetracknoir.ui | 1202 ---------------------------------- facetracknoir/ftnoir_curves.ui | 1069 ------------------------------ facetracknoir/main-facetracknoir.qrc | 9 - facetracknoir/main.cpp | 2 +- facetracknoir/main.ui | 1202 ++++++++++++++++++++++++++++++++++ facetracknoir/mapping.ui | 1069 ++++++++++++++++++++++++++++++ facetracknoir/ui-res.qrc | 9 + facetracknoir/ui.cpp | 424 ++++++++++++ facetracknoir/ui.h | 120 ++++ opentrack/main-settings.hpp | 4 +- 14 files changed, 2829 insertions(+), 2809 deletions(-) delete mode 100644 facetracknoir/facetracknoir.cpp delete mode 100644 facetracknoir/facetracknoir.h delete mode 100644 facetracknoir/facetracknoir.ui delete mode 100644 facetracknoir/ftnoir_curves.ui delete mode 100644 facetracknoir/main-facetracknoir.qrc create mode 100644 facetracknoir/main.ui create mode 100644 facetracknoir/mapping.ui create mode 100644 facetracknoir/ui-res.qrc create mode 100644 facetracknoir/ui.cpp create mode 100644 facetracknoir/ui.h diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index f00d3657..db5a4a75 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -1,4 +1,3 @@ -#include "./facetracknoir.h" #include "./curve-config.h" #include "opentrack/main-settings.hpp" MapWidget::MapWidget(Mappings& m, main_settings& s) : diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index 2104b7fa..d1ef7ad2 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -1,7 +1,7 @@ #pragma once #include #include "opentrack/mappings.hpp" -#include "ui_ftnoir_curves.h" +#include "ui_mapping.h" class MapWidget: public QWidget { diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp deleted file mode 100644 index 3ea95baa..00000000 --- a/facetracknoir/facetracknoir.cpp +++ /dev/null @@ -1,408 +0,0 @@ -/******************************************************************************* -* FaceTrackNoIR This program is a private project of the some enthusiastic -* gamers from Holland, who don't like to pay much for -* head-tracking. -* -* Copyright (C) 2011 Wim Vriend (Developing) -* Ron Hendriks (Researching and Testing) -* -* Homepage -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 3 of the License, or (at your -* option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, see . -*********************************************************************************/ -#include "facetracknoir.h" -#include "opentrack/tracker.h" -#include - -#ifndef _WIN32 -# include -#else -# include -#endif - -MainWindow::MainWindow() : - pose_update_timer(this), - kbd_quit(QKeySequence("Ctrl+Q"), this), - no_feed_pixmap(":/images/no-feed.png") -{ - ui.setupUi(this); - - setFixedSize(size()); - - updateButtonState(false, false); - ui.video_frame_label->setPixmap(no_feed_pixmap); - QDir::setCurrent(QCoreApplication::applicationDirPath()); - - connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); - connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); - connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); - - connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); - connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); - connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); - connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showProtocolSettings())); - connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterSettings())); - - modules.filters().push_front(std::make_shared("", dylib::Filter)); - - for (auto x : modules.trackers()) - ui.iconcomboTrackerSource->addItem(x->icon, x->name); - - for (auto x : modules.protocols()) - ui.iconcomboProtocol->addItem(x->icon, x->name); - - for (auto x : modules.filters()) - ui.iconcomboFilter->addItem(x->icon, x->name); - - fill_profile_combobox(); - - tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); - tie_setting(s.protocol_dll, ui.iconcomboProtocol); - tie_setting(s.filter_dll, ui.iconcomboFilter); - - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); - connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); - - connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); - connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); - kbd_quit.setEnabled(true); -} - -MainWindow::~MainWindow() -{ - stopTracker(); - save(); - _exit(0); -} - -void MainWindow::open() { - QFileDialog dialog(this); - dialog.setFileMode(QFileDialog::ExistingFile); - - QString fileName = dialog.getOpenFileName( - this, - tr("Open the settings file"), - QCoreApplication::applicationDirPath() + "/settings/", - tr("Settings file (*.ini);;All Files (*)"), - NULL); - - if (! fileName.isEmpty() ) { - { - QSettings settings("opentrack"); - settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); - } - fill_profile_combobox(); - load_settings(); - } -} - -void MainWindow::save_mappings() { - pose.save_mappings(); -} - -#if defined(__unix) || defined(__linux) || defined(__APPLE__) -# include -#endif - -void MainWindow::save() { - b->save(); - save_mappings(); - -#if defined(__unix) || defined(__linux) - QSettings settings("opentrack"); - const QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QByteArray bytes = QFile::encodeName(currentFile); - const char* filename_as_asciiz = bytes.constData(); - - if (access(filename_as_asciiz, R_OK | W_OK)) - { - QMessageBox::warning(this, "Something went wrong", "Check permissions and ownership for your .ini file!", QMessageBox::Ok, QMessageBox::NoButton); - } -#endif -} - -void MainWindow::saveAs() -{ - QSettings settings("opentrack"); - QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - - QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), - oldFile, - tr("Settings file (*.ini);;All Files (*)")); - if (!fileName.isEmpty()) { - - QFileInfo newFileInfo ( fileName ); - if ((newFileInfo.exists()) && (oldFile != fileName)) { - QFile newFileFile ( fileName ); - newFileFile.remove(); - } - - QFileInfo oldFileInfo ( oldFile ); - if (oldFileInfo.exists()) { - QFile oldFileFile ( oldFile ); - oldFileFile.copy( fileName ); - } - - settings.setValue ("SettingsFile", fileName); - save(); - } - - fill_profile_combobox(); -} - -void MainWindow::load_mappings() { - pose.load_mappings(); -} - -void MainWindow::load_settings() { - b->reload(); - load_mappings(); -} - -extern "C" volatile const char* opentrack_version; - -void MainWindow::fill_profile_combobox() -{ - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() - + "/settings/default.ini" ).toString(); - qDebug() << "Config file now" << currentFile; - QFileInfo pathInfo ( currentFile ); - setWindowTitle(QString( const_cast(opentrack_version) + QStringLiteral(" :: ")) + pathInfo.fileName()); - QDir settingsDir( pathInfo.dir() ); - auto iniFileList = settingsDir.entryList( QStringList { "*.ini" } , QDir::Files, QDir::Name ); - ui.iconcomboProfile->clear(); - for (auto x : iniFileList) - ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); - ui.iconcomboProfile->setCurrentText(pathInfo.fileName()); -} - -void MainWindow::updateButtonState(bool running, bool inertialp) -{ - bool not_running = !running; - ui.iconcomboProfile->setEnabled ( not_running ); - ui.btnStartTracker->setEnabled ( not_running ); - ui.btnStopTracker->setEnabled ( running ); - ui.iconcomboProtocol->setEnabled ( not_running ); - ui.iconcomboFilter->setEnabled ( not_running ); - ui.iconcomboTrackerSource->setEnabled(not_running); - ui.btnStartTracker->setEnabled(not_running); - ui.btnStopTracker->setEnabled(running); - ui.video_frame_label->setVisible(not_running || inertialp); -} - -void MainWindow::bindKeyboardShortcuts() -{ - if (work) - work->reload_shortcuts(); -} - -void MainWindow::startTracker( ) { - b->save(); - load_settings(); - bindKeyboardShortcuts(); - - // tracker dtor needs run first - work = nullptr; - - libs = SelectedLibraries(ui.video_frame, current_tracker(), current_protocol(), current_filter()); - work = std::make_shared(s, pose, libs, this, winId()); - - { - double p[6] = {0,0,0, 0,0,0}; - display_pose(p, p); - } - - if (!libs.correct) - { - QMessageBox::warning(this, "Library load error", - "One of libraries failed to load. Check installation.", - QMessageBox::Ok, - QMessageBox::NoButton); - return; - } - - pose_update_timer.start(50); - - // NB check valid since SelectedLibraries ctor called - // trackers take care of layout state updates - const bool is_inertial = ui.video_frame->layout() == nullptr; - updateButtonState(true, is_inertial); -} - -void MainWindow::stopTracker( ) { - //ui.game_name->setText("Not connected"); - - pose_update_timer.stop(); - ui.pose_display->rotateBy(0, 0, 0); - - if (pTrackerDialog) - { - pTrackerDialog->unregister_tracker(); - pTrackerDialog = nullptr; - } - - if (pProtocolDialog) - { - pProtocolDialog->unregister_protocol(); - pProtocolDialog = nullptr; - } - - if (pFilterDialog) - { - pFilterDialog->unregister_filter(); - pFilterDialog = nullptr; - } - - work = nullptr; - libs = SelectedLibraries(); - - { - double p[6] = {0,0,0, 0,0,0}; - display_pose(p, p); - } - updateButtonState(false, false); -} - -void MainWindow::display_pose(const double *mapped, const double *raw) -{ - ui.pose_display->rotateBy(mapped[Yaw], mapped[Pitch], mapped[Roll]); - - if (mapping_widget) - mapping_widget->update(); - - double mapped_[6], raw_[6]; - - for (int i = 0; i < 6; i++) - { - mapped_[i] = (int) mapped[i]; - raw_[i] = (int) raw[i]; - } - - ui.raw_x->display(raw_[TX]); - ui.raw_y->display(raw_[TY]); - ui.raw_z->display(raw_[TZ]); - ui.raw_yaw->display(raw_[Yaw]); - ui.raw_pitch->display(raw_[Pitch]); - ui.raw_roll->display(raw_[Roll]); - - ui.pose_x->display(mapped_[TX]); - ui.pose_y->display(mapped_[TY]); - ui.pose_z->display(mapped_[TZ]); - ui.pose_yaw->display(mapped_[Yaw]); - ui.pose_pitch->display(mapped_[Pitch]); - ui.pose_roll->display(mapped_[Roll]); -} - -void MainWindow::showHeadPose() -{ - double mapped[6], raw[6]; - - work->tracker->get_raw_and_mapped_poses(mapped, raw); - - display_pose(mapped, raw); - -#if 0 - if (libs.pProtocol) - { - const QString name = libs.pProtocol->game_name(); - ui.game_name->setText(name); - } -#endif -} - -template -ptr mk_dialog(ptr lib) -{ - if (lib) - { - auto dialog = ptr(reinterpret_cast(lib->Dialog())); - dialog->setWindowFlags(Qt::Dialog); - dialog->setFixedSize(dialog->size()); - return dialog; - } - - return nullptr; -} - -void MainWindow::showTrackerSettings() -{ - auto dialog = mk_dialog(current_tracker()); - - if (dialog) { - pTrackerDialog = dialog; - dialog->register_tracker(libs.pTracker.get()); - dialog->show(); - } -} - -void MainWindow::showProtocolSettings() { - auto dialog = mk_dialog(current_protocol()); - - if (dialog) { - pProtocolDialog = dialog; - dialog->show(); - } -} - -void MainWindow::showFilterSettings() { - auto dialog = mk_dialog(current_filter()); - - if (dialog) { - pFilterDialog = dialog; - dialog->register_filter(libs.pFilter.get()); - dialog->show(); - } -} - -void MainWindow::showKeyboardShortcuts() { - shortcuts_widget = std::make_shared(); - shortcuts_widget->setWindowFlags(Qt::Dialog); - connect(shortcuts_widget.get(), SIGNAL(reload()), this, SLOT(bindKeyboardShortcuts())); - shortcuts_widget->show(); -} - -void MainWindow::showCurveConfiguration() { - mapping_widget = std::make_shared(pose, s); - mapping_widget->setWindowFlags(Qt::Dialog); - mapping_widget->show(); -} - -void MainWindow::exit() { - QCoreApplication::exit(0); -} - -void MainWindow::profileSelected(int index) -{ - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QFileInfo pathInfo ( currentFile ); - settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + ui.iconcomboProfile->itemText(index)); - load_settings(); -} - -void MainWindow::shortcutRecentered() -{ - qDebug() << "Center"; - if (work) - work->tracker->center(); -} - -void MainWindow::shortcutToggled() -{ - qDebug() << "Toggle"; - if (work) - work->tracker->toggle_enabled(); -} diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h deleted file mode 100644 index 6e7ea4e0..00000000 --- a/facetracknoir/facetracknoir.h +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* -* MainWindow This program is a private project of the some enthusiastic -* gamers from Holland, who don't like to pay much for -* head-tracking. -* -* Copyright (C) 2010 Wim Vriend (Developing) -* Ron Hendriks (Researching and Testing) -* -* Homepage -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 3 of the License, or (at your -* option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, see . -*********************************************************************************/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if !defined(_WIN32) -# include "qxt-mini/QxtGlobalShortcut" -#else -# include -#endif - -#include "ui_facetracknoir.h" - -#include "opentrack/options.hpp" -#include "opentrack/main-settings.hpp" -#include "opentrack/plugin-support.h" -#include "opentrack/tracker.h" -#include "opentrack/shortcuts.h" -#include "opentrack/work.hpp" -#include "opentrack/state.hpp" -#include "curve-config.h" - -using namespace options; - -class MainWindow : public QMainWindow, private State -{ - Q_OBJECT - - Ui::OpentrackUI ui; - QTimer pose_update_timer; - ptr shortcuts_widget; - ptr mapping_widget; - QShortcut kbd_quit; - QPixmap no_feed_pixmap; - ptr pFilterDialog; - ptr pProtocolDialog; - ptr pTrackerDialog; - - ptr current_tracker() - { - return modules.trackers().value(ui.iconcomboTrackerSource->currentIndex(), nullptr); - } - ptr current_protocol() - { - return modules.protocols().value(ui.iconcomboProtocol->currentIndex(), nullptr); - } - ptr current_filter() - { - return modules.filters().value(ui.iconcomboFilter->currentIndex(), nullptr); - } - - void createIconGroupBox(); - void load_settings(); - void updateButtonState(bool running, bool inertialp); - void fill_profile_combobox(); - void display_pose(const double* mapped, const double* raw); - -public slots: - void shortcutRecentered(); - void shortcutToggled(); - void bindKeyboardShortcuts(); -private slots: - void open(); - void save(); - void saveAs(); - void exit(); - void profileSelected(int index); - - void showTrackerSettings(); - void showProtocolSettings(); - void showFilterSettings(); - void showKeyboardShortcuts(); - void showCurveConfiguration(); - void showHeadPose(); - - void startTracker(); - void stopTracker(); -public: - MainWindow(); - ~MainWindow(); - void save_mappings(); - void load_mappings(); -}; diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui deleted file mode 100644 index 69ae1f8a..00000000 --- a/facetracknoir/facetracknoir.ui +++ /dev/null @@ -1,1202 +0,0 @@ - - - Lovecraftian Octopus - OpentrackUI - - - - 0 - 0 - 708 - 504 - - - - - :/images/facetracknoir.png:/images/facetracknoir.png - - - #video_feed { border: 0; } - - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Raised - - - 0 - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 480 - 360 - - - - - 480 - 360 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 480 - 360 - - - - - 480 - 360 - - - - - - - - - - - - - - - - - QFrame::NoFrame - - - 0 - - - - 12 - - - 6 - - - 12 - - - 8 - - - 4 - - - - - - 0 - 0 - - - - - 80 - 90 - - - - - - - - - 0 - 0 - - - - Raw tracker data - - - - 0 - - - 0 - - - 0 - - - 0 - - - 3 - - - 2 - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - yaw - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TZ - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - TX - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TY - - - - - - - - - - - 0 - 0 - - - - Game data - - - - 0 - - - 0 - - - 0 - - - 0 - - - 3 - - - 2 - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TY - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - yaw - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TZ - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - TX - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - - - - - - - - 0 - - - 0 - - - 6 - - - 0 - - - - - Controls - - - true - - - - 4 - - - 12 - - - 4 - - - 12 - - - - - false - - - - 0 - 0 - - - - Stop - - - - - - - - 0 - 0 - - - - Start - - - - - - - - - - Settings - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 2 - - - - - - 0 - 0 - - - - Keys - - - - :/images/tools.png:/images/tools.png - - - - 80 - 24 - - - - - - - - - 0 - 0 - - - - Mapping - - - - :/images/curves.png:/images/curves.png - - - - 80 - 24 - - - - - - - - - - - Filter - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 2 - - - - - - - - true - - - ... - - - false - - - - - - - - - - Tracker - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 2 - - - - - - - - true - - - ... - - - false - - - - - - - - - - Protocol - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 2 - - - - - true - - - ... - - - false - - - - - - - - - - - - - Profile - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 2 - - - - - - 0 - 0 - - - - 10 - - - - - - - - 0 - 0 - - - - Load - - - - - - - true - - - - 0 - 0 - - - - Save - - - - - - - true - - - - 0 - 0 - - - - Save... - - - - - - - - - - - - - - - - - - GLWidget - QWidget -
glwidget.h
-
-
- - - - -
diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui deleted file mode 100644 index 9f422b9b..00000000 --- a/facetracknoir/ftnoir_curves.ui +++ /dev/null @@ -1,1069 +0,0 @@ - - - UICCurveConfigurationDialog - - - - 0 - 0 - 970 - 655 - - - - - 0 - 0 - - - - Mapping properties - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - background-color: #ccc; - - - - - - - - - QTabWidget::North - - - 6 - - - - Yaw - - - - - 0 - 0 - 930 - 260 - - - - - 255 - 0 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 166 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - - 255 - 0 - 0 - - - - - 255 - 255 - 255 - - - - - - - Pitch - - - - - 0 - 0 - 930 - 260 - - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 199 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Roll - - - - - 0 - 0 - 930 - 260 - - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 271 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - X - - - - - 0 - 0 - 930 - 260 - - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 228 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - Y - - - - - 0 - 0 - 930 - 260 - - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 229 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Z - - - - - 0 - 0 - 930 - 260 - - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 263 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - Options - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Center pose - - - Qt::AlignCenter - - - true - - - false - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - TX - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RY - - - - - - - TY - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - TZ - - - - - - - RZ - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RX - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - - - - - 65536 - 65536 - - - - - true - - - - Output remap - - - Qt::AlignCenter - - - true - - - false - - - - QLayout::SetMinAndMaxSize - - - 6 - - - - - X - - - - - - - Yaw - - - - - - - Pitch - - - - - - - Y - - - - - - - Z - - - - - - - Roll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - Source - - - - - - - Invert - - - - - - - Destination - - - - - - - - - - - 0 - 0 - - - - - - - Translation compensation - - - true - - - - - - - 0 - 0 - - - - - - - Enable - - - - - - - - - - Disable Z axis compensation - - - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - QFunctionConfigurator - QWidget -
qfunctionconfigurator.h
-
-
- - pos_rx - pos_ry - pos_rz - ry_altp - rz_altp - tx_altp - ty_altp - tz_altp - tcomp_enable - tabWidget - pos_tx - buttonBox - pos_ty - rx_altp - pos_tz - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
diff --git a/facetracknoir/main-facetracknoir.qrc b/facetracknoir/main-facetracknoir.qrc deleted file mode 100644 index 0b28b032..00000000 --- a/facetracknoir/main-facetracknoir.qrc +++ /dev/null @@ -1,9 +0,0 @@ - - - images/tools.png - images/settings16.png - images/curves.png - images/facetracknoir.png - images/no-feed.png - - diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index ee8da907..9c2ced45 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -1,4 +1,4 @@ -#include "facetracknoir.h" +#include "ui.h" #include #include #include diff --git a/facetracknoir/main.ui b/facetracknoir/main.ui new file mode 100644 index 00000000..69ae1f8a --- /dev/null +++ b/facetracknoir/main.ui @@ -0,0 +1,1202 @@ + + + Lovecraftian Octopus + OpentrackUI + + + + 0 + 0 + 708 + 504 + + + + + :/images/facetracknoir.png:/images/facetracknoir.png + + + #video_feed { border: 0; } + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 480 + 360 + + + + + 480 + 360 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 480 + 360 + + + + + 480 + 360 + + + + + + + + + + + + + + + + + QFrame::NoFrame + + + 0 + + + + 12 + + + 6 + + + 12 + + + 8 + + + 4 + + + + + + 0 + 0 + + + + + 80 + 90 + + + + + + + + + 0 + 0 + + + + Raw tracker data + + + + 0 + + + 0 + + + 0 + + + 0 + + + 3 + + + 2 + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + + + + + + + + 0 + 0 + + + + Game data + + + + 0 + + + 0 + + + 0 + + + 0 + + + 3 + + + 2 + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + + + + + + + 0 + + + 0 + + + 6 + + + 0 + + + + + Controls + + + true + + + + 4 + + + 12 + + + 4 + + + 12 + + + + + false + + + + 0 + 0 + + + + Stop + + + + + + + + 0 + 0 + + + + Start + + + + + + + + + + Settings + + + true + + + + 4 + + + 0 + + + 4 + + + 4 + + + 2 + + + + + + 0 + 0 + + + + Keys + + + + :/images/tools.png:/images/tools.png + + + + 80 + 24 + + + + + + + + + 0 + 0 + + + + Mapping + + + + :/images/curves.png:/images/curves.png + + + + 80 + 24 + + + + + + + + + + + Filter + + + true + + + + 4 + + + 0 + + + 4 + + + 4 + + + 2 + + + + + + + + true + + + ... + + + false + + + + + + + + + + Tracker + + + true + + + + 4 + + + 0 + + + 4 + + + 4 + + + 2 + + + + + + + + true + + + ... + + + false + + + + + + + + + + Protocol + + + true + + + + 4 + + + 0 + + + 4 + + + 4 + + + 2 + + + + + true + + + ... + + + false + + + + + + + + + + + + + Profile + + + true + + + + 4 + + + 0 + + + 4 + + + 4 + + + 2 + + + + + + 0 + 0 + + + + 10 + + + + + + + + 0 + 0 + + + + Load + + + + + + + true + + + + 0 + 0 + + + + Save + + + + + + + true + + + + 0 + 0 + + + + Save... + + + + + + + + + + + + + + + + + + GLWidget + QWidget +
glwidget.h
+
+
+ + + + +
diff --git a/facetracknoir/mapping.ui b/facetracknoir/mapping.ui new file mode 100644 index 00000000..9f422b9b --- /dev/null +++ b/facetracknoir/mapping.ui @@ -0,0 +1,1069 @@ + + + UICCurveConfigurationDialog + + + + 0 + 0 + 970 + 655 + + + + + 0 + 0 + + + + Mapping properties + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + background-color: #ccc; + + + + + + + + + QTabWidget::North + + + 6 + + + + Yaw + + + + + 0 + 0 + 930 + 260 + + + + + 255 + 0 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 166 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + + 255 + 0 + 0 + + + + + 255 + 255 + 255 + + + + + + + Pitch + + + + + 0 + 0 + 930 + 260 + + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 199 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Roll + + + + + 0 + 0 + 930 + 260 + + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 271 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + X + + + + + 0 + 0 + 930 + 260 + + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 228 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + Y + + + + + 0 + 0 + 930 + 260 + + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 229 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Z + + + + + 0 + 0 + 930 + 260 + + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 263 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + Options + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Center pose + + + Qt::AlignCenter + + + true + + + false + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + TX + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RY + + + + + + + TY + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TZ + + + + + + + RZ + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RX + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + + + + + 65536 + 65536 + + + + + true + + + + Output remap + + + Qt::AlignCenter + + + true + + + false + + + + QLayout::SetMinAndMaxSize + + + 6 + + + + + X + + + + + + + Yaw + + + + + + + Pitch + + + + + + + Y + + + + + + + Z + + + + + + + Roll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + Source + + + + + + + Invert + + + + + + + Destination + + + + + + + + + + + 0 + 0 + + + + + + + Translation compensation + + + true + + + + + + + 0 + 0 + + + + + + + Enable + + + + + + + + + + Disable Z axis compensation + + + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + QFunctionConfigurator + QWidget +
qfunctionconfigurator.h
+
+
+ + pos_rx + pos_ry + pos_rz + ry_altp + rz_altp + tx_altp + ty_altp + tz_altp + tcomp_enable + tabWidget + pos_tx + buttonBox + pos_ty + rx_altp + pos_tz + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/facetracknoir/ui-res.qrc b/facetracknoir/ui-res.qrc new file mode 100644 index 00000000..0b28b032 --- /dev/null +++ b/facetracknoir/ui-res.qrc @@ -0,0 +1,9 @@ + + + images/tools.png + images/settings16.png + images/curves.png + images/facetracknoir.png + images/no-feed.png + + diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp new file mode 100644 index 00000000..edd3a818 --- /dev/null +++ b/facetracknoir/ui.cpp @@ -0,0 +1,424 @@ +/******************************************************************************* +* FaceTrackNoIR This program is a private project of the some enthusiastic +* gamers from Holland, who don't like to pay much for +* head-tracking. +* +* Copyright (C) 2011 Wim Vriend (Developing) +* Ron Hendriks (Researching and Testing) +* +* Homepage +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 3 of the License, or (at your +* option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see . +*********************************************************************************/ +#include "ui.h" +#include "opentrack/tracker.h" +#include + +#ifndef _WIN32 +# include +#else +# include +#endif + +MainWindow::MainWindow() : + pose_update_timer(this), + kbd_quit(QKeySequence("Ctrl+Q"), this), + no_feed_pixmap(":/images/no-feed.png") +{ + ui.setupUi(this); + + setFixedSize(size()); + + updateButtonState(false, false); + ui.video_frame_label->setPixmap(no_feed_pixmap); + QDir::setCurrent(QCoreApplication::applicationDirPath()); + + connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); + connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); + connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); + + connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); + connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); + connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); + connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showProtocolSettings())); + connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterSettings())); + + modules.filters().push_front(std::make_shared("", dylib::Filter)); + + for (auto x : modules.trackers()) + ui.iconcomboTrackerSource->addItem(x->icon, x->name); + + for (auto x : modules.protocols()) + ui.iconcomboProtocol->addItem(x->icon, x->name); + + for (auto x : modules.filters()) + ui.iconcomboFilter->addItem(x->icon, x->name); + + fill_profile_combobox(); + + tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); + tie_setting(s.protocol_dll, ui.iconcomboProtocol); + tie_setting(s.filter_dll, ui.iconcomboFilter); + + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); + connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + + connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); + connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); + kbd_quit.setEnabled(true); + + ensure_tray(); + if (s.tray_enabled) + hide(); +} + +MainWindow::~MainWindow() +{ + stopTracker(); + save(); + _exit(0); +} + +void MainWindow::open() { + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::ExistingFile); + + QString fileName = dialog.getOpenFileName( + this, + tr("Open the settings file"), + QCoreApplication::applicationDirPath() + "/settings/", + tr("Settings file (*.ini);;All Files (*)"), + NULL); + + if (! fileName.isEmpty() ) { + { + QSettings settings("opentrack"); + settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); + } + fill_profile_combobox(); + load_settings(); + } +} + +void MainWindow::save_mappings() { + pose.save_mappings(); +} + +#if defined(__unix) || defined(__linux) || defined(__APPLE__) +# include +#endif + +void MainWindow::save() { + b->save(); + save_mappings(); + +#if defined(__unix) || defined(__linux) + QSettings settings("opentrack"); + const QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QByteArray bytes = QFile::encodeName(currentFile); + const char* filename_as_asciiz = bytes.constData(); + + if (access(filename_as_asciiz, R_OK | W_OK)) + { + QMessageBox::warning(this, "Something went wrong", "Check permissions and ownership for your .ini file!", QMessageBox::Ok, QMessageBox::NoButton); + } +#endif +} + +void MainWindow::saveAs() +{ + QSettings settings("opentrack"); + QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + + QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), + oldFile, + tr("Settings file (*.ini);;All Files (*)")); + if (!fileName.isEmpty()) { + + QFileInfo newFileInfo ( fileName ); + if ((newFileInfo.exists()) && (oldFile != fileName)) { + QFile newFileFile ( fileName ); + newFileFile.remove(); + } + + QFileInfo oldFileInfo ( oldFile ); + if (oldFileInfo.exists()) { + QFile oldFileFile ( oldFile ); + oldFileFile.copy( fileName ); + } + + settings.setValue ("SettingsFile", fileName); + save(); + } + + fill_profile_combobox(); +} + +void MainWindow::load_mappings() { + pose.load_mappings(); +} + +void MainWindow::load_settings() { + b->reload(); + load_mappings(); +} + +extern "C" volatile const char* opentrack_version; + +void MainWindow::fill_profile_combobox() +{ + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + + "/settings/default.ini" ).toString(); + qDebug() << "Config file now" << currentFile; + QFileInfo pathInfo ( currentFile ); + setWindowTitle(QString( const_cast(opentrack_version) + QStringLiteral(" :: ")) + pathInfo.fileName()); + QDir settingsDir( pathInfo.dir() ); + auto iniFileList = settingsDir.entryList( QStringList { "*.ini" } , QDir::Files, QDir::Name ); + ui.iconcomboProfile->clear(); + for (auto x : iniFileList) + ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); + ui.iconcomboProfile->setCurrentText(pathInfo.fileName()); +} + +void MainWindow::updateButtonState(bool running, bool inertialp) +{ + bool not_running = !running; + ui.iconcomboProfile->setEnabled ( not_running ); + ui.btnStartTracker->setEnabled ( not_running ); + ui.btnStopTracker->setEnabled ( running ); + ui.iconcomboProtocol->setEnabled ( not_running ); + ui.iconcomboFilter->setEnabled ( not_running ); + ui.iconcomboTrackerSource->setEnabled(not_running); + ui.btnStartTracker->setEnabled(not_running); + ui.btnStopTracker->setEnabled(running); + ui.video_frame_label->setVisible(not_running || inertialp); +} + +void MainWindow::bindKeyboardShortcuts() +{ + if (work) + work->reload_shortcuts(); +} + +void MainWindow::startTracker( ) { + b->save(); + load_settings(); + bindKeyboardShortcuts(); + + // tracker dtor needs run first + work = nullptr; + + libs = SelectedLibraries(ui.video_frame, current_tracker(), current_protocol(), current_filter()); + work = std::make_shared(s, pose, libs, this, winId()); + + { + double p[6] = {0,0,0, 0,0,0}; + display_pose(p, p); + } + + if (!libs.correct) + { + QMessageBox::warning(this, "Library load error", + "One of libraries failed to load. Check installation.", + QMessageBox::Ok, + QMessageBox::NoButton); + return; + } + + pose_update_timer.start(50); + + // NB check valid since SelectedLibraries ctor called + // trackers take care of layout state updates + const bool is_inertial = ui.video_frame->layout() == nullptr; + updateButtonState(true, is_inertial); +} + +void MainWindow::stopTracker( ) { + //ui.game_name->setText("Not connected"); + + pose_update_timer.stop(); + ui.pose_display->rotateBy(0, 0, 0); + + if (pTrackerDialog) + { + pTrackerDialog->unregister_tracker(); + pTrackerDialog = nullptr; + } + + if (pProtocolDialog) + { + pProtocolDialog->unregister_protocol(); + pProtocolDialog = nullptr; + } + + if (pFilterDialog) + { + pFilterDialog->unregister_filter(); + pFilterDialog = nullptr; + } + + work = nullptr; + libs = SelectedLibraries(); + + { + double p[6] = {0,0,0, 0,0,0}; + display_pose(p, p); + } + updateButtonState(false, false); +} + +void MainWindow::display_pose(const double *mapped, const double *raw) +{ + ui.pose_display->rotateBy(mapped[Yaw], mapped[Pitch], mapped[Roll]); + + if (mapping_widget) + mapping_widget->update(); + + double mapped_[6], raw_[6]; + + for (int i = 0; i < 6; i++) + { + mapped_[i] = (int) mapped[i]; + raw_[i] = (int) raw[i]; + } + + ui.raw_x->display(raw_[TX]); + ui.raw_y->display(raw_[TY]); + ui.raw_z->display(raw_[TZ]); + ui.raw_yaw->display(raw_[Yaw]); + ui.raw_pitch->display(raw_[Pitch]); + ui.raw_roll->display(raw_[Roll]); + + ui.pose_x->display(mapped_[TX]); + ui.pose_y->display(mapped_[TY]); + ui.pose_z->display(mapped_[TZ]); + ui.pose_yaw->display(mapped_[Yaw]); + ui.pose_pitch->display(mapped_[Pitch]); + ui.pose_roll->display(mapped_[Roll]); +} + +void MainWindow::showHeadPose() +{ + double mapped[6], raw[6]; + + work->tracker->get_raw_and_mapped_poses(mapped, raw); + + display_pose(mapped, raw); + +#if 0 + if (libs.pProtocol) + { + const QString name = libs.pProtocol->game_name(); + ui.game_name->setText(name); + } +#endif +} + +template +ptr mk_dialog(ptr lib) +{ + if (lib) + { + auto dialog = ptr(reinterpret_cast(lib->Dialog())); + dialog->setWindowFlags(Qt::Dialog); + dialog->setFixedSize(dialog->size()); + return dialog; + } + + return nullptr; +} + +void MainWindow::showTrackerSettings() +{ + auto dialog = mk_dialog(current_tracker()); + + if (dialog) { + pTrackerDialog = dialog; + dialog->register_tracker(libs.pTracker.get()); + dialog->show(); + } +} + +void MainWindow::showProtocolSettings() { + auto dialog = mk_dialog(current_protocol()); + + if (dialog) { + pProtocolDialog = dialog; + dialog->show(); + } +} + +void MainWindow::showFilterSettings() { + auto dialog = mk_dialog(current_filter()); + + if (dialog) { + pFilterDialog = dialog; + dialog->register_filter(libs.pFilter.get()); + dialog->show(); + } +} + +void MainWindow::showKeyboardShortcuts() { + shortcuts_widget = std::make_shared(); + shortcuts_widget->setWindowFlags(Qt::Dialog); + connect(shortcuts_widget.get(), SIGNAL(reload()), this, SLOT(bindKeyboardShortcuts())); + shortcuts_widget->show(); +} + +void MainWindow::showCurveConfiguration() { + mapping_widget = std::make_shared(pose, s); + mapping_widget->setWindowFlags(Qt::Dialog); + mapping_widget->show(); +} + +void MainWindow::exit() { + QCoreApplication::exit(0); +} + +void MainWindow::profileSelected(int index) +{ + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QFileInfo pathInfo ( currentFile ); + settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + ui.iconcomboProfile->itemText(index)); + load_settings(); +} + +void MainWindow::shortcutRecentered() +{ + qDebug() << "Center"; + if (work) + work->tracker->center(); +} + +void MainWindow::shortcutToggled() +{ + qDebug() << "Toggle"; + if (work) + work->tracker->toggle_enabled(); +} + +void MainWindow::ensure_tray() +{ + tray = nullptr; + if (s.tray_enabled) + { + tray = std::make_shared(this); + tray->setIcon(QIcon(":/images/facetracknoir.png")); + tray->show(); + connect(tray.get(), SIGNAL(activated()), this, SLOT(show())); + } +} diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h new file mode 100644 index 00000000..9419936f --- /dev/null +++ b/facetracknoir/ui.h @@ -0,0 +1,120 @@ +/******************************************************************************* +* MainWindow This program is a private project of the some enthusiastic +* gamers from Holland, who don't like to pay much for +* head-tracking. +* +* Copyright (C) 2010 Wim Vriend (Developing) +* Ron Hendriks (Researching and Testing) +* +* Homepage +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 3 of the License, or (at your +* option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see . +*********************************************************************************/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(_WIN32) +# include "qxt-mini/QxtGlobalShortcut" +#else +# include +#endif + +#include "ui_facetracknoir.h" + +#include "opentrack/options.hpp" +#include "opentrack/main-settings.hpp" +#include "opentrack/plugin-support.h" +#include "opentrack/tracker.h" +#include "opentrack/shortcuts.h" +#include "opentrack/work.hpp" +#include "opentrack/state.hpp" +#include "curve-config.h" + +using namespace options; + +class MainWindow : public QMainWindow, private State +{ + Q_OBJECT + + Ui::OpentrackUI ui; + ptr tray; + QTimer pose_update_timer; + ptr shortcuts_widget; + ptr mapping_widget; + QShortcut kbd_quit; + QPixmap no_feed_pixmap; + ptr pFilterDialog; + ptr pProtocolDialog; + ptr pTrackerDialog; + + ptr current_tracker() + { + return modules.trackers().value(ui.iconcomboTrackerSource->currentIndex(), nullptr); + } + ptr current_protocol() + { + return modules.protocols().value(ui.iconcomboProtocol->currentIndex(), nullptr); + } + ptr current_filter() + { + return modules.filters().value(ui.iconcomboFilter->currentIndex(), nullptr); + } + + void createIconGroupBox(); + void load_settings(); + void updateButtonState(bool running, bool inertialp); + void fill_profile_combobox(); + void display_pose(const double* mapped, const double* raw); + void ensure_tray(); + +public slots: + void shortcutRecentered(); + void shortcutToggled(); + void bindKeyboardShortcuts(); +private slots: + void open(); + void save(); + void saveAs(); + void exit(); + void profileSelected(int index); + + void showTrackerSettings(); + void showProtocolSettings(); + void showFilterSettings(); + void showKeyboardShortcuts(); + void showCurveConfiguration(); + void showHeadPose(); + + void startTracker(); + void stopTracker(); +public: + MainWindow(); + ~MainWindow(); + void save_mappings(); + void load_mappings(); +}; diff --git a/opentrack/main-settings.hpp b/opentrack/main-settings.hpp index e41a23c9..83ec8968 100644 --- a/opentrack/main-settings.hpp +++ b/opentrack/main-settings.hpp @@ -27,6 +27,7 @@ struct main_settings { value tracker_dll, tracker2_dll, filter_dll, protocol_dll; axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll; value tcomp_p, tcomp_tz; + value tray_enabled; main_settings(pbundle b) : b(b), tracker_dll(b, "tracker-dll", ""), @@ -40,6 +41,7 @@ struct main_settings { a_pitch(b, "pitch", Pitch), a_roll(b, "roll", Roll), tcomp_p(b, "compensate-translation", true), - tcomp_tz(b, "compensate-translation-disable-z-axis", false) + tcomp_tz(b, "compensate-translation-disable-z-axis", false), + tray_enabled(false, "use-system-tray", true) {} }; -- cgit v1.2.3