Skip to content
Snippets Groups Projects
Commit a39e8e5f authored by Sergey Sharybin's avatar Sergey Sharybin
Browse files

Fix #26555: SVG Import (stars wrong scale)

Transformation for non-container objects was applied twice when they were USEd.
Get rid of confusing checks for special cases in USE.createGeom and use special
flag (instancing) which tells geometry is it "normal" geometry creation or
geometry creation initiated by USE node (SYMBOL would be handled differently
int this two cases)

Quick tests showed none regressions.
parent 59bd26a2
No related branches found
No related tags found
No related merge requests found
...@@ -1022,7 +1022,7 @@ class SVGGeometry: ...@@ -1022,7 +1022,7 @@ class SVGGeometry:
pass pass
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Internal handler to create real geometries Internal handler to create real geometries
""" """
...@@ -1041,7 +1041,7 @@ class SVGGeometry: ...@@ -1041,7 +1041,7 @@ class SVGGeometry:
return None return None
def createGeom(self): def createGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1055,7 +1055,7 @@ class SVGGeometry: ...@@ -1055,7 +1055,7 @@ class SVGGeometry:
if matrix is not None: if matrix is not None:
self._pushMatrix(matrix) self._pushMatrix(matrix)
self._doCreateGeom() self._doCreateGeom(instancing)
if matrix is not None: if matrix is not None:
self._popMatrix() self._popMatrix()
...@@ -1092,13 +1092,13 @@ class SVGGeometryContainer(SVGGeometry): ...@@ -1092,13 +1092,13 @@ class SVGGeometryContainer(SVGGeometry):
if ob is not None: if ob is not None:
self._geometries.append(ob) self._geometries.append(ob)
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
for geom in self._geometries: for geom in self._geometries:
geom.createGeom() geom.createGeom(instancing)
def getGeometries(self): def getGeometries(self):
""" """
...@@ -1139,7 +1139,7 @@ class SVGGeometryPATH(SVGGeometry): ...@@ -1139,7 +1139,7 @@ class SVGGeometryPATH(SVGGeometry):
self._splines = pathParser.getSplines() self._splines = pathParser.getSplines()
self._styles = SVGParseStyles(self._node, self._context) self._styles = SVGParseStyles(self._node, self._context)
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1190,7 +1190,7 @@ class SVGGeometryDEFS(SVGGeometryContainer): ...@@ -1190,7 +1190,7 @@ class SVGGeometryDEFS(SVGGeometryContainer):
Container for referenced elements Container for referenced elements
""" """
def _doCreateGeom(self): def createGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1203,12 +1203,26 @@ class SVGGeometrySYMBOL(SVGGeometryContainer): ...@@ -1203,12 +1203,26 @@ class SVGGeometrySYMBOL(SVGGeometryContainer):
Referenced element Referenced element
""" """
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
pass self._pushMatrix(self.getNodeMatrix())
super()._doCreateGeom(False)
self._popMatrix()
def createGeom(self, instancing):
"""
Create real geometries
"""
if not instancing:
return
super().createGeom(instancing)
class SVGGeometryG(SVGGeometryContainer): class SVGGeometryG(SVGGeometryContainer):
...@@ -1224,7 +1238,7 @@ class SVGGeometryUSE(SVGGeometry): ...@@ -1224,7 +1238,7 @@ class SVGGeometryUSE(SVGGeometry):
User of referenced elements User of referenced elements
""" """
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1239,34 +1253,7 @@ class SVGGeometryUSE(SVGGeometry): ...@@ -1239,34 +1253,7 @@ class SVGGeometryUSE(SVGGeometry):
self._pushMatrix(self.getNodeMatrix()) self._pushMatrix(self.getNodeMatrix())
geomMatrix = None geom.createGeom(True)
nodeMatrix = None
if not isinstance(geom, SVGGeometryUSE):
geomMatrix = geom.getTransformMatrix()
if isinstance(geom, SVGGeometrySYMBOL):
nodeMatrix = geom.getNodeMatrix()
if nodeMatrix:
self._pushMatrix(nodeMatrix)
if geomMatrix:
self._pushMatrix(geomMatrix)
if isinstance(geom, SVGGeometryContainer):
geometries = geom.getGeometries()
else:
geometries = [geom]
for g in geometries:
g.createGeom()
if geomMatrix:
self._popMatrix()
if nodeMatrix:
self._popMatrix()
self._popMatrix() self._popMatrix()
...@@ -1345,7 +1332,7 @@ class SVGGeometryRECT(SVGGeometry): ...@@ -1345,7 +1332,7 @@ class SVGGeometryRECT(SVGGeometry):
bezt.handle_left_type = 'VECTOR' bezt.handle_left_type = 'VECTOR'
bezt.handle_right_type = 'VECTOR' bezt.handle_right_type = 'VECTOR'
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1467,7 +1454,7 @@ class SVGGeometryELLIPSE(SVGGeometry): ...@@ -1467,7 +1454,7 @@ class SVGGeometryELLIPSE(SVGGeometry):
self._rx = self._node.getAttribute('rx') or '0' self._rx = self._node.getAttribute('rx') or '0'
self._ry = self._node.getAttribute('ry') or '0' self._ry = self._node.getAttribute('ry') or '0'
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1585,7 +1572,7 @@ class SVGGeometryLINE(SVGGeometry): ...@@ -1585,7 +1572,7 @@ class SVGGeometryLINE(SVGGeometry):
self._x2 = self._node.getAttribute('x2') or '0' self._x2 = self._node.getAttribute('x2') or '0'
self._y2 = self._node.getAttribute('y2') or '0' self._y2 = self._node.getAttribute('y2') or '0'
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1666,7 +1653,7 @@ class SVGGeometryPOLY(SVGGeometry): ...@@ -1666,7 +1653,7 @@ class SVGGeometryPOLY(SVGGeometry):
self._points.append((float(prev), float(p))) self._points.append((float(prev), float(p)))
prev = None prev = None
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1728,7 +1715,7 @@ class SVGGeometrySVG(SVGGeometryContainer): ...@@ -1728,7 +1715,7 @@ class SVGGeometrySVG(SVGGeometryContainer):
Main geometry holder Main geometry holder
""" """
def _doCreateGeom(self): def _doCreateGeom(self, instancing):
""" """
Create real geometries Create real geometries
""" """
...@@ -1738,7 +1725,7 @@ class SVGGeometrySVG(SVGGeometryContainer): ...@@ -1738,7 +1725,7 @@ class SVGGeometrySVG(SVGGeometryContainer):
self._pushMatrix(self.getNodeMatrix()) self._pushMatrix(self.getNodeMatrix())
self._pushRect(rect) self._pushRect(rect)
super()._doCreateGeom() super()._doCreateGeom(False)
self._popRect() self._popRect()
self._popMatrix() self._popMatrix()
...@@ -1824,7 +1811,7 @@ def load_svg(filepath): ...@@ -1824,7 +1811,7 @@ def load_svg(filepath):
loader = SVGLoader(filepath) loader = SVGLoader(filepath)
loader.parse() loader.parse()
loader.createGeom() loader.createGeom(False)
def load(operator, context, filepath=""): def load(operator, context, filepath=""):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment