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 #ifndef __NEOWTKCOORD_H
00028 #define __NEOWTKCOORD_H
00029
00030
00031 #include "base.h"
00032
00033 #ifdef HAVE_NEOCHUNKIO
00034 # include <neochunkio/complex.h>
00035 # include "chunktype.h"
00036 #endif
00037
00038
00045 namespace NeoWTK
00046 {
00047
00048
00054 class NEOWTK_API Coord
00055 {
00056 public:
00057
00059 int x;
00060
00062 int y;
00063
00067 Coord() : x(0), y(0) {}
00068
00073 Coord( int iX, int iY ) : x(iX), y(iY) {}
00074
00080 inline void Set( int iX, int iY ) { x = iX; y = iY; }
00081
00087 inline Coord operator + ( const Coord &rkCoord ) const { return Coord( x + rkCoord.x, y + rkCoord.y ); }
00088
00094 inline Coord operator - ( const Coord &rkCoord ) const { return Coord( x - rkCoord.x, y - rkCoord.y ); }
00095
00101 inline Coord operator * ( float fScale ) const { return Coord( int( float( x ) * fScale ), int( float( y ) * fScale ) ); }
00102
00108 inline Coord &operator += ( const Coord &rkCoord ) { x += rkCoord.x; y += rkCoord.y; return( *this ); }
00109
00115 inline Coord &operator -= ( const Coord &rkCoord ) { x -= rkCoord.x; y -= rkCoord.y; return( *this ); }
00116
00122 inline Coord &operator *= ( float fScale ) { x = int( float( x ) * fScale ); y = int( float( y ) * fScale ); return( *this ); }
00123
00128 inline Coord operator - () const { return Coord( -x, -y ); }
00129
00135 inline bool operator == ( const Coord &rkCoord ) const { return( ( x == rkCoord.x ) && ( y == rkCoord.y ) ); }
00136
00142 inline bool operator != ( const Coord &rkCoord ) const { return( ( x != rkCoord.x ) || ( y != rkCoord.y ) ); }
00143 };
00144
00145
00146 #ifdef HAVE_NEOCHUNKIO
00147
00148
00154 class NEOWTK_API CoordChunk : public NeoChunkIO::ComplexChunk
00155 {
00156 public:
00157
00159 Coord m_kCoord;
00160
00161
00168 CoordChunk( unsigned short usType, const NeoEngine::HashString &rstrType, const NeoEngine::HashString &rstrID = "" ) : NeoChunkIO::ComplexChunk( usType, rstrType, rstrID ) {}
00169
00173 virtual ~CoordChunk() {}
00174
00181 virtual int ParseData( unsigned int uiFlags, NeoEngine::FileManager *pkFileManager );
00182
00190 static NeoChunkIO::Chunk *Allocator( unsigned short usType, const NeoEngine::HashString &rstrType, const NeoEngine::HashString &rstrID ) { return new CoordChunk( usType, rstrType, rstrID ); }
00191 };
00192
00193
00194 #endif
00197 };
00200 #endif