Commit 88e0623e authored by sumpfralle's avatar sumpfralle

r674@erker: lars | 2010-02-16 13:39:38 +0100

 visualization is configurable via the GUI
 fixed draw_callback for PushCutter


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@132 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b5cbb9a3
...@@ -306,10 +306,27 @@ class ProjectGui: ...@@ -306,10 +306,27 @@ class ProjectGui:
# connect buttons with activities # connect buttons with activities
self.gui.get_object("GenerateToolPathButton").connect("clicked", self.generate_toolpath) self.gui.get_object("GenerateToolPathButton").connect("clicked", self.generate_toolpath)
self.gui.get_object("SaveToolPathButton").connect("clicked", self.save_toolpath) self.gui.get_object("SaveToolPathButton").connect("clicked", self.save_toolpath)
self.gui.get_object("Toggle3dView").connect("toggled", self.toggle_3d_view)
# add tool radius for experimental ODE collisions # add tool radius for experimental ODE collisions
obj = self.gui.get_object("ToolRadiusControl") obj = self.gui.get_object("ToolRadiusControl")
self.settings.add_item("tool_radius", obj.get_value, obj.set_value) self.settings.add_item("tool_radius", obj.get_value, obj.set_value)
# visual settings
self.gui.get_object("Toggle3dView").connect("toggled", self.toggle_3d_view)
for name, objname in (("show_model", "ShowModelCheckBox"),
("show_axes", "ShowAxesCheckBox"),
("show_bounding_box", "ShowBoundingCheckBox"),
("show_toolpath", "ShowToolPathCheckBox"),
("show_drill_progress", "ShowDrillProgressCheckBox")):
obj = self.gui.get_object(objname)
self.settings.add_item(name, obj.get_active, obj.set_active)
obj.connect("toggled", self.update_view)
# preconfigure some values
self.settings.set("show_model", True)
self.settings.set("show_toolpath", True)
self.settings.set("show_bounding_box", True)
self.settings.set("show_axes", True)
skip_obj = self.gui.get_object("DrillProgressFrameSkipControl")
self.settings.add_item("drill_progress_frame_skip", skip_obj.get_value, skip_obj.set_value)
self.settings.set("drill_progress_frame_skip", 20)
def gui_activity_guard(func): def gui_activity_guard(func):
def wrapper(self, *args, **kwargs): def wrapper(self, *args, **kwargs):
...@@ -475,13 +492,16 @@ class ProjectGui: ...@@ -475,13 +492,16 @@ class ProjectGui:
class UpdateView: class UpdateView:
def __init__(self, func, skip=10): def __init__(self, func, skip=10):
self.count = 0 self.count = 0
self.skip = skip self.freq = skip + 1
self.func = func self.func = func
def update(self): def update(self):
if self.count % self.skip == 0: if self.count % self.freq == 0:
self.func() self.func()
self.count += 1 self.count += 1
updater = UpdateView(self.update_view, 2) if self.settings.get("show_drill_progress"):
draw_callback = UpdateView(self.update_view, self.settings.get("drill_progress_frame_skip")).update
else:
draw_callback = None
radius = float(self.gui.get_object("ToolRadiusControl").get_value()) radius = float(self.gui.get_object("ToolRadiusControl").get_value())
cuttername = None cuttername = None
for name in ("SphericalCutter", "CylindricalCutter", "ToroidalCutter"): for name in ("SphericalCutter", "CylindricalCutter", "ToroidalCutter"):
...@@ -536,9 +556,9 @@ class ProjectGui: ...@@ -536,9 +556,9 @@ class ProjectGui:
else: else:
dy = utils.INFINITE dy = utils.INFINITE
if direction == "x": if direction == "x":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dx, dy, 0, updater.update) self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dx, dy, 0, draw_callback)
elif direction == "y": elif direction == "y":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, dx, 1, updater.update) self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, dx, 1, draw_callback)
elif pathgenerator == "PushCutter": elif pathgenerator == "PushCutter":
if pathprocessor == "PathAccumulator": if pathprocessor == "PathAccumulator":
...@@ -567,11 +587,11 @@ class ProjectGui: ...@@ -567,11 +587,11 @@ class ProjectGui:
else: else:
dz = utils.INFINITE dz = utils.INFINITE
if direction == "x": if direction == "x":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, 0, dy, dz, updater.update) self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, 0, dy, dz, draw_callback)
elif direction == "y": elif direction == "y":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, 0, dz, updater.update) self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, 0, dz, draw_callback)
elif direction == "xy": elif direction == "xy":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, dy, dz, updater.update) self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, dy, dz, draw_callback)
print "Time elapsed: %f" % (time.time() - start_time) print "Time elapsed: %f" % (time.time() - start_time)
self.update_view() self.update_view()
......
...@@ -124,17 +124,22 @@ def draw_complete_model_view(settings): ...@@ -124,17 +124,22 @@ def draw_complete_model_view(settings):
GL.glMatrixMode(GL.GL_MODELVIEW) GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity() GL.glLoadIdentity()
# axes # axes
if settings.get("show_axes"):
draw_axes(settings) draw_axes(settings)
# stock model # stock model
if settings.get("show_bounding_box"):
draw_bounding_box(float(settings.get("minx")), float(settings.get("miny")), draw_bounding_box(float(settings.get("minx")), float(settings.get("miny")),
float(settings.get("minz")), float(settings.get("maxx")), float(settings.get("minz")), float(settings.get("maxx")),
float(settings.get("maxy")), float(settings.get("maxz"))) float(settings.get("maxy")), float(settings.get("maxz")))
# draw the model # draw the model
if settings.get("show_model"):
GL.glColor3f(*COLORS["model"]) GL.glColor3f(*COLORS["model"])
settings.get("model").to_OpenGL() settings.get("model").to_OpenGL()
# draw the toolpath # draw the toolpath
if settings.get("show_toolpath"):
draw_toolpath(settings.get("toolpath")) draw_toolpath(settings.get("toolpath"))
# draw the drill # draw the drill
if settings.get("show_drill_progress"):
draw_cutter(settings.get("cutter")) draw_cutter(settings.get("cutter"))
@keep_gl_mode @keep_gl_mode
......
This diff is collapsed.
...@@ -47,11 +47,11 @@ class PushCutter: ...@@ -47,11 +47,11 @@ class PushCutter:
while z >= minz: while z >= minz:
if dy > 0: if dy > 0:
self.pa.new_direction(0) self.pa.new_direction(0)
self.GenerateToolPathSlice(minx, maxx, miny, maxy, z, 0, dy) self.GenerateToolPathSlice(minx, maxx, miny, maxy, z, 0, dy, draw_callback)
self.pa.end_direction() self.pa.end_direction()
if dx > 0: if dx > 0:
self.pa.new_direction(1) self.pa.new_direction(1)
self.GenerateToolPathSlice(minx, maxx, miny, maxy, z, dx, 0) self.GenerateToolPathSlice(minx, maxx, miny, maxy, z, dx, 0, draw_callback)
self.pa.end_direction() self.pa.end_direction()
self.pa.finish() self.pa.finish()
...@@ -81,7 +81,7 @@ class PushCutter: ...@@ -81,7 +81,7 @@ class PushCutter:
tmax = t tmax = t
return (zmax, tmax) return (zmax, tmax)
def GenerateToolPathSlice(self, minx, maxx, miny, maxy, z, dx, dy): def GenerateToolPathSlice(self, minx, maxx, miny, maxy, z, dx, dy, draw_callback=None):
global DEBUG_PUSHCUTTER, DEBUG_PUSHCUTTER2, DEBUG_PUSHCUTTER3 global DEBUG_PUSHCUTTER, DEBUG_PUSHCUTTER2, DEBUG_PUSHCUTTER3
c = self.cutter c = self.cutter
model = self.model model = self.model
......
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