1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
\r
3 // File: ModuleBase_WidgetFeatureSelector.h
\r
4 // Created: 5 Sep 2016
\r
5 // Author: Natalia Ermolaeva
\r
7 #ifndef ModuleBase_WidgetFeatureSelector_H
\r
8 #define ModuleBase_WidgetFeatureSelector_H
\r
10 #include "ModuleBase.h"
\r
11 #include "ModuleBase_WidgetSelector.h"
\r
13 class Config_WidgetAPI;
\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
24 * <feature_selector id="main_object"
\r
25 * label="Main object"
\r
26 * tooltip="Select an object solid"
\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
34 class MODULEBASE_EXPORT ModuleBase_WidgetFeatureSelector : public ModuleBase_WidgetValidated
\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
46 virtual ~ModuleBase_WidgetFeatureSelector();
\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
57 /// Returns list of widget controls
\r
58 /// \return a control list
\r
59 virtual QList<QWidget*> getControls() const;
\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
65 /// The method called when widget is deactivated
\r
66 virtual void deactivate();
\r
69 /// The method called when widget is activated
\r
70 virtual void activateCustom();
\r
72 /// Saves the internal parameters to the given feature
\r
73 /// \return True in success
\r
74 virtual bool storeValueCustom();
\r
76 virtual bool restoreValueCustom();
\r
78 /// Computes and updates name of selected object in the widget
\r
79 virtual void updateSelectionName();
\r
81 // Update focus after the attribute value change
\r
82 virtual void updateFocus();
\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
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
94 /// Called on selection changed event
\r
95 virtual void onSelectionChanged();
\r
97 //----------- Class members -------------
\r
99 /// Label of the widget
\r
102 /// Input control of the widget
\r
103 QLineEdit* myTextLine;
\r