diff --git a/Packages/vcs/Lib/VTKPlots.py b/Packages/vcs/Lib/VTKPlots.py index 8d6751a7aa..f1e188a78d 100644 --- a/Packages/vcs/Lib/VTKPlots.py +++ b/Packages/vcs/Lib/VTKPlots.py @@ -344,6 +344,7 @@ def createRenWin(self, *args, **kargs): if not self.bg: self.createDefaultInteractor(self.renderer) self.renWin.AddRenderer(self.renderer) + self.renWin.AddObserver("ModifiedEvent", self.configureEvent) if self.bg: self.renWin.SetOffScreenRendering(True) if "open" in kargs and kargs["open"]: @@ -357,7 +358,7 @@ def createRenderer(self, *args, **kargs): return ren def update(self, *args, **kargs): - self._lastSize = -1 + self._lastSize = None if self.renWin: if self.get3DPlot(): plots_args = [] @@ -1076,9 +1077,11 @@ def png(self, file, width=None, height=None, if width is not None and height is not None: if self.renWin.GetSize() != (width, height): user_dims = (self.canvas.bgX, self.canvas.bgY, sz[0], sz[1]) - self.renWin.SetSize(width, height) + # We need to set canvas.bgX and canvas.bgY before we do renWin.SetSize + # otherwise, canvas.bgX,canvas.bgY will win self.canvas.bgX = width self.canvas.bgY = height + self.renWin.SetSize(width, height) self.configureEvent(None, None) else: user_dims = None diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index a73d30bb3d..12312e5b22 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -333,6 +333,11 @@ cdat_add_test(vcs_test_meshfill_zoom_flip "${BASELINE_DIR}/vcs_test_meshfill_zoom_flip.png" flip ) +cdat_add_test(vcs_test_isofill_labels_off.png + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/vcs_test_isofill_labels_off.py + "${BASELINE_DIR}/vcs_test_isofill_labels_off.png" + ) cdat_add_test(vcs_test_meshfill_zoom_flip "${PYTHON_EXECUTABLE}" ${cdat_SOURCE_DIR}/testing/vcs/vcs_test_meshfill_zoom.py diff --git a/testing/vcs/vcs_test_isofill_labels_off.py b/testing/vcs/vcs_test_isofill_labels_off.py new file mode 100644 index 0000000000..aafa7a773a --- /dev/null +++ b/testing/vcs/vcs_test_isofill_labels_off.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +import cdms2 +import os +import sys +import vcs + +# Test that the image is created properly when we call plot with bg = 0 and +# then we save a png. If the default png size is bigger than the screen size, +# the image was not resized properly + +pth = os.path.join(os.path.dirname(__file__), "..") +sys.path.append(pth) +import checkimage + +cdmsfile = cdms2.open(os.path.join(vcs.sample_data, 'clt.nc')) +clt = cdmsfile('clt') +clt = clt(latitude=(-90.0, 90.0),squeeze=1,longitude=(-180.0, 175.0),time=('1979-01', '1988-12'),) + +x = vcs.init() +x.setantialiasing(0) +x.drawlogooff() + +gmIsofill = vcs.getisofill('a_robinson_isofill') +args = [] +args.append(clt) +gmIsofill.datawc_calendar = 135441 +gmIsofill.datawc_timeunits = 'days since 2000' +gmIsofill.projection = 'robinson' +kwargs = {} +kwargs[ 'cdmsfile' ] = cdmsfile.id +#kwargs[ 'bg' ] = 1 +args.append( gmIsofill ) +x.plot( *args, **kwargs) +fileName = os.path.basename(__file__) +fileName = os.path.splitext(fileName)[0] +fileName = fileName + '.png' +x.png(fileName) +ret = checkimage.check_result_image(fileName, sys.argv[1], checkimage.defaultThreshold) +sys.exit(ret)