2002-09-05 11:31:30 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file GraphicsParams.cpp
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-02-27 09:59:52 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 11:31:30 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-02-27 09:59:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GraphicsParams.h"
|
2003-09-05 03:10:30 +00:00
|
|
|
|
2008-02-07 17:04:06 +00:00
|
|
|
#include <cstdlib>
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2003-09-05 03:10:30 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2003-09-05 03:10:30 +00:00
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace graphics {
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
Params::Params()
|
2008-06-13 07:34:55 +00:00
|
|
|
: display(true),
|
2002-08-24 22:02:30 +00:00
|
|
|
scale(100),
|
2014-10-18 13:26:49 +00:00
|
|
|
pixel_ratio(1.0),
|
2008-04-20 03:08:11 +00:00
|
|
|
angle(0)
|
2002-05-28 11:50:04 +00:00
|
|
|
{}
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
bool operator==(Params const & a, Params const & b)
|
2002-02-27 09:59:52 +00:00
|
|
|
{
|
2002-08-24 22:02:30 +00:00
|
|
|
return (a.filename == b.filename &&
|
|
|
|
a.display == b.display &&
|
|
|
|
a.bb == b.bb &&
|
|
|
|
a.scale == b.scale &&
|
2014-10-18 13:26:49 +00:00
|
|
|
a.pixel_ratio == b.pixel_ratio &&
|
2008-04-20 03:08:11 +00:00
|
|
|
a.angle == b.angle);
|
2002-02-27 09:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
bool operator!=(Params const & a, Params const & b)
|
2002-02-27 09:59:52 +00:00
|
|
|
{
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
ostream & operator<<(ostream & os, BoundingBox const & bb)
|
2003-09-29 21:42:13 +00:00
|
|
|
{
|
2015-07-16 20:04:08 +00:00
|
|
|
os << bb.xl.asString() << ' ' << bb.yb.asString() << ' '
|
|
|
|
<< bb.xr.asString() << ' ' << bb.yt.asString();
|
2003-09-29 21:42:13 +00:00
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
BoundingBox::BoundingBox()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
BoundingBox::BoundingBox(string const & bb)
|
|
|
|
{
|
|
|
|
if (bb.empty())
|
|
|
|
return;
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
istringstream is(bb.c_str());
|
2002-04-04 14:49:54 +00:00
|
|
|
string a, b, c, d;
|
|
|
|
is >> a >> b >> c >> d;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2015-07-16 20:04:08 +00:00
|
|
|
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());
|
|
|
|
|
2002-04-11 18:40:20 +00:00
|
|
|
// inBP returns the length in Postscript points.
|
2002-02-27 09:59:52 +00:00
|
|
|
// Note further that there are 72 Postscript pixels per inch.
|
2015-07-16 20:04:08 +00:00
|
|
|
if (xr_tmp.inBP() <= xl_tmp.inBP() || yt_tmp.inBP() <= yb_tmp.inBP())
|
2002-02-27 09:59:52 +00:00
|
|
|
return;
|
2002-04-04 10:24:33 +00:00
|
|
|
|
|
|
|
xl = xl_tmp;
|
|
|
|
yb = yb_tmp;
|
|
|
|
xr = xr_tmp;
|
|
|
|
yt = yt_tmp;
|
2002-02-27 09:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
bool BoundingBox::empty() const
|
2002-02-27 09:59:52 +00:00
|
|
|
{
|
2015-07-16 20:04:08 +00:00
|
|
|
return xl.zero() && yb.zero() && xr.zero() && yt.zero();
|
2002-02-27 09:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool operator==(BoundingBox const & a, BoundingBox const & b)
|
|
|
|
{
|
|
|
|
return (a.xl == b.xl &&
|
|
|
|
a.yb == b.yb &&
|
|
|
|
a.xr == b.xr &&
|
|
|
|
a.yt == b.yt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool operator!=(BoundingBox const & a, BoundingBox const & b)
|
|
|
|
{
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
} // namespace graphics
|
|
|
|
} // namespace lyx
|