Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom 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 * \ingroup GUI
26 * A class for creation of widgets instances in for property panel using XML deskription of 
27 * a feature
28 */
29 class MODULEBASE_EXPORT ModuleBase_WidgetFactory
30 {
31  public:
32    /// Constructor
33    /// \param theXmlRepresentation content of XML file
34    /// \param theWorkshop reference to workshop instance
35   ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
36                            ModuleBase_IWorkshop* theWorkshop);
37   virtual ~ModuleBase_WidgetFactory();
38
39   /// Creates content widget for property panel
40   /// \param theParent a parent widget
41   void createWidget(QWidget* theParent);
42
43   /// Returns list of model widgets
44   QList<ModuleBase_ModelWidget*> getModelWidgets() const
45   {
46     return myModelWidgets;
47   }
48
49  protected:
50    /// Create widget by its type
51    /// \param theType a type
52    /// \param theParent a parent widget
53   QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
54
55    /// Create a widget of container type
56    /// \param theType a type
57    /// \param theParent a parent widget
58   QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
59
60   /// Create label widget
61   /// \param theParent a parent widget
62   QWidget* labelControl(QWidget* theParent);
63
64   /// Create double spin box widget
65   /// \param theParent a parent widget
66   QWidget* doubleSpinBoxControl(QWidget* theParent);
67
68   /// Create double value editor widget
69   /// \param theParent a parent widget
70   QWidget* doubleValueEditor(QWidget* theParent);
71
72   /// Create shape selector widget
73   /// \param theParent a parent widget
74   QWidget* shapeSelectorControl(QWidget* theParent);
75
76   /// Create boolean input widget
77   /// \param theParent a parent widget
78   QWidget* booleanControl(QWidget* theParent);
79
80   /// Create file selector widget
81   /// \param theParent a parent widget
82   QWidget* fileSelectorControl(QWidget* theParent);
83
84   /// Create choice widget (combo box)
85   /// \param theParent a parent widget
86   QWidget* choiceControl(QWidget* theParent);
87
88   /// Create line edit widget
89   /// \param theParent a parent widget
90   QWidget* lineEditControl(QWidget* theParent);
91
92   /// Create multi selector widget
93   /// \param theParent a parent widget
94   QWidget* multiSelectorControl(QWidget* theParent);
95
96   /// Convert STD string to QT string
97   /// \param theStdString is STD string
98   static QString qs(const std::string& theStdString);
99
100  private:
101    /// API object for XML reading
102   Config_WidgetAPI* myWidgetApi;
103
104   /// Reference to workshop
105   ModuleBase_IWorkshop* myWorkshop;
106
107   /// List of created model widgets
108   QList<ModuleBase_ModelWidget*> myModelWidgets;
109
110   /// Id of current parent
111   std::string myParentId;
112 };
113
114 #endif /* ModuleBase_WidgetFactory_H_ */