diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-07-16 06:52:10 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-07-16 06:52:10 +0200 |
commit | 77d25651472233dee0fc8ac03de3560eb6a267c9 (patch) | |
tree | f01493dc201f89c821276635c5892ee04aaf7521 | |
parent | 2da709f686124722ac769f7a884eb260fd80c545 (diff) |
Draw quarter-ellipse in place of user-defined curve when requested
-rw-r--r-- | ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 136 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.cpp | 4 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.h | 1 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 62 |
4 files changed, 156 insertions, 47 deletions
diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 6cb28176..0fe8f920 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ <rect> <x>0</x> <y>0</y> - <width>880</width> - <height>673</height> + <width>868</width> + <height>729</height> </rect> </property> <property name="windowTitle"> @@ -44,18 +44,100 @@ <property name="minimumSize"> <size> <width>850</width> - <height>574</height> + <height>650</height> </size> </property> <property name="maximumSize"> <size> <width>300</width> - <height>574</height> + <height>650</height> </size> </property> <property name="currentIndex"> <number>0</number> </property> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Preset</string> + </attribute> + <widget class="QLabel" name="label_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>111</width> + <height>16</height> + </rect> + </property> + <property name="text"> + <string>Rotation smoothing</string> + </property> + </widget> + <widget class="QLabel" name="label_3"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>111</width> + <height>16</height> + </rect> + </property> + <property name="text"> + <string>Translation smoothing</string> + </property> + </widget> + <widget class="QDoubleSpinBox" name="rotationCircle"> + <property name="geometry"> + <rect> + <x>130</x> + <y>10</y> + <width>81</width> + <height>22</height> + </rect> + </property> + <property name="minimum"> + <double>0.100000000000000</double> + </property> + <property name="maximum"> + <double>10.000000000000000</double> + </property> + <property name="value"> + <double>3.000000000000000</double> + </property> + </widget> + <widget class="QDoubleSpinBox" name="translationCircle"> + <property name="geometry"> + <rect> + <x>130</x> + <y>40</y> + <width>81</width> + <height>22</height> + </rect> + </property> + <property name="minimum"> + <double>0.100000000000000</double> + </property> + <property name="maximum"> + <double>10.000000000000000</double> + </property> + <property name="value"> + <double>0.750000000000000</double> + </property> + </widget> + <widget class="QPushButton" name="resetCircle"> + <property name="geometry"> + <rect> + <x>130</x> + <y>70</y> + <width>75</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>Set curves</string> + </property> + </widget> + </widget> <widget class="QWidget" name="tab"> <attribute name="title"> <string>Rotation</string> @@ -64,19 +146,19 @@ <property name="geometry"> <rect> <x>20</x> - <y>20</y> + <y>10</y> <width>819</width> - <height>510</height> + <height>571</height> </rect> </property> <property name="maxInputEGU" stdset="0"> - <number>6</number> + <number>10</number> </property> <property name="maxOutputEGU" stdset="0"> - <number>8</number> + <number>10</number> </property> <property name="pixPerEGU_Input" stdset="0"> - <number>127</number> + <number>57</number> </property> <property name="pixPerEGU_Output" stdset="0"> <number>57</number> @@ -120,19 +202,19 @@ <property name="geometry"> <rect> <x>20</x> - <y>20</y> + <y>10</y> <width>819</width> - <height>510</height> + <height>581</height> </rect> </property> <property name="maxInputEGU" stdset="0"> - <number>6</number> + <number>10</number> </property> <property name="maxOutputEGU" stdset="0"> - <number>8</number> + <number>10</number> </property> <property name="pixPerEGU_Input" stdset="0"> - <number>127</number> + <number>57</number> </property> <property name="pixPerEGU_Output" stdset="0"> <number>57</number> @@ -322,32 +404,6 @@ background:none;</string> </widget> </item> <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Smoothing:</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="smoothingFactor"> - <property name="decimals"> - <number>3</number> - </property> - <property name="minimum"> - <double>0.100000000000000</double> - </property> - <property name="maximum"> - <double>100.000000000000000</double> - </property> - <property name="singleStep"> - <double>0.010000000000000</double> - </property> - <property name="value"> - <double>1.000000000000000</double> - </property> - </widget> - </item> - <item> <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 3c845899..a53f689e 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -21,8 +21,8 @@ #endif
FTNoIR_Filter::FTNoIR_Filter() :
- functionConfig("Accela-Scaling-Rotation", 6, 8),
- translationFunctionConfig("Accela-Scaling-Translation", 6, 8)
+ functionConfig("Accela-Scaling-Rotation", 10, 10),
+ translationFunctionConfig("Accela-Scaling-Translation", 10, 10)
{
first_run = true;
kMagicNumber = 100.0f;
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index fa1e9bcd..2e954c37 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -96,6 +96,7 @@ private slots: void doCancel();
void settingChanged(bool) { settingsDirty = true; }
void settingChanged(int) { settingsDirty = true; }
+ void resetCircle();
};
//*******************************************************************************************************
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 2e9bd61b..46801bde 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -27,8 +27,9 @@ 20130102 - WVR: Added 'reduction factor' to accommodate Patrick's need for speed.
*/
#include "ftnoir_filter_accela/ftnoir_filter_accela.h"
-#include "math.h"
+#include <math.h>
#include <QDebug>
+#include <algorithm>
#include "facetracknoir/global-settings.h"
//*******************************************************************************************************
@@ -39,8 +40,8 @@ //
FilterControls::FilterControls() :
QWidget(),
- functionConfig("Accela-Scaling-Rotation", 6, 8),
- translationFunctionConfig("Accela-Scaling-Translation", 6, 8)
+ functionConfig("Accela-Scaling-Rotation", 10, 10),
+ translationFunctionConfig("Accela-Scaling-Translation", 10, 10)
{
ui.setupUi( this );
@@ -50,6 +51,7 @@ FilterControls::FilterControls() : connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
connect(ui.scalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool)));
connect(ui.translationScalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool)));
+ connect(ui.resetCircle, SIGNAL(clicked()), this, SLOT(resetCircle()));
// Connect slider for reduction
//connect(ui.slideReduction, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int)));
@@ -148,12 +150,63 @@ void FilterControls::loadSettings() { iniFile.beginGroup ( "Accela" );
ui.slideReduction->setValue (iniFile.value ( "Reduction", 100 ).toInt());
ui.slideZoom->setValue(iniFile.value("zoom-slowness", 0).toInt());
- ui.smoothingFactor->setValue(iniFile.value("smoothing-factor", 1).toFloat());
+ ui.rotationCircle->setValue(iniFile.value("preset-rotation", 3).toDouble());
+ ui.translationCircle->setValue(iniFile.value("preset-translation", 0.75).toDouble());
iniFile.endGroup ();
settingsDirty = false;
}
+void FilterControls::resetCircle()
+{
+ QSettings settings("opentrack"); // Registry settings (in HK_USER)
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+ iniFile.beginGroup ( "Accela" );
+ iniFile.setValue("preset-rotation", ui.rotationCircle->value());
+ iniFile.setValue("preset-translation", ui.translationCircle->value());
+ iniFile.endGroup();
+
+ // essentially unit circles elongated on the X axis
+ double elongations[] = {
+ ui.rotationCircle->value(), ui.translationCircle->value()
+ };
+
+ FunctionConfig* configs[] = {
+ &functionConfig, &translationFunctionConfig
+ };
+
+ QFunctionConfigurator* widgets[] = {
+ ui.scalingConfig, ui.translationScalingConfig
+ };
+
+ for (int i = 0; i < 2; i++)
+ {
+ FunctionConfig& cfg = *configs[i];
+ double sz = elongations[i];
+
+ cfg.removeAllPoints();
+
+ for (double x = 0; x <= sz+1e-1; x += 1e-1)
+ {
+ double sq = sz*sz-x*x;
+ double val;
+ if (sq <= 1e-4)
+ val = 0;
+ else
+ val = std::min<double>(sqrt(sq), sz);
+
+ cfg.addPoint(QPointF(x, 10*(sz-val)/sz));
+ }
+
+ cfg.saveSettings(iniFile);
+
+ widgets[i]->setConfig(&cfg, currentFile);
+ }
+
+ settingsDirty = false;
+}
+
//
// Save the current Settings to the currently 'active' INI-file.
//
@@ -168,7 +221,6 @@ void FilterControls::save() { iniFile.beginGroup ( "Accela" );
iniFile.setValue ( "Reduction", ui.slideReduction->value() );
iniFile.setValue("zoom-slowness", ui.slideZoom->value());
- iniFile.setValue("smoothing-factor", ui.smoothingFactor->value());
iniFile.endGroup ();
functionConfig.saveSettings(iniFile);
|