Not so soon, I guess, since that FIXME was from r6305.
[lyx.git] / src / graphics / GraphicsParams.cpp
bloba53d2c57b1ffb4f038c998cde7ceeea046f9b34c
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.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "GraphicsParams.h"
15 #include "Length.h"
17 #include <cstdlib>
18 #include <sstream>
20 using namespace std;
22 namespace lyx {
23 namespace graphics {
25 Params::Params()
26 : display(true),
27 scale(100),
28 angle(0)
32 bool operator==(Params const & a, Params const & b)
34 return (a.filename == b.filename &&
35 a.display == b.display &&
36 a.bb == b.bb &&
37 a.scale == b.scale &&
38 a.angle == b.angle);
42 bool operator!=(Params const & a, Params const & b)
44 return !(a == b);
48 ostream & operator<<(ostream & os, BoundingBox const & bb)
50 os << bb.xl << ' ' << bb.yb << ' ' << bb.xr << ' ' << bb.yt;
51 return os;
55 BoundingBox::BoundingBox()
56 : xl(0), yb(0), xr(0), yt(0)
60 BoundingBox::BoundingBox(string const & bb)
61 : xl(0), yb(0), xr(0), yt(0)
63 if (bb.empty())
64 return;
66 istringstream is(bb.c_str());
67 string a, b, c, d;
68 is >> a >> b >> c >> d;
70 // inBP returns the length in Postscript points.
71 // Note further that there are 72 Postscript pixels per inch.
72 unsigned int const xl_tmp = abs(Length(a).inBP());
73 unsigned int const yb_tmp = abs(Length(b).inBP());
74 unsigned int const xr_tmp = abs(Length(c).inBP());
75 unsigned int const yt_tmp = abs(Length(d).inBP());
77 if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp)
78 return;
80 xl = xl_tmp;
81 yb = yb_tmp;
82 xr = xr_tmp;
83 yt = yt_tmp;
87 bool BoundingBox::empty() const
89 return (!xl && !yb && !xr && !yt);
93 bool operator==(BoundingBox const & a, BoundingBox const & b)
95 return (a.xl == b.xl &&
96 a.yb == b.yb &&
97 a.xr == b.xr &&
98 a.yt == b.yt);
102 bool operator!=(BoundingBox const & a, BoundingBox const & b)
104 return !(a == b);
107 } // namespace graphics
108 } // namespace lyx