X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ModelWidget.cpp;h=fdfffa34389b7df51a34a367975047e4141ebec0;hb=aee09da348319d21259bee81c45d00a08f657de0;hp=69cd60c463ba29b321ad6d99cf508fe7c15fb82a;hpb=7e9e955376b504dc7d9e0a5e79a9a38943a53fcd;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 69cd60c46..fdfffa343 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -31,6 +32,7 @@ //#define DEBUG_VALUE_STATE //#define DEBUG_WIDGET_INSTANCE +//#define DEBUG_ENABLE_SKETCH_INPUT_FIELDS ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_WidgetAPI* theData) @@ -53,6 +55,13 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, myAttributeID = theData ? theData->widgetId() : ""; myIsObligatory = theData->getBooleanAttribute(ATTR_OBLIGATORY, 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())); } @@ -78,6 +87,24 @@ bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const return theObject->data()->attribute(attributeID())->isInitialized(); } +bool ModuleBase_ModelWidget::isValueEnabled() const +{ + bool anEnabled = true; + if (myIsValueEnabled == DefinedInPreferences) { +#ifdef DEBUG_ENABLE_SKETCH_INPUT_FIELDS + bool aCanDisable = false; +#else + //Config_PropManager::boolean(SKETCH_TAB_NAME, "disable_input_fields", "true"); + bool aCanDisable = true; +#endif + if (aCanDisable) + anEnabled = false; + } + else if (myIsValueEnabled == Off) + anEnabled = false; + return anEnabled; +} + void ModuleBase_ModelWidget::processValueState() { if (myState == ModifiedInPP || myState == ModifiedInViewer) @@ -188,8 +215,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; }