From: sbh Date: Mon, 27 Oct 2014 13:16:08 +0000 (+0300) Subject: The "concealment" attribute added X-Git-Tag: V_0.5~69^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e97b8971af2bac1be9a67956de5ee4194f1fd10f;p=modules%2Fshaper.git The "concealment" attribute added --- diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 1f7a65b2d..5c4ffba8e 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -92,7 +92,7 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theNode, bool Config_FeatureReader::isInternalFeature(xmlNodePtr theNode) { - std::string prop = getProperty(theNode, FEATURE_INTERNAL); + std::string prop = getProperty(theNode, ATTRIBUTE_INTERNAL); std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower); if (prop.empty() || prop == "false" || prop == "0") { return false; diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 5a4eb4683..46338306b 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -50,8 +50,10 @@ const static char* FEATURE_ICON = "icon"; const static char* FEATURE_TEXT = "title"; const static char* FEATURE_KEYSEQUENCE = "keysequence"; const static char* FEATURE_NESTED = "nested"; -const static char* FEATURE_INTERNAL = "internal"; -const static char* FEATURE_OBLIGATORY = "obligatory"; + +const static char* ATTRIBUTE_INTERNAL = "internal"; +const static char* ATTRIBUTE_OBLIGATORY = "obligatory"; +const static char* ATTRIBUTE_CONCEALMENT = "concealment"; // TODO: Rename const static char* PREVIOUS_FEATURE_PARAM = "previous_feature_param"; const static char* ANY_WDG_TOOLTIP = FEATURE_TOOLTIP; diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index c7c5f4bdd..4158caaa9 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -6,6 +6,7 @@ activate="true" shape_types="face" use_subshapes="true" + concealment="true" /> diff --git a/src/Model/Model_Validator.cpp b/src/Model/Model_Validator.cpp index 987db716e..d1adbbbe9 100644 --- a/src/Model/Model_Validator.cpp +++ b/src/Model/Model_Validator.cpp @@ -211,8 +211,7 @@ bool Model_ValidatorsFactory::validate(const boost::shared_ptr return true; } -void Model_ValidatorsFactory::registerNotObligatory( - std::string theFeature, std::string theAttribute) +void Model_ValidatorsFactory::registerNotObligatory(std::string theFeature, std::string theAttribute) { std::map::const_iterator it = myIDs.find(kDefaultId); if (it != myIDs.end()) { @@ -222,3 +221,10 @@ void Model_ValidatorsFactory::registerNotObligatory( } } } + +void Model_ValidatorsFactory::registerConcealment(std::string theFeature, std::string theAttribute) +{ + +} + + diff --git a/src/Model/Model_Validator.h b/src/Model/Model_Validator.h index 38d2d7bf5..cfaeb89c5 100644 --- a/src/Model/Model_Validator.h +++ b/src/Model/Model_Validator.h @@ -72,6 +72,10 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory /// so, it is not needed for the standard validation mechanism virtual void registerNotObligatory(std::string theFeature, std::string theAttribute); + /// register that this attribute conceals in the object browser + /// all referenced features after execution + virtual void registerConcealment(std::string theFeature, std::string theAttribute); + protected: void addDefaultValidators(std::list& theValidators) const; /// Get instance from Session diff --git a/src/ModelAPI/ModelAPI_Validator.h b/src/ModelAPI/ModelAPI_Validator.h index ea47856f4..940be4c4d 100644 --- a/src/ModelAPI/ModelAPI_Validator.h +++ b/src/ModelAPI/ModelAPI_Validator.h @@ -83,6 +83,10 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory /// so, it is not needed for the standard validation mechanism virtual void registerNotObligatory(std::string theFeature, std::string theAttribute) = 0; + /// register that this attribute conceals in the object browser + /// all referenced features after execution + virtual void registerConcealment(std::string theFeature, std::string theAttribute) = 0; + protected: /// Get instance from Session ModelAPI_ValidatorsFactory() diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index dde892d22..5a6ba6e1e 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -26,7 +26,6 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_ myParentId(theParentId) { myIsComputedDefault = false; - myIsObligatory = theData ? theData->getBooleanAttribute(FEATURE_OBLIGATORY, true) : true; myAttributeID = theData ? theData->widgetId() : ""; } diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 48a650e32..25c0bf246 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -48,10 +48,6 @@ Q_OBJECT /// on operation's execute, like radius for circle's constraint (can not be zero) bool isComputedDefault() { return myIsComputedDefault; } - /// Returns false for non-obligatory widgets which are - /// valid even if they are not initialized - bool isObligatory() { return myIsObligatory; } - /// Defines if it is supposed that the widget should interact with the viewer. virtual bool isViewerSelector() { return false; } @@ -145,8 +141,7 @@ signals: FeaturePtr myFeature; bool myIsComputedDefault; /// Value should be computed on execute, - /// like radius for circle's constraint (can not be zero) - bool myIsObligatory; /// Non-obligatory widget is valid even if it is not initialized + /// like radius for circle's constraint (can not be zero) }; #endif diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 057c4d5d3..cbe7503a8 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -71,7 +71,7 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) //Create a widget (doublevalue, groupbox, toolbox, etc. QWidget* aWidget = createWidgetByType(aWdgType, theParent); if (aWidget) { - if (!myWidgetApi->getBooleanAttribute(FEATURE_INTERNAL, false)) { + if (!myWidgetApi->getBooleanAttribute(ATTRIBUTE_INTERNAL, false)) { aWidgetLay->addWidget(aWidget); } else { aWidget->setVisible(false); @@ -121,6 +121,25 @@ QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent) return result; } +void ModuleBase_WidgetFactory::processAttributes() +{ + // register that this attribute in feature is not obligatory for the feature execution + // so, it is not needed for the standard validation mechanism + bool isObligatory = true; + bool isConcealment = false; + if( myWidgetApi ){ + isObligatory = myWidgetApi->getBooleanAttribute(ATTRIBUTE_OBLIGATORY, true); + isConcealment = myWidgetApi->getBooleanAttribute(ATTRIBUTE_CONCEALMENT, false); + } + boost::shared_ptr aSession = ModelAPI_Session::get(); + if (!isObligatory) { + aSession->validators()->registerNotObligatory(myParentId, myWidgetApi->widgetId()); + } + if(isConcealment) { + aSession->validators()->registerConcealment(myParentId, myWidgetApi->widgetId()); + } +} + QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType, QWidget* theParent) { @@ -174,14 +193,7 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType #endif } if (result) { - // register that this attribute in feature is not obligatory for the feature execution - // so, it is not needed for the standard validation mechanism - bool isObligatory = - myWidgetApi ? myWidgetApi->getBooleanAttribute(FEATURE_OBLIGATORY, true) : true; - if (!isObligatory) { - ModelAPI_Session::get()->validators()->registerNotObligatory( - myParentId, myWidgetApi->widgetId()); - } + processAttributes(); } return result; diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index fd267d418..43b8208b6 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -53,6 +53,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory QString qs(const std::string& theStdString) const; + void processAttributes(); private: Config_WidgetAPI* myWidgetApi;