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
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
#include "Length.h"
|
2002-05-28 11:50:04 +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),
|
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 &&
|
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
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
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.
|
2007-04-28 12:58:49 +00:00
|
|
|
unsigned int const xl_tmp = abs(Length(a).inBP());
|
|
|
|
unsigned int const yb_tmp = abs(Length(b).inBP());
|
|
|
|
unsigned int const xr_tmp = abs(Length(c).inBP());
|
|
|
|
unsigned int const yt_tmp = abs(Length(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
|