]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/iselection.h
ok
[xonotic/netradiant.git] / include / iselection.h
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 #if !defined(INCLUDED_ISELECTION_H)
23 #define INCLUDED_ISELECTION_H
24
25 #include <cstddef>
26 #include "generic/constant.h"
27
28 class Renderer;
29 class View;
30
31 class Callback;
32
33 template<typename FirstArgument>
34 class Callback1;
35
36 class Selectable
37 {
38 public:
39   STRING_CONSTANT(Name, "Selectable");
40
41   virtual void setSelected(bool select) = 0;
42   virtual bool isSelected() const = 0;
43 };
44
45 namespace scene
46 {
47   class Instance;
48 };
49
50 class InstanceSelectionObserver
51 {
52 public:
53   virtual void onSelectedChanged(scene::Instance& instance) = 0;
54 };
55
56 template<typename Element> class BasicVector3;
57 typedef BasicVector3<float> Vector3;
58 template<typename Element> class BasicVector4;
59 typedef BasicVector4<float> Vector4;
60 class Matrix4;
61 typedef Vector4 Quaternion;
62
63 typedef Callback1<const Selectable&> SelectionChangeCallback;
64
65 class SelectionSystem
66 {
67 public:
68   INTEGER_CONSTANT(Version, 1);
69   STRING_CONSTANT(Name, "selection");
70
71   enum EMode
72   {
73     eEntity,
74     ePrimitive,
75     eComponent,
76   };
77
78   enum EComponentMode
79   {
80     eDefault,
81     eVertex,
82     eEdge,
83     eFace,
84   };
85
86   enum EManipulatorMode
87   {
88     eTranslate,
89     eRotate,
90     eScale,
91     eDrag,
92     eClip,
93   };
94
95   virtual void SetMode(EMode mode) = 0;
96   virtual EMode Mode() const = 0;
97   virtual void SetComponentMode(EComponentMode mode) = 0;
98   virtual EComponentMode ComponentMode() const = 0;
99   virtual void SetManipulatorMode(EManipulatorMode mode) = 0;
100   virtual EManipulatorMode ManipulatorMode() const = 0;
101
102   virtual SelectionChangeCallback getObserver(EMode mode) = 0;
103   virtual std::size_t countSelected() const = 0;
104   virtual std::size_t countSelectedComponents() const = 0;
105   virtual void onSelectedChanged(scene::Instance& instance, const Selectable& selectable) = 0;
106   virtual void onComponentSelection(scene::Instance& instance, const Selectable& selectable) = 0;
107   virtual scene::Instance& ultimateSelected() const = 0;
108   virtual scene::Instance& penultimateSelected() const = 0;
109   virtual void setSelectedAll(bool selected) = 0;
110   virtual void setSelectedAllComponents(bool selected) = 0;
111
112   class Visitor
113   {
114   public:
115     virtual void visit(scene::Instance& instance) const = 0;
116   };
117   virtual void foreachSelected(const Visitor& visitor) const = 0;
118   virtual void foreachSelectedComponent(const Visitor& visitor) const = 0;
119
120   virtual void addSelectionChangeCallback(const SelectionChangeCallback& callback) = 0;
121
122   virtual void NudgeManipulator(const Vector3& nudge, const Vector3& view) = 0;
123
124   virtual void translateSelected(const Vector3& translation) = 0;
125   virtual void rotateSelected(const Quaternion& rotation) = 0;
126   virtual void scaleSelected(const Vector3& scaling) = 0;
127
128   virtual void pivotChanged() const = 0;
129 };
130
131 #include "modulesystem.h"
132
133 template<typename Type>
134 class GlobalModule;
135 typedef GlobalModule<SelectionSystem> GlobalSelectionModule;
136
137 template<typename Type>
138 class GlobalModuleRef;
139 typedef GlobalModuleRef<SelectionSystem> GlobalSelectionModuleRef;
140
141 inline SelectionSystem& GlobalSelectionSystem()
142 {
143   return GlobalSelectionModule::getTable();
144 }
145
146
147 #endif