Skip to content

Commit

Permalink
BUG #1770: Display meshfill template elements through renderTemplate.
Browse files Browse the repository at this point in the history
This deletes some displays which reduces memory leaks.
  • Loading branch information
danlipsa committed Jul 25, 2016
1 parent b3b5576 commit 3873bdc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Packages/vcs/vcs/VTKPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,10 @@ def plotContinents(self, wc, projection, wrap, vp, priority, **kargs):
priority=priority,
create_renderer=True)

def renderTemplate(self, tmpl, data, gm, taxis, zaxis, **kargs):
def renderTemplate(self, tmpl, data, gm, taxis, zaxis, X=None, Y=None, **kargs):
# ok first basic template stuff, let's store the displays
# because we need to return actors for min/max/mean
displays = tmpl.plot(self.canvas, data, gm, bg=self.bg, **kargs)
displays = tmpl.plot(self.canvas, data, gm, bg=self.bg, X=X, Y=Y, **kargs)
returned = {}
for d in displays:
if d is None:
Expand Down
21 changes: 13 additions & 8 deletions Packages/vcs/vcs/vcsvtk/meshfillpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,26 @@ def _plotInternal(self):
create_renderer=True)
actors.append([act, plotting_dataset_bounds])

t = self._originalData1.getTime()
if self._originalData1.ndim > 2:
z = self._originalData1.getAxis(-3)
else:
z = None
self._resultDict["vtk_backend_actors"] = actors
kwargs = {"vtk_backend_grid": self._vtkDataSet,
"dataset_bounds": self._vtkDataSetBounds,
"plotting_dataset_bounds": plotting_dataset_bounds,
"vtk_backend_geo": self._vtkGeoTransform}
if ("ratio_autot_viewport" in self._resultDict):
kwargs["ratio_autot_viewport"] = vp
self._template.plot(self._context().canvas, self._data1, self._gm,
bg=self._context().bg,
X=numpy.arange(min(x1, x2),
max(x1, x2) * 1.1,
abs(x2 - x1) / 10.),
Y=numpy.arange(min(y1, y2),
max(y1, y2) * 1.1,
abs(y2 - y1) / 10.), **kwargs)
self._resultDict.update(self._context().renderTemplate(self._template, self._data1, self._gm,
t, z,
X=numpy.arange(min(x1, x2),
max(x1, x2) * 1.1,
abs(x2 - x1) / 10.),
Y=numpy.arange(min(y1, y2),
max(y1, y2) * 1.1,
abs(y2 - y1) / 10.), **kwargs))

legend = getattr(self._gm, "legend", None)

Expand Down
2 changes: 1 addition & 1 deletion testing/vcs/test_vcs_meshfill_no_wrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
h = f("heat")
x = regression.init()
x.plot(h, bg=1)
regression.run(x, "vcs_test_meshfill_no_wrapping.png")
regression.run(x, "test_vcs_meshfill_no_wrapping.png")
2 changes: 1 addition & 1 deletion testing/vcs/test_vcs_meshfill_regular_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
s = f("clt")
x.meshfill(s, bg=1)
regression.run(x, "test_meshfill_regular_grid.png")
regression.run(x, "test_vcs_meshfill_regular_grid.png")

0 comments on commit 3873bdc

Please sign in to comment.