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