Commit 6797b868 authored by sumpfralle's avatar sumpfralle

various cleanups

allow color to be specified when adding a model


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1211 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 50e75a7c
......@@ -20,6 +20,7 @@
<child>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkComboBox" id="SupportGridTypesControl">
<property name="visible">True</property>
......
......@@ -105,13 +105,6 @@ def draw_complete_model_view(settings):
# we need to wait until the color change is active
GL.glFinish()
obj.to_OpenGL()
# draw the support grid
if False and settings.get("show_support_grid") and settings.get("current_support_model"):
color = settings.get("color_support_grid")
GL.glColor4f(color["red"], color["green"], color["blue"], color["alpha"])
# we need to wait until the color change is active
GL.glFinish()
settings.get("current_support_model").to_OpenGL()
# draw the toolpath simulation
if settings.get("show_simulation"):
moves = settings.get("simulation_toolpath_moves")
......
......@@ -176,7 +176,8 @@ class Models(pycam.Plugins.ListPluginBase):
def get_visible(self):
return [model for model in self if model["visible"]]
def add_model(self, model, name=None, name_template="Model #%d"):
def add_model(self, model, name=None, name_template="Model #%d",
color=None):
model_dict = ModelEntity(model)
if not name:
model_id = 1
......@@ -185,6 +186,7 @@ class Models(pycam.Plugins.ListPluginBase):
model_id += 1
name = name_template % model_id
model_dict["name"] = name
if not color:
color = self.core.get("color_model")
if not color:
color = self.FALLBACK_COLOR.copy()
......
......@@ -41,6 +41,7 @@ class OpenGLViewModel(pycam.Plugins.PluginBase):
("model-changed","visual-item-updated"),
("model-list-changed","visual-item-updated"))
self.core.get("register_display_item")("show_model", "Show Model", 10)
self.core.get("register_color") ("color_model", "Model", 10)
self.core.register_chain("get_draw_dimension", self.get_draw_dimension)
self.register_event_handlers(self._event_handlers)
self.core.emit_event("visual-item-updated")
......
......@@ -132,13 +132,9 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self.core.register_ui("preferences", "Colors", color_frame, 30)
self.core.set("register_color", self.register_color_setting)
self.core.set("unregister_color", self.unregister_color_setting)
# TODO: move the "tool" color to a separate plugin
# TODO: move "material" to simulation viewer
# TODO: move "support grid" to support grid visualization
# TODO: move "cutter" and "material" to simulation viewer
for name, label, weight in (
("color_background", "Background", 10),
("color_model", "Model", 20),
("color_support_grid", "Support grid", 30),
("color_cutter", "Tool", 50),
("color_material", "Material", 80)):
self.core.get("register_color")(name, label, weight)
......@@ -152,9 +148,8 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self.core.set("unregister_display_item",
self.unregister_display_item)
# visual and general settings
# TODO: move support grid and drill to a separate plugin
# TODO: move drill and directions to a separate plugin
for name, label, weight in (
("show_support_grid", "Show Support Grid", 20),
("show_drill", "Show Tool", 70),
("show_directions", "Show Directions", 80)):
self.core.get("register_display_item")(name, label, weight)
......@@ -237,10 +232,9 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self.core.unregister_ui("view_menu", toggle_3d)
self.unregister_gtk_accelerator("opengl", toggle_3d)
self.core.unregister_ui("view_menu", toggle_3d)
for name in ("color_background", "color_model",
"color_support_grid", "color_cutter", "color_material"):
for name in ("color_background", "color_cutter", "color_material"):
self.core.get("unregister_color")(name)
for name in ("show_support_grid", "show_drill", "show_directions"):
for name in ("show_drill", "show_directions"):
self.core.get("unregister_display_item")(name)
self.window.remove_accel_group(self.core.get("gtk-accel-group"))
self.unregister_gtk_handlers(self._gtk_handlers)
......@@ -530,9 +524,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
#GL.glEnable(GL.GL_MULTISAMPLE_ARB)
GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
GL.glPolygonOffset(1.0, 1.0)
col = self.core.get("color_model")
col = (col["red"], col["green"], col["blue"], col["alpha"])
GL.glMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, col)
# ambient and diffuse material lighting is defined in OpenGLViewModel
GL.glMaterial(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR,
(1.0, 1.0, 1.0, 1.0))
GL.glMaterial(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, (100.0))
......
......@@ -151,7 +151,7 @@ def get_support_grid(minx, maxx, miny, maxy, z_plane, dist_x, dist_y, thickness,
return grid_model
def get_support_distributed(model, z_plane, average_distance,
min_bridges_per_polygon, thickness, height, length, bounds,
min_bridges_per_polygon, thickness, height, length, bounds=None,
start_at_corners=False):
if (average_distance == 0) or (length == 0) or (thickness == 0) \
or (height == 0):
......@@ -163,7 +163,7 @@ def get_support_distributed(model, z_plane, average_distance,
if model:
model = model.get_flat_projection(Plane(Point(0, 0, z_plane),
Vector(0, 0, 1)))
if model:
if model and bounds:
model = model.get_cropped_model_by_bounds(bounds)
if model:
polygons = model.get_polygons()
......
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