Commit 81c0d469 authored by sumpfralle's avatar sumpfralle

visualize the rapid movements to safety height in the toolpath view

reduce the number of cone layers to one (sufficient and resource-friendly)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@820 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 587afcb6
...@@ -157,7 +157,7 @@ class Line(TransformableContainer): ...@@ -157,7 +157,7 @@ class Line(TransformableContainer):
# center the cone # center the cone
GL.glTranslatef(0, 0, -cone_length / 2) GL.glTranslatef(0, 0, -cone_length / 2)
# draw the cone # draw the cone
GLUT.glutSolidCone(cone_radius, cone_length, 12, 2) GLUT.glutSolidCone(cone_radius, cone_length, 12, 1)
GL.glPopMatrix() GL.glPopMatrix()
def get_intersection(self, line, infinite_lines=False): def get_intersection(self, line, infinite_lines=False):
......
...@@ -774,7 +774,8 @@ def draw_complete_model_view(settings): ...@@ -774,7 +774,8 @@ def draw_complete_model_view(settings):
draw_toolpath(toolpath_obj.get_path(), draw_toolpath(toolpath_obj.get_path(),
settings.get("color_toolpath_cut"), settings.get("color_toolpath_cut"),
settings.get("color_toolpath_return"), settings.get("color_toolpath_return"),
settings.get("show_directions")) safety_height=settings.get("gcode_safety_height"),
show_directions=settings.get("show_directions"))
# draw the drill # draw the drill
if settings.get("show_drill_progress"): if settings.get("show_drill_progress"):
cutter = settings.get("cutter") cutter = settings.get("cutter")
...@@ -787,24 +788,48 @@ def draw_complete_model_view(settings): ...@@ -787,24 +788,48 @@ def draw_complete_model_view(settings):
draw_toolpath(toolpath_in_progress, draw_toolpath(toolpath_in_progress,
settings.get("color_toolpath_cut"), settings.get("color_toolpath_cut"),
settings.get("color_toolpath_return"), settings.get("color_toolpath_return"),
settings.get("show_directions")) safety_height=settings.get("gcode_safety_height"),
show_directions=settings.get("show_directions"))
@keep_gl_mode @keep_gl_mode
@keep_matrix @keep_matrix
def draw_toolpath(toolpath, color_forward, color_backward, def draw_toolpath(toolpath, color_forward, color_backward,
show_directions=False): safety_height=None, show_directions=False):
draw_line = lambda p1, p2: Line(p1, p2).to_OpenGL(
show_directions=show_directions)
GL.glMatrixMode(GL.GL_MODELVIEW) GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity() GL.glLoadIdentity()
p_last = None
if toolpath: if toolpath:
last = None
for path in toolpath: for path in toolpath:
if last: if not path:
# ignore empty paths
continue
if (p_last is None) and (not safety_height is None):
current = path.points[0]
p_last = Point(current.x, current.y, safety_height)
if p_last:
p_next = path.points[0]
GL.glColor4f(*color_backward) GL.glColor4f(*color_backward)
Line(last, path.points[0]).to_OpenGL( # Draw the connection between the last and the next path.
show_directions=show_directions) # Respect the safety height.
if (not safety_height is None) and \
((p_last.x != p_next.x) or (p_last.y != p_next.y)):
# first move up
safety_last = Point(p_last.x, p_last.y, safety_height)
safety_next = Point(p_next.x, p_next.y, safety_height)
connect_points = (p_last, safety_last, safety_next, p_next)
else:
# ignore safety height
connect_points = (p_last, p_next)
for i in range(len(connect_points) - 1):
draw_line(connect_points[i], connect_points[i + 1])
GL.glColor4f(*color_forward) GL.glColor4f(*color_forward)
for index in range(len(path.points) - 1): for index in range(len(path.points) - 1):
Line(path.points[index], path.points[index + 1]).to_OpenGL( draw_line(path.points[index], path.points[index + 1])
show_directions=show_directions) p_last = path.points[-1]
last = path.points[-1] if (not p_last is None) and (not safety_height is None):
GL.glColor4f(*color_backward)
p_last_safety = Point(p_last.x, p_last.y, safety_height)
draw_line(p_last, p_last_safety)
...@@ -694,6 +694,8 @@ class ProjectGui: ...@@ -694,6 +694,8 @@ class ProjectGui:
gcode_safety_height = self.gui.get_object("SafetyHeightControl") gcode_safety_height = self.gui.get_object("SafetyHeightControl")
self.settings.add_item("gcode_safety_height", self.settings.add_item("gcode_safety_height",
gcode_safety_height.get_value, gcode_safety_height.set_value) gcode_safety_height.get_value, gcode_safety_height.set_value)
# redraw the toolpath if safety height changed
gcode_safety_height.connect("value-changed", self.update_view)
gcode_path_mode = self.gui.get_object("GCodeCornerStyleControl") gcode_path_mode = self.gui.get_object("GCodeCornerStyleControl")
self.settings.add_item("gcode_path_mode", gcode_path_mode.get_active, self.settings.add_item("gcode_path_mode", gcode_path_mode.get_active,
gcode_path_mode.set_active) gcode_path_mode.set_active)
......
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