Commit 488f60c9 authored by Lars Kruse's avatar Lars Kruse

adapt other plugins to the recent changes of the Toolpaths plugin

* TaskTypeMilling returns a tuple of (moves, parameters) - instead of a
  complete Toolpath instance
* ToolpathCrop uses the Crop filter instead of the object methods for cropping
* ToolpathGrid uses the Copy filter instead of just calling "list(..)"
* ToolpathCrop and ToolpathGrid use "add_new" instead of "append" for new
  Toolpaths
parent 02f33aa7
...@@ -81,6 +81,5 @@ class TaskTypeMilling(pycam.Plugins.PluginBase): ...@@ -81,6 +81,5 @@ class TaskTypeMilling(pycam.Plugins.PluginBase):
for item_name in ("tool", "process", "bounds"): for item_name in ("tool", "process", "bounds"):
self.core.call_chain("get_toolpath_information", self.core.call_chain("get_toolpath_information",
environment[item_name], data) environment[item_name], data)
tp = pycam.Toolpath.Toolpath(moves, parameters=data) return moves, data
return tp
...@@ -337,8 +337,7 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -337,8 +337,7 @@ class Tasks(pycam.Plugins.ListPluginBase):
# we were not successful (similar to a "cancel" request) # we were not successful (similar to a "cancel" request)
result = False result = False
else: else:
# TODO: create a real toolpath object self.core.get("toolpaths").add_new(toolpath)
self.core.get("toolpaths").append(toolpath)
# return "False" if the action was cancelled # return "False" if the action was cancelled
result = not progress.update() result = not progress.update()
if not use_multi_progress: if not use_multi_progress:
......
...@@ -24,6 +24,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -24,6 +24,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import pycam.Plugins import pycam.Plugins
from pycam.Geometry.PointUtils import * from pycam.Geometry.PointUtils import *
from pycam.Geometry.Plane import Plane from pycam.Geometry.Plane import Plane
import pycam.Toolpath.Filters as Filters
import pycam.Gui.ControlsGTK import pycam.Gui.ControlsGTK
...@@ -163,12 +164,15 @@ class ToolpathCrop(pycam.Plugins.PluginBase): ...@@ -163,12 +164,15 @@ class ToolpathCrop(pycam.Plugins.PluginBase):
keep_original = self.gui.get_object( keep_original = self.gui.get_object(
"ToolpathCropKeepOriginal").get_active() "ToolpathCropKeepOriginal").get_active()
for toolpath in self.core.get("toolpaths").get_selected(): for toolpath in self.core.get("toolpaths").get_selected():
new_tp = toolpath.get_cropped_copy(polygons) # Store the new toolpath first separately - otherwise we can't
if new_tp.path: # revert the changes in case of an empty result.
new_path = toolpath | Filters.Crop(polygons)
if new_path | Filters.MovesOnly():
if keep_original: if keep_original:
self.core.get("toolpaths").append(new_tp) self.core.get("toolpaths").add_new((new_path,
toolpath.get_params()))
else: else:
toolpath.path = new_tp.path toolpath.path = new_path
self.core.emit_event("toolpath-changed") self.core.emit_event("toolpath-changed")
else: else:
self.log.info("Toolpath cropping: the result is empty") self.log.info("Toolpath cropping: the result is empty")
......
...@@ -23,7 +23,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -23,7 +23,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import pycam.Plugins import pycam.Plugins
from pycam.Geometry.PointUtils import * from pycam.Geometry.PointUtils import *
import pycam.Toolpath.Filters import pycam.Toolpath.Filters as Filters
class ToolpathGrid(pycam.Plugins.PluginBase): class ToolpathGrid(pycam.Plugins.PluginBase):
...@@ -95,20 +95,21 @@ class ToolpathGrid(pycam.Plugins.PluginBase): ...@@ -95,20 +95,21 @@ class ToolpathGrid(pycam.Plugins.PluginBase):
y_space = self.gui.get_object("GridYDistance").get_value() y_space = self.gui.get_object("GridYDistance").get_value()
x_dim, y_dim = self._get_toolpaths_dim(toolpaths) x_dim, y_dim = self._get_toolpaths_dim(toolpaths)
for toolpath in toolpaths: for toolpath in toolpaths:
new_path = list(toolpath.path) # start with a copy of the original
new_path = toolpath | Filters.Copy()
for x in range(x_count): for x in range(x_count):
for y in range(y_count): for y in range(y_count):
shift_x = x * (x_space + x_dim) shift_matrix = (
shift_y = y * (y_space + y_dim) (1, 0, 0, x * (x_space + x_dim)),
shift_filter = pycam.Toolpath.Filters.TransformPosition(( (0, 1, 0, y * (y_space + y_dim)),
(1, 0, 0, shift_x), (0, 1, 0, shift_y), (0, 0, 1, 0))) (0, 0, 1, 0))
new_path.extend(toolpath.path | shift_filter) shifted = toolpath | Filters.TransformPosition(shift_matrix)
new_path.extend(shifted)
if not self.gui.get_object("KeepOriginal").get_active(): if not self.gui.get_object("KeepOriginal").get_active():
toolpath.path = new_path toolpath.path = new_path
self.core.emit_event("toolpath-changed") self.core.emit_event("toolpath-changed")
else: else:
new_toolpath = toolpath.copy() self.core.get("toolpaths").add_new((new_path,
new_toolpath.path = new_path toolpath.get_params()))
self.core.get("toolpaths").append(new_toolpath)
self.core.get("toolpaths").select(toolpaths) self.core.get("toolpaths").select(toolpaths)
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