Salome HOME
Issue #1701 Preselecting before calling constraints does not put objects in the input...
[modules/shaper.git] / src / ModuleBase / ModuleBase_ModelWidget.cpp
index b172e101e9ed7518e2a8bf99ec22fd4656808b7f..713adea890d132a12a0b4b231bf6a3190eb14d7e 100644 (file)
@@ -54,7 +54,12 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
   myAttributeID = theData ? theData->widgetId() : "";
   myIsObligatory = theData->getBooleanAttribute(ATTR_OBLIGATORY, true);
 
-  myIsValueEnabled = theData->getBooleanAttribute(DOUBLE_WDG_ENABLE_VALUE, true);
+  myIsValueEnabled = On; // not defined or "true"
+  std::string anEnableValue = theData->getProperty(DOUBLE_WDG_ENABLE_VALUE);
+  if (anEnableValue == "false")
+    myIsValueEnabled = Off;
+  if (anEnableValue == DOUBLE_WDG_ENABLE_VALUE_BY_PREFERENCES)
+    myIsValueEnabled = DefinedInPreferences;
 
   connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
   connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified()));
@@ -84,9 +89,13 @@ bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
 bool ModuleBase_ModelWidget::isValueEnabled() const
 {
   bool anEnabled = true;
-  bool aCanDisable = Config_PropManager::boolean("Sketch planes", "disable_input_fields", "true");
-  if (aCanDisable)
-    anEnabled = myIsValueEnabled;
+  if (myIsValueEnabled == DefinedInPreferences) {
+    bool aCanDisable = Config_PropManager::boolean(SKETCH_TAB_NAME, "disable_input_fields", "true");
+    if (aCanDisable)
+      anEnabled = false;
+  }
+  else if (myIsValueEnabled == Off)
+    anEnabled = false;
   return anEnabled;
 }
 
@@ -200,8 +209,13 @@ void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool
   /// after debug, it may be corrected
   myFlushUpdateBlocked = !isUpdateFlushed;
   myFeature = theFeature;
-  if (theToStoreValue)
-    storeValue();
+  if (theToStoreValue) {
+    /// it is possible that the attribute is filled before the operation is started,
+    /// e.g. by reentrant operation case some attributes are filled by values of
+    /// feature of previous operation, we should not lost them here
+    if (!theFeature->data()->attribute(attributeID())->isInitialized())
+      storeValue();
+  }
   myFlushUpdateBlocked = false;
 }