Commit 83e435f3 authored by sumpfralle's avatar sumpfralle

cleaned up the spiral code a bit


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1178 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent f481228e
......@@ -133,7 +133,8 @@ class PathParamPattern(pycam.Plugins.PluginBase):
def setup(self):
widget = pycam.Gui.ControlsGTK.InputChoice(
(("grid", "grid"), ("spiral", "spiral")),
(("grid", pycam.Toolpath.MotionGrid.get_fixed_grid),
("spiral", pycam.Toolpath.MotionGrid.get_spiral)),
change_handler=lambda widget=None: self.core.emit_event(
"process-changed"))
self.core.get("register_parameter")("process", "pathgenerator",
......
......@@ -41,7 +41,7 @@ class ProcessStrategySlicing(pycam.Plugins.PluginBase):
"material_allowance": 0,
"milling_style": pycam.Toolpath.MotionGrid.MILLING_STYLE_IGNORE,
"grid_direction": pycam.Toolpath.MotionGrid.GRID_DIRECTION_X,
"path_pattern": "grid",
"path_pattern": pycam.Toolpath.MotionGrid.get_fixed_grid,
}
self.core.get("register_parameter_set")("process", "slicing",
"Slice removal", self.run_process, parameters=parameters,
......@@ -60,9 +60,7 @@ class ProcessStrategySlicing(pycam.Plugins.PluginBase):
(1.0 - process["parameters"]["overlap"])
path_generator = pycam.PathGenerators.PushCutter.PushCutter(
pycam.PathProcessors.PathAccumulator.PathAccumulator())
grid_func = {"grid": pycam.Toolpath.MotionGrid.get_fixed_grid,
"spiral": pycam.Toolpath.MotionGrid.get_spiral}
motion_grid = grid_func[process["parameters"]["path_pattern"]](
motion_grid = process["parameters"]["path_pattern"](
(low, high), process["parameters"]["step_down"],
line_distance=line_distance,
grid_direction=process["parameters"]["grid_direction"],
......
......@@ -74,10 +74,8 @@ class Processes(pycam.Plugins.ListPluginBase):
"process", "pathgenerator")
self.core.register_ui("process_parameters", "Path parameters",
parameter_widget, weight=10)
selection = self._modelview.get_selection()
selection.connect("changed",
lambda widget, event: self.core.emit_event(event),
"process-selection-changed")
self._gtk_handlers.append((self._modelview.get_selection(),
"changed", "process-selection-changed"))
self._gtk_handlers.append((self.gui.get_object("NameCell"),
"edited", self._edit_process_name))
self._treemodel = self.gui.get_object("ProcessList")
......
......@@ -160,7 +160,8 @@ def get_fixed_grid_layer(minx, maxx, miny, maxy, z, line_distance,
def get_fixed_grid((low, high), layer_distance, line_distance=None,
step_width=None, grid_direction=GRID_DIRECTION_X,
milling_style=MILLING_STYLE_IGNORE, start_position=START_Z):
milling_style=MILLING_STYLE_IGNORE, start_position=START_Z,
reverse=False):
""" Calculate the grid positions for toolpath moves
"""
if isiterable(layer_distance):
......@@ -223,7 +224,7 @@ def get_spiral_layer_lines(minx, maxx, miny, maxy, z, line_distance_x,
return lines
def get_spiral_layer(minx, maxx, miny, maxy, z, line_distance, step_width,
grid_direction, start_position=START_Z):
grid_direction, start_position, reverse):
current_location = _get_position(minx, maxx, miny, maxy, z,
start_position)
if line_distance > 0:
......@@ -234,6 +235,8 @@ def get_spiral_layer(minx, maxx, miny, maxy, z, line_distance, step_width,
lines = get_spiral_layer_lines(minx, maxx, miny, maxy, z,
line_distance_x, line_distance_y, grid_direction,
start_position, current_location)
if reverse:
lines.reverse()
# turn the lines into steps
for start, end in lines:
points = []
......@@ -249,11 +252,15 @@ def get_spiral_layer(minx, maxx, miny, maxy, z, line_distance, step_width,
for step in steps:
next_point = line.p1.add(line.dir.mul(step))
points.append(next_point)
if reverse:
points.reverse()
yield points
def get_spiral((low, high), layer_distance, line_distance=None,
step_width=None, grid_direction=GRID_DIRECTION_X,
milling_style=MILLING_STYLE_IGNORE, start_position=START_Z):
step_width=None, grid_direction=None,
milling_style=MILLING_STYLE_IGNORE,
start_position=(START_X | START_Y | START_Z),
reverse=True):
""" Calculate the grid positions for toolpath moves
"""
if isiterable(layer_distance):
......@@ -264,19 +271,16 @@ def get_spiral((low, high), layer_distance, line_distance=None,
else:
layers = floatrange(low[2], high[2], inc=layer_distance,
reverse=bool(start_position & START_Z))
# only X _or_ Y are allowed
if grid_direction != GRID_DIRECTION_X:
grid_direction = GRID_DIRECTION_Y
if ((milling_style == MILLING_STYLE_CLIMB),
(grid_direction == GRID_DIRECTION_X),
(start_position & START_X > 0)).count(True) % 2 == 0:
if (milling_style == MILLING_STYLE_CLIMB) == \
(start_position & START_X > 0):
start_direction = GRID_DIRECTION_X
else:
start_direction = GRID_DIRECTION_Y
for z in layers:
yield get_spiral_layer(low[0], high[0], low[1], high[1], z,
line_distance, step_width=step_width,
grid_direction=start_direction, start_position=start_position)
grid_direction=start_direction, start_position=start_position,
reverse=reverse)
def get_lines_layer(lines, z, last_z=None, step_width=None,
milling_style=MILLING_STYLE_CONVENTIONAL):
......
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