Fix Symbol based View positioning

This commit is contained in:
WandererFan
2017-09-13 21:23:47 -04:00
committed by wmayer
parent 8431ec0fc1
commit 00edf63be8
2 changed files with 11 additions and 20 deletions

View File

@@ -51,26 +51,17 @@ QGCustomSvg::~QGCustomSvg()
void QGCustomSvg::centerAt(QPointF centerPos)
{
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);
}
centerAt(centerPos.x(),centerPos.y());
}
void QGCustomSvg::centerAt(double cX, double cY)
{
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);
}
QRectF box = boundingRect();
double width = box.width();
double height = box.height();
double newX = (cX - width/2.) * scale();
double newY = (cY - height/2.) * scale();
setPos(newX,newY);
}
bool QGCustomSvg::load(QByteArray *svgBytes)
@@ -87,12 +78,14 @@ QRectF QGCustomSvg::boundingRect() const
double w = box.width();
double h = box.height();
QRectF newRect(0,0,w,h);
return newRect.adjusted(-1.,-1.,1.,1.);
return newRect;
}
void QGCustomSvg::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
//painter->drawRect(boundingRect()); //good for debugging
QGraphicsSvgItem::paint (painter, &myOption, widget);
}

View File

@@ -107,9 +107,7 @@ void QGIViewSymbol::draw()
}
drawSvg();
if (borderVisible) {
drawBorder();
}
QGIView::draw();
}
void QGIViewSymbol::drawSvg()