Commit 11b1e7f5 authored by Lars Kruse's avatar Lars Kruse

switched tool parameters handling to new Filter style

* this currently fails to expose the tool radius to the path processor
parent bec2127a
......@@ -59,9 +59,10 @@ class TaskTypeMilling(pycam.Plugins.PluginBase):
return
funcs = {}
for key, set_name in (("tool", "shape"), ("process", "strategy")):
funcs[key] = self.core.get("get_parameter_sets")(
key)[environment[key][set_name]]["func"]
tool = funcs["tool"](tool=environment["tool"], environment=environment)
funcs[key] = self.core.get("get_parameter_sets")(key)\
[environment[key][set_name]]["func"]
tool, tool_filters = funcs["tool"](environment["tool"]["parameters"])
self.log.info("Filters: %s" % str(tool_filters))
path_generator, motion_grid, (low, high) = funcs["process"](
environment["process"], environment=environment)
if path_generator is None:
......@@ -78,7 +79,7 @@ class TaskTypeMilling(pycam.Plugins.PluginBase):
self.log.info("No valid moves found")
return None
data = {}
for item_name in ("tool", "process", "bounds"):
for item_name in ("process", "bounds"):
self.core.call_chain("get_toolpath_information",
environment[item_name], data)
return moves, data
......
......@@ -23,6 +23,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import pycam.Plugins
import pycam.Gui.ControlsGTK
from pycam.Toolpath.Filters import toolpath_filter
class ToolParamRadius(pycam.Plugins.PluginBase):
......@@ -39,20 +40,19 @@ class ToolParamRadius(pycam.Plugins.PluginBase):
self.core.get("register_parameter")("tool", "radius", self.control)
self.core.register_ui("tool_size", "Tool Diameter",
self.control.get_widget(), weight=10)
self.core.register_chain("get_toolpath_information",
self.get_toolpath_information)
self.core.register_chain("toolpath_filters",
self.get_toolpath_filters)
return True
def teardown(self):
self.core.get("unregister_parameter")("tool", "radius")
self.core.unregister_ui("tool_size", self.control.get_widget())
self.core.unregister_chain("get_toolpath_information",
self.get_toolpath_information)
self.core.unregister_chain("get_toolpath_filters",
self.get_toolpath_filters)
def get_toolpath_information(self, item, data):
if item in self.core.get("tools") and \
"radius" in item["parameters"]:
data["tool_radius"] = item["parameters"]["radius"]
@toolpath_filter("tool", "radius")
def get_toolpath_filters(self, radius):
return [pycam.Toolpath.Filters.TinySidewaysMovesFilter(2 * radius)]
class ToolParamTorusRadius(pycam.Plugins.PluginBase):
......@@ -87,20 +87,20 @@ class ToolParamFeedrate(pycam.Plugins.PluginBase):
self.core.get("register_parameter")("tool", "feedrate", self.control)
self.core.register_ui("tool_speed", "Feedrate",
self.control.get_widget(), weight=10)
self.core.register_chain("get_toolpath_information",
self.get_toolpath_information)
self.core.register_chain("get_toolpath_filters",
self.get_toolpath_filters)
return True
def teardown(self):
self.core.unregister_ui("tool_speed", self.control.get_widget())
self.core.get("unregister_parameter")("tool", "feedrate")
self.core.unregister_chain("get_toolpath_information",
self.get_toolpath_information)
self.core.unregister_chain("get_toolpath_filters",
self.get_toolpath_filters)
@toolpath_filter("tool", "feedrate")
def get_toolpath_filters(self, feedrate):
return [pycam.Toolpath.Filters.MachineSetting("feedrate", feedrate)]
def get_toolpath_information(self, item, data):
if item in self.core.get("tools") and \
"feedrate" in item["parameters"]:
data["tool_feedrate"] = item["parameters"]["feedrate"]
class ToolParamSpindleSpeed(pycam.Plugins.PluginBase):
......@@ -115,18 +115,18 @@ class ToolParamSpindleSpeed(pycam.Plugins.PluginBase):
self.control)
self.core.register_ui("tool_speed", "Spindle Speed",
self.control.get_widget(), weight=50)
self.core.register_chain("get_toolpath_information",
self.get_toolpath_information)
self.core.register_chain("get_toolpath_filters",
self.get_toolpath_filters)
return True
def teardown(self):
self.core.unregister_ui("tool_speed", self.control.get_widget())
self.core.get("unregister_parameter")("tool", "spindle_speed")
self.core.unregister_chain("get_toolpath_information",
self.get_toolpath_information)
self.core.unregister_chain("get_toolpath_filters",
self.get_toolpath_filters)
def get_toolpath_information(self, item, data):
if item in self.core.get("tools") and \
"spindle_speed" in item["parameters"]:
data["spindle_speed"] = item["parameters"]["spindle_speed"]
@toolpath_filter("tool", "spindle_speed")
def get_toolpath_filters(self, spindle_speed):
return [pycam.Toolpath.Filters.MachineSetting("spindle_speed",
spindle_speed)]
......@@ -27,6 +27,20 @@ import pycam.Cutters.ToroidalCutter
import pycam.Cutters.CylindricalCutter
def tool_params_and_filters(*param_names):
def get_params_and_filters_inner(func):
def get_tool_func(self, parameters):
filters = []
self.core.call_chain("get_toolpath_filters", "tool", parameters, filters)
args = []
for param_name in param_names:
args.append(parameters[param_name])
cutter = func(*args)
return cutter, filters
return get_tool_func
return get_params_and_filters_inner
class ToolTypeBallNose(pycam.Plugins.PluginBase):
DEPENDS = ["Tools", "ToolParamRadius", "ToolParamFeedrate"]
......@@ -45,8 +59,9 @@ class ToolTypeBallNose(pycam.Plugins.PluginBase):
def teardown(self):
self.core.get("unregister_parameter_set")("tool", "ballnose")
def get_tool(self, tool, environment=None):
return pycam.Cutters.SphericalCutter(tool["parameters"]["radius"])
@tool_params_and_filters("radius")
def get_tool(self, radius):
return pycam.Cutters.SphericalCutter(radius)
class ToolTypeBullNose(pycam.Plugins.PluginBase):
......@@ -69,10 +84,9 @@ class ToolTypeBullNose(pycam.Plugins.PluginBase):
def teardown(self):
self.core.get("unregister_parameter_set")("tool", "bullnose")
def get_tool(self, tool, environment=None):
return pycam.Cutters.ToroidalCutter(
tool["parameters"]["radius"],
tool["parameters"]["torus_radius"])
@tool_params_and_filters("radius", "torus_radius")
def get_tool(self, radius, torus_radius):
return pycam.Cutters.ToroidalCutter(radius, torus_radius)
class ToolTypeFlat(pycam.Plugins.PluginBase):
......@@ -92,6 +106,7 @@ class ToolTypeFlat(pycam.Plugins.PluginBase):
def teardown(self):
self.core.get("unregister_parameter_set")("tool", "flat")
def get_tool(self, tool, environment=None):
return pycam.Cutters.CylindricalCutter(tool["parameters"]["radius"])
@tool_params_and_filters("radius", "torus_radius")
def get_tool(self, radius):
return pycam.Cutters.CylindricalCutter(radius)
......@@ -39,8 +39,11 @@ from itertools import groupby
log = pycam.Utils.log.get_logger()
MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID, MOVE_ARC, MOVE_SAFETY, TOOL_CHANGE, \
MACHINE_SETTING = range(6)
MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID, MOVE_ARC, MOVE_SAFETY, MACHINE_SETTING = \
range(5)
MOVES_LIST = (MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID, MOVE_ARC, MOVE_SAFETY)
CORNER_STYLE_EXACT_PATH, CORNER_STYLE_EXACT_STOP, CORNER_STYLE_OPTIMIZE_SPEED, \
CORNER_STYLE_OPTIMIZE_TOLERANCE = range(4)
def _check_colinearity(p1, p2, p3):
......
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