Comment 3 for bug 947090

Revision history for this message
Joachim Haga (jobh) wrote :

The following hack is only very lightly tested, but should "fix" it.

=== modified file 'src/viper/viper_dolfin.py'
--- src/viper/viper_dolfin.py 2012-02-09 09:06:11 +0000
+++ src/viper/viper_dolfin.py 2012-03-05 14:43:26 +0000
@@ -410,11 +410,16 @@
             return self.autoplot(plot_object, *args, **kwargs)
         return self.figureplot(plot_object, *args, **kwargs)

- def autoplot(self, plot_object, *args, **kwargs):
+ def get_plotter(self, plot_object):
         for (idx, (plotter,obj)) in self.plots.items():
             if obj is plot_object:
- plotter.update(plot_object, **kwargs)
                 return plotter
+
+ def autoplot(self, plot_object, *args, **kwargs):
+ plotter = self.get_plotter(plot_object)
+ if plotter:
+ plotter.update(plot_object, **kwargs)
+ return plotter
         idx = self.random.randint(0,10000)
         keys = self.plots.keys()
         while idx in keys:
@@ -452,6 +457,8 @@
     global _plotter
     if _plotter is None:
         _plotter = PlotManager()
+
+ new_window = not _plotter.get_plotter(data)
     n_old_plots = len(_plotter.plots)

     interactive = False
@@ -460,7 +467,7 @@
         kwargs["interactive"] = False
     fig = _plotter.plot(data, **kwargs)

- if n_old_plots > 0 and kwargs.get('autoposition', True):
+ if new_window and kwargs.get('autoposition', True):
         x, y = fig.window_size
         nx, ny = n_old_plots%3, n_old_plots//3
         fig.renWin.SetPosition(nx*x, ny*y)