Commit ebb5eea8 authored by sumpfralle's avatar sumpfralle

fixed simulation position shifting: move to end failed to complete the toolpath visualization


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@997 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 4d6ecc31
...@@ -859,8 +859,13 @@ class ProjectGui: ...@@ -859,8 +859,13 @@ class ProjectGui:
lambda value: speed_factor_widget.set_value(math.log10(max(0.001, value)))) lambda value: speed_factor_widget.set_value(math.log10(max(0.001, value))))
simulation_progress = self.gui.get_object("SimulationProgressTimelineValue") simulation_progress = self.gui.get_object("SimulationProgressTimelineValue")
def update_simulation_progress(widget): def update_simulation_progress(widget):
complete = self.settings.get("simulation_complete_distance") if widget.get_value() == 100:
self.settings.set("simulation_current_distance", widget.get_value() / 100.0 * complete) # a negative value indicates, that the simulation is finished
self.settings.set("simulation_current_distance", -1)
else:
complete = self.settings.get("simulation_complete_distance")
partial = widget.get_value() / 100.0 * complete
self.settings.set("simulation_current_distance", partial)
simulation_progress.connect("value-changed", update_simulation_progress) simulation_progress.connect("value-changed", update_simulation_progress)
# update the speed factor label # update the speed factor label
speed_factor_widget.connect("value-changed", speed_factor_widget.connect("value-changed",
...@@ -3506,14 +3511,15 @@ class ProjectGui: ...@@ -3506,14 +3511,15 @@ class ProjectGui:
return True return True
def update_toolpath_simulation(self, widget=None, toolpath=None): def update_toolpath_simulation(self, widget=None, toolpath=None):
s = self.settings
# update the GUI # update the GUI
while gtk.events_pending(): while gtk.events_pending():
gtk.main_iteration() gtk.main_iteration()
if not self.settings.get("show_simulation"): if not s.get("show_simulation"):
# cancel # cancel
return False return False
safety_height = self.settings.get("gcode_safety_height") safety_height = s.get("gcode_safety_height")
if not self.settings.get("simulation_toolpath"): if not s.get("simulation_toolpath"):
# get the currently selected toolpath, if none is give # get the currently selected toolpath, if none is give
if toolpath is None: if toolpath is None:
toolpath_index = self._treeview_get_active_index(self.toolpath_table, self.toolpath) toolpath_index = self._treeview_get_active_index(self.toolpath_table, self.toolpath)
...@@ -3521,35 +3527,44 @@ class ProjectGui: ...@@ -3521,35 +3527,44 @@ class ProjectGui:
return return
else: else:
toolpath = self.toolpath[toolpath_index] toolpath = self.toolpath[toolpath_index]
self.settings.set("simulation_toolpath", toolpath) s.set("simulation_toolpath", toolpath)
# set the current cutter # set the current cutter
self.cutter = toolpath.toolpath_settings.get_tool() self.cutter = toolpath.toolpath_settings.get_tool()
# calculate steps # calculate steps
self.settings.set("simulation_machine_time", s.set("simulation_machine_time",
toolpath.get_machine_time(safety_height=safety_height)) toolpath.get_machine_time(safety_height=safety_height))
self.settings.set("simulation_complete_distance", s.set("simulation_complete_distance",
toolpath.get_machine_movement_distance( toolpath.get_machine_movement_distance(
safety_height=safety_height)) safety_height=safety_height))
self.settings.set("simulation_current_distance", 0) s.set("simulation_current_distance", 0)
else: else:
toolpath = self.settings.get("simulation_toolpath") toolpath = s.get("simulation_toolpath")
if (self.settings.get("simulation_current_distance") \ if (s.get("simulation_current_distance") \
< self.settings.get("simulation_complete_distance")): < s.get("simulation_complete_distance")):
time_step = 1.0 / self.settings.get("drill_progress_max_fps") if s.get("simulation_current_distance") < 0:
feedrate = toolpath.toolpath_settings.get_tool_settings()["feedrate"] # "-1" -> simulation is finished
distance_step = self.settings.get("simulation_speed_factor") * time_step * feedrate / 60 updated_distance = s.get("simulation_complete_distance")
self.settings.set("simulation_current_distance", else:
self.settings.get("simulation_current_distance") \ time_step = 1.0 / s.get("drill_progress_max_fps")
+ distance_step) feedrate = toolpath.toolpath_settings.get_tool_settings(
moves = toolpath.get_moves(safety_height=safety_height, )["feedrate"]
max_movement=self.settings.get("simulation_current_distance")) distance_step = s.get("simulation_speed_factor") * \
self.settings.set("simulation_toolpath_moves", moves) time_step * feedrate / 60
if moves: updated_distance = min(distance_step + \
self.cutter.moveto(moves[-1][0]) s.get("simulation_current_distance"),
self.update_view() s.get("simulation_complete_distance"))
progress_value_percent = 100.0 * self.settings.get("simulation_current_distance") \ if updated_distance != s.get("simulation_current_distance"):
/ self.settings.get("simulation_complete_distance") s.set("simulation_current_distance", updated_distance)
self.gui.get_object("SimulationProgressTimelineValue").set_value(progress_value_percent) moves = toolpath.get_moves(safety_height=safety_height,
max_movement=updated_distance)
s.set("simulation_toolpath_moves", moves)
if moves:
self.cutter.moveto(moves[-1][0])
self.update_view()
progress_value_percent = 100.0 * s.get("simulation_current_distance") \
/ s.get("simulation_complete_distance")
self.gui.get_object("SimulationProgressTimelineValue").set_value(
progress_value_percent)
return True return True
@progress_activity_guard @progress_activity_guard
......
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