Commit 1310c800 authored by sumpfralle's avatar sumpfralle

fixed toolpath simulation


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1233 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 3ddeba63
This diff is collapsed.
...@@ -102,23 +102,6 @@ def draw_direction_cone(p1, p2, position=0.5, precision=12, size=0.1): ...@@ -102,23 +102,6 @@ def draw_direction_cone(p1, p2, position=0.5, precision=12, size=0.1):
def draw_complete_model_view(settings): def draw_complete_model_view(settings):
GL.glMatrixMode(GL.GL_MODELVIEW) GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity() GL.glLoadIdentity()
# draw the material (for simulation mode)
if settings.get("show_simulation"):
obj = settings.get("simulation_object")
if not obj is None:
color = settings.get("color_material")
GL.glColor4f(color["red"], color["green"], color["blue"], color["alpha"])
# we need to wait until the color change is active
GL.glFinish()
obj.to_OpenGL()
# draw the toolpath simulation
if settings.get("show_simulation"):
moves = settings.get("simulation_toolpath_moves")
if not moves is None:
draw_toolpath(moves, settings.get("color_toolpath_cut"),
settings.get("color_toolpath_return"),
show_directions=settings.get("show_directions"),
lighting=settings.get("view_light"))
# draw the drill # draw the drill
if settings.get("show_drill"): if settings.get("show_drill"):
cutter = settings.get("cutter") cutter = settings.get("cutter")
......
...@@ -32,23 +32,25 @@ class OpenGLViewToolpath(pycam.Plugins.PluginBase): ...@@ -32,23 +32,25 @@ class OpenGLViewToolpath(pycam.Plugins.PluginBase):
def setup(self): def setup(self):
import OpenGL.GL import OpenGL.GL
self._GL = OpenGL.GL self._GL = OpenGL.GL
self.core.register_event("visualize-items", self.draw_toolpath) self.core.register_event("visualize-items", self.draw_toolpaths)
self.core.get("register_color")("color_toolpath_cut", "Toolpath cut", self.core.get("register_color")("color_toolpath_cut", "Toolpath cut",
60) 60)
self.core.get("register_color")("color_toolpath_return", self.core.get("register_color")("color_toolpath_return",
"Toolpath rapid", 70) "Toolpath rapid", 70)
self.core.register_chain("get_draw_dimension", self.get_draw_dimension) self.core.register_chain("get_draw_dimension", self.get_draw_dimension)
self.core.get("register_display_item")("show_toolpath", "Show Toolpath", 30), self.core.get("register_display_item")("show_toolpath", "Show Toolpath", 30),
self.core.set("draw_toolpath_moves_func", self._draw_toolpath_moves)
self.core.emit_event("visual-item-updated") self.core.emit_event("visual-item-updated")
return True return True
def teardown(self): def teardown(self):
self.core.unregister_chain("get_draw_dimension", self.core.unregister_chain("get_draw_dimension",
self.get_draw_dimension) self.get_draw_dimension)
self.core.unregister_event("visualize-items", self.draw_toolpath) self.core.unregister_event("visualize-items", self.draw_toolpaths)
self.core.get("unregister_color")("color_toolpath_cut") self.core.get("unregister_color")("color_toolpath_cut")
self.core.get("unregister_color")("color_toolpath_return") self.core.get("unregister_color")("color_toolpath_return")
self.core.get("unregister_display_item")("show_toolpath") self.core.get("unregister_display_item")("show_toolpath")
self.core.remove_item("draw_toolpath_moves_func")
self.core.emit_event("visual-item-updated") self.core.emit_event("visual-item-updated")
def get_draw_dimension(self, low, high): def get_draw_dimension(self, low, high):
...@@ -68,18 +70,20 @@ class OpenGLViewToolpath(pycam.Plugins.PluginBase): ...@@ -68,18 +70,20 @@ class OpenGLViewToolpath(pycam.Plugins.PluginBase):
def _is_visible(self): def _is_visible(self):
return self.core.get("show_toolpath") \ return self.core.get("show_toolpath") \
and not self.core.get("toolpath_in_progress") \ and not self.core.get("toolpath_in_progress") \
and not (self.core.get("show_simulation") \ and not self.core.get("show_simulation")
and self.core.get("simulation_toolpath_moves"))
def draw_toolpath(self): def draw_toolpaths(self):
if self._is_visible(): if self._is_visible():
for toolpath in self.core.get("toolpaths").get_visible():
moves = toolpath.get_moves(self.core.get("gcode_safety_height"))
self._draw_toolpath_moves(moves)
def _draw_toolpath_moves(self, moves):
GL = self._GL GL = self._GL
GL.glDisable(GL.GL_LIGHTING) GL.glDisable(GL.GL_LIGHTING)
show_directions = self.core.get("show_directions") show_directions = self.core.get("show_directions")
color_rapid = self.core.get("color_toolpath_return") color_rapid = self.core.get("color_toolpath_return")
color_cut = self.core.get("color_toolpath_cut") color_cut = self.core.get("color_toolpath_cut")
for toolpath in self.core.get("toolpaths").get_visible():
moves = toolpath.get_moves(self.core.get("gcode_safety_height"))
GL.glMatrixMode(GL.GL_MODELVIEW) GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity() GL.glLoadIdentity()
last_position = None last_position = None
......
This diff is collapsed.
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