Use Decimal for depth calculation. Fixes #130.

This commit is contained in:
Juan Pablo Caram 2015-12-29 16:34:13 -05:00
parent 705d038e1c
commit ea27748697
2 changed files with 19 additions and 4 deletions

View File

@ -60,6 +60,13 @@ class CanvasCache(QtCore.QObject):
log.debug("Canvas update requested: %s" % str(extents))
# Note: This information here might be out of date. Establish
# a protocol regarding when to change the canvas in the main
# thread and when to check these values here in the background,
# or pass this data in the signal (safer).
log.debug("Size: %s [px]" % str(self.plotcanvas.get_axes_pixelsize()))
log.debug("Density: %s [units/px]" % str(self.plotcanvas.get_density()))
# Move the requested screen portion to the main thread
# and inform about the update:

View File

@ -16,6 +16,7 @@ from matplotlib.figure import Figure
import re
import sys
import traceback
from decimal import Decimal
import collections
import numpy as np
@ -2865,17 +2866,24 @@ class CNCjob(Geometry):
#--------- Multi-pass ---------
else:
if isinstance(self.z_cut, Decimal):
z_cut = self.z_cut
else:
z_cut = Decimal(self.z_cut).quantize(Decimal('0.000000001'))
if depthpercut is None:
depthpercut = self.z_cut
depthpercut = z_cut
elif not isinstance(depthpercut, Decimal):
depthpercut = Decimal(depthpercut).quantize(Decimal('0.000000001'))
depth = 0
reverse = False
while depth > self.z_cut:
while depth > z_cut:
# Increase depth. Limit to z_cut.
depth -= depthpercut
if depth < self.z_cut:
depth = self.z_cut
if depth < z_cut:
depth = z_cut
# Cut at specific depth and do not lift the tool.
# Note: linear2gcode() will use G00 to move to the