1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_WidgetMultiSelector.h
6 * Created on: Oct 8, 2014
10 #ifndef MODULEBASE_WIDGETMULTISELECTOR_H_
11 #define MODULEBASE_WIDGETMULTISELECTOR_H_
13 #include <ModuleBase.h>
14 #include <ModuleBase_WidgetValidated.h>
16 #include <GeomAPI_Shape.h>
17 #include <ModelAPI_Result.h>
18 #include <ModelAPI_AttributeSelectionList.h>
20 #include <NCollection_List.hxx>
21 #include <TopoDS_Shape.hxx>
25 #include <QStringList>
31 class ModuleBase_IWorkshop;
37 * Implementation of widget for shapes selection. This widget provides selection of several shapes.
38 * It can be defined in XML file as following:
40 * <multi_selector id="group_list"
41 * tooltip="Select a set of objects"
42 * type_choice="Vertices Edges Faces Solids" />
44 * It uses folloing parameters:
45 * - id - is a name of corresponded attribute
46 * - tooltip - a tooltip for the widget
47 * - type_choice - list of expected shape types.
49 class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_WidgetValidated
54 /// \param theParent the parent object
55 /// \param theWorkshop instance of workshop interface
56 /// \param theData the widget configuation. The attribute of the model widget is obtained from
57 /// \param theParentId is Id of a parent of the current attribute
58 ModuleBase_WidgetMultiSelector(QWidget* theParent,
59 ModuleBase_IWorkshop* theWorkshop,
60 const Config_WidgetAPI* theData,
61 const std::string& theParentId);
62 virtual ~ModuleBase_WidgetMultiSelector();
64 virtual bool restoreValue();
66 /// Returns list of widget controls
67 /// \return a control list
68 virtual QList<QWidget*> getControls() const;
70 virtual bool eventFilter(QObject* , QEvent* );
72 /// The methiod called when widget is deactivated
73 virtual void deactivate();
75 /// Fills the attribute with the value of the selected owner
76 /// \param theOwner a selected owner
77 virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
80 /// Slot is called on selection type changed
81 void onSelectionTypeChanged();
83 /// Slot is called on selection changed
84 void onSelectionChanged();
87 /// Slot for copy command in a list pop-up menu
90 /// Slot is called on selection of list of selected items
91 void onListSelection();
94 /// The methiod called when widget is activated
95 virtual void activateCustom();
97 /// Saves the internal parameters to the given feature
98 /// \return True in success
99 virtual bool storeValueCustom() const;
101 /// Creates a backup of the current values of the attribute
102 /// It should be realized in the specific widget because of different
103 /// parameters of the current attribute
104 virtual void storeAttributeValue();
106 /// Creates a backup of the current values of the attribute
107 /// It should be realized in the specific widget because of different
108 /// parameters of the current attribute
109 /// \param theValid a boolean flag, if restore happens for valid parameters
110 virtual void restoreAttributeValue(const bool theValid);
112 /// Set current shape type for selection
113 void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
115 /// Start shape selection
116 void activateShapeSelection();
119 /// Update selection list
120 void updateSelectionList(AttributeSelectionListPtr);
123 QListWidget* myListControl;
125 /// Combobox of types
126 QComboBox* myTypeCombo;
128 //TODO: Move into the base of selectors
129 ModuleBase_IWorkshop* myWorkshop;
131 /// If true then local selector has to be activated in context
134 /// Provides correspondance between Result object and its shape
135 typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;
137 /// An action for pop-up menu in a list control
138 QAction* myCopyAction;
140 /// backup parameters of the model attribute. The class processes three types of attribute:
141 /// Reference, RefAttr and Selection. Depending on the attribute type, only the attribute parameter
142 /// values are reserved in the backup
143 /// Variable of selection type
144 std::string mySelectionType;
146 /// Variable of GeomSelection
147 QList<GeomSelection> mySelection;
150 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */