Salome HOME
Adding Naming DS for Placement operation.
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index d3dd6f7ee16f288558d95a371f384d3100181d92..f246677ce22ad2e8a0aaff7dbac4d01854c3c991 100644 (file)
@@ -3,36 +3,47 @@
 // Author:      Vitaly Smetannikov
 
 #include "ModuleBase_Tools.h"
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_Document.h>
+#include <QWidget>
+#include <QLayout>
 
-namespace ModuleBase_Tools
-{
+namespace ModuleBase_Tools {
+
+//******************************************************************
 
 //******************************************************************
-boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
+
+void adjustMargins(QWidget* theWidget)
 {
-  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(!theWidget)
+    return;
+  adjustMargins(theWidget->layout());
 }
 
-//******************************************************************
-FeaturePtr feature(ObjectPtr theObject)
+void adjustMargins(QLayout* theLayout)
 {
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
-  if (!aFeature) {
-    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-    if (aResult) {
-      PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
-      DocumentPtr aDoc = aMgr->rootDocument();
-      return aDoc->feature(aResult);
-    }
-  }
-  return aFeature;
+  if(!theLayout)
+    return;
+  theLayout->setContentsMargins(2, 5, 5, 2);
+  theLayout->setSpacing(4);
 }
 
+void zeroMargins(QWidget* theWidget)
+{
+  if(!theWidget)
+    return;
+  zeroMargins(theWidget->layout());
 }
+
+void zeroMargins(QLayout* theLayout)
+{
+  if(!theLayout)
+    return;
+  theLayout->setContentsMargins(0, 0, 0, 0);
+  theLayout->setSpacing(5);
+}
+
+
+
+}
+
+