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