-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-/*
- * ModuleBase_WidgetFactory.cpp
- *
- * Created on: Apr 3, 2014
- * Author: sbh
- */
-
-#include <ModuleBase_WidgetFactory.h>
-#include <ModuleBase_IconFactory.h>
-
-#include <ModuleBase_Operation.h>
-#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetEditor.h>
-#include <ModuleBase_WidgetSwitch.h>
-#include <ModuleBase_WidgetShapeSelector.h>
-#include <ModuleBase_WidgetDoubleValue.h>
-#include <ModuleBase_WidgetIntValue.h>
-#include <ModuleBase_WidgetBoolValue.h>
-#include <ModuleBase_WidgetFileSelector.h>
-#include <ModuleBase_WidgetChoice.h>
-#include <ModuleBase_IWorkshop.h>
-#include <ModuleBase_IModule.h>
-#include <ModuleBase_Tools.h>
-#include <ModuleBase_WidgetLineEdit.h>
-#include <ModuleBase_WidgetMultiSelector.h>
-#include <ModuleBase_WidgetConcealedObjects.h>
-#include <ModuleBase_WidgetLabel.h>
-#include <ModuleBase_WidgetToolbox.h>
-#include <ModuleBase_PageBase.h>
-#include <ModuleBase_PageGroupBox.h>
-#include <ModuleBase_WidgetOptionalBox.h>
-#include <ModuleBase_PageWidget.h>
-#include <ModuleBase_WidgetExprEditor.h>
-#include <ModuleBase_WidgetCreatorFactory.h>
-#include <ModuleBase_WidgetAction.h>
-
-#include <ModelAPI_Validator.h>
-#include <ModelAPI_Session.h>
-
-#include <Config_Keywords.h>
-#include <Config_WidgetAPI.h>
-
-#include <QWidget>
-#include <QHBoxLayout>
-#include <QGridLayout>
-#include <QSpinBox>
-#include <QMetaProperty>
-#include <QLabel>
-#include <QPixmap>
-#include <QGroupBox>
-#include <QToolBox>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-#include <cfloat>
-#include <climits>
-
-ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
- ModuleBase_IWorkshop* theWorkshop)
- : myWorkshop(theWorkshop)
-{
- myWidgetApi = new Config_WidgetAPI(theXmlRepresentation);
-}
-
-ModuleBase_WidgetFactory::~ModuleBase_WidgetFactory()
-{
- delete myWidgetApi;
-}
-
-void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage, bool alignToTop)
-{
- std::string aWType = myWidgetApi->widgetType();
- if (aWType == NODE_FEATURE) {
- // if XML definition of the feature contains the next key, the widgets should not be created,
- // but a specific panel should be made. However, to provide persistent of the panel values,
- // we need to get into the panel the feature of the operation. As a result this panel should
- // be created after the feature creating(create operation). The method setPanel() of this
- // class is used for this. Here, we just return to avoid the widgets creation.
- std::string aPanelName = myWidgetApi->getProperty(PROPERTY_PANEL_ID);
- if (!aPanelName.empty())
- return;
- }
-
- if (!myWidgetApi->toChildWidget())
- return;
-
- do { //Iterate over each node
- std::string aWdgType = myWidgetApi->widgetType();
- // Create PageGroup TODO: extract
- if (myWidgetApi->isGroupBoxWidget() ||
- ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
-
- //if current widget is groupbox (container) process it's children recursively
- ModuleBase_PageBase* aPage = createPageByType(aWdgType, thePage->pageWidget());
-
- createWidget(aPage);
- thePage->addPageWidget(aPage);
- } else {
- // Create a ModelWidget
- ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, thePage->pageWidget());
- if (aWidget) {
- if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {
- thePage->addModelWidget(aWidget);
- } else {
- aWidget->setVisible(false);
- }
- }
- // Create PagedContainer TODO: extract
- if (myWidgetApi->isPagedWidget()) {
- //If current widget is toolbox or switch-casebox then fetch all
- //it's pages recursively and setup into the widget.
- if (myWidgetApi->toChildWidget()) {
- do {
- QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
- QString aCaseId = qs(myWidgetApi->getProperty(_ID));
- ModuleBase_PageBase* aPage = new ModuleBase_PageWidget(aWidget);
- createWidget(aPage);
- if (aWdgType == WDG_SWITCH || aWdgType == WDG_TOOLBOX) {
- ModuleBase_PagedContainer* aContainer = qobject_cast<ModuleBase_PagedContainer*>(aWidget);
-
- QString anIconPath = qs( myWidgetApi->getProperty( CONTAINER_PAGE_ICON ) );
- QPixmap anIcon = ModuleBase_IconFactory::loadPixmap( anIconPath );
- aContainer->addPage( aPage, aPageName, aCaseId, anIcon );
- }
- } while (myWidgetApi->toNextWidget());
- }
- }
- }
- } while (myWidgetApi->toNextWidget());
-
- if (alignToTop)
- thePage->alignToTop();
-}
-
-void ModuleBase_WidgetFactory::createPanel(ModuleBase_PageBase* thePage,
- const FeaturePtr& theFeature)
-{
- std::string aPanelName = myWidgetApi->getProperty(PROPERTY_PANEL_ID);
- if (!aPanelName.empty() && ModuleBase_WidgetCreatorFactory::get()->hasPanelWidget(aPanelName)) {
- QWidget* aPanel = ModuleBase_WidgetCreatorFactory::get()->createPanelByType(aPanelName,
- thePage->pageWidget(), theFeature);
- thePage->addWidget(aPanel);
- thePage->alignToTop();
- }
-}
-
-void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage,
- const std::string& theWidgetId)
-{
- bool aFound = false;
- moveToWidgetId(theWidgetId, aFound);
- if (aFound) {
- std::string aWdgType = myWidgetApi->widgetType();
-
- // Create a ModelWidget
- ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, thePage->pageWidget());
- if (aWidget) {
- if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {
- thePage->addModelWidget(aWidget);
- }
- else {
- aWidget->setVisible(false);
- }
- }
- }
- thePage->alignToTop();
-}
-
-void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theAttributeId,
- std::string& theTitle)
-{
- bool aFound = false;
- moveToWidgetId(theAttributeId, aFound);
- if (aFound) {
- theTitle = QString::fromStdString(myWidgetApi->widgetLabel()).toStdString().c_str();
- if (theTitle.empty())
- theTitle = QString::fromStdString(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)).toStdString().c_str();
- }
-}
-
-void ModuleBase_WidgetFactory::getGreedAttribute(std::string& theAttributeId)
-{
- if (!theAttributeId.empty())
- return;
-
- if (!myWidgetApi->toChildWidget())
- return;
-
- do { //Iterate over each node
- std::string aWdgType = myWidgetApi->widgetType();
- // Find title under PageGroup
- if (myWidgetApi->isGroupBoxWidget() ||
- ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
- getGreedAttribute(theAttributeId);
- }
- else {
- // Find title here
- std::string anAttributeId = myWidgetApi->widgetId();
- if (myWidgetApi->getBooleanAttribute(ATTR_GREED, false))
- theAttributeId = anAttributeId;
- if (theAttributeId.empty() && myWidgetApi->isPagedWidget()) {
- //If current widget is toolbox or switch-casebox then fetch all
- //it's pages recursively and setup into the widget.
- if (myWidgetApi->toChildWidget()) {
- do {
- getGreedAttribute(theAttributeId);
- } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
- }
- }
- }
- } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
-}
-
-void ModuleBase_WidgetFactory::moveToWidgetId(const std::string& theWidgetId, bool& theFound)
-{
- if (theFound)
- return;
-
- if (!myWidgetApi->toChildWidget())
- return;
-
- do { //Iterate over each node
- std::string aWdgType = myWidgetApi->widgetType();
- // Find title under PageGroup
- if (myWidgetApi->isGroupBoxWidget() ||
- ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
- moveToWidgetId(theWidgetId, theFound);
- }
- else {
- // Find title here
- std::string anAttributeId = myWidgetApi->widgetId();
- theFound = anAttributeId == theWidgetId;
- if (!theFound && myWidgetApi->isPagedWidget()) {
- //If current widget is toolbox or switch-casebox then fetch all
- //it's pages recursively and setup into the widget.
- if (myWidgetApi->toChildWidget()) {
- do {
- moveToWidgetId(theWidgetId, theFound);
- } while (!theFound && myWidgetApi->toNextWidget());
- }
- }
- }
- } while (!theFound && myWidgetApi->toNextWidget());
-}
-
-ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::string& theType,
- QWidget* theParent)
-{
- ModuleBase_PageBase* aResult = NULL;
-
- if (theType == WDG_GROUP) {
- QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
- ModuleBase_PageGroupBox* aPage = new ModuleBase_PageGroupBox(theParent);
- aPage->setTitle(aGroupName);
- aResult = aPage;
- }
- else if (theType == WDG_OPTIONALBOX) {
- ModuleBase_WidgetOptionalBox* aPage = new ModuleBase_WidgetOptionalBox(theParent,
- myWidgetApi);
- aResult = aPage;
- }
- if (!aResult)
- aResult = ModuleBase_WidgetCreatorFactory::get()->createPageByType(theType, theParent,
- myWidgetApi);
-
- ModuleBase_ModelWidget* aWidget = dynamic_cast<ModuleBase_ModelWidget*>(aResult);
- if (aWidget)
- myModelWidgets.append(aWidget);
-
- return aResult;
-}
-
-ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,
- QWidget* theParent)
-{
- ModuleBase_ModelWidget* result = NULL;
-
- if (theType == WDG_INFO) {
- result = new ModuleBase_WidgetLabel(theParent, myWidgetApi);
- } else if (theType == WDG_DOUBLEVALUE) {
- result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi);
- } else if (theType == WDG_INTEGERVALUE) {
- result = new ModuleBase_WidgetIntValue(theParent, myWidgetApi);
- } else if (theType == WDG_SHAPE_SELECTOR) {
- result = new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi);
- } else if (theType == WDG_BOOLVALUE) {
- result = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi);
- //} else if (theType == WDG_DOUBLEVALUE_EDITOR) {
- // result = new ModuleBase_WidgetEditor(theParent, myWidgetApi);
- } else if (theType == WDG_FILE_SELECTOR) {
- result = new ModuleBase_WidgetFileSelector(theParent, myWidgetApi);
- } else if (theType == WDG_CHOICE) {
- result = new ModuleBase_WidgetChoice(theParent, myWidgetApi);
- } else if (theType == WDG_STRINGVALUE) {
- std::string aPlaceHolder = myWidgetApi->getProperty( WDG_PLACE_HOLDER );
- result = new ModuleBase_WidgetLineEdit( theParent, myWidgetApi, aPlaceHolder );
- } else if (theType == WDG_EXPR_EDITOR) {
- std::string aPlaceHolder = myWidgetApi->getProperty( WDG_PLACE_HOLDER );
- result = new ModuleBase_WidgetExprEditor( theParent, myWidgetApi, aPlaceHolder );
- } else if (theType == WDG_MULTISELECTOR) {
- result = new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi);
- } else if (theType == WDG_CONCEALED_OBJECTS_VIEW) {
- result = new ModuleBase_WidgetConcealedObjects(theParent, myWidgetApi);
- } else if (theType == WDG_TOOLBOX) {
- result = new ModuleBase_WidgetToolbox(theParent, myWidgetApi);
- } else if (theType == WDG_SWITCH) {
- result = new ModuleBase_WidgetSwitch(theParent, myWidgetApi);
- } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE ||
- theType == NODE_VALIDATOR) {
- // Do nothing for "box" and "case"
- result = NULL;
- } else if (theType == WDG_ACTION) {
- result = new ModuleBase_WidgetAction(theParent, myWidgetApi);
- } else {
- result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi);
- if (!result)
- result = ModuleBase_WidgetCreatorFactory::get()->createWidgetByType(theType, theParent,
- myWidgetApi, myWorkshop);
- #ifdef _DEBUG
- if (!result) {
- qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type %s", theType.c_str());
- }
- #endif
- }
- if (result)
- myModelWidgets.append(result);
- return result;
-}
-
-QString ModuleBase_WidgetFactory::qs(const std::string& theStdString)
-{
- return QString::fromStdString(theStdString);
-}
-
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
+/*\r
+ * ModuleBase_WidgetFactory.cpp\r
+ *\r
+ * Created on: Apr 3, 2014\r
+ * Author: sbh\r
+ */\r
+\r
+#include <ModuleBase_WidgetFactory.h>\r
+#include <ModuleBase_IconFactory.h>\r
+\r
+#include <ModuleBase_Operation.h>\r
+#include <ModuleBase_OperationDescription.h>\r
+#include <ModuleBase_WidgetEditor.h>\r
+#include <ModuleBase_WidgetSwitch.h>\r
+#include <ModuleBase_WidgetShapeSelector.h>\r
+#include <ModuleBase_WidgetFeatureSelector.h>\r
+#include <ModuleBase_WidgetDoubleValue.h>\r
+#include <ModuleBase_WidgetIntValue.h>\r
+#include <ModuleBase_WidgetBoolValue.h>\r
+#include <ModuleBase_WidgetFileSelector.h>\r
+#include <ModuleBase_WidgetChoice.h>\r
+#include <ModuleBase_IWorkshop.h>\r
+#include <ModuleBase_IModule.h>\r
+#include <ModuleBase_Tools.h>\r
+#include <ModuleBase_WidgetLineEdit.h>\r
+#include <ModuleBase_WidgetMultiSelector.h>\r
+#include <ModuleBase_WidgetConcealedObjects.h>\r
+#include <ModuleBase_WidgetLabel.h>\r
+#include <ModuleBase_WidgetToolbox.h>\r
+#include <ModuleBase_PageBase.h>\r
+#include <ModuleBase_PageGroupBox.h>\r
+#include <ModuleBase_WidgetOptionalBox.h>\r
+#include <ModuleBase_PageWidget.h>\r
+#include <ModuleBase_WidgetExprEditor.h>\r
+#include <ModuleBase_WidgetCreatorFactory.h>\r
+#include <ModuleBase_WidgetAction.h>\r
+\r
+#include <ModelAPI_Validator.h>\r
+#include <ModelAPI_Session.h>\r
+\r
+#include <Config_Keywords.h>\r
+#include <Config_WidgetAPI.h>\r
+\r
+#include <QWidget>\r
+#include <QHBoxLayout>\r
+#include <QGridLayout>\r
+#include <QSpinBox>\r
+#include <QMetaProperty>\r
+#include <QLabel>\r
+#include <QPixmap>\r
+#include <QGroupBox>\r
+#include <QToolBox>\r
+\r
+#ifdef _DEBUG\r
+#include <QDebug>\r
+#endif\r
+\r
+#include <cfloat>\r
+#include <climits>\r
+\r
+ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,\r
+ ModuleBase_IWorkshop* theWorkshop)\r
+ : myWorkshop(theWorkshop)\r
+{\r
+ myWidgetApi = new Config_WidgetAPI(theXmlRepresentation);\r
+}\r
+\r
+ModuleBase_WidgetFactory::~ModuleBase_WidgetFactory()\r
+{\r
+ delete myWidgetApi;\r
+}\r
+\r
+void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage, bool alignToTop)\r
+{\r
+ std::string aWType = myWidgetApi->widgetType();\r
+ if (aWType == NODE_FEATURE) {\r
+ // if XML definition of the feature contains the next key, the widgets should not be created,\r
+ // but a specific panel should be made. However, to provide persistent of the panel values,\r
+ // we need to get into the panel the feature of the operation. As a result this panel should\r
+ // be created after the feature creating(create operation). The method setPanel() of this\r
+ // class is used for this. Here, we just return to avoid the widgets creation.\r
+ std::string aPanelName = myWidgetApi->getProperty(PROPERTY_PANEL_ID);\r
+ if (!aPanelName.empty())\r
+ return;\r
+ }\r
+\r
+ if (!myWidgetApi->toChildWidget())\r
+ return;\r
+\r
+ do { //Iterate over each node\r
+ std::string aWdgType = myWidgetApi->widgetType();\r
+ // Create PageGroup TODO: extract\r
+ if (myWidgetApi->isGroupBoxWidget() ||\r
+ ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {\r
+\r
+ //if current widget is groupbox (container) process it's children recursively\r
+ ModuleBase_PageBase* aPage = createPageByType(aWdgType, thePage->pageWidget());\r
+\r
+ createWidget(aPage);\r
+ thePage->addPageWidget(aPage);\r
+ } else {\r
+ // Create a ModelWidget\r
+ ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, thePage->pageWidget());\r
+ if (aWidget) {\r
+ if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {\r
+ thePage->addModelWidget(aWidget);\r
+ } else {\r
+ aWidget->setVisible(false);\r
+ }\r
+ }\r
+ // Create PagedContainer TODO: extract\r
+ if (myWidgetApi->isPagedWidget()) {\r
+ //If current widget is toolbox or switch-casebox then fetch all\r
+ //it's pages recursively and setup into the widget.\r
+ if (myWidgetApi->toChildWidget()) {\r
+ do {\r
+ QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));\r
+ QString aCaseId = qs(myWidgetApi->getProperty(_ID));\r
+ ModuleBase_PageBase* aPage = new ModuleBase_PageWidget(aWidget);\r
+ createWidget(aPage);\r
+ if (aWdgType == WDG_SWITCH || aWdgType == WDG_TOOLBOX) {\r
+ ModuleBase_PagedContainer* aContainer = qobject_cast<ModuleBase_PagedContainer*>(aWidget);\r
+\r
+ QString anIconPath = qs( myWidgetApi->getProperty( CONTAINER_PAGE_ICON ) );\r
+ QPixmap anIcon = ModuleBase_IconFactory::loadPixmap( anIconPath );\r
+ aContainer->addPage( aPage, aPageName, aCaseId, anIcon );\r
+ }\r
+ } while (myWidgetApi->toNextWidget());\r
+ }\r
+ }\r
+ }\r
+ } while (myWidgetApi->toNextWidget());\r
+\r
+ if (alignToTop)\r
+ thePage->alignToTop();\r
+}\r
+\r
+void ModuleBase_WidgetFactory::createPanel(ModuleBase_PageBase* thePage,\r
+ const FeaturePtr& theFeature)\r
+{\r
+ std::string aPanelName = myWidgetApi->getProperty(PROPERTY_PANEL_ID);\r
+ if (!aPanelName.empty() && ModuleBase_WidgetCreatorFactory::get()->hasPanelWidget(aPanelName)) {\r
+ QWidget* aPanel = ModuleBase_WidgetCreatorFactory::get()->createPanelByType(aPanelName,\r
+ thePage->pageWidget(), theFeature);\r
+ thePage->addWidget(aPanel);\r
+ thePage->alignToTop();\r
+ }\r
+}\r
+\r
+void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage,\r
+ const std::string& theWidgetId)\r
+{\r
+ bool aFound = false;\r
+ moveToWidgetId(theWidgetId, aFound);\r
+ if (aFound) {\r
+ std::string aWdgType = myWidgetApi->widgetType();\r
+\r
+ // Create a ModelWidget\r
+ ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, thePage->pageWidget());\r
+ if (aWidget) {\r
+ if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {\r
+ thePage->addModelWidget(aWidget);\r
+ }\r
+ else {\r
+ aWidget->setVisible(false);\r
+ }\r
+ }\r
+ }\r
+ thePage->alignToTop();\r
+}\r
+\r
+void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theAttributeId,\r
+ std::string& theTitle)\r
+{\r
+ bool aFound = false;\r
+ moveToWidgetId(theAttributeId, aFound);\r
+ if (aFound) {\r
+ theTitle = QString::fromStdString(myWidgetApi->widgetLabel()).toStdString().c_str();\r
+ if (theTitle.empty())\r
+ theTitle = QString::fromStdString(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)).toStdString().c_str();\r
+ }\r
+}\r
+\r
+void ModuleBase_WidgetFactory::getGreedAttribute(std::string& theAttributeId)\r
+{\r
+ if (!theAttributeId.empty())\r
+ return;\r
+\r
+ if (!myWidgetApi->toChildWidget())\r
+ return;\r
+\r
+ do { //Iterate over each node\r
+ std::string aWdgType = myWidgetApi->widgetType();\r
+ // Find title under PageGroup\r
+ if (myWidgetApi->isGroupBoxWidget() ||\r
+ ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {\r
+ getGreedAttribute(theAttributeId);\r
+ }\r
+ else {\r
+ // Find title here\r
+ std::string anAttributeId = myWidgetApi->widgetId();\r
+ if (myWidgetApi->getBooleanAttribute(ATTR_GREED, false))\r
+ theAttributeId = anAttributeId;\r
+ if (theAttributeId.empty() && myWidgetApi->isPagedWidget()) {\r
+ //If current widget is toolbox or switch-casebox then fetch all\r
+ //it's pages recursively and setup into the widget.\r
+ if (myWidgetApi->toChildWidget()) {\r
+ do {\r
+ getGreedAttribute(theAttributeId);\r
+ } while (theAttributeId.empty() && myWidgetApi->toNextWidget());\r
+ }\r
+ }\r
+ }\r
+ } while (theAttributeId.empty() && myWidgetApi->toNextWidget());\r
+}\r
+\r
+void ModuleBase_WidgetFactory::moveToWidgetId(const std::string& theWidgetId, bool& theFound)\r
+{\r
+ if (theFound)\r
+ return;\r
+\r
+ if (!myWidgetApi->toChildWidget())\r
+ return;\r
+\r
+ do { //Iterate over each node\r
+ std::string aWdgType = myWidgetApi->widgetType();\r
+ // Find title under PageGroup\r
+ if (myWidgetApi->isGroupBoxWidget() ||\r
+ ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {\r
+ moveToWidgetId(theWidgetId, theFound);\r
+ }\r
+ else {\r
+ // Find title here\r
+ std::string anAttributeId = myWidgetApi->widgetId();\r
+ theFound = anAttributeId == theWidgetId;\r
+ if (!theFound && myWidgetApi->isPagedWidget()) {\r
+ //If current widget is toolbox or switch-casebox then fetch all\r
+ //it's pages recursively and setup into the widget.\r
+ if (myWidgetApi->toChildWidget()) {\r
+ do {\r
+ moveToWidgetId(theWidgetId, theFound);\r
+ } while (!theFound && myWidgetApi->toNextWidget());\r
+ }\r
+ }\r
+ }\r
+ } while (!theFound && myWidgetApi->toNextWidget());\r
+}\r
+\r
+ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::string& theType,\r
+ QWidget* theParent)\r
+{\r
+ ModuleBase_PageBase* aResult = NULL;\r
+\r
+ if (theType == WDG_GROUP) {\r
+ QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));\r
+ ModuleBase_PageGroupBox* aPage = new ModuleBase_PageGroupBox(theParent);\r
+ aPage->setTitle(aGroupName);\r
+ aResult = aPage;\r
+ }\r
+ else if (theType == WDG_OPTIONALBOX) {\r
+ ModuleBase_WidgetOptionalBox* aPage = new ModuleBase_WidgetOptionalBox(theParent,\r
+ myWidgetApi);\r
+ aResult = aPage;\r
+ }\r
+ if (!aResult)\r
+ aResult = ModuleBase_WidgetCreatorFactory::get()->createPageByType(theType, theParent,\r
+ myWidgetApi);\r
+\r
+ ModuleBase_ModelWidget* aWidget = dynamic_cast<ModuleBase_ModelWidget*>(aResult);\r
+ if (aWidget)\r
+ myModelWidgets.append(aWidget);\r
+\r
+ return aResult;\r
+}\r
+\r
+ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,\r
+ QWidget* theParent)\r
+{\r
+ ModuleBase_ModelWidget* result = NULL;\r
+\r
+ if (theType == WDG_INFO) {\r
+ result = new ModuleBase_WidgetLabel(theParent, myWidgetApi);\r
+ } else if (theType == WDG_DOUBLEVALUE) {\r
+ result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi);\r
+ } else if (theType == WDG_INTEGERVALUE) {\r
+ result = new ModuleBase_WidgetIntValue(theParent, myWidgetApi);\r
+ } else if (theType == WDG_SHAPE_SELECTOR) {\r
+ result = new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi);\r
+ } else if (theType == WDG_FEATURE_SELECTOR) {\r
+ result = new ModuleBase_WidgetFeatureSelector(theParent, myWorkshop, myWidgetApi);\r
+ } else if (theType == WDG_BOOLVALUE) {\r
+ result = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi);\r
+ //} else if (theType == WDG_DOUBLEVALUE_EDITOR) {\r
+ // result = new ModuleBase_WidgetEditor(theParent, myWidgetApi);\r
+ } else if (theType == WDG_FILE_SELECTOR) {\r
+ result = new ModuleBase_WidgetFileSelector(theParent, myWidgetApi);\r
+ } else if (theType == WDG_CHOICE) {\r
+ result = new ModuleBase_WidgetChoice(theParent, myWidgetApi);\r
+ } else if (theType == WDG_STRINGVALUE) {\r
+ std::string aPlaceHolder = myWidgetApi->getProperty( WDG_PLACE_HOLDER );\r
+ result = new ModuleBase_WidgetLineEdit( theParent, myWidgetApi, aPlaceHolder );\r
+ } else if (theType == WDG_EXPR_EDITOR) {\r
+ std::string aPlaceHolder = myWidgetApi->getProperty( WDG_PLACE_HOLDER );\r
+ result = new ModuleBase_WidgetExprEditor( theParent, myWidgetApi, aPlaceHolder );\r
+ } else if (theType == WDG_MULTISELECTOR) {\r
+ result = new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi);\r
+ } else if (theType == WDG_CONCEALED_OBJECTS_VIEW) {\r
+ result = new ModuleBase_WidgetConcealedObjects(theParent, myWidgetApi);\r
+ } else if (theType == WDG_TOOLBOX) {\r
+ result = new ModuleBase_WidgetToolbox(theParent, myWidgetApi);\r
+ } else if (theType == WDG_SWITCH) {\r
+ result = new ModuleBase_WidgetSwitch(theParent, myWidgetApi);\r
+ } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE ||\r
+ theType == NODE_VALIDATOR) {\r
+ // Do nothing for "box" and "case"\r
+ result = NULL;\r
+ } else if (theType == WDG_ACTION) {\r
+ result = new ModuleBase_WidgetAction(theParent, myWidgetApi);\r
+ } else {\r
+ result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi);\r
+ if (!result)\r
+ result = ModuleBase_WidgetCreatorFactory::get()->createWidgetByType(theType, theParent,\r
+ myWidgetApi, myWorkshop);\r
+ #ifdef _DEBUG\r
+ if (!result) {\r
+ qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type %s", theType.c_str());\r
+ }\r
+ #endif\r
+ }\r
+ if (result)\r
+ myModelWidgets.append(result);\r
+ return result;\r
+}\r
+\r
+QString ModuleBase_WidgetFactory::qs(const std::string& theStdString)\r
+{\r
+ return QString::fromStdString(theStdString);\r
+}\r
+\r