Salome HOME
Bugfix: treat attribute as valid and initialized if it's default value is equual...
authorsbh <sergey.belash@opencascade.com>
Wed, 3 Sep 2014 13:22:56 +0000 (17:22 +0400)
committersbh <sergey.belash@opencascade.com>
Wed, 3 Sep 2014 13:22:56 +0000 (17:22 +0400)
src/Model/Model_AttributeReference.cpp
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetFileSelector.cpp
src/XGUI/XGUI_Workshop.cpp

index dfb54c5f10331298e535624aba6457cb10ee2cf9..120291627cacfa263112badbeebf9454c2efb5b1 100644 (file)
@@ -12,6 +12,8 @@ using namespace std;
 
 void Model_AttributeReference::setValue(ObjectPtr theObject)
 {
+  if(!theObject)
+    return;
   if (!myIsInitialized || value() != theObject) {
     boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(
         theObject->data());
index 80c4cb856c00509eb93bc34b766d0f2c0668775b..6ad8f52054e0d506b402cffcfeb092dcceccf833 100644 (file)
@@ -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() : "";
index 2d626c58b371e7531368b5be8e7449030b2cce35..bc520ffb35742870864471055bb738fa7db0c767 100644 (file)
@@ -67,13 +67,6 @@ Q_OBJECT
   /// \return a control list
   virtual QList<QWidget*> 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;
index e6bbdad250ee58087af360c81475676116dddd3f..6cd23ff9794843c679d57f36f9beda1196a8b134 100644 (file)
@@ -46,11 +46,8 @@ bool ModuleBase_WidgetBoolValue::storeValue() const
 {
   DataPtr aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
-
-  if (aBool->value() != myCheckBox->isChecked()) {
-    aBool->setValue(myCheckBox->isChecked());
-    updateObject(myFeature);
-  }
+  aBool->setValue(myCheckBox->isChecked());
+  updateObject(myFeature);
   return true;
 }
 
index 361c07cfc8da1153c14d45fa38f51deac4f99113..f98bf3dcf9cf25814c82e053d8989f5f6b667d8a 100644 (file)
@@ -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;
 }
 
index 7d834cca412be1c0266670bb609ece6bfc20d9a5..a2e8186c8f2e85797ae3468b11507ab77f803405 100644 (file)
@@ -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;
 }
 
index d91f4d98e759ccfa0493909f562e566e544df7f3..6aacc23e3fe327437035c39d8dff387c8686fe0a 100644 (file)
@@ -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();