Kaynağa Gözat

Use Decimal for depth calculation. Fixes #130.

Juan Pablo Caram 10 yıl önce
ebeveyn
işleme
ea27748697
2 değiştirilmiş dosya ile 19 ekleme ve 4 silme
  1. 7 0
      PlotCanvas.py
  2. 12 4
      camlib.py

+ 7 - 0
PlotCanvas.py

@@ -60,6 +60,13 @@ class CanvasCache(QtCore.QObject):
 
 
         log.debug("Canvas update requested: %s" % str(extents))
         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
         # Move the requested screen portion to the main thread
         # and inform about the update:
         # and inform about the update:
 
 

+ 12 - 4
camlib.py

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