Commit 5bf55e8a authored by sumpfralle's avatar sumpfralle

added the transparency (alpha) component to all configurable colors


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@682 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 801573d8
......@@ -3,6 +3,7 @@ Version 0.3.1 - UNRELEASED
* allow to reverse the direction of a 2D contour model
* added optional "orthogonal" view (instead of perspective)
* added a "recent files" item to the file menu
* added the transparency (alpha) component to all configurable colors
Version 0.3.0 - 2010-08-16
* added support for importing contour paths from SVG files (requires Inkscape and pstoedit)
......
......@@ -5500,6 +5500,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
......@@ -5527,6 +5528,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
......@@ -5541,6 +5543,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
......@@ -5596,6 +5599,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
......@@ -5625,6 +5629,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
......@@ -5654,6 +5659,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
......@@ -5684,6 +5690,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
......@@ -5713,6 +5720,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
......
......@@ -698,7 +698,7 @@ def draw_bounding_box(minx, miny, minz, maxx, maxy, maxz, color):
p8 = [maxx, miny, maxz]
# lower rectangle
GL.glBegin(GL.GL_LINES)
GL.glColor3f(*color)
GL.glColor4f(*color)
# all combinations of neighbouring corners
for corner_pair in [(p1, p2), (p1, p5), (p1, p4), (p2, p3),
(p2, p6), (p3, p4), (p3, p7), (p4, p8), (p5, p6),
......@@ -726,15 +726,15 @@ def draw_complete_model_view(settings):
if settings.get("show_simulation"):
obj = settings.get("simulation_object")
if not obj is None:
GL.glColor3f(*settings.get("color_material"))
GL.glColor4f(*settings.get("color_material"))
obj.to_OpenGL()
# draw the model
if settings.get("show_model"):
GL.glColor3f(*settings.get("color_model"))
GL.glColor4f(*settings.get("color_model"))
settings.get("model").to_OpenGL()
# draw the support grid
if settings.get("show_support_grid") and settings.get("support_grid"):
GL.glColor3f(*settings.get("color_support_grid"))
GL.glColor4f(*settings.get("color_support_grid"))
settings.get("support_grid").to_OpenGL()
# draw the toolpath
# don't do it, if a new toolpath is just being calculated
......@@ -750,7 +750,7 @@ def draw_complete_model_view(settings):
if settings.get("show_drill_progress"):
cutter = settings.get("cutter")
if not cutter is None:
GL.glColor3f(*settings.get("color_cutter"))
GL.glColor4f(*settings.get("color_cutter"))
cutter.to_OpenGL()
# also show the toolpath that is currently being calculated
toolpath_in_progress = settings.get("toolpath_in_progress")
......@@ -768,13 +768,13 @@ def draw_toolpath(toolpath, color_forward, color_backward):
last = None
for path in toolpath:
if last:
GL.glColor3f(*color_backward)
GL.glColor4f(*color_backward)
GL.glBegin(GL.GL_LINES)
GL.glVertex3f(last.x, last.y, last.z)
last = path.points[0]
GL.glVertex3f(last.x, last.y, last.z)
GL.glEnd()
GL.glColor3f(*color_forward)
GL.glColor4f(*color_forward)
GL.glBegin(GL.GL_LINE_STRIP)
for point in path.points:
GL.glVertex3f(point.x, point.y, point.z)
......
......@@ -82,14 +82,14 @@ PREFERENCES_DEFAULTS = {
"show_bounding_box": True,
"show_toolpath": True,
"show_drill_progress": False,
"color_background": (0.0, 0.0, 0.0),
"color_model": (0.5, 0.5, 1.0),
"color_support_grid": (0.8, 0.8, 0.3),
"color_bounding_box": (0.3, 0.3, 0.3),
"color_cutter": (1.0, 0.2, 0.2),
"color_toolpath_cut": (1.0, 0.5, 0.5),
"color_toolpath_return": (0.5, 1.0, 0.5),
"color_material": (1.0, 0.5, 0.0),
"color_background": (0.0, 0.0, 0.0, 1.0),
"color_model": (0.5, 0.5, 1.0, 1.0),
"color_support_grid": (0.8, 0.8, 0.3, 1.0),
"color_bounding_box": (0.3, 0.3, 0.3, 1.0),
"color_cutter": (1.0, 0.2, 0.2, 1.0),
"color_toolpath_cut": (1.0, 0.5, 0.5, 1.0),
"color_toolpath_return": (0.5, 1.0, 0.5, 1.0),
"color_material": (1.0, 0.5, 0.0, 1.0),
"view_light": True,
"view_shadow": True,
"view_polygon": True,
......@@ -495,12 +495,23 @@ class ProjectGui:
def get_color_wrapper(obj):
def gtk_color_to_float():
gtk_color = obj.get_color()
return (gtk_color.red / GTK_COLOR_MAX, gtk_color.green / GTK_COLOR_MAX, gtk_color.blue / GTK_COLOR_MAX)
alpha = obj.get_alpha()
return (gtk_color.red / GTK_COLOR_MAX,
gtk_color.green / GTK_COLOR_MAX,
gtk_color.blue / GTK_COLOR_MAX,
alpha / GTK_COLOR_MAX)
return gtk_color_to_float
def set_color_wrapper(obj):
def set_gtk_color_by_float((red, green, blue)):
def set_gtk_color_by_float(components):
# use alpha if it was given
if len(components) == 3:
alpha = 1.0
else:
alpha = components[3]
red, green, blue = components[:3]
obj.set_color(gtk.gdk.Color(int(red * GTK_COLOR_MAX),
int(green * GTK_COLOR_MAX), int(blue * GTK_COLOR_MAX)))
obj.set_alpha(int(alpha * GTK_COLOR_MAX))
return set_gtk_color_by_float
for name, objname in (("color_background", "ColorBackground"),
("color_model", "ColorModel"),
......
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