]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/iselection.h
Merge branch 'illwieckz/undodetail' fix !103
[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 #include "generic/callback.h"
28 #include "signal/signalfwd.h"
29
30 class Renderer;
31 class View;
32
33 class Selectable
34 {
35 public:
36 STRING_CONSTANT( Name, "Selectable" );
37
38 virtual void setSelected( bool select ) = 0;
39 virtual bool isSelected() const = 0;
40 };
41
42 namespace scene
43 {
44 class Instance;
45 }
46
47 class InstanceSelectionObserver
48 {
49 public:
50 virtual void onSelectedChanged( scene::Instance& instance ) = 0;
51 };
52
53 template<typename Element> class BasicVector3;
54 typedef BasicVector3<float> Vector3;
55 template<typename Element> class BasicVector4;
56 typedef BasicVector4<float> Vector4;
57 class Matrix4;
58 typedef Vector4 Quaternion;
59
60 typedef Callback<void(const Selectable&)> SelectionChangeCallback;
61 typedef SignalHandler1<const Selectable&> SelectionChangeHandler;
62
63 class SelectionSystem
64 {
65 public:
66 virtual ~SelectionSystem() = default;
67 INTEGER_CONSTANT( Version, 1 );
68 STRING_CONSTANT( Name, "selection" );
69
70 enum EMode
71 {
72         eEntity,
73         ePrimitive,
74         eComponent,
75 };
76
77 enum EComponentMode
78 {
79         eDefault,
80         eVertex,
81         eEdge,
82         eFace,
83 };
84
85 enum EManipulatorMode
86 {
87         eTranslate,
88         eRotate,
89         eScale,
90         eDrag,
91         eClip,
92 };
93
94 virtual void SetMode( EMode mode ) = 0;
95 virtual EMode Mode() const = 0;
96 virtual void SetComponentMode( EComponentMode mode ) = 0;
97 virtual EComponentMode ComponentMode() const = 0;
98 virtual void SetManipulatorMode( EManipulatorMode mode ) = 0;
99 virtual EManipulatorMode ManipulatorMode() const = 0;
100
101 virtual SelectionChangeCallback getObserver( EMode mode ) = 0;
102 virtual std::size_t countSelected() const = 0;
103 virtual std::size_t countSelectedComponents() const = 0;
104 virtual void onSelectedChanged( scene::Instance& instance, const Selectable& selectable ) = 0;
105 virtual void onComponentSelection( scene::Instance& instance, const Selectable& selectable ) = 0;
106 virtual scene::Instance& ultimateSelected() const = 0;
107 virtual scene::Instance& penultimateSelected() const = 0;
108 virtual void setSelectedAll( bool selected ) = 0;
109 virtual void setSelectedAllComponents( bool selected ) = 0;
110
111 class Visitor
112 {
113 public:
114 virtual void visit( scene::Instance& instance ) const = 0;
115 };
116 virtual void foreachSelected( const Visitor& visitor ) const = 0;
117 virtual void foreachSelectedComponent( const Visitor& visitor ) const = 0;
118
119 virtual void addSelectionChangeCallback( const SelectionChangeHandler& handler ) = 0;
120
121 virtual void NudgeManipulator( const Vector3& nudge, const Vector3& view ) = 0;
122
123 virtual void translateSelected( const Vector3& translation ) = 0;
124 virtual void rotateSelected( const Quaternion& rotation ) = 0;
125 virtual void scaleSelected( const Vector3& scaling ) = 0;
126
127 virtual void pivotChanged() const = 0;
128 };
129
130 #include "modulesystem.h"
131
132 template<typename Type>
133 class GlobalModule;
134 typedef GlobalModule<SelectionSystem> GlobalSelectionModule;
135
136 template<typename Type>
137 class GlobalModuleRef;
138 typedef GlobalModuleRef<SelectionSystem> GlobalSelectionModuleRef;
139
140 inline SelectionSystem& GlobalSelectionSystem(){
141         return GlobalSelectionModule::getTable();
142 }
143
144
145 #endif