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
import pycam.Cutters
import pycam.PathGenerators
import pycam.PathProcessors
import pycam.Gui.ode_objects as ode_objects
import pycam.Geometry.utils as utils
import pycam.Gui.OpenGLTools as ogl_tools
import threading
......@@ -324,16 +323,24 @@ class ProjectGui:
self.settings.add_item("tool_radius", obj.get_value, obj.set_value)
obj = self.gui.get_object("TorusRadiusControl")
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)
for name, objname in (("show_model", "ShowModelCheckBox"),
("show_axes", "ShowAxesCheckBox"),
("show_bounding_box", "ShowBoundingCheckBox"),
("show_toolpath", "ShowToolPathCheckBox"),
("show_drill_progress", "ShowDrillProgressCheckBox")):
("show_drill_progress", "ShowDrillProgressCheckBox"),
("enable_ode", "SettingEnableODE")):
obj = self.gui.get_object(objname)
self.settings.add_item(name, obj.get_active, obj.set_active)
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
self.settings.set("show_model", True)
self.settings.set("show_toolpath", True)
......@@ -415,7 +422,10 @@ class ProjectGui:
self.view3d.paint()
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
def toggle_3d_view(self, widget=None, value=None):
......@@ -749,7 +759,7 @@ class ProjectGui:
response = dialog.run()
filename = dialog.get_filename()
dialog.hide()
if response == gtk.RESPONSE_CANCEL:
if response != gtk.RESPONSE_OK:
dialog.destroy()
return None
if os.path.exists(filename):
......
import OpenGL.GL as GL
import OpenGL.GLUT as GLUT
import ode_objects
# "ode" is imported later, if required
#import ode_objects
MODEL_TRANSFORMATIONS = {
......@@ -185,6 +186,7 @@ def scale_model(model, scale):
model.transform(matrix)
def generate_physics(settings, cutter, physics=None):
import ode_objects
if physics is None:
physics = ode_objects.PhysicalWorld()
physics.reset()
......@@ -198,3 +200,10 @@ def generate_physics(settings, cutter, physics=None):
physics.set_drill(shape_info[0], shape_info[2])
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