2002-09-05 11:31:30 +00:00
|
|
|
/**
|
2002-02-27 09:59:52 +00:00
|
|
|
* \file GraphicsParams.C
|
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-09-05 11:31:30 +00:00
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
2002-02-27 09:59:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2002-07-20 15:25:41 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
#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-07-20 15:25:41 +00:00
|
|
|
using std::abs;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
namespace grfx {
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace grfx
|