X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgraphics%2FGraphicsParams.cpp;h=f23c1f49ee0cd8ffd00148e31dd4195f651c7cea;hb=a900667ea1bb516ac562a6c45e4f3a1e4071b01b;hp=d13dc1800fdc0737f4ca8dc37b7cd2e954425e8e;hpb=f497296c30e6da2f97b16da8ad1c9e96feffb16b;p=lyx.git diff --git a/src/graphics/GraphicsParams.cpp b/src/graphics/GraphicsParams.cpp index d13dc1800f..f23c1f49ee 100644 --- a/src/graphics/GraphicsParams.cpp +++ b/src/graphics/GraphicsParams.cpp @@ -12,21 +12,18 @@ #include "GraphicsParams.h" -#include "lyxlength.h" - +#include #include - -using std::string; -using std::abs; - +using namespace std; namespace lyx { namespace graphics { Params::Params() - : display(ColorDisplay), + : display(true), scale(100), + pixel_ratio(1.0), angle(0) {} @@ -37,6 +34,7 @@ bool operator==(Params const & a, Params const & b) a.display == b.display && a.bb == b.bb && a.scale == b.scale && + a.pixel_ratio == b.pixel_ratio && a.angle == b.angle); } @@ -47,36 +45,43 @@ bool operator!=(Params const & a, Params const & b) } -std::ostream & operator<<(std::ostream & os, BoundingBox const & bb) +ostream & operator<<(ostream & os, BoundingBox const & bb) { - os << bb.xl << ' ' << bb.yb << ' ' << bb.xr << ' ' << bb.yt; + os << bb.xl.asString() << ' ' << bb.yb.asString() << ' ' + << bb.xr.asString() << ' ' << bb.yt.asString(); return os; } BoundingBox::BoundingBox() - : xl(0), yb(0), xr(0), yt(0) {} BoundingBox::BoundingBox(string const & bb) - : xl(0), yb(0), xr(0), yt(0) { if (bb.empty()) return; - std::istringstream is(bb.c_str()); + istringstream is(bb.c_str()); string a, b, c, d; is >> a >> b >> c >> d; + Length xl_tmp = Length(a); + if (xl_tmp.value() < 0) + xl_tmp = Length(-xl_tmp.value(), xl_tmp.unit()); + Length yb_tmp = Length(b); + if (yb_tmp.value() < 0) + yb_tmp = Length(-yb_tmp.value(), yb_tmp.unit()); + Length xr_tmp = Length(c); + if (xr_tmp.value() < 0) + xr_tmp = Length(-xr_tmp.value(), xr_tmp.unit()); + Length yt_tmp = Length(d); + if (yt_tmp.value() < 0) + yt_tmp = Length(-yt_tmp.value(), yt_tmp.unit()); + // inBP returns the length in Postscript points. // Note further that there are 72 Postscript pixels per inch. - unsigned int const xl_tmp = abs(LyXLength(a).inBP()); - unsigned int const yb_tmp = abs(LyXLength(b).inBP()); - unsigned int const xr_tmp = abs(LyXLength(c).inBP()); - unsigned int const yt_tmp = abs(LyXLength(d).inBP()); - - if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp) + if (xr_tmp.inBP() <= xl_tmp.inBP() || yt_tmp.inBP() <= yb_tmp.inBP()) return; xl = xl_tmp; @@ -88,7 +93,7 @@ BoundingBox::BoundingBox(string const & bb) bool BoundingBox::empty() const { - return (!xl && !yb && !xr && !yt); + return xl.zero() && yb.zero() && xr.zero() && yt.zero(); }