Changeset 2538


Ignore:
Timestamp:
05/18/12 19:44:44 (13 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (related to CAS-3749)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: added a new method, _alive(), in asaplotbase class

Test Programs: Interactive tests

Put in Release Notes: No

Module(s):

Description:

Added a new method, _alive(), in asaplotbase class. The method return True
if asaplot instance is alive. More complete check compared to 'is_dead' parameter.
asapplotter._assert_plotter method is simplified by calling this function.

Fixed misc bugs found in interactive tests.

  1. set back linewidth = 1 in plots invoked by modules, interactivemask, asapmath, and asapfitter.
  2. interactivemask module: plotter in properly quited at the end.
  3. interactivemask module: avoid error when user close interacive plot window before calling the finalization method, finish_selection().
  4. added definition of a dummy function, quit(), in asaplot class.


Location:
trunk/python
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapfitter.py

    r2535 r2538  
    541541                         on the plot
    542542        """
     543        from matplotlib import rc as rcp
    543544        if not self.fitted:
    544545            return
  • trunk/python/asaplot.py

    r2483 r2538  
    2626        self.window = None
    2727        self.canvas = FigureCanvasAgg(self.figure)
    28         self.figmgr = FigureManagerBase(self.canvas,1)
     28        self.figmgr = FigureManagerBase(self.canvas,0)
    2929        # This seems necessary when using Gcf, as this is done in
    3030        # pyplot.figure. Otherwise this can cause atexit errors at cleanup
     
    3232        self.figmgr._cidgcf = None
    3333        _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr
     34
     35    def quit(self):
     36        # never dextroy non-GUI plotter.
     37        pass
    3438
    3539    def map(self):
  • trunk/python/asaplotbase.py

    r2451 r2538  
    1212from matplotlib import rc, rcParams
    1313from matplotlib.ticker import OldScalarFormatter
     14from matplotlib import _pylab_helpers
    1415
    1516from asap.parameters import rcParams as asaprcParams
     
    850851                    rotation=rotate,transform = trans)
    851852        self.axes.set_autoscale_on(True)
     853
     854    def _alive(self):
     855        # Return True if the GUI alives.
     856        if (not self.is_dead) and \
     857               self.figmgr and hasattr(self.figmgr, "num"):
     858            figid = self.figmgr.num
     859            # Make sure figid=0 is what asapplotter expects.
     860            # It might be already destroied/overridden by matplotlib
     861            # commands or other methods using asaplot.
     862            return _pylab_helpers.Gcf.has_fignum(figid) and \
     863                   (self.figmgr == _pylab_helpers.Gcf.get_fig_manager(figid))
     864        return False
  • trunk/python/asapmath.py

    r2535 r2538  
    33from asap.logging import asaplog, asaplog_post_dec
    44from asap.selector import selector
    5 #from asap import asaplotgui
    65from asap.asapplotter import new_asaplot
     6from matplotlib import rc as rcp
    77
    88@asaplog_post_dec
  • trunk/python/asapplotter.py

    r2535 r2538  
    140140                       when plot window is not alive.
    141141        """
    142         isAlive = (self._plotter != None and not self._plotter.is_dead)
     142        isAlive = (self._plotter is not None) and self._plotter._alive()
    143143        # More tests
    144         if isAlive:
    145             if self._plotter.figmgr:
    146                 figmgr = self._plotter.figmgr
    147                 figid = figmgr.num
    148                 # Make sure figid=0 is what asapplotter expects.
    149                 # It might be already destroied/overridden by matplotlib
    150                 # commands or other plotting methods using asaplot.
    151                 isAlive = _pylab_helpers.Gcf.has_fignum(figid) and \
    152                           (figmgr == \
    153                            _pylab_helpers.Gcf.get_fig_manager(figid))
    154             else:
    155                 isAlive = False
     144        #if isAlive:
     145        #    if self._plotter.figmgr:
     146        #        figmgr = self._plotter.figmgr
     147        #        figid = figmgr.num
     148        #        # Make sure figid=0 is what asapplotter expects.
     149        #        # It might be already destroied/overridden by matplotlib
     150        #        # commands or other plotting methods using asaplot.
     151        #        isAlive = _pylab_helpers.Gcf.has_fignum(figid) and \
     152        #                  (figmgr == \
     153        #                   _pylab_helpers.Gcf.get_fig_manager(figid))
     154        #    else:
     155        #        isAlive = False
    156156           
    157157        if isAlive:
  • trunk/python/interactivemask.py

    r2453 r2538  
    156156            self.showmask = True
    157157
    158         #if not self.p._plotter or self.p._plotter.is_dead:
    159158        if not self.p:
    160159            asaplog.push('A new ASAP plotter will be loaded')
     
    164163            self.newplot = True
    165164        self.p._assert_plotter(action='reload')
     165        from matplotlib import rc as rcp
     166        rcp('lines', linewidth=1)
    166167       
    167168        # Plot selected spectra if needed
     
    339340        if callback: self.callback=callback
    340341        if self.callback: self.callback()
    341         if not self.event: self.p._plotter.register('button_press',None)
     342        if not self.event:
     343            try: self.p._plotter.register('button_press',None)
     344            except: pass # plotter window is closed by X button.
    342345        # Finish the plot
    343346        if not self.newplot:
    344347            self.clear_polygon()
    345348        else:
    346             self.p._plotter.unmap()
     349            #self.p._plotter.unmap()
     350            self.p._plotter.quit()
    347351            self.p._plotter = None
    348352            del self.p
Note: See TracChangeset for help on using the changeset viewer.