From b9b2d531219f3c2e4a3bf80fe4a8bf2c97b4d5b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Tue, 10 Dec 2013 13:32:40 +0100 Subject: [PATCH] Fix condition effect parameters creation. --- conditioneffectsettings.cpp | 6 ++++-- conditioneffectsettings.ui | 10 +++++----- ffbconditioneffect.cpp | 1 - ffbconditioneffectparameters.h | 22 +++++++--------------- globals.h | 2 +- mainwindow.cpp | 1 + 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/conditioneffectsettings.cpp b/conditioneffectsettings.cpp index 15b458a..8ec9540 100644 --- a/conditioneffectsettings.cpp +++ b/conditioneffectsettings.cpp @@ -8,6 +8,7 @@ ConditionEffectSettings::ConditionEffectSettings(QWidget* parent) : { ui->setupUi(this); connect(ui->cbox_axis, SIGNAL(currentIndexChanged(int)), this, SLOT(axisChanged(const int))); + axisChanged(ui->cbox_axis->currentIndex()); } void ConditionEffectSettings::axisChanged(const int idx) @@ -45,13 +46,14 @@ bool ConditionEffectSettings::fillFromParameters(const std::shared_ptrqle_leftCoeffX->setText(QString::number(cdParams->leftCoeff[FFBConditionEffectParameters::Axis::X])); ui->qle_rightCoeffX->setText(QString::number(cdParams->rightCoeff[FFBConditionEffectParameters::Axis::X])); ui->qle_leftSatX->setText(QString::number(cdParams->leftSat[FFBConditionEffectParameters::Axis::X])); - ui->qle_rightSatX->setText(QString::number(cdParams->rightCoeff[FFBConditionEffectParameters::Axis::X])); + ui->qle_rightSatX->setText(QString::number(cdParams->rightSat[FFBConditionEffectParameters::Axis::X])); + ui->qle_centerY->setText(QString::number(cdParams->center[FFBConditionEffectParameters::Axis::Y])); ui->qle_deadbandY->setText(QString::number(cdParams->deadband[FFBConditionEffectParameters::Axis::Y])); ui->qle_leftCoeffY->setText(QString::number(cdParams->leftCoeff[FFBConditionEffectParameters::Axis::Y])); ui->qle_rightCoeffY->setText(QString::number(cdParams->rightCoeff[FFBConditionEffectParameters::Axis::Y])); ui->qle_leftSatY->setText(QString::number(cdParams->leftSat[FFBConditionEffectParameters::Axis::Y])); - ui->qle_rightSatY->setText(QString::number(cdParams->rightCoeff[FFBConditionEffectParameters::Axis::Y])); + ui->qle_rightSatY->setText(QString::number(cdParams->rightSat[FFBConditionEffectParameters::Axis::Y])); return true; } diff --git a/conditioneffectsettings.ui b/conditioneffectsettings.ui index 16c1344..2cf0303 100644 --- a/conditioneffectsettings.ui +++ b/conditioneffectsettings.ui @@ -152,7 +152,7 @@ - 1 + 0 @@ -229,7 +229,7 @@ - 1 + 0 @@ -300,7 +300,7 @@ - 1 + 0 @@ -371,7 +371,7 @@ - 1 + 0 @@ -442,7 +442,7 @@ - 1 + 0 diff --git a/ffbconditioneffect.cpp b/ffbconditioneffect.cpp index a0dbf4f..56961c2 100644 --- a/ffbconditioneffect.cpp +++ b/ffbconditioneffect.cpp @@ -49,7 +49,6 @@ bool FFBConditionEffect::setParameters(const std::shared_ptr(params)); - //return setParameters(cdParams); } catch (const std::bad_cast& ex) { qCritical(ex.what()); return false; diff --git a/ffbconditioneffectparameters.h b/ffbconditioneffectparameters.h index 9e16335..d37b117 100644 --- a/ffbconditioneffectparameters.h +++ b/ffbconditioneffectparameters.h @@ -7,10 +7,7 @@ class FFBConditionEffectParameters : public FFBEffectParameters { public: - enum class Axis : quint8 { NONE = 0, X = 1, Y = 2 }; - struct Axis_less { - bool operator()(Axis a, Axis b) const { return quint8(a) == quint8(b); } - }; + enum class Axis : quint8 { NONE, X, Y }; FFBConditionEffectParameters(); bool centerFromString(const QString& center, Axis a); @@ -21,19 +18,14 @@ public: bool rightSatFromString(const QString& rightSat, Axis a); inline void subtypeFromIdx(const ConditionSubtypes subtype) { this->subtype = subtype; } - std::map center; - std::map deadband; - std::map leftCoeff; - std::map rightCoeff; - std::map leftSat; - std::map rightSat; + std::map center; + std::map deadband; + std::map leftCoeff; + std::map rightCoeff; + std::map leftSat; + std::map rightSat; ConditionSubtypes subtype; private: - inline bool qstringToInt(int& val, const QString& str) { - bool ok = false; - val = str.toInt(&ok); - return ok; - } }; #endif // FFBCONDITIONEFFECTPARAMETERS_H diff --git a/globals.h b/globals.h index 1760468..9dff3a3 100644 --- a/globals.h +++ b/globals.h @@ -4,7 +4,7 @@ #define APP_NAME "FFBChecker" static const int APP_VERSION_MAJOR(0); static const int APP_VERSION_MINOR(2); -static const char APP_VERSION_REL('b'); +static const char APP_VERSION_REL('c'); enum class FFBEffectTypes { NONE, CONSTANT, PERIODIC, RAMP, CONDITION, RUMBLE}; enum class PeriodicWaveforms { NONE, SQUARE, TRIANGLE, SINE, SAW_UP, SAW_DOWN }; diff --git a/mainwindow.cpp b/mainwindow.cpp index f5ae49c..2869120 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -254,6 +254,7 @@ bool MainWindow::readEffectParameters(std::shared_ptr& para std::shared_ptr iParams = std::shared_ptr(new FFBConditionEffectParameters); if (!readGeneralEffectParameters(iParams)) return false; + if (!iParams->centerFromString(m_conditionEffSet->centerX(), FFBConditionEffectParameters::Axis::X)) { QMessageBox::warning(this, res_inputFormatErrCap, "Invalid data in field \"Center\""); return false; -- 2.43.5