Salome HOME
Within Issue #143 highlight active inputs
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFactory.cpp
index 1063cfa9acf272b0d1bc6fc1c2e7001ce718b90a..9ce1c133fa9f9a6a4ad05c756300f0aabda1e95f 100644 (file)
@@ -22,6 +22,9 @@
 #include <ModuleBase_WidgetChoice.h>
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IModule.h>
+#include <ModuleBase_Tools.h>
+
+#include <ModelAPI_Validator.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -61,7 +64,6 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
     return;
 
   QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent);
-  aWidgetLay->setContentsMargins(2, 2, 2, 2);
   do {  //Iterate over each node
     std::string aWdgType = myWidgetApi->widgetType();
     //Create a widget (doublevalue, groupbox, toolbox, etc.
@@ -77,6 +79,7 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
       //if current widget is groupbox (container) process it's children recursively
       QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
       createWidget(aWidget);
+      ModuleBase_Tools::adjustMargins(aWidget);
       QGroupBox* aGrBox = qobject_cast<QGroupBox*>(aWidget);
       aGrBox->setTitle(aGroupName);
     }
@@ -87,6 +90,7 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
       do {
         QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
         QWidget* aPage = new QWidget(aWidget);
+        ModuleBase_Tools::adjustMargins(aPage);
         createWidget(aPage);
         if (aWdgType == WDG_SWITCH) {
           ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
@@ -161,6 +165,17 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
     if (!result) {qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type");}
 #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());
+    }
+  }
+
   return result;
 }