X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ParamSpinBox.cpp;h=1fdad51d3682ff889c22d401bd96be370ce285e5;hb=872ac5e3e0196ad70c2a01a79bd070c9a7d4a2e6;hp=af554aa84f9742bce8e627c4a1d2b1b22300a253;hpb=d4f365bcf214f4bce0bf84c47915f2d4a819668f;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index af554aa84..1fdad51d3 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -11,6 +12,7 @@ #include #include +#include /*! \class ModuleBase_ParamSpinBox @@ -61,28 +63,8 @@ void ModuleBase_ParamSpinBox::stepBy(int steps) */ void ModuleBase_ParamSpinBox::connectSignalsAndSlots() { - connect(this, SIGNAL(editingFinished()), - this, SLOT(onEditingFinished())); - connect(this, SIGNAL(valueChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); - - //connect(lineEdit(), SIGNAL(textChanged(const QString&)), - // this, SLOT(onTextChanged(const QString&))); - - //connect(lineEdit(), SIGNAL(textChanged(const QString&)), - // this, SIGNAL(textChanged(const QString&))); -} - -/*! - \brief This function is called when editing is finished. - */ -void ModuleBase_ParamSpinBox::onEditingFinished() -{ - if (myTextValue.isNull()) - myTextValue = text(); - - setText(myTextValue); } /*! @@ -91,11 +73,6 @@ void ModuleBase_ParamSpinBox::onEditingFinished() void ModuleBase_ParamSpinBox::onTextChanged(const QString& text) { myTextValue = text; - - double value = 0; - if (isValid(text, value) == Acceptable) { - myCorrectValue = text; - } } /*! @@ -114,6 +91,14 @@ double ModuleBase_ParamSpinBox::valueFromText(const QString& theText) const return aValue; } +QString ModuleBase_ParamSpinBox::textFromValue (double theValue) const +{ + if (hasVariable(myTextValue)){ + return myTextValue; + } + return ModuleBase_DoubleSpinBox::textFromValue(theValue); +} + /*! \brief This function is used to determine whether input is valid. \param str currently entered value @@ -154,8 +139,7 @@ void ModuleBase_ParamSpinBox::setValue(const double value) { ModuleBase_DoubleSpinBox::setValue(value); - myCorrectValue = ModuleBase_DoubleSpinBox::textFromValue(value); - myTextValue = myCorrectValue; + myTextValue = ModuleBase_DoubleSpinBox::textFromValue(value); } /*! @@ -187,7 +171,7 @@ bool ModuleBase_ParamSpinBox::isAcceptVariables() const bool ModuleBase_ParamSpinBox::hasVariable() const { - return hasVariable(text()); + return hasVariable(myTextValue); } bool ModuleBase_ParamSpinBox::hasVariable(const QString& theText) const @@ -234,16 +218,7 @@ bool ModuleBase_ParamSpinBox::findVariable(const QString& theName, double& outValue) const { - SessionPtr aSession = ModelAPI_Session::get(); - DocumentPtr aDocument = aSession->activeDocument(); - ObjectPtr aParamObj = aDocument->objectByName(ModelAPI_ResultParameter::group(), - theName.toStdString()); - ResultParameterPtr aParam = std::dynamic_pointer_cast(aParamObj); - if(!aParam.get()) - return false; - AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); - outValue = aValueAttribute->value(); - return true; + return ModelAPI_Tools::findVariable(theName.toStdString(), outValue); } /*! @@ -264,5 +239,7 @@ void ModuleBase_ParamSpinBox::keyPressEvent(QKeyEvent* e) void ModuleBase_ParamSpinBox::showEvent(QShowEvent* theEvent) { ModuleBase_DoubleSpinBox::showEvent(theEvent); - //setText(myTextValue); + if (hasVariable(myTextValue)) { + setText(myTextValue); + } }