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_BRUSHNODE_H )
23 #define INCLUDED_BRUSHNODE_H
25 #include "instancelib.h"
27 #include "brushtokens.h"
31 public scene::Node::Symbiot,
32 public scene::Instantiable,
33 public scene::Cloneable
37 NodeTypeCastTable m_casts;
40 NodeStaticCast<BrushNode, scene::Instantiable>::install( m_casts );
41 NodeStaticCast<BrushNode, scene::Cloneable>::install( m_casts );
42 NodeContainedCast<BrushNode, Snappable>::install( m_casts );
43 NodeContainedCast<BrushNode, TransformNode>::install( m_casts );
44 NodeContainedCast<BrushNode, Brush>::install( m_casts );
45 NodeContainedCast<BrushNode, XMLImporter>::install( m_casts );
46 NodeContainedCast<BrushNode, XMLExporter>::install( m_casts );
47 NodeContainedCast<BrushNode, MapImporter>::install( m_casts );
48 NodeContainedCast<BrushNode, MapExporter>::install( m_casts );
49 NodeContainedCast<BrushNode, Nameable>::install( m_casts );
50 NodeContainedCast<BrushNode, BrushDoom3>::install( m_casts );
52 NodeTypeCastTable& get(){
59 InstanceSet m_instances;
61 BrushTokenImporter m_mapImporter;
62 BrushTokenExporter m_mapExporter;
63 BrushXMLImporter m_xmlImporter;
64 BrushXMLExporter m_xmlExporter;
68 typedef LazyStatic<TypeCasts> StaticTypeCasts;
70 Snappable& get( NullType<Snappable>){
73 TransformNode& get( NullType<TransformNode>){
76 Brush& get( NullType<Brush>){
79 XMLImporter& get( NullType<XMLImporter>){
82 XMLExporter& get( NullType<XMLExporter>){
85 MapImporter& get( NullType<MapImporter>){
88 MapExporter& get( NullType<MapExporter>){
91 Nameable& get( NullType<Nameable>){
94 BrushDoom3& get( NullType<BrushDoom3>){
99 m_node( this, this, StaticTypeCasts::instance().get() ),
100 m_brush( m_node, InstanceSetEvaluateTransform<BrushInstance>::Caller( m_instances ), InstanceSet::BoundsChangedCaller( m_instances ) ),
101 m_mapImporter( m_brush ),
102 m_mapExporter( m_brush ),
103 m_xmlImporter( m_brush ),
104 m_xmlExporter( m_brush ){
106 BrushNode( const BrushNode& other ) :
107 scene::Node::Symbiot( other ),
108 scene::Instantiable( other ),
109 scene::Cloneable( other ),
110 m_node( this, this, StaticTypeCasts::instance().get() ),
111 m_brush( other.m_brush, m_node, InstanceSetEvaluateTransform<BrushInstance>::Caller( m_instances ), InstanceSet::BoundsChangedCaller( m_instances ) ),
112 m_mapImporter( m_brush ),
113 m_mapExporter( m_brush ),
114 m_xmlImporter( m_brush ),
115 m_xmlExporter( m_brush ){
124 scene::Node& clone() const {
125 return ( new BrushNode( *this ) )->node();
128 scene::Instance* create( const scene::Path& path, scene::Instance* parent ){
129 return new BrushInstance( path, parent, m_brush );
131 void forEachInstance( const scene::Instantiable::Visitor& visitor ){
132 m_instances.forEachInstance( visitor );
134 void insert( scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance ){
135 m_instances.insert( observer, path, instance );
137 scene::Instance* erase( scene::Instantiable::Observer* observer, const scene::Path& path ){
138 return m_instances.erase( observer, path );
142 inline Brush* Node_getBrush( scene::Node& node ){
143 return NodeTypeCast<Brush>::cast( node );