From: sbh Date: Wed, 3 Sep 2014 13:22:56 +0000 (+0400) Subject: Bugfix: treat attribute as valid and initialized if it's default value is equual... X-Git-Tag: V_0.4.4~90 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2b0773dd16ddc859eb8d4cbb52afded33eb25c97;p=modules%2Fshaper.git Bugfix: treat attribute as valid and initialized if it's default value is equual to model's default value --- diff --git a/src/Model/Model_AttributeReference.cpp b/src/Model/Model_AttributeReference.cpp index dfb54c5f1..120291627 100644 --- a/src/Model/Model_AttributeReference.cpp +++ b/src/Model/Model_AttributeReference.cpp @@ -12,6 +12,8 @@ using namespace std; void Model_AttributeReference::setValue(ObjectPtr theObject) { + if(!theObject) + return; if (!myIsInitialized || value() != theObject) { boost::shared_ptr aData = boost::dynamic_pointer_cast( theObject->data()); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 80c4cb856..6ad8f5205 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -17,7 +17,6 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) : QObject(theParent), - myHasDefaultValue(false), myParentId(theParentId) { myAttributeID = theData ? theData->widgetId() : ""; diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 2d626c58b..bc520ffb3 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -67,13 +67,6 @@ Q_OBJECT /// \return a control list virtual QList getControls() const = 0; - /// Returns whether the control has a default value - /// \return a boolean value - bool hasDefaultValue() const - { - return myHasDefaultValue; - } - /// Returns the attribute name /// \returns the string value std::string attributeID() const @@ -118,8 +111,6 @@ signals: void updateObject(ObjectPtr theObj) const; - bool myHasDefaultValue; /// the boolean state whether the control has a default value - std::string myAttributeID; /// the attribute name of the model feature std::string myParentId; /// name of parent FeaturePtr myFeature; diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index e6bbdad25..6cd23ff97 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -46,11 +46,8 @@ bool ModuleBase_WidgetBoolValue::storeValue() const { DataPtr aData = myFeature->data(); boost::shared_ptr aBool = aData->boolean(attributeID()); - - if (aBool->value() != myCheckBox->isChecked()) { - aBool->setValue(myCheckBox->isChecked()); - updateObject(myFeature); - } + aBool->setValue(myCheckBox->isChecked()); + updateObject(myFeature); return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 361c07cfc..f98bf3dcf 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -69,7 +69,6 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, aProp = theData->getProperty(DOUBLE_WDG_DFLT); double aDefVal = QString::fromStdString(aProp).toDouble(&isOk); - myHasDefaultValue = isOk; if (isOk) { mySpinBox->setValue(aDefVal); } @@ -93,10 +92,8 @@ bool ModuleBase_WidgetDoubleValue::storeValue() const { DataPtr aData = myFeature->data(); AttributeDoublePtr aReal = aData->real(attributeID()); - if (aReal->value() != mySpinBox->value()) { - aReal->setValue(mySpinBox->value()); - updateObject(myFeature); - } + aReal->setValue(mySpinBox->value()); + updateObject(myFeature); return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp index 7d834cca4..a2e8186c8 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp @@ -29,8 +29,6 @@ ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent, const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId) { - myHasDefaultValue = false; - myTitle = QString::fromStdString(theData->getProperty("title")); //TODO(sbh): Get them from the feature myFormats = getSupportedFormats(theData); @@ -67,12 +65,9 @@ bool ModuleBase_WidgetFileSelector::storeValue() const { DataPtr aData = myFeature->data(); AttributeStringPtr aStringAttr = aData->string(attributeID()); - QString aModelValue = QString::fromStdString(aStringAttr->value()); QString aWidgetValue = myPathField->text(); - if(aModelValue != aWidgetValue) { - aStringAttr->setValue(aWidgetValue.toStdString()); - updateObject(myFeature); - } + aStringAttr->setValue(aWidgetValue.toStdString()); + updateObject(myFeature); return true; } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index d91f4d98e..6aacc23e3 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -417,7 +417,7 @@ void XGUI_Workshop::onOperationStarted() //QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue())); QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged())); // Init default values - if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) { + if (!aOperation->isEditOperation()) { //aWidget->storeValue(aOperation->feature()); aWidget->storeValue();