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