]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetMultiSelector.h
Salome HOME
Property panel widgets redesign
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetMultiSelector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModuleBase_WidgetMultiSelector.h
5  *
6  *  Created on: Oct 8, 2014
7  *      Author: sbh
8  */
9
10 #ifndef MODULEBASE_WIDGETMULTISELECTOR_H_
11 #define MODULEBASE_WIDGETMULTISELECTOR_H_
12
13 #include <ModuleBase.h>
14 #include <ModuleBase_ModelWidget.h>
15 #include <ModuleBase_FilterNoDegeneratedEdge.h>
16
17 #include <GeomAPI_Shape.h>
18 #include <ModelAPI_Result.h>
19 #include <ModelAPI_AttributeSelectionList.h>
20
21 #include <NCollection_List.hxx>
22 #include <TopoDS_Shape.hxx>
23
24 #include <QList>
25 #include <QString>
26 #include <QStringList>
27 #include <QPair>
28
29 class QWidget;
30 class QListWidget;
31 class QComboBox;
32 class ModuleBase_IWorkshop;
33 class QAction;
34
35
36 /**
37 * \ingroup GUI
38 * Implementation of widget for shapes selection. This widget provides selection of several shapes.
39 * It can be defined in XML file as following:
40 * \code
41 * <multi_selector id="group_list" 
42 *    tooltip="Select a set of objects" 
43 *    type_choice="Vertices Edges Faces Solids" /> 
44 * \endcode
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.
49 */
50 class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_ModelWidget
51 {
52   Q_OBJECT
53  public:
54   /// Constructor
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();
64
65   virtual bool restoreValue();
66
67   /// Returns list of widget controls
68   /// \return a control list
69   virtual QList<QWidget*> getControls() const;
70
71   virtual bool eventFilter(QObject* , QEvent* );
72
73  public slots:
74   /// Activate or deactivate selection
75   void activateSelection(bool toActivate);
76
77   /// Slot is called on selection type changed
78   void onSelectionTypeChanged();
79
80   /// Slot is called on selection changed
81   void onSelectionChanged();
82
83 protected slots:
84   /// Slot for copy command in a list pop-up menu
85   void onCopyItem();
86
87   /// Slot is called on selection of list of selected items
88   void onListSelection();
89
90  protected:
91   /// Saves the internal parameters to the given feature
92   /// \return True in success
93   virtual bool storeValue() const;
94
95   /// Provide filtering of selected shapes
96    /// \param theShapesToFilter source list of shapes
97    /// \param theResult result list of shapes
98   void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
99                     NCollection_List<TopoDS_Shape>& theResult);
100
101   /// Set current shape type for selection
102   void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
103
104   /// Start shape selection
105   void activateShapeSelection();
106
107  private:
108    /// Update selection list
109    void updateSelectionList(AttributeSelectionListPtr);
110
111    /// List control
112   QListWidget* myListControl;
113
114   /// Combobox of types
115   QComboBox* myTypeCombo;
116
117   //TODO: Move into the base of selectors
118   ModuleBase_IWorkshop* myWorkshop;
119
120   /// If true then local selector has to be activated in context
121   bool myIsActive;
122
123   /// Provides correspondance between Result object and its shape
124   typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;
125
126   /// Variable of GeomSelection type
127   QList<GeomSelection> mySelection;
128
129   /// An action for pop-up menu in a list control
130   QAction* myCopyAction;
131
132   /// A filter for the Edges type, which avoid the generated edges selection
133   Handle(ModuleBase_FilterNoDegeneratedEdge) myEdgesTypeFilter;
134 };
135
136 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */