Salome HOME
It was impossible to select another face of the same object. Fixed.
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetMultiSelector.h
1 /*
2  * ModuleBase_WidgetMultiSelector.h
3  *
4  *  Created on: Oct 8, 2014
5  *      Author: sbh
6  */
7
8 #ifndef MODULEBASE_WIDGETMULTISELECTOR_H_
9 #define MODULEBASE_WIDGETMULTISELECTOR_H_
10
11 #include <ModuleBase.h>
12 #include <ModuleBase_ModelWidget.h>
13
14 #include <GeomAPI_Shape.h>
15 #include <ModelAPI_Result.h>
16
17 #include <NCollection_List.hxx>
18 #include <TopoDS_Shape.hxx>
19
20 #include <QList>
21 #include <QString>
22 #include <QStringList>
23 #include <QPair>
24
25 class QWidget;
26 class QListWidget;
27 class QComboBox;
28 class ModuleBase_IWorkshop;
29
30 class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_ModelWidget
31 {
32   Q_OBJECT
33  public:
34   ModuleBase_WidgetMultiSelector(QWidget* theParent,
35                                  ModuleBase_IWorkshop* theWorkshop,
36                                  const Config_WidgetAPI* theData,
37                                  const std::string& theParentId);
38   virtual ~ModuleBase_WidgetMultiSelector();
39
40   /// Saves the internal parameters to the given feature
41   /// \param theObject a model feature to be changed
42   virtual bool storeValue() const;
43
44   virtual bool restoreValue();
45
46   /// Returns the internal parent wiget control, that can be shown anywhere
47   /// \returns the widget
48   QWidget* getControl() const;
49
50   /// Returns list of widget controls
51   /// \return a control list
52   virtual QList<QWidget*> getControls() const;
53
54   virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
55
56  public slots:
57   void activateSelection(bool toActivate);
58   void onSelectionTypeChanged();
59   void onSelectionChanged();
60
61  protected:
62   void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
63                     NCollection_List<TopoDS_Shape>& theResult);
64   void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
65   void activateShapeSelection();
66
67  private:
68    void updateSelectionList();
69
70   QListWidget* myListControl;
71   QComboBox* myTypeCombo;
72   QWidget* myMainWidget;
73
74   //TODO: Move into the base of selectors
75   ModuleBase_IWorkshop* myWorkshop;
76
77   /// If true then local selector has to be activated in context
78   bool myUseSubShapes;
79   bool myIsActive;
80
81   typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;
82   QList<GeomSelection> mySelection;
83 };
84
85 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */