BSize.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
10 #include <UI\UIFramework.h>
11 #include <UI\Core\MathUtils.h>
12 
14 
15 //=======================================================================================
37 //=======================================================================================
39  {
40  public:
42  BSize ();
44  BSize (int w, int h);
45 
47  bool IsNull () const;
49  bool IsEmpty () const;
51  bool IsValid () const;
52 
54  int Width () const;
56  int Height () const;
58  void SetWidth (int w);
60  void SetHeight (int h);
62  void Transpose ();
63 
65  BSize ExpandedTo (const BSize &) const;
67  BSize BoundedTo (const BSize &) const;
68 
70  BSize &operator += (const BSize &);
72  BSize &operator -= (const BSize &);
74  BSize &operator *= (double c);
76  BSize &operator /= (double c);
77 
79  friend bool operator == (const BSize &, const BSize &);
81  friend bool operator != (const BSize &, const BSize &);
82 
84  friend const BSize operator + (const BSize &, const BSize &);
86  friend const BSize operator - (const BSize &, const BSize &);
88  friend const BSize operator * (const BSize &, double);
90  friend const BSize operator * (double, const BSize &);
92  friend const BSize operator / (const BSize &, double);
93 
94  private:
95  int m_width;
96  int m_height;
97 
98  };
99 
100 
101 /*****************************************************************************
102  BSize inline friend operators
103  *****************************************************************************/
104 
106 inline bool operator == (const BSize &s1, const BSize &s2)
107  {
108  return s1.Width () == s2.Width () && s1.Height () == s2.Height ();
109  }
110 
112 inline bool operator != (const BSize &s1, const BSize &s2)
113  {
114  return s1.Width () != s2.Width () || s1.Height () != s2.Height ();
115  }
116 
118 inline const BSize operator + (const BSize & s1, const BSize & s2)
119  {
120  return BSize (s1.Width () + s2.Width (), s1.Height () + s2.Height ());
121  }
122 
124 inline const BSize operator - (const BSize &s1, const BSize &s2)
125  {
126  return BSize (s1.Width () - s2.Width (), s1.Height () - s2.Height ());
127  }
128 
130 inline const BSize operator * (const BSize &s, double c)
131  {
132  return BSize (Round (s.Width ()*c), Round (s.Height ()*c));
133  }
134 
136 inline const BSize operator * (double c, const BSize &s)
137  {
138  return BSize (Round (s.Width ()*c), Round (s.Height ()*c));
139  }
140 
142 inline const BSize operator / (const BSize &s, double c)
143  {
144  return BSize (Round (s.Width () / c), Round (s.Height () / c));
145  }
146 
147 
void operator+=(DPoint3d &point, DVec3d const &vector)
operator overload for in-place addition of a point plus a vector
int Height() const
Returns the height.
bool operator!=(const BSize &s1, const BSize &s2)
Operator overload for BSize != (not equal test).
Definition: BSize.h:112
The BSize class defines the size of a two - dimensional object using integer point precision...
Definition: BSize.h:38
#define BEGIN_BENTLEY_UIFRAMEWORK_NAMESPACE
Definition: UIFramework.h:14
void operator*=(DVec3d &vector, double const scalar)
operator overload for in-place multiplication of a vector times a scalar,
#define DLLEXPORT
Definition: basedefs.h:137
const BSize operator+(const BSize &s1, const BSize &s2)
Operator overload for BSize + (add).
Definition: BSize.h:118
const BSize operator*(const BSize &s, double c)
Operator overload for BSize * (multiply).
Definition: BSize.h:130
void operator-=(DPoint3d &point, DVec3d const &vector)
operator overload for in-place subtraction of a point minus a vector
#define END_BENTLEY_UIFRAMEWORK_NAMESPACE
Definition: UIFramework.h:15
int Width() const
Returns the width.
bool operator==(const BSize &s1, const BSize &s2)
Operator overload for BSize == (equality test).
Definition: BSize.h:106
const BSize operator/(const BSize &s, double c)
Operator overload for BSize / (divide).
Definition: BSize.h:142
const BSize operator-(const BSize &s1, const BSize &s2)
Operator overload for BSize - (subtract).
Definition: BSize.h:124

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.