From 961ea56517a179bcdc1b741575df5f3817f94d28 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 24 Jun 2014 14:25:50 +0400 Subject: [PATCH] refs #80 - Sketch base GUI: create/draw point, circle and arc Hide internal widgets. --- src/ModuleBase/ModuleBase_WidgetFactory.cpp | 16 +++++++++++++++- src/ModuleBase/ModuleBase_WidgetFactory.h | 5 +++++ src/SketchPlugin/plugin-Sketch.xml | 6 +++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 0ced5bb8b..e122c5250 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -61,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 @@ -195,6 +199,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) { diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index 3493028c5..b29fba9eb 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -45,6 +45,11 @@ protected: QWidget* booleanControl(QWidget* theParent); QWidget* point2dDistanceControl(QWidget* theParent); + /// Check whether the XML definition for the given type contains internal property + /// \param theType the widget type + /// \return the boolean result + bool isInternalWidget(const std::string& theType); + QString qs(const std::string& theStdString) const; private: diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 5b1dcf600..c741ab09c 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -24,9 +24,9 @@ -- 2.39.2