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