1 /*
2  Copyright (C) 2010-2014 Kristian Duske
3 
4  This file is part of TrenchBroom.
5 
6  TrenchBroom is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  TrenchBroom is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef TrenchBroom_HitFilter
21 #define TrenchBroom_HitFilter
22 
23 #include "Hit.h"
24 #include "SharedPointer.h"
25 
26 namespace TrenchBroom {
27     namespace Model {
28         class HitFilter {
29         private:
30             class Always;
31             class Never;
32         public:
33             static HitFilter* always();
34             static HitFilter* never();
35 
36             virtual ~HitFilter();
37             bool matches(const Hit& hit) const;
38         private:
39             virtual bool doMatches(const Hit& hit) const = 0;
40         };
41 
42         class HitFilterChain : public HitFilter {
43         private:
44             const HitFilter* m_filter;
45             const HitFilter* m_next;
46         public:
47             HitFilterChain(const HitFilter* filter, const HitFilter* next);
48             ~HitFilterChain();
49         private:
50             bool doMatches(const Hit& hit) const;
51         };
52 
53         class TypedHitFilter : public HitFilter {
54         private:
55             Hit::HitType m_typeMask;
56         public:
57             TypedHitFilter(Hit::HitType typeMask);
58         private:
59             bool doMatches(const Hit& hit) const;
60         };
61 
62         class SelectionHitFilter : public HitFilter {
63         private:
64             bool doMatches(const Hit& hit) const;
65         };
66 
67         class MinDistanceHitFilter : public HitFilter {
68         private:
69             FloatType m_minDistance;
70         public:
71             MinDistanceHitFilter(FloatType minDistance);
72         private:
73             bool doMatches(const Hit& hit) const;
74         };
75 
76         class EditorContext;
77 
78         class ContextHitFilter : public HitFilter {
79         private:
80             const EditorContext& m_context;
81         public:
82             ContextHitFilter(const EditorContext& context);
83         private:
84             bool doMatches(const Hit& hit) const;
85         };
86     }
87 }
88 
89 #endif /* defined(TrenchBroom_HitFilter) */
90