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