1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetFeatureSelector.h
5 // Author: Natalia Ermolaeva
7 #ifndef ModuleBase_WidgetFeatureSelector_H
8 #define ModuleBase_WidgetFeatureSelector_H
10 #include "ModuleBase.h"
11 #include "ModuleBase_WidgetSelector.h"
13 class Config_WidgetAPI;
20 * Implementation of widget for feature selection.
21 * This type of widget can be defined in XML file with 'feature_selector' keyword.
24 * <feature_selector id="main_object"
26 * tooltip="Select an object solid"
29 * It can use following parameters:
30 * - id - name of object attribute
31 * - label - content of widget's label
32 * - tooltip - the witget's tooltip text
34 class MODULEBASE_EXPORT ModuleBase_WidgetFeatureSelector : public ModuleBase_WidgetValidated
40 /// \param theParent the parent object
41 /// \param theWorkshop instance of workshop interface
42 /// \param theData the widget configuation. The attribute of the model widget is obtained from
43 ModuleBase_WidgetFeatureSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
44 const Config_WidgetAPI* theData);
46 virtual ~ModuleBase_WidgetFeatureSelector();
48 /// Set the given wrapped value to the current widget
49 /// This value should be processed in the widget according to the needs
50 /// The method is called by the current operation to process the operation preselection.
51 /// It is redefined to check the value validity and if it is, fill the attribute with by value
52 /// \param theValues the wrapped selection values
53 /// \param theToValidate a flag on validation of the values
54 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
55 const bool theToValidate);
57 /// Returns list of widget controls
58 /// \return a control list
59 virtual QList<QWidget*> getControls() const;
61 /// Fills the attribute with the value of the selected owner
62 /// \param thePrs a selected owner
63 virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
65 /// The method called when widget is deactivated
66 virtual void deactivate();
69 /// The method called when widget is activated
70 virtual void activateCustom();
72 /// Saves the internal parameters to the given feature
73 /// \return True in success
74 virtual bool storeValueCustom();
76 virtual bool restoreValueCustom();
78 /// Computes and updates name of selected object in the widget
79 virtual void updateSelectionName();
81 // Update focus after the attribute value change
82 virtual void updateFocus();
84 /// Checks whether all active viewer filters validate the presentation
85 /// \param thePrs a selected presentation in the view
86 /// \return a boolean value
87 virtual bool isValidInFilters(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
89 /// Emits model changed info, updates the current control by selection change
90 /// \param theDone a state whether the selection is set
91 virtual void updateOnSelectionChanged(const bool theDone);
94 /// Called on selection changed event
95 virtual void onSelectionChanged();
97 //----------- Class members -------------
99 /// Label of the widget
102 /// Input control of the widget
103 QLineEdit* myTextLine;