+ 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, myWidgetApi);
+ ModuleBase_ModelWidget* aModelWdg = dynamic_cast<ModuleBase_ModelWidget*>(aPanel);
+ if (aModelWdg)
+ thePage->addModelWidget(aModelWdg);
+ else
+ 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();
+ }
+ else
+ theTitle = theAttributeId;
+}
+
+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());