]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetFactory.h
Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom.git into Dev_0.7.1
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFactory.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModuleBase_WidgetFactory.h
5  *
6  *  Created on: Apr 3, 2014
7  *      Author: sbh
8  */
9
10 #ifndef ModuleBase_WidgetFactory_H_
11 #define ModuleBase_WidgetFactory_H_
12
13 #include "ModuleBase.h"
14 #include "ModuleBase_ModelWidget.h"
15
16 #include <QString>
17 #include <QList>
18
19 class QObject;
20 class QWidget;
21 class Config_WidgetAPI;
22 class ModuleBase_IWorkshop;
23
24 /**
25 * A class for creation of widgets instances in for property panel using XML deskription of 
26 * a feature
27 */
28 class MODULEBASE_EXPORT ModuleBase_WidgetFactory
29 {
30  public:
31    /// Constructor
32    /// \param theXmlRepresentation content of XML file
33    /// \param theWorkshop reference to workshop instance
34   ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
35                            ModuleBase_IWorkshop* theWorkshop);
36   virtual ~ModuleBase_WidgetFactory();
37
38   /// Creates content widget for property panel
39   /// \param theParent a parent widget
40   void createWidget(QWidget* theParent);
41
42   /// Returns list of model widgets
43   QList<ModuleBase_ModelWidget*> getModelWidgets() const
44   {
45     return myModelWidgets;
46   }
47
48  protected:
49    /// Create widget by its type
50    /// \param theType a type
51    /// \param theParent a parent widget
52   QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
53
54    /// Create a widget of container type
55    /// \param theType a type
56    /// \param theParent a parent widget
57   QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
58
59   /// Create label widget
60   /// \param theParent a parent widget
61   QWidget* labelControl(QWidget* theParent);
62
63   /// Create double spin box widget
64   /// \param theParent a parent widget
65   QWidget* doubleSpinBoxControl(QWidget* theParent);
66
67   /// Create double value editor widget
68   /// \param theParent a parent widget
69   QWidget* doubleValueEditor(QWidget* theParent);
70
71   /// Create shape selector widget
72   /// \param theParent a parent widget
73   QWidget* shapeSelectorControl(QWidget* theParent);
74
75   /// Create boolean input widget
76   /// \param theParent a parent widget
77   QWidget* booleanControl(QWidget* theParent);
78
79   /// Create file selector widget
80   /// \param theParent a parent widget
81   QWidget* fileSelectorControl(QWidget* theParent);
82
83   /// Create choice widget (combo box)
84   /// \param theParent a parent widget
85   QWidget* choiceControl(QWidget* theParent);
86
87   /// Create line edit widget
88   /// \param theParent a parent widget
89   QWidget* lineEditControl(QWidget* theParent);
90
91   /// Create multi selector widget
92   /// \param theParent a parent widget
93   QWidget* multiSelectorControl(QWidget* theParent);
94
95   /// Convert STD string to QT string
96   /// \param theStdString is STD string
97   static QString qs(const std::string& theStdString);
98
99  private:
100    /// API object for XML reading
101   Config_WidgetAPI* myWidgetApi;
102
103   /// Reference to workshop
104   ModuleBase_IWorkshop* myWorkshop;
105
106   /// List of created model widgets
107   QList<ModuleBase_ModelWidget*> myModelWidgets;
108
109   /// Id of current parent
110   std::string myParentId;
111 };
112
113 #endif /* ModuleBase_WidgetFactory_H_ */