2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
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.
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.
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
22 #if !defined( INCLUDED_IPATCH_H )
23 #define INCLUDED_IPATCH_H
25 #include "debugging/debugging.h"
26 #include "generic/constant.h"
27 #include "generic/vector.h"
34 template<typename Element>
40 typedef Element value_type;
41 typedef value_type* iterator;
42 typedef const value_type* const_iterator;
45 : m_size( 0 ), m_data( 0 ){
47 ArrayReference( std::size_t size, Element* data )
48 : m_size( size ), m_data( data ){
54 const_iterator begin() const {
58 return m_data + m_size;
60 const_iterator end() const {
61 return m_data + m_size;
64 value_type& operator[]( std::size_t index ){
65 ASSERT_MESSAGE( index < size(), "array index out of bounds" );
68 const value_type& operator[]( std::size_t index ) const {
69 ASSERT_MESSAGE( index < size(), "array index out of bounds" );
75 const value_type* data() const {
78 std::size_t size() const {
86 template<typename Element>
92 typedef Element value_type;
93 typedef value_type* iterator;
94 typedef const value_type* const_iterator;
97 : m_x( 0 ), m_y( 0 ), m_data( 0 ){
99 Matrix( std::size_t x, std::size_t y, Element* data )
100 : m_x( x ), m_y( y ), m_data( data ){
106 const_iterator begin() const {
110 return m_data + size();
112 const_iterator end() const {
113 return m_data + size();
116 value_type& operator[]( std::size_t index ){
117 ASSERT_MESSAGE( index < size(), "array index out of bounds" );
118 return m_data[index];
120 const value_type& operator[]( std::size_t index ) const {
121 ASSERT_MESSAGE( index < size(), "array index out of bounds" );
122 return m_data[index];
124 value_type& operator()( std::size_t x, std::size_t y ){
125 ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
126 return m_data[x * m_y + y];
128 const value_type& operator()( std::size_t x, std::size_t y ) const {
129 ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
130 return m_data[x * m_y + y];
135 const value_type* data() const {
138 std::size_t x() const {
141 std::size_t y() const {
144 std::size_t size() const {
159 typedef Matrix<PatchControl> PatchControlMatrix;
165 INTEGER_CONSTANT( Version, 1 );
166 STRING_CONSTANT( Name, "patch" );
167 virtual scene::Node& createPatch() = 0;
168 virtual void Patch_undoSave( scene::Node& patch ) const = 0;
169 virtual void Patch_resize( scene::Node& patch, std::size_t width, std::size_t height ) const = 0;
170 virtual PatchControlMatrix Patch_getControlPoints( scene::Node& patch ) const = 0;
171 virtual void Patch_controlPointsChanged( scene::Node& patch ) const = 0;
172 virtual const char* Patch_getShader( scene::Node& patch ) const = 0;
173 virtual void Patch_setShader( scene::Node& patch, const char* shader ) const = 0;
176 #include "modulesystem.h"
178 template<typename Type>
180 typedef ModuleRef<PatchCreator> PatchModuleRef;
182 template<typename Type>
184 typedef GlobalModule<PatchCreator> GlobalPatchModule;
186 template<typename Type>
187 class GlobalModuleRef;
188 typedef GlobalModuleRef<PatchCreator> GlobalPatchModuleRef;
190 inline PatchCreator& GlobalPatchCreator(){
191 return GlobalPatchModule::getTable();