Salome HOME
Define abstract module class
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index dfd282ea34fe5e90343f49154cf837cc6ca40f16..ffb17b5c2b2560c666c15fa902234819e1d5da87 100644 (file)
@@ -5,18 +5,42 @@
 #include "ModuleBase_Tools.h"
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Document.h>
 
-namespace ModuleBase_Tools
-{
+namespace ModuleBase_Tools {
+
+//******************************************************************
 
 //******************************************************************
-boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
+
+void adjustMargins(QWidget* theWidget)
+{
+  if(!theWidget)
+    return;
+  adjustMargins(theWidget->layout());
+}
+
+void adjustMargins(QLayout* theLayout)
+{
+  if(!theLayout)
+    return;
+  theLayout->setContentsMargins(5, 5, 5, 5);
+  theLayout->setSpacing(5);
+}
+
+void zeroMargins(QWidget* theWidget)
+{
+  if(!theWidget)
+    return;
+  zeroMargins(theWidget->layout());
+}
+
+void zeroMargins(QLayout* theLayout)
 {
-  ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
-  if (aBody) return aBody->shape();
-  ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
-  if (aConstruct) return aConstruct->shape();
-  return boost::shared_ptr<GeomAPI_Shape>();
+  if(!theLayout)
+    return;
+  theLayout->setContentsMargins(0, 0, 0, 0);
+  theLayout->setSpacing(5);
 }
 
 }