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>
15 #include <ModuleBase_FilterNoDegeneratedEdge.h>
17 #include <GeomAPI_Shape.h>
18 #include <ModelAPI_Result.h>
19 #include <ModelAPI_AttributeSelectionList.h>
21 #include <NCollection_List.hxx>
22 #include <TopoDS_Shape.hxx>
26 #include <QStringList>
32 class ModuleBase_IWorkshop;
38 * Implementation of widget for shapes selection. This widget provides selection of several shapes.
39 * It can be defined in XML file as following:
41 * <multi_selector id="group_list"
42 * tooltip="Select a set of objects"
43 * type_choice="Vertices Edges Faces Solids" />
45 * It uses folloing parameters:
46 * - id - is a name of corresponded attribute
47 * - tooltip - a tooltip for the widget
48 * - type_choice - list of expected shape types.
50 class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_WidgetValidated
55 /// \param theParent the parent object
56 /// \param theWorkshop instance of workshop interface
57 /// \param theData the widget configuation. The attribute of the model widget is obtained from
58 /// \param theParentId is Id of a parent of the current attribute
59 ModuleBase_WidgetMultiSelector(QWidget* theParent,
60 ModuleBase_IWorkshop* theWorkshop,
61 const Config_WidgetAPI* theData,
62 const std::string& theParentId);
63 virtual ~ModuleBase_WidgetMultiSelector();
65 virtual bool restoreValue();
67 /// Returns list of widget controls
68 /// \return a control list
69 virtual QList<QWidget*> getControls() const;
71 virtual bool eventFilter(QObject* , QEvent* );
73 /// The methiod called when widget is deactivated
74 virtual void deactivate();
76 /// Fills the attribute with the value of the selected owner
77 /// \param theOwner a selected owner
78 virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner);
81 /// Slot is called on selection type changed
82 void onSelectionTypeChanged();
84 /// Slot is called on selection changed
85 void onSelectionChanged();
88 /// Slot for copy command in a list pop-up menu
91 /// Slot is called on selection of list of selected items
92 void onListSelection();
95 /// The methiod called when widget is activated
96 virtual void activateCustom();
98 /// Saves the internal parameters to the given feature
99 /// \return True in success
100 virtual bool storeValueCustom() const;
102 /// Creates a backup of the current values of the attribute
103 /// It should be realized in the specific widget because of different
104 /// parameters of the current attribute
105 /// \param isBackup a boolean flag, if true, store values from the attribute
106 /// to backup, otherwise set the backed up values to the attribute
107 virtual void backupAttributeValue(const bool isBackup);
109 /// Set current shape type for selection
110 void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
112 /// Start shape selection
113 void activateShapeSelection();
116 /// Update selection list
117 void updateSelectionList(AttributeSelectionListPtr);
120 QListWidget* myListControl;
122 /// Combobox of types
123 QComboBox* myTypeCombo;
125 //TODO: Move into the base of selectors
126 ModuleBase_IWorkshop* myWorkshop;
128 /// If true then local selector has to be activated in context
131 /// Provides correspondance between Result object and its shape
132 typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;
134 /// Variable of GeomSelection type
135 QList<GeomSelection> mySelection;
137 /// An action for pop-up menu in a list control
138 QAction* myCopyAction;
140 /// A filter for the Edges type, which avoid the generated edges selection
141 Handle(ModuleBase_FilterNoDegeneratedEdge) myEdgesTypeFilter;
144 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */