Fix Symbol based View positioning
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -107,9 +107,7 @@ void QGIViewSymbol::draw()
|
||||
}
|
||||
|
||||
drawSvg();
|
||||
if (borderVisible) {
|
||||
drawBorder();
|
||||
}
|
||||
QGIView::draw();
|
||||
}
|
||||
|
||||
void QGIViewSymbol::drawSvg()
|
||||
|
||||
Reference in New Issue
Block a user