Commit 23acdb50 authored by sumpfralle's avatar sumpfralle

improved order of GTK definitions

fixed Exception if no model is loaded


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@812 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 86566d09
...@@ -303,8 +303,7 @@ class ModelViewWindowGL: ...@@ -303,8 +303,7 @@ class ModelViewWindowGL:
self.area.set_events(gtk.gdk.MOUSE | gtk.gdk.BUTTON_PRESS_MASK) self.area.set_events(gtk.gdk.MOUSE | gtk.gdk.BUTTON_PRESS_MASK)
self.area.connect("button-press-event", self.mouse_handler) self.area.connect("button-press-event", self.mouse_handler)
self.area.connect('motion-notify-event', self.mouse_handler) self.area.connect('motion-notify-event', self.mouse_handler)
self.area.show() self.container.pack_end(self.area)
self.container.add(self.area)
self.camera = Camera(self.settings, lambda: (self.area.allocation.width, self.camera = Camera(self.settings, lambda: (self.area.allocation.width,
self.area.allocation.height)) self.area.allocation.height))
# Color the dimension value according to the axes. # Color the dimension value according to the axes.
...@@ -322,6 +321,7 @@ class ModelViewWindowGL: ...@@ -322,6 +321,7 @@ class ModelViewWindowGL:
for name in names: for name in names:
self.gui.get_object(name).set_attributes(attributes) self.gui.get_object(name).set_attributes(attributes)
# show the window # show the window
self.area.show()
self.container.show() self.container.show()
self.show() self.show()
...@@ -741,7 +741,24 @@ def draw_complete_model_view(settings): ...@@ -741,7 +741,24 @@ def draw_complete_model_view(settings):
# draw the model # draw the model
if settings.get("show_model"): if settings.get("show_model"):
GL.glColor4f(*settings.get("color_model")) GL.glColor4f(*settings.get("color_model"))
settings.get("model").to_OpenGL() model = settings.get("model")
min_area = abs(model.maxx - model.minx) * abs(model.maxy - model.miny) / 100
"""
# example for coloring specific triangles
groups = model.get_flat_areas(min_area)
all_flat_ids = []
for group in groups:
all_flat_ids.extend([t.id for t in group])
flat_color = (1.0, 0.0, 0.0, 1.0)
normal_color = settings.get("color_model")
def check_triangle_draw(triangle):
if triangle.id in all_flat_ids:
return True, flat_color
else:
return True, normal_color
model.to_OpenGL(visible_filter=check_triangle_draw)
"""
model.to_OpenGL()
# draw the support grid # draw the support grid
if settings.get("show_support_grid") and settings.get("support_grid"): if settings.get("show_support_grid") and settings.get("support_grid"):
GL.glColor4f(*settings.get("color_support_grid")) GL.glColor4f(*settings.get("color_support_grid"))
......
...@@ -329,7 +329,8 @@ class ProjectGui: ...@@ -329,7 +329,8 @@ class ProjectGui:
# bounds setting. # bounds setting.
def get_absolute_limit(key): def get_absolute_limit(key):
if self.model is None: if self.model is None:
return None # avoid problems if no model is loaded
return 0
bounds = self.settings.get("current_bounds") bounds = self.settings.get("current_bounds")
if bounds is None: if bounds is None:
return getattr(self.model, key) return getattr(self.model, key)
......
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