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>
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;
36 * Implementation of widget for shapes selection. This widget provides selection of several shapes.
37 * It can be defined in XML file as following:
39 * <multi_selector id="group_list"
40 * tooltip="Select a set of objects"
41 * type_choice="Vertices Edges Faces Solids" />
43 * It uses folloing parameters:
44 * - id - is a name of corresponded attribute
45 * - tooltip - a tooltip for the widget
46 * - type_choice - list of expected shape types.
48 class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_ModelWidget
53 /// \param theParent the parent object
54 /// \param theWorkshop instance of workshop interface
55 /// \param theData the widget configuation. The attribute of the model widget is obtained from
56 /// \param theParentId is Id of a parent of the current attribute
57 ModuleBase_WidgetMultiSelector(QWidget* theParent,
58 ModuleBase_IWorkshop* theWorkshop,
59 const Config_WidgetAPI* theData,
60 const std::string& theParentId);
61 virtual ~ModuleBase_WidgetMultiSelector();
63 /// Saves the internal parameters to the given feature
64 virtual bool storeValue() const;
66 virtual bool restoreValue();
68 /// Returns the internal parent wiget control, that can be shown anywhere
69 /// \returns the widget
70 QWidget* getControl() const;
72 /// Returns list of widget controls
73 /// \return a control list
74 virtual QList<QWidget*> getControls() const;
76 virtual bool eventFilter(QObject* , QEvent* );
79 /// Activate or deactivate selection
80 void activateSelection(bool toActivate);
82 /// Slot is called on selection type changed
83 void onSelectionTypeChanged();
85 /// Slot is called on selection changed
86 void onSelectionChanged();
89 /// Slot for copy command in a list pop-up menu
92 /// Slot is called on selection of list of selected items
93 void onListSelection();
96 /// Provide filtering of selected shapes
97 /// \param theShapesToFilter source list of shapes
98 /// \param theResult result list of shapes
99 void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
100 NCollection_List<TopoDS_Shape>& theResult);
102 /// Set current shape type for selection
103 void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
105 /// Start shape selection
106 void activateShapeSelection();
109 /// Update selection list
110 void updateSelectionList(AttributeSelectionListPtr);
113 QListWidget* myListControl;
115 /// Combobox of types
116 QComboBox* myTypeCombo;
119 QWidget* myMainWidget;
121 //TODO: Move into the base of selectors
122 ModuleBase_IWorkshop* myWorkshop;
124 /// If true then local selector has to be activated in context
127 /// \typedef GeomSelection provides correspondance between Result object and its shape
128 typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;
130 /// Variable of GeomSelection type
131 QList<GeomSelection> mySelection;
133 /// An action for pop-up menu in a list control
134 QAction* myCopyAction;
137 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */