diff --git a/Packages/vcs/Lib/VTKPlots.py b/Packages/vcs/Lib/VTKPlots.py index 506ce2a86d..7d633381a7 100644 --- a/Packages/vcs/Lib/VTKPlots.py +++ b/Packages/vcs/Lib/VTKPlots.py @@ -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() diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index c2c6761291..6ddc75fe48 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -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 diff --git a/testing/vcs/test_vcs_canvas_background.py b/testing/vcs/test_vcs_canvas_background.py new file mode 100644 index 0000000000..2b2b98cfb6 --- /dev/null +++ b/testing/vcs/test_vcs_canvas_background.py @@ -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) diff --git a/testing/vcs/test_vcs_canvas_background_update.py b/testing/vcs/test_vcs_canvas_background_update.py new file mode 100644 index 0000000000..454f0ef099 --- /dev/null +++ b/testing/vcs/test_vcs_canvas_background_update.py @@ -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)