Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFactory.cpp
index e651ba7d362fbf3d8dbba99b07b4bd78fa7493dd..a88a3086063388ad47af60ad03e314a8f52d1f54 100644 (file)
@@ -16,6 +16,7 @@
 #include <ModuleBase_WidgetSelector.h>
 #include <ModuleBase_WidgetDoubleValue.h>
 #include <ModuleBase_WidgetBoolValue.h>
+#include <ModuleBase_WidgetPoint2dDistance.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -60,7 +61,11 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
     //Create a widget (doublevalue, groupbox, toolbox, etc.
     QWidget* aWidget = createWidgetByType(aWdgType, theParent);
     if (aWidget) {
-      aWidgetLay->addWidget(aWidget);
+      if (!isInternalWidget(aWdgType)) {
+        aWidgetLay->addWidget(aWidget);
+      }
+      else
+        aWidget->setVisible(false);
     }
     if (myWidgetApi->isContainerWidget()) {
       //if current widget is groupbox (container) process it's children recursively
@@ -95,6 +100,7 @@ QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
   QWidget* result = new QWidget(theParent);
   QVBoxLayout* aLabelLay = new QVBoxLayout(result);
   QLabel* aLabel = new QLabel(result);
+  aLabel->setWordWrap(true);
   aLabel->setText(qs(myWidgetApi->getProperty(INFO_WDG_TEXT)));
   aLabel->setToolTip(qs(myWidgetApi->getProperty(INFO_WDG_TOOLTIP)));
   aLabelLay->addWidget(aLabel);
@@ -126,6 +132,9 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
 
   } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
     result = doubleValueEditor(theParent);
+  
+  } else if (theType == WDG_POINT2D_DISTANCE) {
+    result = point2dDistanceControl(theParent);
 
   }
   else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
@@ -191,6 +200,16 @@ QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
   return QString::fromStdString(theStdString);
 }
 
+bool ModuleBase_WidgetFactory::isInternalWidget(const std::string& theType)
+{
+  std::string prop = myWidgetApi->getProperty(FEATURE_INTERNAL);
+
+  std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower);
+  if(prop.empty() || prop == "false" || prop == "0") {
+    return false;
+  }
+  return true; 
+}
 
 QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
 {
@@ -206,4 +225,13 @@ QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
   myModelWidgets.append(aBoolWgt);
 
   return aBoolWgt->getControl();
+}
+
+
+QWidget* ModuleBase_WidgetFactory::point2dDistanceControl(QWidget* theParent)
+{
+  ModuleBase_WidgetPoint2dDistance* aDistWgt = new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi);
+  myModelWidgets.append(aDistWgt);
+
+  return aDistWgt->getControl();
 }
\ No newline at end of file