Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
extents.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_EXTENTS_HPP
9#define ADOBE_EXTENTS_HPP
10
11#include <adobe/config.hpp>
12
13#include <boost/operators.hpp>
14
15#include <array>
16#include <vector>
17
18/**************************************************************************************************/
19
20namespace adobe {
21
22/**************************************************************************************************/
23
24template <typename T = int>
25struct point_2d : boost::equality_comparable<point_2d<T>> {
26 point_2d() : x_m(T()), y_m(T()) {}
27
28 point_2d(const T& x, const T& y) : x_m(x), y_m(y) {}
29
30 T x_m;
31 T y_m;
32
33 friend inline void swap(const point_2d& x, const point_2d& y) BOOST_NOEXCEPT {
34 swap(x.x_m, y.x_m);
35 swap(x.y_m, y.y_m);
36 }
37
38 friend inline bool operator==(const point_2d& x, const point_2d& y) {
39 return (x.x_m == y.x_m) && (x.y_m == y.y_m);
40 }
41};
42
43typedef std::pair<int, int> pair_long_t;
45typedef std::vector<int> guide_set_t;
46
47// REVISIT (sparent) : points of interest need to be named entities. This will become:
48
49#if 0
50struct guide_set_t
51{
52 name_t name_m;
53 int offset_m;
54};
55typedef std::vector<guide_set_t> point_of_interest_set_t;
56#endif
57
58// REVISIT (sparent) : Open issue - are there "alignment" attributes on POIs?
59
63
64/**************************************************************************************************/
65
66struct extents_t :
67#if !defined(ADOBE_NO_DOCUMENTATION)
68 private extents_slices_t,
69 boost::equality_comparable<extents_t>
70#endif
71{
72 struct slice_t : boost::equality_comparable<slice_t> {
73 slice_t() : length_m(0){};
74
80
81 friend bool operator==(const slice_t& x, const slice_t& y);
82 };
83
84 std::array<slice_t, 2> slice_m;
85
88
91
92 int& height() { return vertical().length_m; }
93 int& width() { return horizontal().length_m; }
94
95 const int& height() const { return vertical().length_m; }
96 const int& width() const { return horizontal().length_m; }
97
98 friend bool operator==(const extents_t& x, const extents_t& y);
99};
100
101/**************************************************************************************************/
102
103#ifndef NDEBUG
104std::ostream& operator<<(std::ostream& s, const extents_t& x);
105#endif
106
107#ifndef NDEBUG
108std::ostream& operator<<(std::ostream& s, const extents_t::slice_t& x);
109#endif
110
111/**************************************************************************************************/
112
113} // namespace adobe
114
115/**************************************************************************************************/
116
117namespace std {
118
119template <>
120inline void swap(adobe::extents_t::slice_t& x, adobe::extents_t::slice_t& y) BOOST_NOEXCEPT {
121 swap(x.length_m, y.length_m);
122 swap(x.outset_m, y.outset_m);
123 swap(x.frame_m, y.frame_m);
124 swap(x.inset_m, y.inset_m);
125 swap(x.guide_set_m, y.guide_set_m);
126}
127
128template <>
129inline void swap(adobe::extents_t& x, adobe::extents_t& y) BOOST_NOEXCEPT {
130 swap(x.slice_m, y.slice_m);
131}
132
133} // namespace std
134
135/**************************************************************************************************/
136
137#endif
138
139/**************************************************************************************************/
std::pair< int, int > pair_long_t
Definition extents.hpp:43
std::vector< int > guide_set_t
Definition extents.hpp:45
point_2d< int > point_2d_t
Definition extents.hpp:44
std::ostream & operator<<(std::ostream &s, const extents_t &x)
STL namespace.
void swap(adobe::extents_t::slice_t &x, adobe::extents_t::slice_t &y) BOOST_NOEXCEPT
Definition extents.hpp:120
A utility class for referencing the two slices of a extents_t.
Definition extents.hpp:60
A class containing element geometry for a single orientation.
Definition extents.hpp:72
friend bool operator==(const slice_t &x, const slice_t &y)
An intrinsic geometry class for objects with a graphical representation.
Definition extents.hpp:71
const int & width() const
Definition extents.hpp:96
friend bool operator==(const extents_t &x, const extents_t &y)
std::array< slice_t, 2 > slice_m
Definition extents.hpp:84
const int & height() const
Definition extents.hpp:95
slice_t & vertical()
Definition extents.hpp:86
const slice_t & horizontal() const
Definition extents.hpp:90
const slice_t & vertical() const
Definition extents.hpp:89
slice_t & horizontal()
Definition extents.hpp:87
A character string class for immutable strings.
Definition name.hpp:220
point_2d(const T &x, const T &y)
Definition extents.hpp:28
friend void swap(const point_2d &x, const point_2d &y) BOOST_NOEXCEPT
Definition extents.hpp:33
friend bool operator==(const point_2d &x, const point_2d &y)
Definition extents.hpp:38