Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
[modules/shaper.git] / src / ModuleBase / ModuleBase_ViewerFilters.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_ViewerFilters.h
4 // Created:     07 Okt 2014
5 // Author:      Vitaly SMETANNIKOV
6
7
8 #ifndef ModuleBase_ViewerFilters_H
9 #define ModuleBase_ViewerFilters_H
10
11 #include <QStringList>
12
13 #include <SelectMgr_Filter.hxx>
14 #include <SelectMgr_EntityOwner.hxx>
15 #include <gp_Pln.hxx>
16
17
18 class ModuleBase_IWorkshop;
19
20
21 /**
22 * A filter which provides filtering of selection in 3d viewer.
23 * Installing of this filter lets to select objects which belong to 
24 * currently active document or to global document
25 */
26 DEFINE_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
27 class ModuleBase_ShapeDocumentFilter: public SelectMgr_Filter
28 {
29 public:
30   /// Constructor
31   /// \param theWorkshop instance of workshop interface
32   Standard_EXPORT ModuleBase_ShapeDocumentFilter(ModuleBase_IWorkshop* theWorkshop): SelectMgr_Filter(),
33     myWorkshop(theWorkshop) {}
34
35   /// Returns True if the given owner is acceptable for selection
36   /// \param theOwner the selected owner
37   Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
38
39   DEFINE_STANDARD_RTTI(ModuleBase_ShapeDocumentFilter)
40
41 protected:
42   /// Reference to workshop
43   ModuleBase_IWorkshop* myWorkshop;
44 };
45
46 /**
47 * A filter which provides filtering of selection in 3d viewer.
48 * Installing of this filter lets to select of Vertexes and Edges which belongs to the given plane
49 */
50 DEFINE_STANDARD_HANDLE(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter);
51 class ModuleBase_ShapeInPlaneFilter: public SelectMgr_Filter
52 {
53 public:
54   /// Constructor
55   Standard_EXPORT ModuleBase_ShapeInPlaneFilter(): SelectMgr_Filter() {}
56
57   /// Set working plane
58   /// \param thePane plane object
59   void setPlane(const gp_Pln& thePane) { myPlane = thePane; }
60
61   /// Returns current working plane
62   gp_Pln plane() const { return myPlane; }
63
64   /// Returns True if the given owner is acceptable for selection
65   /// \param theOwner the selected owner
66   Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
67
68   DEFINE_STANDARD_RTTI(ModuleBase_ShapeInPlaneFilter)
69 private:
70   /// Working plane
71   gp_Pln myPlane;
72 };
73
74
75 /**
76 * A filter which provides filtering of selection in 3d viewer.
77 * Installing of this filter lets to select only object of requested type
78 * Accepts following objects types:
79 * - "construction" - to select ModelAPI_ResultConstruction objects
80 */
81 DEFINE_STANDARD_HANDLE(ModuleBase_ObjectTypesFilter, SelectMgr_Filter);
82 class ModuleBase_ObjectTypesFilter: public ModuleBase_ShapeDocumentFilter
83 {
84 public:
85   /// Constructor
86   /// \param theWorkshop instance of workshop interface
87   /// \param theTypes list of object types
88   Standard_EXPORT ModuleBase_ObjectTypesFilter(ModuleBase_IWorkshop* theWorkshop, const QStringList& theTypes): 
89       ModuleBase_ShapeDocumentFilter(theWorkshop), myTypes(theTypes) {}
90
91   /// Returns True if the given owner is acceptable for selection
92   /// \param theOwner the selected owner
93   Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
94
95   DEFINE_STANDARD_RTTI(ModuleBase_ObjectTypesFilter)
96 private:
97   /// List of object types
98   QStringList myTypes;
99 };
100
101 #endif