Salome HOME
Merge branch 'master' of newgeom:newgeom
[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
65  private:
66    void updateSelectionList();
67
68   QListWidget* myListControl;
69   QComboBox* myTypeCombo;
70   QWidget* myMainWidget;
71
72   //TODO: Move into the base of selectors
73   ModuleBase_IWorkshop* myWorkshop;
74
75   /// If true then local selector has to be activated in context
76   QStringList myShapeTypes;
77   bool myUseSubShapes;
78   bool myIsActive;
79
80   typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;
81   QList<GeomSelection> mySelection;
82 };
83
84 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */