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 to be used when the createWidgetByType is called
42 /// \param theCreator a new widget creator
43 void registerCreator(const WidgetCreatorPtr& theCreator);
45 /// Returns true if there is a creator, which can make a panel by the type
46 /// \param theType a type
47 /// \return a boolean value
48 bool hasPanelWidget(const std::string& theType);
50 /// Create panel by its type
51 /// \param theType a type
52 /// \param theParent a parent widget
53 /// \param theFeature a feature to fill the panel
54 /// \return a created panel or null
55 QWidget* createPanelByType(const std::string& theType, QWidget* theParent,
56 const FeaturePtr& theFeature);
58 /// Returns true if there is a creator, which can make a page by the type
59 /// \param theType a type
60 /// \return a boolean value
61 bool hasPageWidget(const std::string& theType);
63 /// Create page by its type
64 /// \param theType a type
65 /// \param theParent a parent widget
66 /// \return a created page or null
67 ModuleBase_PageBase* createPageByType(const std::string& theType,
69 Config_WidgetAPI* theWidgetApi);
71 /// Create widget by its type
72 /// \param theType a type
73 /// \param theParent a parent widget
74 /// \return a created widget or null
75 ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
77 Config_WidgetAPI* theWidgetApi,
78 ModuleBase_IWorkshop* theWorkshop);
81 /// Constructor is hidden
82 ModuleBase_WidgetCreatorFactory();
84 /// Map of widget panel in XML to creator
85 QMap<std::string, WidgetCreatorPtr> myPanelToCreator;
87 /// Map of widget page in XML to creator
88 QMap<std::string, WidgetCreatorPtr> myPageToCreator;
90 /// Map of widget type in XML to creator
91 QMap<std::string, WidgetCreatorPtr> myCreators;
94 typedef std::shared_ptr<ModuleBase_WidgetCreatorFactory> WidgetCreatorFactoryPtr;
96 #endif /* MODULEBASE_WIDGETCREATORFACTORY_H_ */