]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsParams.cpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.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
20 using std::string;
21 using std::abs;
22
23
24 namespace lyx {
25 namespace graphics {
26
27 Params::Params()
28         : display(ColorDisplay),
29           scale(100),
30           angle(0)
31 {}
32
33
34 bool operator==(Params const & a, Params const & b)
35 {
36         return (a.filename == b.filename &&
37                 a.display == b.display &&
38                 a.bb == b.bb &&
39                 a.scale == b.scale &&
40                 a.angle == b.angle);
41 }
42
43
44 bool operator!=(Params const & a, Params const & b)
45 {
46         return !(a == b);
47 }
48
49
50 std::ostream & operator<<(std::ostream & os, BoundingBox const & bb)
51 {
52         os << bb.xl << ' ' << bb.yb << ' ' << bb.xr << ' ' << bb.yt;
53         return os;
54 }
55
56
57 BoundingBox::BoundingBox()
58         : xl(0), yb(0), xr(0), yt(0)
59 {}
60
61
62 BoundingBox::BoundingBox(string const & bb)
63         : xl(0), yb(0), xr(0), yt(0)
64 {
65         if (bb.empty())
66                 return;
67
68         std::istringstream is(bb.c_str());
69         string a, b, c, d;
70         is >> a >> b >> c >> d;
71
72         // inBP returns the length in Postscript points.
73         // Note further that there are 72 Postscript pixels per inch.
74         unsigned int const xl_tmp = abs(Length(a).inBP());
75         unsigned int const yb_tmp = abs(Length(b).inBP());
76         unsigned int const xr_tmp = abs(Length(c).inBP());
77         unsigned int const yt_tmp = abs(Length(d).inBP());
78
79         if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp)
80                 return;
81
82         xl = xl_tmp;
83         yb = yb_tmp;
84         xr = xr_tmp;
85         yt = yt_tmp;
86 }
87
88
89 bool BoundingBox::empty() const
90 {
91         return (!xl && !yb && !xr && !yt);
92 }
93
94
95 bool operator==(BoundingBox const & a, BoundingBox const & b)
96 {
97         return (a.xl == b.xl &&
98                 a.yb == b.yb &&
99                 a.xr == b.xr &&
100                 a.yt == b.yt);
101 }
102
103
104 bool operator!=(BoundingBox const & a, BoundingBox const & b)
105 {
106         return !(a == b);
107 }
108
109 } // namespace graphics
110 } // namespace lyx