Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

coord.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                     coord.h  -  Class for a 2D coordinate
00003                              -------------------
00004     begin                : Sun Nov 17 2002
00005     copyright            : (C) 2002 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, NeoWTK, coord.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2002
00023  Reality Rift Studios. All Rights Reserved.
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

Generated on Wed Jan 21 14:21:20 2004 for NeoWTK by doxygen 1.3.5