Commit f6b3636e authored by Gary Hodgson's avatar Gary Hodgson Committed by Guillaume Seguin

make copy of svg element before scaling, otherwise subsequent calls are scaled again.

parent 2c793281
...@@ -24,6 +24,7 @@ import shutil ...@@ -24,6 +24,7 @@ import shutil
from cairosvg.surface import PNGSurface from cairosvg.surface import PNGSurface
import cStringIO import cStringIO
import imghdr import imghdr
import copy
class DisplayFrame(wx.Frame): class DisplayFrame(wx.Frame):
def __init__(self, parent, title, res=(1024, 768), printer=None, scale=1.0, offset=(0,0)): def __init__(self, parent, title, res=(1024, 768), printer=None, scale=1.0, offset=(0,0)):
...@@ -91,16 +92,20 @@ class DisplayFrame(wx.Frame): ...@@ -91,16 +92,20 @@ class DisplayFrame(wx.Frame):
elif self.slicer == 'Slic3r': elif self.slicer == 'Slic3r':
if int(self.scale) != 1: if int(self.scale) != 1:
height = float(image.get('height').replace('m','')) layercopy = copy.deepcopy(image)
width = float(image.get('width').replace('m','')) height = float(layercopy.get('height').replace('m',''))
width = float(layercopy.get('width').replace('m',''))
image.set('height', str(height*self.scale) + 'mm') layercopy.set('height', str(height*self.scale) + 'mm')
image.set('width', str(width*self.scale) + 'mm') layercopy.set('width', str(width*self.scale) + 'mm')
image.set('viewBox', '0 0 ' + str(height*self.scale) + ' ' + str(width*self.scale)) layercopy.set('viewBox', '0 0 ' + str(height*self.scale) + ' ' + str(width*self.scale))
g = image.find("{http://www.w3.org/2000/svg}g") g = layercopy.find("{http://www.w3.org/2000/svg}g")
g.set('transform', 'scale('+str(self.scale)+')') g.set('transform', 'scale('+str(self.scale)+')')
stream = cStringIO.StringIO(PNGSurface.convert(dpi=self.dpi, bytestring=xml.etree.ElementTree.tostring(layercopy)))
image = wx.ImageFromStream(stream)
dc.DrawBitmap(wx.BitmapFromImage(image), self.offset[0], self.offset[1], True)
else:
stream = cStringIO.StringIO(PNGSurface.convert(dpi=self.dpi, bytestring=xml.etree.ElementTree.tostring(image))) stream = cStringIO.StringIO(PNGSurface.convert(dpi=self.dpi, bytestring=xml.etree.ElementTree.tostring(image)))
image = wx.ImageFromStream(stream) image = wx.ImageFromStream(stream)
dc.DrawBitmap(wx.BitmapFromImage(image), self.offset[0], self.offset[1], True) dc.DrawBitmap(wx.BitmapFromImage(image), self.offset[0], self.offset[1], True)
...@@ -568,7 +573,7 @@ class SettingsFrame(wx.Frame): ...@@ -568,7 +573,7 @@ class SettingsFrame(wx.Frame):
self.display_frame.slicer = self.layers[2] self.display_frame.slicer = self.layers[2]
self.display_frame.dpi = self.get_dpi() self.display_frame.dpi = self.get_dpi()
self.display_frame.draw_layer(self.layers[0][0]) self.display_frame.draw_layer(copy.deepcopy(self.layers[0][0]))
self.calibrate.SetValue(False) self.calibrate.SetValue(False)
self.bounding_box.SetValue(False) self.bounding_box.SetValue(False)
if self.show_first_layer_timer != -1.0 : if self.show_first_layer_timer != -1.0 :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment