summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-11-27 02:32:24 +0100
committerStanislaw Halik <sthalik@misaki.pl>2013-11-27 02:32:24 +0100
commit09aeee333b807be87f456fa226fc0442d5a37364 (patch)
tree71f36a0ae58ca751ccd61671cdbb1fd58c877ac3 /ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
parent8e00d5a1599cc60a823191ed5351d68066682b16 (diff)
make hatire actually buildable
Remove 'captain obvious' comments, references to <windows.h>, fix spelling errors, use UI layouts, and so on Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
Diffstat (limited to 'ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp')
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp121
1 files changed, 18 insertions, 103 deletions
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
index b889341f..1fa482c7 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
@@ -1,32 +1,9 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of some enthusiastic *
-* gamers from Holland, who don't like to pay much for *
-* head-tracking. *
-* *
-* Copyright (C) 2012 Wim Vriend (Developing) *
-* Ron Hendriks (Researching and Testing) *
-* *
-* Homepage: http://facetracknoir.sourceforge.net/home/default.htm *
-* *
-* 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 <http://www.gnu.org/licenses/>. *
-* *
-********************************************************************************/
#include "ftnoir_tracker_hat.h"
#include "ftnoir_tracker_hat_dialog.h"
#include <QMessageBox>
#include <QDebug>
+#include <QtSerialPort/QSerialPortInfo>
//*******************************************************************************************************
// FaceTrackNoIR Client Settings-dialog.
@@ -35,21 +12,16 @@
//
// Constructor for server-settings-dialog
//
-TrackerControls::TrackerControls() : settingsDirty(false), theTracker(NULL), timer(this),
-QWidget()
+TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDirty(false), timer(this)
{
- settingsDirty= false;
- theTracker = NULL;
ui.setupUi( this );
- pre_trame = 0;
settings.load_ini();
- // make SerialPort list
- foreach (QextPortInfo PortInfo , QextSerialEnumerator::getPorts() ) {
- ui.cbSerialPort->addItem(PortInfo.portName);
+ foreach (QSerialPortInfo PortInfo , QSerialPortInfo::availablePorts() ) {
+ ui.cbSerialPort->addItem(PortInfo.portName());
}
- // Stop if no SerialPort dispo
+
if (ui.cbSerialPort->count()<1) {
QMessageBox::critical(this,"FaceTrackNoIR Error", "No SerialPort avaible");
} else {
@@ -77,21 +49,18 @@ QWidget()
ui.chkInvertY->setChecked(settings.InvertY);
ui.chkInvertZ->setChecked(settings.InvertZ);
-
- ui.cb_roll->setCurrentIndex(settings.RollAxe);
- ui.cb_pitch->setCurrentIndex(settings.PitchAxe);
- ui.cb_yaw->setCurrentIndex(settings.YawAxe);
- ui.cb_x->setCurrentIndex(settings.XAxe);
- ui.cb_y->setCurrentIndex(settings.YAxe);
- ui.cb_z->setCurrentIndex(settings.ZAxe);
-
+ ui.cb_roll->setCurrentIndex(settings.RollAxis);
+ ui.cb_pitch->setCurrentIndex(settings.PitchAxis);
+ ui.cb_yaw->setCurrentIndex(settings.YawAxis);
+ ui.cb_x->setCurrentIndex(settings.XAxis);
+ ui.cb_y->setCurrentIndex(settings.YAxis);
+ ui.cb_z->setCurrentIndex(settings.ZAxis);
// Connect Qt signals to member-functions
connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(doSave()));
-
connect(ui.cbSerialPort, SIGNAL(currentIndexChanged(QString)), this,SLOT(set_mod_port(QString)) );
connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) );
@@ -108,7 +77,6 @@ QWidget()
connect( ui.chkInvertY,SIGNAL(toggled(bool)), this,SLOT(set_inv_y(bool)) );
connect( ui.chkInvertZ,SIGNAL(toggled(bool)), this,SLOT(set_inv_z(bool)) );
-
connect(ui.cb_roll, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_roll(int)));
connect(ui.cb_pitch, SIGNAL(currentIndexChanged(int)),this,SLOT(set_rot_pitch(int)));
connect(ui.cb_yaw, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_yaw(int)));
@@ -127,13 +95,8 @@ QWidget()
// Destructor for server-dialog
//
TrackerControls::~TrackerControls() {
- delete this;
}
-
-//
-// Initialize tracker-client-dialog
-//
void TrackerControls::Initialize(QWidget *parent) {
QPoint offsetpos(100, 100);
if (parent) {
@@ -142,35 +105,20 @@ void TrackerControls::Initialize(QWidget *parent) {
show();
}
-
-//
-// Apply online settings to tracker
-//
void TrackerControls::settings_changed()
{
settingsDirty = true;
if (theTracker) theTracker->applysettings(settings);
}
-
-//
-// Center asked to ARDUINO
-//
void TrackerControls::doCenter() {
if (theTracker) theTracker->center();
}
-//
-// Reset asked to ARDUINO
-//
void TrackerControls::doReset() {
if (theTracker) theTracker->reset();
}
-
-//
-// Send command to ARDUINO
-//
void TrackerControls::doSend() {
if (theTracker) {
if (!ui.lineSend->text().isEmpty()) {
@@ -182,10 +130,6 @@ void TrackerControls::doSend() {
}
}
-
-//
-// Display FPS and Status of Arduino.
-//
void TrackerControls::poll_tracker_info()
{
if (theTracker)
@@ -202,13 +146,13 @@ void TrackerControls::poll_tracker_info()
}
- if (pre_trame<num_trame)
- { nb_trame=num_trame-pre_trame;}
+ if (pre_frame<num_trame)
+ { nb_trame=num_trame-pre_frame;}
else
- {nb_trame=(1000-pre_trame)+num_trame;}
+ {nb_trame=(1000-pre_frame)+num_trame;}
ui.lab_vtps->setText(QString::number(nb_trame*(1000/timer.interval())));
- pre_trame=num_trame;
+ pre_frame=num_trame;
}
}
@@ -219,28 +163,15 @@ void TrackerControls::doSave() {
settings.save_ini();
}
-
-//
-// OK clicked on server-dialog
-//
void TrackerControls::doOK() {
settingsDirty=false;
settings.save_ini();
this->close();
}
-//
-// Cancel clicked on server-dialog
-//
void TrackerControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
+ if (settingsDirty) {
int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- // qDebug() << "doCancel says: answer =" << ret;
-
switch (ret) {
case QMessageBox::Save:
settings.save_ini();
@@ -250,10 +181,8 @@ void TrackerControls::doCancel() {
close();
break;
case QMessageBox::Cancel:
- // Cancel was clicked
break;
default:
- // should never be reached
break;
}
}
@@ -264,15 +193,13 @@ void TrackerControls::doCancel() {
void TrackerControls::registerTracker(ITracker *tracker) {
-// theTracker = (FTNoIR_Tracker *) tracker;
- theTracker = static_cast<FTNoIR_Tracker*>(tracker);
+ theTracker = dynamic_cast<FTNoIR_Tracker*>(tracker);
if (isVisible() && settingsDirty) theTracker->applysettings(settings);
ui.cbSerialPort->setEnabled(false);
timer.start(250);
ui.lab_vstatus->setText("HAT START");
}
-
void TrackerControls::unRegisterTracker() {
theTracker = NULL;
ui.cbSerialPort->setEnabled(true);
@@ -281,19 +208,7 @@ void TrackerControls::unRegisterTracker() {
ui.lab_vtps->setText("");
}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
-#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
-
-FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( )
+extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog()
{
return new TrackerControls;
}