merged SVG export fixes for python 3
This commit is contained in:
commit
f6ed67fc33
@ -1,4 +1,5 @@
|
||||
from .Exporter import Exporter
|
||||
from pyqtgraph.python2_3 import asUnicode
|
||||
from pyqtgraph.parametertree import Parameter
|
||||
from pyqtgraph.Qt import QtGui, QtCore, QtSvg
|
||||
import pyqtgraph as pg
|
||||
@ -91,8 +92,8 @@ class SVGExporter(Exporter):
|
||||
md.setData('image/svg+xml', QtCore.QByteArray(xml.encode('UTF-8')))
|
||||
QtGui.QApplication.clipboard().setMimeData(md)
|
||||
else:
|
||||
with open(fileName, 'w') as fh:
|
||||
fh.write(xml.encode('UTF-8'))
|
||||
with open(fileName, 'wb') as fh:
|
||||
fh.write(asUnicode(xml).encode('utf-8'))
|
||||
|
||||
|
||||
xmlHeader = """\
|
||||
@ -222,7 +223,7 @@ def _generateItemSvg(item, nodes=None, root=None):
|
||||
#if hasattr(item, 'setExportMode'):
|
||||
#item.setExportMode(False)
|
||||
|
||||
xmlStr = str(arr)
|
||||
xmlStr = bytes(arr).decode('utf-8')
|
||||
doc = xml.parseString(xmlStr)
|
||||
|
||||
try:
|
||||
@ -340,7 +341,7 @@ def correctCoordinates(node, item):
|
||||
if match is None:
|
||||
vals = [1,0,0,1,0,0]
|
||||
else:
|
||||
vals = map(float, match.groups()[0].split(','))
|
||||
vals = [float(a) for a in match.groups()[0].split(',')]
|
||||
tr = np.array([[vals[0], vals[2], vals[4]], [vals[1], vals[3], vals[5]]])
|
||||
|
||||
removeTransform = False
|
||||
@ -349,9 +350,9 @@ def correctCoordinates(node, item):
|
||||
continue
|
||||
if ch.tagName == 'polyline':
|
||||
removeTransform = True
|
||||
coords = np.array([map(float, c.split(',')) for c in ch.getAttribute('points').strip().split(' ')])
|
||||
coords = np.array([[float(a) for a in c.split(',')] for c in ch.getAttribute('points').strip().split(' ')])
|
||||
coords = pg.transformCoordinates(tr, coords, transpose=True)
|
||||
ch.setAttribute('points', ' '.join([','.join(map(str, c)) for c in coords]))
|
||||
ch.setAttribute('points', ' '.join([','.join([str(a) for a in c]) for c in coords]))
|
||||
elif ch.tagName == 'path':
|
||||
removeTransform = True
|
||||
newCoords = ''
|
||||
|
Loading…
Reference in New Issue
Block a user