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
|
|
|
|
2002-05-28 12:03:42 +00:00
|
|
|
#include "lyxlength.h"
|
2002-05-28 11:50:04 +00:00
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2003-09-05 03:10:30 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
using std::string;
|
2002-07-20 15:25:41 +00:00
|
|
|
using std::abs;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
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()
|
2002-06-26 14:15:08 +00:00
|
|
|
: display(ColorDisplay),
|
2002-08-24 22:02:30 +00:00
|
|
|
scale(100),
|
2002-02-27 09:59:52 +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 &&
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-29 21:42:13 +00:00
|
|
|
std::ostream & operator<<(std::ostream & os, BoundingBox const & bb)
|
|
|
|
{
|
|
|
|
os << bb.xl << ' ' << bb.yb << ' ' << bb.xr << ' ' << bb.yt;
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
BoundingBox::BoundingBox()
|
|
|
|
: xl(0), yb(0), xr(0), yt(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
BoundingBox::BoundingBox(string const & bb)
|
2002-04-04 10:24:33 +00:00
|
|
|
: xl(0), yb(0), xr(0), yt(0)
|
2002-02-27 09:59:52 +00:00
|
|
|
{
|
|
|
|
if (bb.empty())
|
|
|
|
return;
|
|
|
|
|
2002-04-04 14:49:54 +00:00
|
|
|
std::istringstream is(bb.c_str());
|
|
|
|
string a, b, c, d;
|
|
|
|
is >> a >> b >> c >> d;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
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.
|
2002-08-24 22:02:30 +00:00
|
|
|
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());
|
2002-04-04 10:24:33 +00:00
|
|
|
|
2002-04-04 14:49:54 +00:00
|
|
|
if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp)
|
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
|
|
|
{
|
|
|
|
return (!xl && !yb && !xr && !yt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|