Commit d3ceb14a authored by sumpfralle's avatar sumpfralle

added detailed progress bars to the contour model operations during "generate_toolpath"

the GUI now handles an interrupted "generate_toolpath" properly


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@517 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent d22a9a46
...@@ -2131,7 +2131,11 @@ class ProjectGui: ...@@ -2131,7 +2131,11 @@ class ProjectGui:
log.info("Toolpath generation time: %f" % (time.time() - start_time)) log.info("Toolpath generation time: %f" % (time.time() - start_time))
if isinstance(toolpath, basestring): if toolpath is None:
# user interruption
# return "False" if the action was cancelled
return not self._progress_cancel_requested
elif isinstance(toolpath, basestring):
# an error occoured - "toolpath" contains the error message # an error occoured - "toolpath" contains the error message
log.error("Failed to generate toolpath: %s" % toolpath) log.error("Failed to generate toolpath: %s" % toolpath)
# we were not successful (similar to a "cancel" request) # we were not successful (similar to a "cancel" request)
......
...@@ -25,6 +25,7 @@ import pycam.PathProcessors ...@@ -25,6 +25,7 @@ import pycam.PathProcessors
import pycam.Cutters import pycam.Cutters
import pycam.Toolpath.SupportGrid import pycam.Toolpath.SupportGrid
import pycam.Geometry.Model import pycam.Geometry.Model
from pycam.Utils import ProgressCounter
DIRECTIONS = frozenset(("x", "y", "xy")) DIRECTIONS = frozenset(("x", "y", "xy"))
...@@ -156,14 +157,34 @@ def generate_toolpath(model, tool_settings=None, ...@@ -156,14 +157,34 @@ def generate_toolpath(model, tool_settings=None,
if (not contour_model is None) and (engrave_offset > 0): if (not contour_model is None) and (engrave_offset > 0):
if not callback is None: if not callback is None:
callback(text="Preparing contour model with offset ...") callback(text="Preparing contour model with offset ...")
contour_model = contour_model.get_offset_model(engrave_offset) progress_callback = ProgressCounter(len(contour_model.get_lines()),
callback).increment
else:
progress_callback = None
contour_model = contour_model.get_offset_model(engrave_offset,
callback=progress_callback)
if not callback is None: if not callback is None:
callback(text="Checking contour model with offset for collisions " \ # reset percentage counter after the contour model calculation
+ "...") callback(percent=0)
if contour_model.check_for_collisions(): if callback(text="Checking contour model with offset for " \
return "The contour model contains colliding line groups." \ + "collisions ..."):
+ " This is not allowed in combination with an" \ # quit requested
+ " engraving offset." return None
progress_callback = ProgressCounter(
len(contour_model.get_line_groups()), callback).increment
else:
progress_callback = None
result = contour_model.check_for_collisions(callback=progress_callback)
if result is None:
return None
elif result:
return "The contour model contains colliding line groups. " \
+ "This is not allowed in combination with an " \
+ "engraving offset.\nA collision was detected at " \
+ "(%.2f, %.2f, %.2f)." % (result.x, result.y, result.z)
else:
# no collisions and no user interruption
pass
# Due to some weirdness the height of the drill must be bigger than the # Due to some weirdness the height of the drill must be bigger than the
# object's size. Otherwise some collisions are not detected. # object's size. Otherwise some collisions are not detected.
cutter_height = 4 * (maxy - miny) cutter_height = 4 * (maxy - miny)
......
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