Salome HOME
7e1538b19f09fc9b7d08677f477b834810d2ce68
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFeatureSelector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
2 \r
3 // File:        ModuleBase_WidgetFeatureSelector.h\r
4 // Created:     5 Sep 2016\r
5 // Author:      Natalia Ermolaeva\r
6 \r
7 #ifndef ModuleBase_WidgetFeatureSelector_H\r
8 #define ModuleBase_WidgetFeatureSelector_H\r
9 \r
10 #include "ModuleBase.h"\r
11 #include "ModuleBase_WidgetSelector.h"\r
12 \r
13 class Config_WidgetAPI;\r
14 class QWidget;\r
15 class QLabel;\r
16 class QLineEdit;\r
17 \r
18 /**\r
19 * \ingroup GUI\r
20 * Implementation of widget for feature selection.\r
21 * This type of widget can be defined in XML file with 'feature_selector' keyword.\r
22 * For example:\r
23 * \code\r
24 *   <feature_selector id="main_object" \r
25 *    label="Main object" \r
26 *    tooltip="Select an object solid"\r
27 *  />\r
28 * \endcode\r
29 * It can use following parameters:\r
30 * - id - name of object attribute\r
31 * - label - content of widget's label\r
32 * - tooltip - the witget's tooltip text\r
33 */\r
34 class MODULEBASE_EXPORT ModuleBase_WidgetFeatureSelector : public ModuleBase_WidgetValidated\r
35 {\r
36 Q_OBJECT\r
37  public:\r
38 \r
39   /// Constructor\r
40   /// \param theParent the parent object\r
41   /// \param theWorkshop instance of workshop interface\r
42   /// \param theData the widget configuation. The attribute of the model widget is obtained from\r
43   ModuleBase_WidgetFeatureSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,\r
44                                    const Config_WidgetAPI* theData);\r
45 \r
46   virtual ~ModuleBase_WidgetFeatureSelector();\r
47 \r
48   /// Set the given wrapped value to the current widget\r
49   /// This value should be processed in the widget according to the needs\r
50   /// The method is called by the current operation to process the operation preselection.\r
51   /// It is redefined to check the value validity and if it is, fill the attribute with by value\r
52   /// \param theValues the wrapped selection values\r
53   /// \param theToValidate a flag on validation of the values\r
54   virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,\r
55                             const bool theToValidate);\r
56 \r
57   /// Returns list of widget controls\r
58   /// \return a control list\r
59   virtual QList<QWidget*> getControls() const;\r
60 \r
61   /// Fills the attribute with the value of the selected owner\r
62   /// \param thePrs a selected owner\r
63   virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);\r
64 \r
65   /// The method called when widget is deactivated\r
66   virtual void deactivate();\r
67 \r
68 protected:\r
69   /// The method called when widget is activated\r
70   virtual void activateCustom();\r
71 \r
72   /// Saves the internal parameters to the given feature\r
73   /// \return True in success\r
74   virtual bool storeValueCustom();\r
75 \r
76   virtual bool restoreValueCustom();\r
77 \r
78   /// Computes and updates name of selected object in the widget\r
79   virtual void updateSelectionName();\r
80 \r
81   // Update focus after the attribute value change\r
82   virtual void updateFocus();\r
83 \r
84   /// Checks whether all active viewer filters validate the presentation\r
85   /// \param thePrs a selected presentation in the view\r
86   /// \return a boolean value\r
87   virtual bool isValidInFilters(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);\r
88 \r
89   /// Emits model changed info, updates the current control by selection change\r
90   /// \param theDone a state whether the selection is set\r
91   virtual void updateOnSelectionChanged(const bool theDone);\r
92 \r
93 protected slots:\r
94   /// Called on selection changed event\r
95   virtual void onSelectionChanged();\r
96 \r
97   //----------- Class members -------------\r
98 protected:\r
99   /// Label of the widget\r
100   QLabel* myLabel;\r
101 \r
102   /// Input control of the widget\r
103   QLineEdit* myTextLine;\r
104 };\r
105 \r
106 #endif\r