diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-13 00:45:20 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-13 00:45:20 +0200 |
commit | b89195cee53549704e0807a802f5f05ed5d4e87a (patch) | |
tree | 1042585a3bc0a9deabe491d5c00322736e37d99f /qfunctionconfigurator | |
parent | c98efcbfdebd2e6ce85cb1b3b08a1bc48f3d968b (diff) |
Fix last commit, remove duplicated code
Diffstat (limited to 'qfunctionconfigurator')
-rw-r--r-- | qfunctionconfigurator/functionconfig.cpp | 76 | ||||
-rw-r--r-- | qfunctionconfigurator/functionconfig.h | 4 |
2 files changed, 12 insertions, 68 deletions
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 25d5599a..1c03aa92 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -6,6 +6,7 @@ * notice appear in all copies.
*/
+#include <QCoreApplication>
#include <QPointF>
#include <QList>
#include "functionconfig.h"
@@ -19,32 +20,21 @@ //
// Constructor with List of Points in argument.
//
-FunctionConfig::FunctionConfig(QString title, QList<QPointF> points, int intMaxInput, int intMaxOutput) :
+FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) :
_mutex(QMutex::Recursive)
{
_title = title;
- _points = points;
- _data = 0;
- _size = 0;
- lastValueTracked = QPointF(0,0);
- _tracking_active = false;
- _max_Input = intMaxInput; // Added WVR 20120805
- _max_Output = intMaxOutput;
- reload();
-}
-
-//
-// Constructor with only Title in arguments.
-//
-FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) {
- _title = title;
- _points = QList<QPointF>();
+ _points = QList<QPointF>();
_data = 0;
_size = 0;
lastValueTracked = QPointF(0,0);
_tracking_active = false;
_max_Input = intMaxInput; // Added WVR 20120805
_max_Output = intMaxOutput;
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat );
+ loadSettings(iniFile);
reload();
}
@@ -223,12 +213,15 @@ QList<QPointF> FunctionConfig::getPoints() { // Settings for a specific Curve are loaded from their own Group in the INI-file.
//
void FunctionConfig::loadSettings(QSettings& settings) {
-QPointF newPoint;
+ QPointF newPoint;
QList<QPointF> points;
settings.beginGroup(QString("Curves-%1").arg(_title));
int max = settings.value("point-count", 0).toInt();
+
+ qDebug() << _title << "count" << max;
+
for (int i = 0; i < max; i++) {
newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), (i + 1) * _max_Input/2).toFloat(),
settings.value(QString("point-%1-y").arg(i), (i + 1) * _max_Output/2).toFloat());
@@ -252,53 +245,6 @@ QPointF newPoint; }
//
-// Load the Points for the Function from the INI-file designated by settings.
-// Settings for a specific Curve are loaded from their own Group in the INI-file.
-//
-// A default List of points is available in defPoints, to be used if "point-count" is missing completely.
-//
-void FunctionConfig::loadSettings(QSettings& settings, QList<QPointF>& defPoints) {
-QPointF newPoint;
-
- QList<QPointF> points;
- settings.beginGroup(QString("Curves-%1").arg(_title));
-
- qDebug() << "FunctionConfig::loadSettings2 title = " << _title;
-
- //
- // Read the number of points, that was last saved. Default to defPoints, if key doesn't exist.
- //
- int max = settings.value("point-count", 0).toInt();
- if (max <= 0) {
- qDebug() << "FunctionConfig::loadSettings2 number of points = " << defPoints.count();
- points = defPoints;
- }
- else {
- qDebug() << "FunctionConfig::loadSettings2 max = " << max;
- for (int i = 0; i < max; i++) {
- newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), (i + 1) * _max_Input/2).toFloat(),
- settings.value(QString("point-%1-y").arg(i), (i + 1) * _max_Output/2).toFloat());
- //
- // Make sure the new Point fits in the Function Range.
- // Maybe this can be improved?
- //
- if (newPoint.x() > _max_Input) {
- newPoint.setX(_max_Input);
- }
- if (newPoint.y() > _max_Output) {
- newPoint.setY(_max_Output);
- }
- points.append(newPoint);
- }
- }
- settings.endGroup();
- _mutex.lock();
- _points = points;
- reload();
- _mutex.unlock();
-}
-
-//
// Save the Points for the Function to the INI-file designated by settings.
// Settings for a specific Curve are saved in their own Group in the INI-file.
// The number of Points is also saved, to make loading more convenient.
diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 9f380000..e96d7ffc 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -36,8 +36,7 @@ public: //
// Contructor(s) and destructor
//
- FunctionConfig(QString title, QList<QPointF> points, int intMaxInput, int intMaxOutput);
- FunctionConfig(QString title, int intMaxInput, int intMaxOutput);
+ FunctionConfig(QString title, int intMaxInput, int intMaxOutput);
virtual ~FunctionConfig();
float getValue(float x);
@@ -62,7 +61,6 @@ public: //
void saveSettings(QSettings& settings);
void loadSettings(QSettings& settings);
- void loadSettings(QSettings& settings, QList<QPointF>& defPoints);
void setTrackingActive(bool blnActive) {
_tracking_active = blnActive;
|