Skip to content

Commit

Permalink
Merge pull request #1014 from chaosphere2112/update_background_color
Browse files Browse the repository at this point in the history
Update background color
  • Loading branch information
doutriaux1 committed Feb 10, 2015
2 parents a3d8c80 + 712fa4b commit 7b363f4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Packages/vcs/Lib/VTKPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ def clear(self):
ren.RemoveAllViewProps()
if not ren.GetLayer()==0:
self.renWin.RemoveRenderer(ren)
else:
#Update background color
r,g,b = [c / 255. for c in self.canvas.backgroundcolor]
ren.SetBackground(r,g,b)
ren = renderers.GetNextItem()
if hasValidRenderer and self.renWin.IsDrawable():
self.renWin.Render()
Expand Down
10 changes: 10 additions & 0 deletions testing/vcs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ add_test(vcs_test_taylor_2_quads
${cdat_SOURCE_DIR}/testing/vcs/test_star_triangle_markers.py
"${BASELINE_DIR}/test_star_triangle_markers.png"
)
add_test(vcs_test_canvas_background
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_canvas_background.py
"${BASELINE_DIR}/test_canvas_background.png"
)
add_test(vcs_test_canvas_background_update
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_canvas_background_update.py
"${BASELINE_DIR}/test_canvas_background_update.png"
)
add_test(vcs_test_boxfill_10x10_numpy
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_boxfill_10x10_numpy.py
Expand Down
20 changes: 20 additions & 0 deletions testing/vcs/test_vcs_canvas_background.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import vcs, cdms2, os, sys

pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage

x = vcs.init()

x.drawlogooff()
x.setbgoutputdimensions(500,500, units="pixels")

x.backgroundcolor = (255, 255, 255)
x.open()
fnm = "test_backgroundcolor_white.png"
x.png(fnm)

src=sys.argv[1]
ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)

sys.exit(ret)
22 changes: 22 additions & 0 deletions testing/vcs/test_vcs_canvas_background_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import vcs, cdms2, os, sys

pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage

x = vcs.init()

x.drawlogooff()
x.setbgoutputdimensions(500,500, units="pixels")

x.backgroundcolor = (255, 255, 255)
x.open()
x.backgroundcolor = (255, 255, 0)
x.update()
fnm = "test_backgroundcolor_yellow.png"
x.png(fnm)

src=sys.argv[1]
ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)

sys.exit(ret)

0 comments on commit 7b363f4

Please sign in to comment.