1 // Copyright (C) 2014-2017 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<mailto:webmaster.salome@opencascade.com>
21 * ModuleBase_WidgetFactory.h
23 * Created on: Apr 3, 2014
27 #ifndef MODULEBASE_WIDGETFACTORY_H_
28 #define MODULEBASE_WIDGETFACTORY_H_
30 #include <ModuleBase.h>
31 #include <ModuleBase_ModelWidget.h>
38 class Config_WidgetAPI;
39 class ModuleBase_IWorkshop;
40 class ModuleBase_PageBase;
44 * A class for creation of widgets instances in for property panel using XML deskription of
47 class MODULEBASE_EXPORT ModuleBase_WidgetFactory
51 /// \param theXmlRepresentation content of XML file
52 /// \param theWorkshop reference to workshop instance
53 ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
54 ModuleBase_IWorkshop* theWorkshop);
55 virtual ~ModuleBase_WidgetFactory();
57 /// Creates content widget for property panel
58 /// \param thePage a parent page
59 /// \param alignToTop align to top flag (true by default)
60 void createWidget(ModuleBase_PageBase* thePage, bool alignToTop = true);
62 /// Creates property panel content for the feature
63 /// \param thePage a parent page
64 /// \param theFeature a feature to fill the panel
65 void createPanel(ModuleBase_PageBase* thePage, const FeaturePtr& theFeature);
67 /// Creates one widget for property panel for the widget with given index
68 /// \param thePage a parent widget
69 /// \param theWidgetId a widget index
70 void createWidget(ModuleBase_PageBase* thePage,
71 const std::string& theWidgetId);
73 /// Returns list of model widgets
74 QList<ModuleBase_ModelWidget*> getModelWidgets() const
76 return myModelWidgets;
79 /// Returns the value of the title key from XML definition of the attribute in the feature
80 /// \param theAttributeId a value of a kind of the attribute under the feature
81 /// \param theTitle the result title
82 void getAttributeTitle(const std::string& theAttributeId,
83 std::string& theTitle);
85 /// Returns the identifier of the first found attribute where greed field value is set and true
86 /// \param theAttributeId an outpup parameter with attribute
87 void getGreedAttribute(std::string& theAttributeId);
89 /// Returns widget API from XML
90 const Config_WidgetAPI* widgetAPI() const { return myWidgetApi; }
93 /// check if ModuleBase_Widget has expandable widgets in getControls
94 bool hasExpandingControls(QWidget* theParent);
96 /// Create page by its type
97 /// \param theType a type
98 /// \param theParent a parent widget
99 ModuleBase_PageBase* createPageByType(const std::string& theType,
102 /// Create widget by its type
103 /// \param theType a type
104 /// \param theParent a parent widget
105 ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
106 QWidget* theParent = NULL);
108 /// Convert STD string to QT string
109 /// \param theStdString is STD string
110 static QString qs(const std::string& theStdString);
112 /// It updates internal config api to point in the structure to given id of widget
113 /// The method is recusive and it stops when the found flag is true
114 /// \param theWidgetId a widget id key value
115 /// \param theFound a flag about found windget and recursive search should be stopped
116 void moveToWidgetId(const std::string& theWidgetId, bool& theFound);
119 /// API object for XML reading
120 Config_WidgetAPI* myWidgetApi;
122 /// Reference to workshop
123 ModuleBase_IWorkshop* myWorkshop;
125 /// List of created model widgets
126 QList<ModuleBase_ModelWidget*> myModelWidgets;
129 #endif /* ModuleBase_WidgetFactory_H_ */