Fix scaled QGIViewSymbol boundingRect

This commit is contained in:
WandererFan
2016-11-03 10:37:59 -04:00
parent 41d244a299
commit 472f0b9549
2 changed files with 19 additions and 15 deletions

View File

@@ -51,22 +51,26 @@ QGCustomSvg::~QGCustomSvg()
void QGCustomSvg::centerAt(QPointF centerPos)
{
QRectF box = boundingRect();
double width = box.width();
double height = box.height();
double newX = centerPos.x() - width/2.;
double newY = centerPos.y() - height/2.;
setPos(newX,newY);
if (group()) {
QRectF box = group()->boundingRect();
double width = box.width();
double height = box.height();
double newX = centerPos.x() - width/2.;
double newY = centerPos.y() - height/2.;
setPos(newX,newY);
}
}
void QGCustomSvg::centerAt(double cX, double cY)
{
QRectF box = boundingRect();
double width = box.width();
double height = box.height();
double newX = cX - width/2.;
double newY = cY - height/2.;
setPos(newX,newY);
if (group()) {
QRectF box = group()->boundingRect();
double width = box.width();
double height = box.height();
double newX = cX - width/2.;
double newY = cY - height/2.;
setPos(newX,newY);
}
}
bool QGCustomSvg::load(QByteArray *svgBytes)
@@ -82,7 +86,7 @@ QRectF QGCustomSvg::boundingRect() const
QRectF box = m_svgRender->viewBoxF();
double w = box.width();
double h = box.height();
QRectF newRect(0,0,w*scale(),h*scale());
QRectF newRect(0,0,w,h);
return newRect.adjusted(-1.,-1.,1.,1.);
}