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
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "vgfx.h"
00038 #include "drawer.h"
00039
00040 #include "common/wave_ex.h"
00041
00042 #include "util/parsing.h"
00043
00044
00045
00046 namespace vgfx {
00047
00048
00049
00050 Drawer::~Drawer(void) throw() { }
00051
00052 Primitive::Primitive(void) throw() : m_refcount(0) { }
00053 Primitive::~Primitive(void) throw() { }
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 const char *
00064 Primitive::getID(void)
00065 const
00066 throw()
00067 {
00068 return m_id.c_str();
00069 }
00070
00071
00072
00073 void
00074 Primitive::setID
00075 (
00076 IN const char * id
00077 )
00078 {
00079 ASSERT(id, "null id in Primitive::setID()");
00080 m_id = id;
00081 }
00082
00083
00084
00085 void
00086 Primitive::listContainers
00087 (
00088 IN const VecString& path,
00089 OUT VecString& ids
00090 )
00091 const
00092 {
00093 WAVE_EX(wex);
00094 wex << "Objects of type " << this->getType();
00095 wex << " do not support listContainers() calls.";
00096 }
00097
00098
00099 bool
00100 Primitive::doesContainerExist
00101 (
00102 IN const VecString& path
00103 )
00104 const
00105 {
00106 return false;
00107 }
00108
00109
00110
00111 bool
00112 Primitive::canCreateContainer
00113 (
00114 IN const VecString& path
00115 )
00116 const
00117 {
00118 return false;
00119 }
00120
00121
00122
00123 void
00124 Primitive::removeContainer
00125 (
00126 IN const VecString& path
00127 )
00128 {
00129 WAVE_EX(wex);
00130 wex << "Primitives of type '" << this->getType() << "' do not support ";
00131 wex << "removeContainer() calls.";
00132 }
00133
00134
00135
00136 void
00137 Primitive::getContainerDictionary
00138 (
00139 IN const VecString& path,
00140 OUT dictionary_t& data
00141 )
00142 const
00143 {
00144 WAVE_EX(wex);
00145 wex << "Primitives of type '" << this->getType() << "' do not support ";
00146 wex << "getContainerDictionary() calls.";
00147 }
00148
00149
00150
00151 void
00152 Primitive::setContainerDictionary
00153 (
00154 IN const VecString& path,
00155 IN const dictionary_t& data
00156 )
00157 {
00158 WAVE_EX(wex);
00159 wex << "Primitives of type '" << this->getType() << "' do not support ";
00160 wex << "getContainerDictionary() calls.";
00161 }
00162
00163
00164
00165 void
00166 Primitive::draw
00167 (
00168 IN Drawer * drawer,
00169 IN const rect_t& r,
00170 IN const xform_2d_t& T
00171 )
00172 {
00173 ASSERT(drawer, "null drawer");
00174
00175 }
00176
00177
00178
00179 bool
00180 Primitive::getPrimitive
00181 (
00182 IN const char * tag_path,
00183 IN const xform_2d_t& T,
00184 OUT visit_result_t& vr
00185 )
00186 {
00187 ASSERT(tag_path, "null");
00188
00189 WAVE_EX(wex);
00190 wex << "primitives of type '" << this->getType() << "' do not support ";
00191 wex << "getPrimitive() calls.";
00192
00193 return false;
00194 }
00195
00196
00197
00198 bool
00199 Primitive::visit
00200 (
00201 IN const rect_t& r,
00202 IN const xform_2d_t& T,
00203 IN const char * tag_path,
00204 IN callback_t callback,
00205 IN void * context,
00206 IN eHitDetect hit
00207 )
00208 {
00209 ASSERT(callback, "Primitive::visit() called with null callback");
00210
00211
00212 visit_result_t vr;
00213 vr.p = this;
00214 vr.tag_path = tag_path;
00215 vr.T = T;
00216 return callback(context, vr);
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 #define CREATE(name) \
00235 if ( !strcmp( type, #name ) ) \
00236 { \
00237 init_##name##_t init; \
00238 init_##name##_from_data (data, init); \
00239 return create_##name (init); \
00240 }
00241
00242 smart_ptr<Primitive>
00243 Primitive::create
00244 (
00245 IN const char * type,
00246 IN const dictionary_t& data
00247 )
00248 {
00249 ASSERT(type, "null primitive type name passed in");
00250
00251
00252
00253
00254 CREATE(line)
00255 CREATE(quad)
00256
00257 CREATE(rect)
00258 CREATE(bezier)
00259 CREATE(text)
00260
00261
00262 ASSERT(false, "Unrecognized primitive type: '%s'", type);
00263 return 0;
00264 }
00265
00266
00267
00268 };
00269