00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef PEEKABOT_TYPES_HH_INCLUDED
00013 #define PEEKABOT_TYPES_HH_INCLUDED
00014
00025 #include <cassert>
00026 #include <ostream>
00027 #include <string>
00028 #include <boost/cstdint.hpp>
00029
00030
00031 namespace peekabot
00032 {
00033 using boost::int8_t;
00034 using boost::uint8_t;
00035 using boost::int16_t;
00036 using boost::uint16_t;
00037 using boost::int32_t;
00038 using boost::uint32_t;
00039 using boost::int64_t;
00040 using boost::uint64_t;
00041
00042 typedef boost::uint32_t SourceID;
00043
00044 static const SourceID NOBODY_SOURCE_ID = 0;
00045 static const SourceID SERVER_SOURCE_ID = 1;
00046 static const SourceID GUI_SOURCE_ID = 2;
00047
00048 extern const boost::uint32_t NUMBER_OF_LAYERS;
00049
00050
00051
00057 typedef boost::uint32_t ObjectID;
00058
00070 struct RGBColor
00071 {
00072 RGBColor() throw() : r(0), g(0), b(0)
00073 {
00074 }
00075
00076 RGBColor(const RGBColor &color) throw()
00077 : r(color.r), g(color.g), b(color.b)
00078 {
00079 }
00080
00081 RGBColor(float _r, float _g, float _b) throw()
00082 : r(_r), g(_g), b(_b)
00083 {
00084 }
00085
00086 bool operator==(const RGBColor &color) const throw()
00087 {
00088 return color.r == r && color.g == g && color.b == b;
00089 }
00090
00091 bool operator!=(const RGBColor &color) const throw()
00092 {
00093 return !(color == *this);
00094 }
00095
00099 float r;
00100
00104 float g;
00105
00109 float b;
00110 };
00111
00112 struct RGBAColor : public RGBColor
00113 {
00114 RGBAColor() throw() : RGBColor(), a(1)
00115 {
00116 }
00117
00118 RGBAColor(const RGBAColor &color) throw()
00119 : RGBColor(color), a(color.a)
00120 {
00121 }
00122
00123 RGBAColor(float _r, float _g, float _b, float _a) throw()
00124 : RGBColor(_r, _g, _b), a(_a)
00125 {
00126 }
00127
00128 bool operator==(const RGBAColor &color) const throw()
00129 {
00130 return color.r == r && color.g == g && color.b == b && color.a == a;
00131 }
00132
00133 bool operator!=(const RGBAColor &color) const throw()
00134 {
00135 return !(color == *this);
00136 }
00137
00141 float a;
00142 };
00143
00144 inline std::ostream &operator<<(std::ostream &os, const RGBAColor &color)
00145 {
00146 os << "(" << color.r << ", " << color.g
00147 << ", " << color.b << ", " << color.a << ")";
00148 return os;
00149 }
00150
00151
00166 struct Opacity
00167 {
00168 Opacity() throw()
00169 : is_absolute(false), opacity(1.0f) {}
00170
00171 Opacity(bool _is_absolute, float _opacity) throw()
00172 : is_absolute(_is_absolute), opacity(_opacity) {}
00173
00174 Opacity(const Opacity &o) throw()
00175 : is_absolute(o.is_absolute), opacity(o.opacity) {}
00176
00177 bool operator==(const Opacity &x) const throw()
00178 {
00179 return x.opacity == opacity && x.is_absolute == is_absolute;
00180 }
00181
00182 bool operator!=(const Opacity &x) const throw()
00183 {
00184 return !(x == *this);
00185 }
00186
00187
00188 bool is_absolute;
00189 float opacity;
00190 };
00191
00192 inline std::ostream &operator<<(std::ostream &os, const Opacity &x)
00193 {
00194 os << x.opacity << " " << (x.is_absolute ? "(absolute)":"(relative)");
00195 return os;
00196 }
00197
00198
00199 struct Vector3
00200 {
00201 Vector3() {}
00202
00203 Vector3(const Vector3 &other) : x(other.x), y(other.y), z(other.z) {}
00204
00205 Vector3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) {}
00206
00207 float &operator()(int idx)
00208 {
00209 if( idx == 0 )
00210 return x;
00211 else if( idx == 1 )
00212 return y;
00213 else if( idx == 2 )
00214 return z;
00215 else
00216 assert( false );
00217 }
00218
00219 float operator()(int idx) const
00220 {
00221 if( idx == 0 )
00222 return x;
00223 else if( idx == 1 )
00224 return y;
00225 else if( idx == 2 )
00226 return z;
00227 else
00228 assert( false );
00229 }
00230
00231 float x, y, z;
00232 };
00233
00234
00235 struct Transformation
00236 {
00237 Vector3 &operator()(int idx)
00238 {
00239 if( idx == 0 )
00240 return x;
00241 else if( idx == 1 )
00242 return y;
00243 else if( idx == 2 )
00244 return z;
00245 else if( idx == 3 )
00246 return pos;
00247 else
00248 assert( false );
00249 }
00250
00251 const Vector3 &operator()(int idx) const
00252 {
00253 if( idx == 0 )
00254 return x;
00255 else if( idx == 1 )
00256 return y;
00257 else if( idx == 2 )
00258 return z;
00259 else if( idx == 3 )
00260 return pos;
00261 else
00262 assert( false );
00263 }
00264
00265 inline float &operator()(int row, int col)
00266 {
00267 return (*this)(col)(row);
00268 }
00269
00270 inline float operator()(int row, int col) const
00271 {
00272 return (*this)(col)(row);
00273 }
00274
00275 Vector3 x, y, z;
00276 Vector3 pos;
00277 };
00278
00279
00280 enum Axis
00281 {
00282 X_AXIS = 8,
00283 Y_AXIS = 16,
00284 Z_AXIS = 32
00285 };
00286
00290 enum CoordinateSystem
00291 {
00293 CAMERA_COORDINATES = 64,
00294 WORLD_COORDINATES = 128,
00295 LOCAL_COORDINATES = 256,
00296 PARENT_COORDINATES = 512
00297 };
00298
00299 enum RotationCenterpoint
00300 {
00301 LOCAL_CENTER = 2048,
00302 PARENT_CENTER = 4096,
00303 WORLD_CENTER = 8192,
00304 AVERAGE_CENTER = 16384
00305 };
00306
00317 enum NameConflictPolicy
00318 {
00325 FAIL_ON_CONFLICT,
00326
00333 AUTO_ENUMERATE_ON_CONFLICT,
00334
00341 REPLACE_ON_CONFLICT,
00342
00352 ALIAS_ON_CONFLICT
00353 };
00354
00355 enum LineStyle
00356 {
00357
00358
00359
00360
00361
00362 LINE_STYLE_SOLID = 0xFFFF,
00363 LINE_STYLE_DOTTED = 0x8888,
00364 LINE_STYLE_DASHED = 0xFF80,
00365 LINE_STYLE_DASH_DOT = 0xFF88,
00366 LINE_STYLE_DASH_DOT_DOT = 0xFE44
00367 };
00368
00369 enum GridType
00370 {
00371 REGULAR_GRID = 0,
00372 RADIAL_GRID = 1,
00373 ANGULAR_GRID = 2
00374 };
00375
00376 enum TextAlignment
00377 {
00378 ALIGN_LEFT = 0,
00379 ALIGN_RIGHT = 1,
00380 ALIGN_CENTER = 2
00381 };
00382
00383 typedef boost::uint16_t PropKey;
00384
00385 enum VertexOverflowPolicy
00386 {
00387 VERTEX_OVERFLOW_CLEAR = 0,
00388 VERTEX_OVERFLOW_TRUNCATE = 1,
00389 VERTEX_OVERFLOW_TRUNCATE_HALF = 2
00390 };
00391
00392 typedef boost::uint32_t ObjectType;
00393 }
00394
00395
00396 #endif // PEEKABOT_TYPES_HH_INCLUDED