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_EditorContext
21 #define TrenchBroom_EditorContext
22 
23 #include "Notifier.h"
24 #include "Model/BrushContentType.h"
25 #include "Model/ModelTypes.h"
26 
27 namespace TrenchBroom {
28     namespace Assets {
29         class EntityDefinition;
30     }
31 
32     namespace Model {
33         class EditorContext {
34         public:
35             typedef enum {
36                 EntityLinkMode_All,
37                 EntityLinkMode_Transitive,
38                 EntityLinkMode_Direct,
39                 EntityLinkMode_None
40             } EntityLinkMode;
41         private:
42             bool m_showPointEntities;
43             bool m_showBrushes;
44             Model::BrushContentType::FlagType m_hiddenBrushContentTypes;
45             Bitset m_hiddenEntityDefinitions;
46             EntityLinkMode m_entityLinkMode;
47 
48             bool m_textureLock;
49             bool m_blockSelection;
50 
51             Model::Group* m_currentGroup;
52         public:
53             Notifier0 editorContextDidChangeNotifier;
54         public:
55             EditorContext();
56 
57             bool showPointEntities() const;
58             void setShowPointEntities(bool showPointEntities);
59 
60             bool showBrushes() const;
61             void setShowBrushes(bool showBrushes);
62 
63             Model::BrushContentType::FlagType hiddenBrushContentTypes() const;
64             void setHiddenBrushContentTypes(Model::BrushContentType::FlagType brushContentTypes);
65 
66             bool entityDefinitionHidden(const Model::AttributableNode* entity) const;
67             bool entityDefinitionHidden(const Assets::EntityDefinition* definition) const;
68             void setEntityDefinitionHidden(const Assets::EntityDefinition* definition, bool hidden);
69 
70             EntityLinkMode entityLinkMode() const;
71             void setEntityLinkMode(EntityLinkMode entityLinkMode);
72 
73             bool textureLock() const;
74             void setTextureLock(bool textureLock);
75 
76             bool blockSelection() const;
77             void setBlockSelection(bool blockSelection);
78         public:
79             Model::Group* currentGroup() const;
80             void pushGroup(Model::Group* group);
81             void popGroup();
82         public:
83             bool visible(const Model::Node* node) const;
84             bool visible(const Model::World* world) const;
85             bool visible(const Model::Layer* layer) const;
86             bool visible(const Model::Group* group) const;
87             bool visible(const Model::Entity* entity) const;
88             bool visible(const Model::Brush* brush) const;
89             bool visible(const Model::BrushFace* face) const;
90 
91             bool editable(const Model::Node* node) const;
92             bool editable(const Model::BrushFace* face) const;
93 
94             bool pickable(const Model::Node* node) const;
95             bool pickable(const Model::Layer* layer) const;
96             bool pickable(const Model::Group* group) const;
97             bool pickable(const Model::Entity* entity) const;
98             bool pickable(const Model::Brush* brush) const;
99             bool pickable(const Model::BrushFace* face) const;
100 
101             bool selectable(const Model::Node* node) const;
102             bool selectable(const Model::Layer* layer) const;
103             bool selectable(const Model::Group* group) const;
104             bool selectable(const Model::Entity* entity) const;
105             bool selectable(const Model::Brush* brush) const;
106             bool selectable(const Model::BrushFace* face) const;
107 
108             bool canChangeSelection() const;
109         private:
110             EditorContext(const EditorContext&);
111             EditorContext& operator=(const EditorContext&);
112         };
113     }
114 }
115 
116 #endif /* defined(TrenchBroom_EditorContext) */
117