Salome HOME
Correct processing of the fixed arc in PlaneGCS (issue #1280)
[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 class ModuleBase_PageBase;
24
25 /**
26 * \ingroup GUI
27 * A class for creation of widgets instances in for property panel using XML deskription of 
28 * a feature
29 */
30 class MODULEBASE_EXPORT ModuleBase_WidgetFactory
31 {
32  public:
33    /// Constructor
34    /// \param theXmlRepresentation content of XML file
35    /// \param theWorkshop reference to workshop instance
36   ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
37                            ModuleBase_IWorkshop* theWorkshop);
38   virtual ~ModuleBase_WidgetFactory();
39
40   /// Creates content widget for property panel
41   /// \param theParent a parent widget
42   void createWidget(ModuleBase_PageBase* theParent);
43
44
45   /// Returns list of model widgets
46   QList<ModuleBase_ModelWidget*> getModelWidgets() const
47   {
48     return myModelWidgets;
49   }
50
51   /// Returns the value of the title key from XML definition of the attribute in the feature
52   /// \param theFeatureKind a value of a kind of a feature
53   /// \param theAttributeId a value of a kind of the attribute under the feature
54   /// \param theTitle the result title
55   void getAttributeTitle(const std::string& theFeatureKind,
56                          const std::string& theAttributeId,
57                          std::string& theTitle);
58
59 protected:
60   /// check if ModuleBase_Widget has expandable widgets in getControls
61   bool hasExpandingControls(QWidget* theParent);
62
63   /// Create page by its type
64   /// \param theType a type
65   /// \param theParent a parent widget
66   ModuleBase_PageBase* createPageByType(const std::string& theType,
67                                         QWidget* theParent);
68
69   /// Create widget by its type
70   /// \param theType a type
71   /// \param theParent a parent widget
72   ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
73                                              QWidget* theParent = NULL);
74
75   /// Convert STD string to QT string
76   /// \param theStdString is STD string
77   static QString qs(const std::string& theStdString);
78
79  private:
80    /// API object for XML reading
81   Config_WidgetAPI* myWidgetApi;
82
83   /// Reference to workshop
84   ModuleBase_IWorkshop* myWorkshop;
85
86   /// List of created model widgets
87   QList<ModuleBase_ModelWidget*> myModelWidgets;
88
89   /// Id of current parent
90   std::string myParentId;
91 };
92
93 #endif /* ModuleBase_WidgetFactory_H_ */