1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetCreatorFactory.cpp
4 // Created: 03 Dec 2015
5 // Author: Natalia ERMOLAEVA
7 #ifndef MODULEBASE_WIDGETCREATORFACTORY_H_
8 #define MODULEBASE_WIDGETCREATORFACTORY_H_
10 #include <ModuleBase.h>
17 #include <ModuleBase_IWidgetCreator.h>
19 #include <ModelAPI_Feature.h>
21 class ModuleBase_ModelWidget;
22 class ModuleBase_PageBase;
23 class ModuleBase_IWorkshop;
29 * A class for creation of widgets instances in for property panel using XML deskription of
32 class MODULEBASE_EXPORT ModuleBase_WidgetCreatorFactory
35 /// Returns an singular instance of the class if it exists or create it
36 static std::shared_ptr<ModuleBase_WidgetCreatorFactory> get();
39 virtual ~ModuleBase_WidgetCreatorFactory();
41 /// The creator is added to the internal container
42 /// to be used when the createWidgetByType is called
43 /// \param theCreator a new widget creator
44 void registerCreator(const WidgetCreatorPtr& theCreator);
46 /// Returns true if there is a creator, which can make a panel by the type
47 /// \param theType a type
48 /// \return a boolean value
49 bool hasPanelWidget(const std::string& theType);
51 /// Create panel by its type
52 /// \param theType a type
53 /// \param theParent a parent widget
54 /// \param theFeature a feature to fill the panel
55 /// \return a created panel or null
56 QWidget* createPanelByType(const std::string& theType, QWidget* theParent,
57 const FeaturePtr& theFeature);
59 /// Returns true if there is a creator, which can make a page by the type
60 /// \param theType a type
61 /// \return a boolean value
62 bool hasPageWidget(const std::string& theType);
64 /// Create page by its type
65 /// \param theType a type
66 /// \param theParent a parent widget
67 /// \param theWidgetApi the widget configuration.
68 /// The attribute of the model widget is obtained from XML
69 /// \return a created page or null
70 ModuleBase_PageBase* createPageByType(const std::string& theType,
72 Config_WidgetAPI* theWidgetApi);
74 /// Create widget by its type
75 /// \param theType a type
76 /// \param theParent a parent widget
77 /// \param theWidgetApi the widget configuration.
78 /// The attribute of the model widget is obtained from XML
79 /// \param theWorkshop a workshop object instance
80 /// \return a created widget or null
81 ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
83 Config_WidgetAPI* theWidgetApi,
84 ModuleBase_IWorkshop* theWorkshop);
87 /// Constructor is hidden
88 ModuleBase_WidgetCreatorFactory();
90 /// Map of widget panel in XML to creator
91 QMap<std::string, WidgetCreatorPtr> myPanelToCreator;
93 /// Map of widget page in XML to creator
94 QMap<std::string, WidgetCreatorPtr> myPageToCreator;
96 /// Map of widget type in XML to creator
97 QMap<std::string, WidgetCreatorPtr> myCreators;
100 typedef std::shared_ptr<ModuleBase_WidgetCreatorFactory> WidgetCreatorFactoryPtr;
102 #endif /* MODULEBASE_WIDGETCREATORFACTORY_H_ */