2002-02-27 09:59:52 +00:00
|
|
|
/*
|
|
|
|
* \file GraphicsParams.C
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "GraphicsParams.h"
|
2002-05-28 11:50:04 +00:00
|
|
|
#include "Lsstream.h"
|
2002-05-28 12:03:42 +00:00
|
|
|
#include "lyxlength.h"
|
2002-05-28 11:50:04 +00:00
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
namespace grfx {
|
|
|
|
|
2002-05-28 11:50:04 +00:00
|
|
|
GParams::GParams()
|
2002-03-22 16:37:52 +00:00
|
|
|
: width(0),
|
2002-02-27 09:59:52 +00:00
|
|
|
height(0),
|
|
|
|
scale(0),
|
|
|
|
angle(0)
|
2002-05-28 11:50:04 +00:00
|
|
|
{}
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool operator==(GParams const & a, GParams const & b)
|
|
|
|
{
|
2002-04-04 10:47:47 +00:00
|
|
|
return (a.filename == b.filename &&
|
|
|
|
a.display == b.display &&
|
|
|
|
a.bb == b.bb &&
|
|
|
|
a.width == b.width &&
|
|
|
|
a.height == b.height &&
|
|
|
|
a.scale == b.scale &&
|
|
|
|
a.angle == b.angle);
|
2002-02-27 09:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool operator!=(GParams const & a, GParams const & b)
|
|
|
|
{
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-04-11 18:40:20 +00:00
|
|
|
int const xl_tmp = LyXLength(a).inBP();
|
|
|
|
int const yb_tmp = LyXLength(b).inBP();
|
|
|
|
int const xr_tmp = LyXLength(c).inBP();
|
|
|
|
int const yt_tmp = 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace grfx
|