brushnode.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(INCLUDED_BRUSHNODE_H)
00023 #define INCLUDED_BRUSHNODE_H
00024
00025 #include "instancelib.h"
00026 #include "brush.h"
00027 #include "brushtokens.h"
00028
00029 class BrushNode: public scene::Node, public scene::Instantiable, public scene::Cloneable
00030 {
00031
00032 class TypeCasts
00033 {
00034 NodeTypeCastTable m_casts;
00035 public:
00036 TypeCasts ()
00037 {
00038 NodeContainedCast<BrushNode, Snappable>::install(m_casts);
00039 NodeContainedCast<BrushNode, TransformNode>::install(m_casts);
00040 NodeContainedCast<BrushNode, Brush>::install(m_casts);
00041 NodeContainedCast<BrushNode, MapImporter>::install(m_casts);
00042 NodeContainedCast<BrushNode, MapExporter>::install(m_casts);
00043 }
00044 NodeTypeCastTable& get ()
00045 {
00046 return m_casts;
00047 }
00048 };
00049
00050
00051 InstanceSet m_instances;
00052
00053 Brush m_brush;
00054
00055 BrushTokenImporter m_mapImporter;
00056 BrushTokenExporter m_mapExporter;
00057
00058 public:
00059
00060 typedef LazyStatic<TypeCasts> StaticTypeCasts;
00061
00062
00063 Snappable& get (NullType<Snappable> )
00064 {
00065 return m_brush;
00066 }
00067 TransformNode& get (NullType<TransformNode> )
00068 {
00069 return m_brush;
00070 }
00071 Brush& get (NullType<Brush> )
00072 {
00073 return m_brush;
00074 }
00075 MapImporter& get (NullType<MapImporter> )
00076 {
00077 return m_mapImporter;
00078 }
00079 MapExporter& get (NullType<MapExporter> )
00080 {
00081 return m_mapExporter;
00082 }
00083 Nameable& get (NullType<Nameable> )
00084 {
00085 return m_brush;
00086 }
00087
00088 BrushNode () :
00089 scene::Node(this, StaticTypeCasts::instance().get()), m_brush(*this, InstanceSetEvaluateTransform<
00090 BrushInstance>::Caller(m_instances), InstanceSet::BoundsChangedCaller(m_instances)), m_mapImporter(
00091 m_brush), m_mapExporter(m_brush)
00092 {
00093 }
00094
00095 BrushNode (const BrushNode& other) :
00096 scene::Node(this, StaticTypeCasts::instance().get()), scene::Instantiable(other), scene::Cloneable(other),
00097 m_brush(other.m_brush, *this, InstanceSetEvaluateTransform<BrushInstance>::Caller(m_instances),
00098 InstanceSet::BoundsChangedCaller(m_instances)), m_mapImporter(m_brush), m_mapExporter(
00099 m_brush)
00100 {
00101 }
00102
00103
00104 scene::Node& node ()
00105 {
00106 return *this;
00107 }
00108
00109 scene::Node& clone () const
00110 {
00111 return (new BrushNode(*this))->node();
00112 }
00113
00114 scene::Instance* create (const scene::Path& path, scene::Instance* parent)
00115 {
00116 return new BrushInstance(path, parent, m_brush);
00117 }
00118
00119 void forEachInstance (const scene::Instantiable::Visitor& visitor)
00120 {
00121 m_instances.forEachInstance(visitor);
00122 }
00123
00124 void insert (scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance)
00125 {
00126 m_instances.insert(observer, path, instance);
00127 }
00128 scene::Instance* erase (scene::Instantiable::Observer* observer, const scene::Path& path)
00129 {
00130 return m_instances.erase(observer, path);
00131 }
00132 };
00133
00134
00135 inline Brush* Node_getBrush (scene::Node& node)
00136 {
00137 return NodeTypeCast<Brush>::cast(node);
00138 }
00139
00140 #endif