1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef MODULEBASE_WIDGETFACTORY_H_
21 #define MODULEBASE_WIDGETFACTORY_H_
23 #include <ModuleBase.h>
24 #include <ModuleBase_ModelWidget.h>
31 class Config_WidgetAPI;
32 class ModuleBase_IWorkshop;
33 class ModuleBase_PageBase;
37 * A class for creation of widgets instances in for property panel using XML deskription of
40 class MODULEBASE_EXPORT ModuleBase_WidgetFactory
44 /// \param theXmlRepresentation content of XML file
45 /// \param theWorkshop reference to workshop instance
46 ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
47 ModuleBase_IWorkshop* theWorkshop);
48 virtual ~ModuleBase_WidgetFactory();
50 /// Creates content widget for property panel
51 /// \param thePage a parent page
52 /// \param alignToTop align to top flag (true by default)
53 void createWidget(ModuleBase_PageBase* thePage, bool alignToTop = true);
55 /// Creates property panel content for the feature
56 /// \param thePage a parent page
57 /// \param theFeature a feature to fill the panel
58 void createPanel(ModuleBase_PageBase* thePage, const FeaturePtr& theFeature);
60 /// Creates one widget for property panel for the widget with given index
61 /// \param thePage a parent widget
62 /// \param theWidgetId a widget index
63 void createWidget(ModuleBase_PageBase* thePage,
64 const std::string& theWidgetId);
66 /// Returns list of model widgets
67 QList<ModuleBase_ModelWidget*> getModelWidgets() const
69 return myModelWidgets;
72 /// Returns the value of the title key from XML definition of the attribute in the feature
73 /// \param theAttributeId a value of a kind of the attribute under the feature
74 /// \param theTitle the result title
75 void getAttributeTitle(const std::string& theAttributeId,
76 std::string& theTitle);
78 /// Returns the identifier of the first found attribute where greed field value is set and true
79 /// \param theAttributeId an outpup parameter with attribute
80 void getGreedAttribute(std::string& theAttributeId);
82 /// Returns widget API from XML
83 const Config_WidgetAPI* widgetAPI() const { return myWidgetApi; }
86 /// check if ModuleBase_Widget has expandable widgets in getControls
87 bool hasExpandingControls(QWidget* theParent);
89 /// Create page by its type
90 /// \param theType a type
91 /// \param theParent a parent widget
92 ModuleBase_PageBase* createPageByType(const std::string& theType,
95 /// Create widget by its type
96 /// \param theType a type
97 /// \param theParent a parent widget
98 ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
99 QWidget* theParent = NULL);
101 /// Convert STD string to QT string
102 /// \param theStdString is STD string
103 static QString qs(const std::string& theStdString);
105 /// It updates internal config api to point in the structure to given id of widget
106 /// The method is recusive and it stops when the found flag is true
107 /// \param theWidgetId a widget id key value
108 /// \param theFound a flag about found windget and recursive search should be stopped
109 void moveToWidgetId(const std::string& theWidgetId, bool& theFound);
112 /// API object for XML reading
113 Config_WidgetAPI* myWidgetApi;
115 /// Reference to workshop
116 ModuleBase_IWorkshop* myWorkshop;
118 /// List of created model widgets
119 QList<ModuleBase_ModelWidget*> myModelWidgets;
122 #endif /* ModuleBase_WidgetFactory_H_ */