VR-Forces 4.0.4 Class Documentation
include/vrvGraphics/DtBoundingBox.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (c) 2011 MAK Technologies, Inc.
00003  * All rights reserved.
00004  *****************************************************************************/
00005 
00009 
00010 #pragma once
00011 
00012 #include <vrvGraphics/vrvGraphics.h>
00013 
00014 namespace makVrv
00015 {
00016 
00019    class DT_DLL_VRVGRAPHICS DtPoint
00020    {
00021    public:
00022 
00024       DtPoint( float x = 0.0f, float y = 0.0f )
00025          : myX( x )
00026          , myY( y )
00027       {
00028       }
00029 
00031       inline DtPoint& operator+=( const DtPoint& p2 )
00032       {
00033          myX += p2.myX;
00034          myY += p2.myY;
00035          return *this;
00036       }
00037 
00039       inline DtPoint& operator-=( const DtPoint& p2 )
00040       {
00041          myX -= p2.myX;
00042          myY -= p2.myY;
00043          return *this;
00044       }
00045 
00047       inline bool operator==( const DtPoint& p2 ) const
00048       {
00049          return myX == p2.myX && myY == p2.myY;
00050       }
00051 
00053       inline bool operator!=( const DtPoint& p2 ) const
00054       {
00055          return myX != p2.myX || myY != p2.myY;
00056       }
00057 
00059       inline DtPoint operator+( const DtPoint& p2 ) const
00060       {
00061          return DtPoint( myX + p2.myX, myY + p2.myY );
00062       }
00063 
00065       inline DtPoint operator-( const DtPoint& p2 ) const
00066       {
00067          return DtPoint( myX - p2.myX, myY - p2.myY );
00068       }
00069 
00070    public:
00071 
00072       float myX;
00073       float myY;
00074 
00075    };
00076 
00077 
00080    class DT_DLL_VRVGRAPHICS DtPen
00081    {
00082    public:
00083 
00085       DtPen( const DtPoint& location );
00086 
00088       DtPen( float x = 0.0f, float y = 0.0f );
00089 
00090    public:
00091 
00092       DtPoint myLocation;
00093       DtPoint mySpacing;
00094       float myColor[4];
00095 
00096    };
00097 
00098 
00101    class DT_DLL_VRVGRAPHICS DtBoundingBox
00102    {
00103    public:
00104 
00106       DtBoundingBox();
00107 
00109       DtBoundingBox( float lx, float ly, float ux, float uy );
00110 
00111       //Construct a bounding box from a lower point and an upper point.
00112       DtBoundingBox( DtPoint l, DtPoint u );
00113 
00115       ~DtBoundingBox();
00116 
00119       void invalidate();
00120 
00122       bool valid() const;
00123 
00125       DtBoundingBox& operator+=( const DtPoint vector );
00126 
00128       DtBoundingBox& operator|=( const DtBoundingBox& other );
00129 
00131       void centerOn( DtPoint pos );
00132 
00135       void expandTo( float width, float height );
00136 
00138       void getCenter( DtPoint& point ) const;
00139 
00142 
00144       inline float width() const { return myUpperPoint.myX - myLowerPoint.myX;}
00145 
00147       inline float height() const { return myUpperPoint.myY - myLowerPoint.myY;}
00148 
00150 
00153 
00155       inline DtPoint& upperPoint() { return myUpperPoint; }
00156 
00158       inline const DtPoint& upperPoint() const { return myUpperPoint; }
00159 
00161       inline DtPoint& lowerPoint() { return myLowerPoint; }
00162 
00164       inline const DtPoint& lowerPoint() const { return myLowerPoint; }
00165 
00167 
00169       void toPoints( float points[8] ) const;
00170 
00171    protected:
00172 
00173       DtPoint myLowerPoint;
00174       DtPoint myUpperPoint;
00175 
00176    };
00177 
00178 }

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)