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
......
...@@ -89,47 +89,6 @@ ...@@ -89,47 +89,6 @@
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkVSeparator" id="vseparator8">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="View3dToggleFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment20">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkToggleButton" id="Toggle3dView">
<property name="label" translatable="yes">Show</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="View3dToggleLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;3D View&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -1981,6 +1940,193 @@ ...@@ -1981,6 +1940,193 @@
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkHBox" id="hbox6">
<property name="visible">True</property>
<child>
<object class="GtkFrame" id="frame13">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment21">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox13">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkCheckButton" id="ShowModelCheckBox">
<property name="label" translatable="yes">Show Model</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="ShowToolPathCheckBox">
<property name="label" translatable="yes">Show Toolpath</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="ShowBoundingCheckBox">
<property name="label" translatable="yes">Show Bounding Box</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="ShowAxesCheckBox">
<property name="label" translatable="yes">Show Coordinate System</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="ShowDrillProgressCheckBox">
<property name="label" translatable="yes">Show Drill Progress</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel" id="DrillUpdateSkipLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Skip Drill Progress Frames:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="DrillProgressFrameSkipControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
<property name="adjustment">DrillProgressFrameSkip</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">5</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="VisualSettingsFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Display settings&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVSeparator" id="vseparator9">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="View3dToggleFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment20">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkToggleButton" id="Toggle3dView">
<property name="label" translatable="yes">Show</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="View3dToggleLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;3D View&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="VisualizationTabLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Visualization</property>
</object>
<packing>
<property name="position">4</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>
...@@ -2202,4 +2348,10 @@ ...@@ -2202,4 +2348,10 @@
<property name="page_increment">10</property> <property name="page_increment">10</property>
<property name="page_size">10</property> <property name="page_size">10</property>
</object> </object>
<object class="GtkAdjustment" id="DrillProgressFrameSkip">
<property name="upper">1000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
<property name="page_size">10</property>
</object>
</interface> </interface>
...@@ -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