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_ModelWidget.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_ModelWidget
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 /// Saves the internal parameters to the given feature
66 virtual bool storeValue() const;
68 virtual bool restoreValue();
70 /// Returns the internal parent wiget control, that can be shown anywhere
71 /// \returns the widget
72 QWidget* getControl() const;
74 /// Returns list of widget controls
75 /// \return a control list
76 virtual QList<QWidget*> getControls() const;
78 virtual bool eventFilter(QObject* , QEvent* );
81 /// Activate or deactivate selection
82 void activateSelection(bool toActivate);
84 /// Slot is called on selection type changed
85 void onSelectionTypeChanged();
87 /// Slot is called on selection changed
88 void onSelectionChanged();
91 /// Slot for copy command in a list pop-up menu
94 /// Slot is called on selection of list of selected items
95 void onListSelection();
98 /// Provide filtering of selected shapes
99 /// \param theShapesToFilter source list of shapes
100 /// \param theResult result list of shapes
101 void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
102 NCollection_List<TopoDS_Shape>& theResult);
104 /// Set current shape type for selection
105 void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
107 /// Start shape selection
108 void activateShapeSelection();
111 /// Update selection list
112 void updateSelectionList(AttributeSelectionListPtr);
115 QListWidget* myListControl;
117 /// Combobox of types
118 QComboBox* myTypeCombo;
121 QWidget* myMainWidget;
123 //TODO: Move into the base of selectors
124 ModuleBase_IWorkshop* myWorkshop;
126 /// If true then local selector has to be activated in context
129 /// Provides correspondance between Result object and its shape
130 typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;
132 /// Variable of GeomSelection type
133 QList<GeomSelection> mySelection;
135 /// An action for pop-up menu in a list control
136 QAction* myCopyAction;
138 /// A filter for the Edges type, which avoid the generated edges selection
139 Handle(ModuleBase_FilterNoDegeneratedEdge) myEdgesTypeFilter;
142 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */