From 9b75369b820c4d3a93739dbcb664df329b183e09 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 21 Sep 2012 07:21:02 +0000 Subject: Fix function-config and Accela after recent refactoring. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@149 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui | 12 +++--- FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp | 15 ++------ FaceTrackNoIR/FaceTrackNoIR.cpp | 4 ++ .../qfunctionconfigurator.cpp | 42 ++++++++++++++------- .../QFunctionConfigurator/qfunctionconfigurator.h | 2 +- bin/QFunctionConfigurator.dll | Bin 69632 -> 65536 bytes bin/QFunctionConfigurator.lib | Bin 27876 -> 27454 bytes 7 files changed, 43 insertions(+), 32 deletions(-) diff --git a/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui b/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui index 6171defe..7a5c8047 100644 --- a/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui +++ b/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui @@ -9,7 +9,7 @@ 0 0 - 321 + 880 349 @@ -43,7 +43,7 @@ - 300 + 850 300 @@ -65,8 +65,8 @@ 20 20 - 215 - 220 + 819 + 244 @@ -76,10 +76,10 @@ 8 - 40 + 191 - 20 + 23 1 diff --git a/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp b/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp index 7b1b7008..e6a009f0 100644 --- a/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp +++ b/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp @@ -14,6 +14,7 @@ #include "math.h" #include #include +#include FTNoIR_Filter::FTNoIR_Filter() : functionConfig("Accela-Scaling-Rotation", 4, 8), @@ -85,16 +86,10 @@ void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, T for (i=0;i<6;i++) { - volatile double bleh; - - bleh = target[i]; - - if (bleh != bleh) + if (_isnan(target[i])) return; - bleh = prev_output[i]; - - if (bleh != bleh) + if (_isnan(prev_output[i])) return; double e2 = target[i]; @@ -129,9 +124,7 @@ void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, T output[i] = sum; } - bleh = output[i]; - - if (bleh != bleh) + if (_isnan(output[i])) return; } diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index d4549a10..c841eff6 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -2091,6 +2091,10 @@ void CurveConfigurationDialog::save() { ui.qFunctionPitchDown->saveSettings(currentFile); ui.qFunctionRoll->saveSettings(currentFile); + ui.qFunctionX->saveSettings(currentFile); + ui.qFunctionY->saveSettings(currentFile); + ui.qFunctionZ->saveSettings(currentFile); + settingsDirty = false; // diff --git a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp index b2fb9655..58bf69ac 100644 --- a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp +++ b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp @@ -86,8 +86,8 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); setMouseTracking(true); - moving = 0; // Pointer to the curve-point, that's being moved - movingPoint = 0; // Index of that same point + moving = NULL; // Pointer to the curve-point, that's being moved + movingPoint = 1; // Index of that same point // // Add a Reset-button @@ -262,6 +262,8 @@ QRect scale; // void QFunctionConfigurator::drawFunction(const QRectF &fullRect) { + if (!_config) + return; int i; QPointF prevPoint; QPointF currentPoint; @@ -290,12 +292,15 @@ QPointF currentPoint; QPen pen(colBezier, 2, Qt::SolidLine); prevPoint = graphicalizePoint( QPointF(0,0), "drawFunction lines" ); // Start at the Axis - for (i = 0; i < _draw_points.size(); i++) { - currentPoint = _draw_points[i]; - drawLine(&painter, prevPoint, currentPoint, pen); - prevPoint = currentPoint; + double max = maxInputEGU(); + QPointF prev = graphicalizePoint(QPointF(0, 0)); + double step = 1 / (double) pixPerEGU_Input(); + for (double i = 0; i < max; i += step) { + double val = _config->getValue(i); + QPointF cur = graphicalizePoint(QPointF(i, val)); + drawLine(&painter, prev, cur, pen); + prev = cur; } - painter.restore(); } @@ -451,7 +456,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) if (withinRect(e->pos(), range)) { _config->addPoint(normalizePoint(e->pos())); setConfig(_config, strSettingsFile); - moving = 0; + moving = NULL; emit CurveChanged( true ); } } @@ -467,7 +472,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) // // Check to see if the cursor is touching one of the points. // - moving = 0; + moving = NULL; movingPoint = -1; WaitForSingleObject(_mutex, INFINITE); if (_config) { @@ -541,7 +546,7 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) } } -void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *) +void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) { //qDebug()<<"releasing"; if (moving > 0) { @@ -552,14 +557,14 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *) // WaitForSingleObject(_mutex, INFINITE); if (_config) { - _config->movePoint(movingPoint, _points[movingPoint]); + _config->movePoint(movingPoint, normalizePoint(e->pos())); setConfig(_config, strSettingsFile); } ReleaseMutex(_mutex); } setCursor(Qt::ArrowCursor); - moving = 0; + moving = NULL; movingPoint = 0; } @@ -588,10 +593,19 @@ bool QFunctionConfigurator::withinRect( const QPointF &coord, const QRectF &rect // QPointF QFunctionConfigurator::normalizePoint(QPointF point) const { -QPointF norm; + QPointF norm; norm.setX( (point.x() - range.left()) / pPerEGU_Input ); - norm.setY( (range.bottom() - point.y()) / pPerEGU_Output ); + norm.setY( (range.bottom() - point.y()) / pPerEGU_Output ); + + if (norm.x() > maxInputEGU()) + norm.setX(maxInputEGU()); + else if (norm.x() < 0) + norm.setX(0); + if (norm.y() > maxOutputEGU()) + norm.setY(maxOutputEGU()); + else if (norm.y() < 0) + norm.setY(0); return norm; } diff --git a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h index 48b816ca..c467bc92 100644 --- a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h +++ b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h @@ -168,7 +168,7 @@ private: QRectF range; // The actual rectangle for the Bezier-curve QPointF lastPoint; // The right-most point of the Function QPointF normalizePoint (QPointF point) const; // Convert the graphical Point to a real-life Point - QPointF graphicalizePoint (QPointF point, QString source) const; // Convert the Point to a graphical Point + QPointF graphicalizePoint (QPointF point, QString source = "") const; // Convert the Point to a graphical Point QPointF *moving; int movingPoint; diff --git a/bin/QFunctionConfigurator.dll b/bin/QFunctionConfigurator.dll index 008bdc0b..ce0b952d 100644 Binary files a/bin/QFunctionConfigurator.dll and b/bin/QFunctionConfigurator.dll differ diff --git a/bin/QFunctionConfigurator.lib b/bin/QFunctionConfigurator.lib index 6c49062e..9cf2ffe0 100644 Binary files a/bin/QFunctionConfigurator.lib and b/bin/QFunctionConfigurator.lib differ -- cgit v1.2.3