]> git.lyx.org Git - features.git/blob - src/graphics/GraphicsParams.cpp
'using namespace std' instead of 'using std::xxx'
[features.git] / src / graphics / GraphicsParams.cpp
1 /**
2  * \file GraphicsParams.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GraphicsParams.h"
14
15 #include "Length.h"
16
17 #include <sstream>
18
19 using namespace std;
20
21 namespace lyx {
22 namespace graphics {
23
24 Params::Params()
25         : display(ColorDisplay),
26           scale(100),
27           angle(0)
28 {}
29
30
31 bool operator==(Params const & a, Params const & b)
32 {
33         return (a.filename == b.filename &&
34                 a.display == b.display &&
35                 a.bb == b.bb &&
36                 a.scale == b.scale &&
37                 a.angle == b.angle);
38 }
39
40
41 bool operator!=(Params const & a, Params const & b)
42 {
43         return !(a == b);
44 }
45
46
47 std::ostream & operator<<(std::ostream & os, BoundingBox const & bb)
48 {
49         os << bb.xl << ' ' << bb.yb << ' ' << bb.xr << ' ' << bb.yt;
50         return os;
51 }
52
53
54 BoundingBox::BoundingBox()
55         : xl(0), yb(0), xr(0), yt(0)
56 {}
57
58
59 BoundingBox::BoundingBox(string const & bb)
60         : xl(0), yb(0), xr(0), yt(0)
61 {
62         if (bb.empty())
63                 return;
64
65         std::istringstream is(bb.c_str());
66         string a, b, c, d;
67         is >> a >> b >> c >> d;
68
69         // inBP returns the length in Postscript points.
70         // Note further that there are 72 Postscript pixels per inch.
71         unsigned int const xl_tmp = abs(Length(a).inBP());
72         unsigned int const yb_tmp = abs(Length(b).inBP());
73         unsigned int const xr_tmp = abs(Length(c).inBP());
74         unsigned int const yt_tmp = abs(Length(d).inBP());
75
76         if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp)
77                 return;
78
79         xl = xl_tmp;
80         yb = yb_tmp;
81         xr = xr_tmp;
82         yt = yt_tmp;
83 }
84
85
86 bool BoundingBox::empty() const
87 {
88         return (!xl && !yb && !xr && !yt);
89 }
90
91
92 bool operator==(BoundingBox const & a, BoundingBox const & b)
93 {
94         return (a.xl == b.xl &&
95                 a.yb == b.yb &&
96                 a.xr == b.xr &&
97                 a.yt == b.yt);
98 }
99
100
101 bool operator!=(BoundingBox const & a, BoundingBox const & b)
102 {
103         return !(a == b);
104 }
105
106 } // namespace graphics
107 } // namespace lyx