GUIDOLib  1.7.7
Guido Engine Internal Documentation
NVRect.h
1 #ifndef NVRect_H
2 #define NVRect_H
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2002 Holger Hoos, Juergen Kilian, Kai Renz
7  Copyright (C) 2002-2017 Grame
8 
9  This Source Code Form is subject to the terms of the Mozilla Public
10  License, v. 2.0. If a copy of the MPL was not distributed with this
11  file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 
13  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
14  research@grame.fr
15 
16 */
17 
18 #include <iostream>
19 
20 #include "NVPoint.h"
21 
22 class NVRect
23 {
24  public:
25  NVRect() : left(0), top(0), right(0), bottom(0) { }
26  NVRect(float p_left, float p_top, float p_right, float p_bottom ) :
27  left( p_left ), top( p_top ), right( p_right ), bottom( p_bottom ) { }
28 
29  // virtual ~NVRect() { } // should not be overriden
30 
31  NVRect & operator +=( const NVPoint & in );
32  NVRect & operator -=( const NVPoint & in );
33  NVRect & operator *=( float v );
34  bool operator ==( const NVRect& r ) const { return (left==r.left) && (top==r.top) && (right==r.right) && (bottom==r.bottom); }
35  NVRect operator +( const NVPoint & in ) const;
36 
37  void Print( std::ostream& os ) const { os << "[" << left << ", " << top << ", " << right << ", " << bottom << "]"; }
38  void Set( const NVRect & in )
39  { Set( in.left, in.top, in.right, in.bottom ); }
40 
41  void Set( float inL, float inT, float inR, float inB );
42  void Merge( const NVRect & in );
43  NVRect Scale( float val ) const;
44 
45  float Height() const { return bottom - top; }
46  float Width() const { return right - left; }
47 
48  NVPoint TopLeft() const { return NVPoint (left, top); }
49  NVPoint BottomRight() const { return NVPoint (right, bottom); }
50 
51 
52  float left;
53  float top;
54  float right;
55  float bottom;
56 
57  bool Contains( const NVPoint & p ) const;
58  bool Collides( const NVRect & r ) const;
59 };
60 
61 std::ostream& operator<< (std::ostream& os, const NVRect& r);
62 
63 #endif
NVRect::TopLeft
NVPoint TopLeft() const
Definition: NVRect.h:48
NVRect::left
float left
Definition: NVRect.h:52
NVPoint
Definition: NVPoint.h:20
NVRect::operator==
bool operator==(const NVRect &r) const
Definition: NVRect.h:34
NVRect::NVRect
NVRect(float p_left, float p_top, float p_right, float p_bottom)
Definition: NVRect.h:26
NVRect::NVRect
NVRect()
Definition: NVRect.h:25
NVRect::operator-=
NVRect & operator-=(const NVPoint &in)
NVRect::Contains
bool Contains(const NVPoint &p) const
NVRect::Height
float Height() const
Definition: NVRect.h:45
NVRect::operator+
NVRect operator+(const NVPoint &in) const
NVRect::operator*=
NVRect & operator*=(float v)
NVRect::Width
float Width() const
Definition: NVRect.h:46
NVRect::Print
void Print(std::ostream &os) const
Definition: NVRect.h:37
NVRect::Set
void Set(const NVRect &in)
Definition: NVRect.h:38
NVRect::BottomRight
NVPoint BottomRight() const
Definition: NVRect.h:49
NVRect
Definition: NVRect.h:22
NVRect::Collides
bool Collides(const NVRect &r) const
NVRect::right
float right
Definition: NVRect.h:54
NVRect::Scale
NVRect Scale(float val) const
NVRect::bottom
float bottom
Definition: NVRect.h:55
NVRect::top
float top
Definition: NVRect.h:53
operator<<
std::ostream & operator<<(std::ostream &os, const svgendl &eol)
NVRect::operator+=
NVRect & operator+=(const NVPoint &in)
NVRect::Merge
void Merge(const NVRect &in)

Guido Project Copyright © 2019 Grame-CNCM