Commit 6f20d950 authored by sumpfralle's avatar sumpfralle

r677@erker: lars | 2010-02-17 13:33:30 +0100

 ODE can be enabled via GUI and is detected automatically
 fixed closing of "save file" dialog via ESC


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@135 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent c213eda5
...@@ -11,7 +11,6 @@ import pycam.Gui.common as GuiCommon ...@@ -11,7 +11,6 @@ import pycam.Gui.common as GuiCommon
import pycam.Cutters import pycam.Cutters
import pycam.PathGenerators import pycam.PathGenerators
import pycam.PathProcessors import pycam.PathProcessors
import pycam.Gui.ode_objects as ode_objects
import pycam.Geometry.utils as utils import pycam.Geometry.utils as utils
import pycam.Gui.OpenGLTools as ogl_tools import pycam.Gui.OpenGLTools as ogl_tools
import threading import threading
...@@ -324,16 +323,24 @@ class ProjectGui: ...@@ -324,16 +323,24 @@ class ProjectGui:
self.settings.add_item("tool_radius", obj.get_value, obj.set_value) self.settings.add_item("tool_radius", obj.get_value, obj.set_value)
obj = self.gui.get_object("TorusRadiusControl") obj = self.gui.get_object("TorusRadiusControl")
self.settings.add_item("torus_radius", obj.get_value, obj.set_value) self.settings.add_item("torus_radius", obj.get_value, obj.set_value)
# visual settings # visual and general settings
self.gui.get_object("Toggle3dView").connect("toggled", self.toggle_3d_view) self.gui.get_object("Toggle3dView").connect("toggled", self.toggle_3d_view)
for name, objname in (("show_model", "ShowModelCheckBox"), for name, objname in (("show_model", "ShowModelCheckBox"),
("show_axes", "ShowAxesCheckBox"), ("show_axes", "ShowAxesCheckBox"),
("show_bounding_box", "ShowBoundingCheckBox"), ("show_bounding_box", "ShowBoundingCheckBox"),
("show_toolpath", "ShowToolPathCheckBox"), ("show_toolpath", "ShowToolPathCheckBox"),
("show_drill_progress", "ShowDrillProgressCheckBox")): ("show_drill_progress", "ShowDrillProgressCheckBox"),
("enable_ode", "SettingEnableODE")):
obj = self.gui.get_object(objname) obj = self.gui.get_object(objname)
self.settings.add_item(name, obj.get_active, obj.set_active) self.settings.add_item(name, obj.get_active, obj.set_active)
obj.connect("toggled", self.update_view) obj.connect("toggled", self.update_view)
# set the availability of ODE
if GuiCommon.is_ode_available():
self.settings.set("enable_ode", True)
self.gui.get_object("SettingEnableODE").set_sensitive(True)
else:
self.settings.set("enable_ode", False)
self.gui.get_object("SettingEnableODE").set_sensitive(False)
# preconfigure some values # preconfigure some values
self.settings.set("show_model", True) self.settings.set("show_model", True)
self.settings.set("show_toolpath", True) self.settings.set("show_toolpath", True)
...@@ -415,7 +422,10 @@ class ProjectGui: ...@@ -415,7 +422,10 @@ class ProjectGui:
self.view3d.paint() self.view3d.paint()
def update_physics(self): def update_physics(self):
self.physics = GuiCommon.generate_physics(self.settings, self.cutter, self.physics) if self.settings.get("enable_ode"):
self.physics = GuiCommon.generate_physics(self.settings, self.cutter, self.physics)
else:
self.physics = None
@gui_activity_guard @gui_activity_guard
def toggle_3d_view(self, widget=None, value=None): def toggle_3d_view(self, widget=None, value=None):
...@@ -749,7 +759,7 @@ class ProjectGui: ...@@ -749,7 +759,7 @@ class ProjectGui:
response = dialog.run() response = dialog.run()
filename = dialog.get_filename() filename = dialog.get_filename()
dialog.hide() dialog.hide()
if response == gtk.RESPONSE_CANCEL: if response != gtk.RESPONSE_OK:
dialog.destroy() dialog.destroy()
return None return None
if os.path.exists(filename): if os.path.exists(filename):
......
import OpenGL.GL as GL import OpenGL.GL as GL
import OpenGL.GLUT as GLUT import OpenGL.GLUT as GLUT
import ode_objects # "ode" is imported later, if required
#import ode_objects
MODEL_TRANSFORMATIONS = { MODEL_TRANSFORMATIONS = {
...@@ -185,6 +186,7 @@ def scale_model(model, scale): ...@@ -185,6 +186,7 @@ def scale_model(model, scale):
model.transform(matrix) model.transform(matrix)
def generate_physics(settings, cutter, physics=None): def generate_physics(settings, cutter, physics=None):
import ode_objects
if physics is None: if physics is None:
physics = ode_objects.PhysicalWorld() physics = ode_objects.PhysicalWorld()
physics.reset() physics.reset()
...@@ -198,3 +200,10 @@ def generate_physics(settings, cutter, physics=None): ...@@ -198,3 +200,10 @@ def generate_physics(settings, cutter, physics=None):
physics.set_drill(shape_info[0], shape_info[2]) physics.set_drill(shape_info[0], shape_info[2])
return physics return physics
def is_ode_available():
try:
import ode
return True
except ImportError:
return False
This diff is collapsed.
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