Boost.UI
User Interface Boost library
|
Go to the documentation of this file.
8 #ifndef BOOST_UI_COORD_HPP
9 #define BOOST_UI_COORD_HPP
12 #define BOOST_UI_USE_GEOMETRY
18 #define BOOST_UI_USE_POLYGON
21 #if defined(BOOST_UI_USE_GEOMETRY) && defined(BOOST_UI_USE_POLYGON)
22 #error Unable to use Boost.Geometry with Boost.Polygon
27 #ifdef BOOST_HAS_PRAGMA_ONCE
31 #ifdef BOOST_UI_USE_GEOMETRY
32 #include <boost/geometry.hpp>
33 #include <boost/geometry/geometries/point_xy.hpp>
34 #include <boost/geometry/geometries/box.hpp>
37 #ifdef BOOST_UI_USE_POLYGON
38 #include <boost/polygon/point_data.hpp>
39 #include <boost/polygon/rectangle_data.hpp>
65 {
return m_width == other.m_width && m_height == other.m_height; }
71 const T&
width()
const {
return m_width; }
74 const T&
height()
const {
return m_height; }
121 :
public ::boost::geometry::model::d2::point_xy<T>
123 #ifdef BOOST_UI_USE_POLYGON
124 :
public ::boost::polygon::point_data<T>
127 #if defined(BOOST_UI_USE_GEOMETRY)
128 typedef ::boost::geometry::model::d2::point_xy<T> base_type;
129 #elif defined(BOOST_UI_USE_POLYGON)
130 typedef ::boost::polygon::point_data<T> base_type;
156 #if (defined(BOOST_UI_USE_GEOMETRY) || defined(BOOST_UI_USE_POLYGON)) && !defined(DOXYGEN)
164 base_type(p.
x(), p.
y())
166 m_x(p.
x()), m_y(p.
y())
172 #if defined(BOOST_UI_USE_GEOMETRY) || defined(BOOST_UI_USE_POLYGON)
173 {
return base_type::x(); }
180 #if defined(BOOST_UI_USE_GEOMETRY) || defined(BOOST_UI_USE_POLYGON)
181 {
return base_type::y(); }
188 #if defined(BOOST_UI_USE_GEOMETRY) || defined(BOOST_UI_USE_POLYGON)
196 #if defined(BOOST_UI_USE_GEOMETRY) || defined(BOOST_UI_USE_POLYGON)
204 {
return x() == other.
x() &&
y() == other.
y(); }
225 #if !defined(BOOST_UI_USE_GEOMETRY) && !defined(BOOST_UI_USE_POLYGON)
261 :
public ::boost::geometry::model::box<
262 ::boost::geometry::model::d2::point_xy<T> >
264 #ifdef BOOST_UI_USE_POLYGON
265 :
public ::boost::polygon::rectangle_data<T>
268 #ifdef BOOST_UI_USE_GEOMETRY
269 typedef ::boost::geometry::model::d2::point_xy<T> point_type;
270 typedef ::boost::geometry::model::box<point_type> base_type;
272 #ifdef BOOST_UI_USE_POLYGON
273 typedef ::boost::polygon::rectangle_data<T> base_type;
282 #if defined(BOOST_UI_USE_GEOMETRY)
283 : base_type(point_type(T(), T()), point_type(T(), T()))
284 #elif defined(BOOST_UI_USE_POLYGON)
285 : base_type(T(), T(), T(), T())
292 base_type(point_type(
x,
y),
316 base_type(point_type(point1.
x(), point1.
y()),
317 point_type(point2.
x(), point2.
y()))
319 base_type(point1.
x(), point1.
y(),
320 point2.
x(), point2.
y())
322 m_point(point1.
x(), point1.
y()), m_size(point2 - point1)
326 #if (defined(BOOST_UI_USE_GEOMETRY) || defined(BOOST_UI_USE_POLYGON)) && !defined(DOXYGEN)
327 basic_rect(
const base_type& other) : base_type(other) {}
333 base_type(point_type(other.
x(), other.
y()),
334 point_type(static_cast<T>(other.
x()) +
335 static_cast<T>(other.
width()),
336 static_cast<T>(other.
y()) +
337 static_cast<T>(other.
height())))
339 base_type(other.
x(), other.
y(),
340 static_cast<T>(other.
x()) +
341 static_cast<T>(other.
width()),
342 static_cast<T>(other.
y()) +
343 static_cast<T>(other.
height()))
345 m_point(other.
x(), other.
y()), m_size(other.
width(), other.
height())
353 #if defined(BOOST_UI_USE_GEOMETRY)
354 {
return this->min_corner().x(); }
355 #elif defined(BOOST_UI_USE_POLYGON)
356 {
return this->get(::boost::polygon::HORIZONTAL).low(); }
358 {
return m_point.x(); }
363 #if defined(BOOST_UI_USE_GEOMETRY)
364 {
return this->min_corner().y(); }
365 #elif defined(BOOST_UI_USE_POLYGON)
366 {
return this->get(::boost::polygon::VERTICAL).low(); }
368 {
return m_point.y(); }
373 #if defined(BOOST_UI_USE_GEOMETRY)
374 {
return this->max_corner().x() - this->min_corner().x(); }
375 #elif defined(BOOST_UI_USE_POLYGON)
376 {
return this->get(::boost::polygon::HORIZONTAL).high() -
377 this->get(::boost::polygon::HORIZONTAL).low(); }
379 {
return m_size.width(); }
384 #if defined(BOOST_UI_USE_GEOMETRY)
385 {
return this->max_corner().y() - this->min_corner().y(); }
386 #elif defined(BOOST_UI_USE_POLYGON)
387 {
return this->get(::boost::polygon::VERTICAL).high() -
388 this->get(::boost::polygon::VERTICAL).low(); }
390 {
return m_size.height(); }
396 return x() == other.
x() &&
y() == other.
y() &&
404 #if !defined(BOOST_UI_USE_GEOMETRY) && !defined(BOOST_UI_USE_POLYGON)
429 #endif // BOOST_UI_COORD_HPP
basic_size< T > operator/(const basic_size< T > &lhs, const T &value)
Arithmetic operation.
Definition: coord.hpp:108
T y() const
Returns y coordinate.
Definition: coord.hpp:179
basic_rect< coord_type > rect
2D rectangle coordinates
Definition: coord.hpp:424
basic_point & operator+=(const basic_size< T > &other)
Arithmetic operation.
Definition: coord.hpp:210
2D point data structure with custom coordinates type
Definition: coord.hpp:119
void y(const T &y)
Sets y coordinate.
Definition: coord.hpp:195
basic_size & operator/=(const T &value)
Arithmetic operation.
Definition: coord.hpp:83
basic_rect()
Constructs rectangle with empty coordinates.
Definition: coord.hpp:281
basic_point()
Constructs point with empty coordinates.
Definition: coord.hpp:139
bool operator!=(const basic_point &other) const
Compares two points.
Definition: coord.hpp:205
basic_rect(const basic_rect< D > &other)
Constructs rectangle with coordinates.
Definition: coord.hpp:331
T width() const
Returns width.
Definition: coord.hpp:372
Boost C++ libraries namespace.
Definition: window.hpp:19
basic_size()
Constructs empty size object.
Definition: coord.hpp:52
basic_size(const T &width, const T &height)
Constructs size with width and height.
Definition: coord.hpp:55
T height() const
Returns height.
Definition: coord.hpp:383
basic_size< coord_type > size
2D size coordinates
Definition: coord.hpp:416
T value_type
Type of coordinates.
Definition: coord.hpp:136
T x() const
Returns x coordinate.
Definition: coord.hpp:171
basic_rect(const basic_point< T > &point, const basic_size< T > &size)
Constructs rectangle with coordinates.
Definition: coord.hpp:302
T x() const
Returns x coordinate.
Definition: coord.hpp:352
basic_point & operator-=(const basic_size< T > &other)
Arithmetic operation.
Definition: coord.hpp:216
#define BOOST_UI_USE_POLYGON
Enables Boost.Polygon.
Definition: coord.hpp:18
basic_point< coord_type > point
2D point coordinates
Definition: coord.hpp:420
basic_point< T > operator-(const basic_point< T > &lhs, const basic_size< T > &rhs)
Arithmetic operation.
Definition: coord.hpp:240
bool operator==(const basic_size &other) const
Compares two sizes.
Definition: coord.hpp:64
uistring operator+(const uistring &lhs, const uistring &rhs)
Concatenates two strings or the string and the character.
Definition: string.hpp:408
bool operator!=(const basic_size &other) const
Compares two sizes.
Definition: coord.hpp:66
int coord_type
Widget coordinates signed number type.
Definition: coord.hpp:412
void x(const T &x)
Sets x coordinate.
Definition: coord.hpp:187
basic_point(const basic_point< D > &p)
Constructs size with an other size object.
Definition: coord.hpp:162
basic_size & operator*=(const T &value)
Arithmetic operation.
Definition: coord.hpp:77
basic_rect(const basic_point< T > &point1, const basic_point< T > &point2)
Constructs rectangle with coordinates.
Definition: coord.hpp:314
bool operator==(const basic_point &other) const
Compares two points.
Definition: coord.hpp:203
basic_point(const T &x, const T &y)
Constructs point with x and y coordinates.
Definition: coord.hpp:148
basic_size(const basic_size< D > &s)
Constructs size with an other size object.
Definition: coord.hpp:60
const T & height() const
Retruns height.
Definition: coord.hpp:74
const T & width() const
Retruns width.
Definition: coord.hpp:71
#define BOOST_UI_USE_GEOMETRY
Enables Boost.Geometry.
Definition: coord.hpp:14
2D size of object data structure with custom coordinates type
Definition: coord.hpp:48
bool operator!=(const basic_rect &other) const
Compares two rectangles.
Definition: coord.hpp:399
T y() const
Returns y coordinate.
Definition: coord.hpp:362
bool operator==(const basic_rect &other) const
Compares two rectangles.
Definition: coord.hpp:394
2D rectangle plane figure data structure with custom coordinates type
Definition: coord.hpp:259
basic_rect(const T &x, const T &y, const T &width, const T &height)
Constructs rectangle with coordinates.
Definition: coord.hpp:290
T value_type
Type of coordinates.
Definition: coord.hpp:278
basic_size< T > operator*(const T &value, const basic_size< T > &rhs)
Arithmetic operation.
Definition: coord.hpp:98