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