From a6482e9aa62f631ddd9756e140236367ab50b858 Mon Sep 17 00:00:00 2001 From: daid Date: Wed, 16 May 2012 13:48:15 +0200 Subject: [PATCH] re-use old slice in project planner, if we are slicing the same object again with the same settings but on a different position. This improves slicing time a lot when making a lot of the same objects. --- Cura/gui/projectPlanner.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index ae7b1dc..d579ee4 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -1,7 +1,7 @@ from __future__ import absolute_import import __init__ -import wx, os, platform, types, webbrowser, math, subprocess, threading, time +import wx, os, platform, types, webbrowser, math, subprocess, threading, time, re import ConfigParser from wx import glcanvas @@ -920,9 +920,16 @@ class ProjectSliceProgressWindow(wx.Frame): resultFile.write(data) data = f.read(4096) f.close() + savedCenterX = action.centerX + savedCenterY = action.centerY else: f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r") for line in f: + if line[0] != ';': + if 'X' in line: + line = self._adjustNumberInLine(line, 'X', action.centerX - savedCenterX) + if 'Y' in line: + line = self._adjustNumberInLine(line, 'Y', action.centerY - savedCenterY) resultFile.write(line) f.close() @@ -952,6 +959,10 @@ class ProjectSliceProgressWindow(wx.Frame): wx.CallAfter(self.statusText.SetLabel, status) wx.CallAfter(self.OnSliceDone) + def _adjustNumberInLine(self, line, tag, f): + m = re.search('^(.*'+tag+')([0-9\.]*)(.*)$', line) + return m.group(1) + str(float(m.group(2)) + f) + m.group(3) + '\n' + def OnSliceDone(self): self.abortButton.Destroy() self.closeButton = wx.Button(self, -1, "Close")