Salome HOME
updated copyright message
[modules/shaper.git] / src / ModuleBase / ModuleBase_ViewerFilters.h
1 // Copyright (C) 2014-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef ModuleBase_ViewerFilters_H
21 #define ModuleBase_ViewerFilters_H
22
23 #include <QStringList>
24
25 #include <SelectMgr_Filter.hxx>
26 #include <SelectMgr_EntityOwner.hxx>
27
28 #include <GeomAPI_Pln.h>
29
30
31 class ModuleBase_IWorkshop;
32
33
34 /**
35 * \class ModuleBase_ShapeDocumentFilter
36 * \ingroup GUI
37 * A filter which provides filtering of selection in 3d viewer.
38 * Installing of this filter lets to select objects which belong to 
39 * currently active document or to global document
40 */
41 DEFINE_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
42 class ModuleBase_ShapeDocumentFilter: public SelectMgr_Filter
43 {
44 public:
45   /// Constructor
46   /// \param theWorkshop instance of workshop interface
47   Standard_EXPORT
48     ModuleBase_ShapeDocumentFilter(ModuleBase_IWorkshop* theWorkshop): SelectMgr_Filter(),
49     myWorkshop(theWorkshop) {}
50
51   /// Returns True if the given owner is acceptable for selection
52   /// \param theOwner the selected owner
53   Standard_EXPORT virtual
54     Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
55
56   /// Add an object type name to list of non selectable objects
57   /// \param theType - a name of an object type
58   Standard_EXPORT void addNonSelectableType(const QString& theType)
59   {
60     if (!myNonSelectableTypes.contains(theType))
61       myNonSelectableTypes.append(theType);
62   }
63
64   /// Removes an object type name from list of non selectable objects
65   /// \param theType - a name of an object type
66   Standard_EXPORT void removeNonSelectableType(const QString& theType)
67   {
68     if (myNonSelectableTypes.contains(theType))
69       myNonSelectableTypes.removeAll(theType);
70   }
71
72   /// Returns list of non-selectable an object type names
73   Standard_EXPORT QStringList nonSelectableTypes() const
74   {
75     return myNonSelectableTypes;
76   }
77
78   DEFINE_STANDARD_RTTIEXT(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter)
79
80 protected:
81   /// Reference to workshop
82   ModuleBase_IWorkshop* myWorkshop;
83
84   QStringList myNonSelectableTypes;
85 };
86
87 /**
88 * \class ModuleBase_ShapeInPlaneFilter
89 * \ingroup GUI
90 * A filter which provides filtering of selection in 3d viewer.
91 * Installing of this filter lets to select of Vertexes and Edges which belongs to the given plane
92 */
93 DEFINE_STANDARD_HANDLE(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter);
94 class ModuleBase_ShapeInPlaneFilter: public SelectMgr_Filter
95 {
96 public:
97   /// Constructor
98   Standard_EXPORT ModuleBase_ShapeInPlaneFilter(): SelectMgr_Filter() {}
99
100   /// Set working plane
101   /// \param thePlane a plane object
102   void setPlane(const std::shared_ptr<GeomAPI_Pln>& thePlane) { myPlane = thePlane; }
103
104   /// Returns current working plane
105   std::shared_ptr<GeomAPI_Pln> plane() const { return myPlane; }
106
107   /// Returns True if the given owner is acceptable for selection
108   /// \param theOwner the selected owner
109   Standard_EXPORT virtual
110     Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
111
112   DEFINE_STANDARD_RTTIEXT(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter)
113 private:
114   /// Working plane
115   std::shared_ptr<GeomAPI_Pln> myPlane;
116 };
117
118 #endif