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