]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetFactory.h
Salome HOME
71834e86d3db0d8bfe80e377eff9eef5c6400c14
[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
44   /// Returns list of model widgets
45   QList<ModuleBase_ModelWidget*> getModelWidgets() const
46   {
47     return myModelWidgets;
48   }
49
50  protected:
51   /// check if ModuleBase_Widget has expandable widgets in getControls
52   bool hasExpandingControls(QWidget* theParent);
53    /// Create widget by its type
54    /// \param theType a type
55    /// \param theParent a parent widget
56   QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
57
58    /// Create a widget of container type
59    /// \param theType a type
60    /// \param theParent a parent widget
61   QWidget* createContainer(const std::string& theType, QWidget* theParent);
62
63   /// Create label widget
64   /// \param theParent a parent widget
65   QWidget* labelControl(QWidget* theParent);
66
67   /// Create double spin box widget
68   /// \param theParent a parent widget
69   QWidget* doubleSpinBoxControl(QWidget* theParent);
70
71   /// Create double value editor widget
72   /// \param theParent a parent widget
73   QWidget* doubleValueEditor(QWidget* theParent);
74
75   /// Create shape selector widget
76   /// \param theParent a parent widget
77   QWidget* shapeSelectorControl(QWidget* theParent);
78
79   /// Create boolean input widget
80   /// \param theParent a parent widget
81   QWidget* booleanControl(QWidget* theParent);
82
83   /// Create file selector widget
84   /// \param theParent a parent widget
85   QWidget* fileSelectorControl(QWidget* theParent);
86
87   /// Create choice widget (combo box)
88   /// \param theParent a parent widget
89   QWidget* choiceControl(QWidget* theParent);
90
91   /// Create line edit widget
92   /// \param theParent a parent widget
93   QWidget* lineEditControl(QWidget* theParent);
94
95   /// Create multi selector widget
96   /// \param theParent a parent widget
97   QWidget* multiSelectorControl(QWidget* theParent);
98
99   /// Convert STD string to QT string
100   /// \param theStdString is STD string
101   static QString qs(const std::string& theStdString);
102
103  private:
104    /// API object for XML reading
105   Config_WidgetAPI* myWidgetApi;
106
107   /// Reference to workshop
108   ModuleBase_IWorkshop* myWorkshop;
109
110   /// List of created model widgets
111   QList<ModuleBase_ModelWidget*> myModelWidgets;
112
113   /// Id of current parent
114   std::string myParentId;
115 };
116
117 #endif /* ModuleBase_WidgetFactory_H_ */