Fix scaled QGIViewSymbol boundingRect
This commit is contained in:
parent
a812ad2d5e
commit
06e8c6734d
|
@ -51,23 +51,27 @@ QGCustomSvg::~QGCustomSvg()
|
|||
|
||||
void QGCustomSvg::centerAt(QPointF centerPos)
|
||||
{
|
||||
QRectF box = boundingRect();
|
||||
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();
|
||||
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.);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ QGIViewSymbol::QGIViewSymbol()
|
|||
|
||||
m_svgItem = new QGCustomSvg();
|
||||
addToGroup(m_svgItem);
|
||||
m_svgItem->setPos(0.,0.);
|
||||
m_svgItem->centerAt(0.,0.);
|
||||
}
|
||||
|
||||
QGIViewSymbol::~QGIViewSymbol()
|
||||
|
@ -137,5 +137,5 @@ void QGIViewSymbol::symbolToSvg(QByteArray qba)
|
|||
if (!m_svgItem->load(&qba)) {
|
||||
Base::Console().Error("Error - Could not load Symbol into SVG renderer for %s\n", getViewObject()->getNameInDocument());
|
||||
}
|
||||
m_svgItem->setPos(0.,0.);
|
||||
m_svgItem->centerAt(0.,0.);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user