Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFactory.cpp
index 985c56a50fd24749f50e91c820876e053fa4cb3b..bd45e4ee04ae26eabd8b8a42cbde496e3f80423b 100644 (file)
@@ -27,6 +27,7 @@
 #include <ModuleBase_WidgetMultiSelector.h>
 
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -72,7 +73,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);
@@ -122,6 +123,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<ModelAPI_Session> 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)
 {
@@ -175,14 +195,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;