PRectanglei.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PObject.h>
17 
18 PAPILLON_BEGIN_NAMESPACE
19 
20 class PPoint2Df;
21 class PPoint2Di;
22 class PRectanglef;
23 class PSizei;
24 
33 class PAPILLON_API_CORE PRectanglei : public PObject
34 {
35 public:
45  explicit PRectanglei(papillon::int32 x = 0, papillon::int32 y = 0, papillon::int32 w = 0, papillon::int32 h = 0);
46 
50  PRectanglei(const PRectanglei& other);
51 
55  virtual ~PRectanglei();
56 
60  PRectanglei& operator=(const PRectanglei& other);
61 
65  bool IsValid() const;
66 
71  bool operator==(const PRectanglei& other) const;
72 
77  bool operator!=(const PRectanglei& other) const;
78 
82  papillon::int32 GetX() const;
83 
87  papillon::int32 GetY() const;
88 
93  papillon::int32 GetWidth() const;
94 
99  papillon::int32 GetHeight() const;
100 
104  PPoint2Di GetOrigin() const;
105 
109  PPoint2Df GetOriginf() const;
110 
114  PSizei GetSize() const;
115 
119  PPoint2Df GetCentre() const;
120 
124  papillon::int32 GetArea() const;
125 
131  PRectanglei ClipBy(const PRectanglei& other) const;
132 
137  PRectanglei Expand(papillon::int32 expandBy) const;
138 
142  PRectanglei Expanded(papillon::int32 expandBy) const;
143 
147  PRectanglei Intersected(const PRectanglei& other) const;
148 
152  float GetOverlapArea(const PRectanglei& rectangle) const;
153 
164  float GetDiceCoefficient(const PRectanglei& rectangle) const;
165 
172  bool Contains(const PPoint2Di& p) const;
173 
178  bool Contains(const PRectanglei& r) const;
179 
183  PRectanglef ToPRectanglef() const;
184 
191  static PResult FromString(const PString& s, PRectanglei& r);
192 };
193 
194 PAPILLON_END_NAMESPACE
The PString class provides an Unicode character strings.
Definition: PString.h:37
The PPoint2Df class represents a 2D-point with float coordinates; PPoint2Df instances are immutable (...
Definition: PPoint2Df.h:28
The PSizei class represents the size of an image or a rectangle: width (int) and height (int); PSizei...
Definition: PSizei.h:27
The PResult class represents the result returned by most of Papillon functions; this class is used to...
Definition: PResult.h:159
PResult FromString(const PString &s)
Builds a PObject from a string (destringify).
The PObject class is the root class of all Papillon classes; all PObject behaves like shared referenc...
Definition: PObject.h:27
The PRectanglei class represents an axis-aligned rectangle with 32-bit int coordinates; PRectanglei i...
Definition: PRectanglei.h:33
The PRectanglef class represents an axis-aligned rectangle with float coordinates; PRectanglef instan...
Definition: PRectanglef.h:34
Class PObject: the root class of all Papillon classes.
PObject & operator=(const PObject &obj)
Performs a shared copy of other to this object.
Definition: PObject.h:45
The PPoint2Di class represents a 2D-point with 32-bit int coordinates; PPoint2Di instances are immuta...
Definition: PPoint2Di.h:27