Changeset 2196


Ignore:
Timestamp:
Apr 5, 2016 5:24:38 PM (7 years ago)
Author:
toby
Message:

redo plot window graphics to redraw after refinement (need to update more plotting routines & save plot zoom stack, etc.)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2185 r2196  
    37233723                if dlg2.ShowModal() == wx.ID_OK:
    37243724                    Id = 0
     3725                    self.G2plotNB.setReplotFlags() # mark all plots as old
    37253726                    self.PatternTree.DeleteChildren(self.root)
    37263727                    self.HKL = []
    3727                     G2IO.ProjFileOpen(self)
     3728                    G2IO.ProjFileOpen(self,False)
    37283729                    Id =  self.root
    37293730                    txt = None
     
    37343735                    self.PatternTree.SelectItem(Id)
    37353736                    G2gd.MovePatternTreeToGrid(self,Id)
     3737                    self.G2plotNB.replotAll() # refresh any plots not yet updated
    37363738            finally:
    37373739                dlg2.Destroy()
     
    37803782                if dlg.ShowModal() == wx.ID_OK:
    37813783                    Id = 0
     3784                    self.G2plotNB.setReplotFlags() # mark all plots as old
    37823785                    self.PickIdText = None  #force reload of PickId contents
    37833786                    self.PatternTree.DeleteChildren(self.root)
     
    37853788                    if self.G2plotNB.plotList:
    37863789                        self.G2plotNB.clear()
    3787                     G2IO.ProjFileOpen(self)
     3790                    G2IO.ProjFileOpen(self,False)
    37883791                    Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequential results')
    37893792                    self.PatternTree.SelectItem(Id)
    3790    
     3793                    self.G2plotNB.replotAll() # refresh any plots not yet updated
    37913794            finally:
    37923795                dlg.Destroy()
  • trunk/GSASIIIO.py

    r2167 r2196  
    762762        return head,data,Npix,image
    763763       
    764 def ProjFileOpen(G2frame):
     764def ProjFileOpen(G2frame,showProvenance=True):
    765765    'Read a GSAS-II project file and load into the G2 data tree'
    766766    if not os.path.exists(G2frame.GSASprojectfile):
     
    770770    LastSavedUsing = None
    771771    file = open(G2frame.GSASprojectfile,'rb')
    772     print 'load from file: ',G2frame.GSASprojectfile
     772    if showProvenance: print 'loading from file: ',G2frame.GSASprojectfile
    773773    G2frame.SetTitle("GSAS-II data tree: "+
    774774                     os.path.split(G2frame.GSASprojectfile)[1])
     
    795795                if datum[0] == 'Controls' and 'LastSavedUsing' in datum[1]:
    796796                    LastSavedUsing = datum[1]['LastSavedUsing']
    797                 if datum[0] == 'Controls' and 'PythonVersions' in datum[1] and GSASIIpath.GetConfigValue('debug'):
     797                if datum[0] == 'Controls' and 'PythonVersions' in datum[1] and GSASIIpath.GetConfigValue('debug') and showProvenance:
    798798                    print('Packages used to create .GPX file:')
    799799                    if 'dict' in str(type(datum[1]['PythonVersions'])):  #patch
  • trunk/GSASIIplot.py

    r2193 r2196  
    6868nxs = np.newaxis
    6969   
    70 class G2PlotMpl(wx.Panel):   
     70class _tabPlotWin(wx.Panel):   
     71    'Creates a basic tabbed plot window for GSAS-II graphics'
     72    def __init__(self,parent,id=-1,dpi=None,**kwargs):
     73        self.ReplotRoutine = None
     74        self.ReplotArgs = []
     75        self.ReplotKwArgs = {}
     76        self.needsUpdate = True
     77        wx.Panel.__init__(self,parent,id=id,**kwargs)
     78       
     79    def AddRefresh(self,ReplotRoutine,ReplotArgs=[],ReplotKwArgs={}):
     80        '''Define a routine used to refresh the plot
     81       
     82        :param function ReplotRoutine: function to be called
     83        :param list ReplotArgs: list of positional parameters, if any
     84        :param dict ReplotKwArgs: dict of keyword parameters, if any
     85        '''
     86        self.ReplotRoutine = ReplotRoutine
     87        self.ReplotArgs = ReplotArgs
     88        self.ReplotKwArgs = ReplotKwArgs
     89
     90    def Refresh(self):
     91        'Replots the selected tab'
     92        if self.ReplotRoutine:
     93            #print 'Refresh G2PlotMpl with',self.ReplotRoutine
     94            if not self.needsUpdate:
     95                #print 'already updated\n'
     96                return True
     97            #if self.ReplotArgs: print '...args',self.ReplotArgs
     98            #if self.ReplotKwArgs: print '...KWargs',self.ReplotKwArgs
     99            self.ReplotRoutine(*self.ReplotArgs,**self.ReplotKwArgs)
     100            return True
     101        else:
     102            return False
     103class G2PlotMpl(_tabPlotWin):   
    71104    'Creates a Matplotlib 2-D plot in the GSAS-II graphics window'
    72105    def __init__(self,parent,id=-1,dpi=None,**kwargs):
    73         wx.Panel.__init__(self,parent,id=id,**kwargs)
     106        _tabPlotWin.__init__(self,parent,id=id,**kwargs)
    74107        mpl.rcParams['legend.fontsize'] = 10
    75108        self.figure = mpl.figure.Figure(dpi=dpi,figsize=(5,6))
     
    84117        self.SetSizer(sizer)
    85118       
    86 class G2PlotOgl(wx.Panel):
     119class G2PlotOgl(_tabPlotWin):
    87120    'Creates an OpenGL plot in the GSAS-II graphics window'
    88121    def __init__(self,parent,id=-1,dpi=None,**kwargs):
    89         self.figure = wx.Panel.__init__(self,parent,id=id,**kwargs)
     122        self.figure = _tabPlotWin.__init__(self,parent,id=id,**kwargs)
    90123        if 'win' in sys.platform:           #Windows (& Mac) already double buffered
    91124            self.canvas = wx.glcanvas.GLCanvas(self,-1,**kwargs)
     
    105138        self.SetSizer(sizer)
    106139       
    107 class G2Plot3D(wx.Panel):
     140class G2Plot3D(_tabPlotWin):
    108141    'Creates a 3D Matplotlib plot in the GSAS-II graphics window'
    109142    def __init__(self,parent,id=-1,dpi=None,**kwargs):
    110         wx.Panel.__init__(self,parent,id=id,**kwargs)
     143        _tabPlotWin.__init__(self,parent,id=id,**kwargs)
    111144        self.figure = mpl.figure.Figure(dpi=dpi,figsize=(6,6))
    112145        self.canvas = Canvas(self,-1,self.figure)
     
    124157    def __init__(self,parent,id=-1):
    125158        wx.Panel.__init__(self,parent,id=id)
    126         #so one can't delete a plot page!!
     159        #so one can't delete a plot page from tab!!
    127160        self.nb = wx.aui.AuiNotebook(self, \
    128161            style=wx.aui.AUI_NB_DEFAULT_STYLE ^ wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
     
    136169        self.nb.Bind(wx.EVT_KEY_UP,self.OnNotebookKey)
    137170       
    138         self.plotList = []
     171        self.plotList = []   # contains the tab label for each plot
     172        self.panelList = []   # contains the panel object for each plot
     173        self.figList = []   # contains the figure object for each plot
     174        self.pageOnTop = None # keep track of top page during refresh all
     175        self.skipPageChange = False
    139176       
    140177    def OnNotebookKey(self,event):
     
    156193            pass
    157194
     195    def _addPage(self,name,page):
     196        'Add the newly created page to the notebook and associated lists'
     197        self.skipPageChange = True
     198        self.nb.AddPage(page,name)       
     199        self.plotList.append(name)
     200        self.panelList.append(page) # panel object for plot
     201        self.figList.append(page.figure)  # figure object for plot
     202        self.skipPageChange = False
     203
     204    def registerReplot(self,name,ReplotRoutine,ReplotArgs=[],ReplotKwArgs={}):
     205        'Define the routine and args needed to replot a figure'
     206        try:
     207            plotNum = self.plotList.index(name)
     208        except ValueError:
     209            print('No plot tab labeled '+name)
     210            GSASIIpath.IPyBreak()
     211        page = self.panelList[plotNum]
     212        page.AddRefresh(ReplotRoutine,ReplotArgs,ReplotKwArgs)
     213       
     214    def setReplotFlags(self):
     215        'Flag all plots as needing a redraw'
     216        for page in self.panelList:
     217            page.needsUpdate = True
     218        self.pageOnTop = self.nb.GetSelection()
     219       
     220    def clearReplotFlag(self,name):
     221        'Set when redrawing a plot so that it is not done twice'
     222        try:
     223            plotNum = self.plotList.index(name)
     224        except ValueError:
     225            print('clearReplotFlag: No plot tab labeled '+name)
     226        page = self.panelList[plotNum]
     227        page.needsUpdate = False
     228
     229    def ResetOnTop(self):
     230        'Put the saved page back on top'
     231        self.SetSelectionNoRefresh(self.pageOnTop)
     232       
     233    def SetSelectionNoRefresh(self,plotNum):
     234        'Raises a plot tab without triggering a refresh via OnPageChanged'
     235        self.skipPageChange = True
     236        self.nb.SetSelection(plotNum) # raises plot tab
     237        self.skipPageChange = False
     238
     239    def RaisePageNoRefresh(self,Page):
     240        'Raises a plot tab without triggering a refresh via OnPageChanged'
     241        self.skipPageChange = True
     242        Page.SetFocus()
     243        self.skipPageChange = False
     244               
     245    def replotAll(self):
     246        'refresh all current plots, if not already redrawn'
     247        for page,label in zip(self.panelList,self.plotList):
     248            if page.Refresh():
     249                pass
     250            elif GSASIIpath.GetConfigValue('debug'):
     251                print('No refresh for '+label)               
     252        if self.pageOnTop is not None:
     253            wx.CallLater(150,self.ResetOnTop)
     254       
    158255    def addMpl(self,name=""):
    159256        'Add a tabbed page with a matplotlib plot'
    160257        page = G2PlotMpl(self.nb)
    161         self.nb.AddPage(page,name)
    162        
    163         self.plotList.append(name)
    164        
     258        self._addPage(name,page)
    165259        return page.figure
    166260       
     
    168262        'Add a tabbed page with a 3D plot'
    169263        page = G2Plot3D(self.nb)
    170         self.nb.AddPage(page,name)
    171        
    172         self.plotList.append(name)
    173        
     264        self._addPage(name,page)
    174265        return page.figure
    175266       
     
    177268        'Add a tabbed page with an openGL plot'
    178269        page = G2PlotOgl(self.nb)
    179         self.nb.AddPage(page,name)
    180        
    181         self.plotList.append(name)
    182        
     270        self._addPage(name,page)
     271        self.RaisePageNoRefresh(page)   # need to give window focus before GL use
    183272        return page.figure
    184273       
     
    188277            item = self.plotList.index(name)
    189278            del self.plotList[item]
     279            del self.panelList[item]
     280            del self.figList[item]
    190281            self.nb.DeletePage(item)
    191282        except ValueError:          #no plot of this name - do nothing
     
    197288            self.nb.DeletePage(0)
    198289        self.plotList = []
     290        self.panelList = []
     291        self.figList = []
    199292        self.status.DestroyChildren()
    200293       
     
    209302       
    210303    def OnPageChanged(self,event):
    211         'respond to someone pressing a tab on the plot window'
    212         if self.plotList:
     304        '''respond to someone pressing a tab on the plot window.
     305        Called when a plot tab is clicked. on some platforms (Mac for sure) this
     306        is also called when a plot is created or selected with .SetSelection() or
     307        .SetFocus(). The self.skipPageChange is used variable is set to suppress
     308        repeated replotting.
     309        '''
     310        if self.skipPageChange:
     311#            print 'skipping OnPageChanged'
     312            self.skipPageChange = False
     313            return
     314#        print 'OnPageChanged'
     315        self.status.DestroyChildren()                           #get rid of special stuff on status bar
     316        self.status.SetStatusText('',1)  # clear old status message
     317        page = self.nb.GetCurrentPage()
     318        page.needsUpdate = True
     319        if page.Refresh():  # refresh plot, if possible
     320            pass
     321        elif self.plotList:
    213322            self.status.SetStatusText('Better to select this from GSAS-II data tree',1)
    214         self.status.DestroyChildren()                           #get rid of special stuff on status bar
    215323       
    216324class GSASIItoolbar(Toolbar):
     
    409517        Page.figure.clf()
    410518        Plot = Page.figure.gca()          #get a fresh plot after clf()
     519        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    411520    except ValueError:
    412521        Plot = G2frame.G2plotNB.addMpl('Structure Factors').gca()
     
    424533        if 'HKLF' in Name:
    425534            Page.Choice += ('w: select |DFsq|/sig','1: select |DFsq|>sig','3: select |DFsq|>3sig',)
    426     Page.SetFocus()
     535#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    427536    Plot.set_aspect(aspect='equal')
    428537   
     
    10101119        plotNum = G2frame.G2plotNB.plotList.index('3D Structure Factors')
    10111120        Page = G2frame.G2plotNB.nb.GetPage(plotNum)       
     1121        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    10121122    except ValueError:
    10131123        Plot = G2frame.G2plotNB.addOgl('3D Structure Factors')
     
    10181128        altDown = False
    10191129    Font = Page.GetFont()
    1020     Page.SetFocus()
     1130#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    10211131    Page.Choice = None
    10221132    choice = [' save as/key:','jpeg','tiff','bmp','h: view down h','k: view down k','l: view down l',
     
    10491159################################################################################
    10501160           
    1051 def PlotPatterns(G2frame,newPlot=False,plotType='PWDR'):
     1161def PlotPatterns(G2frame,newPlot=False,plotType='PWDR',TreeItemText=None):
    10521162    '''Powder pattern plotting package - displays single or multiple powder patterns as intensity vs
    10531163    2-theta, q or TOF. Can display multiple patterns as "waterfall plots" or contour plots. Log I
    10541164    plotting available.
     1165
     1166    The histogram to be plotted is found in G2frame.PatternId unless the histogram name is specified
     1167    as TreeItemText
    10551168    '''
    10561169    global exclLines
     
    10591172    global Pattern
    10601173    plottype = plotType
     1174    if TreeItemText:
     1175        G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,TreeItemText)
     1176    else:
     1177        TreeItemText = G2frame.PatternTree.GetItemText(G2frame.PatternId)
     1178       
    10611179    if not G2frame.PatternId:
    10621180        return
     
    11851303            Page.canvas.SetCursor(wx.CROSS_CURSOR)
    11861304            try:
    1187                 Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))
     1305                Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters')
     1306                if not Id: return
     1307                Parms,Parms2 = G2frame.PatternTree.GetItemPyData(Id)
    11881308                if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype:
    11891309                    q = xpos
     
    15171637        Page.figure.clf()
    15181638        Plot = Page.figure.gca()          #get a fresh plot after clf()
     1639        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    15191640    except ValueError:
    15201641        if plottype == 'SASD':
     
    15311652        Page.canvas.mpl_connect('button_release_event', OnRelease)
    15321653        Page.canvas.mpl_connect('button_press_event',OnPress)
    1533     if plottype == 'PWDR':  # avoids a very nasty clash with KILL_FOCUS in SASD TextCtrl?
    1534         Page.SetFocus()
     1654    G2frame.G2plotNB.registerReplot('Powder Patterns',
     1655        ReplotRoutine=PlotPatterns,
     1656        ReplotKwArgs={'G2frame':G2frame, 'plotType':plottype,
     1657                      'TreeItemText':TreeItemText, 'newPlot':True
     1658                      })
     1659    G2frame.G2plotNB.status.SetStatusText('histogram: '+TreeItemText,1)
     1660    G2frame.G2plotNB.clearReplotFlag('Powder Patterns')
     1661#    if plottype == 'PWDR':  # avoids a very nasty clash with KILL_FOCUS in SASD TextCtrl?
     1662#        Page.SetFocus()
    15351663    G2frame.G2plotNB.status.DestroyChildren()
    15361664    if G2frame.Contour:
     
    19762104        Page.figure.clf()
    19772105        Plot = Page.figure.gca()          #get a fresh plot after clf()
     2106        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    19782107    except ValueError:
    19792108        newPlot = True
     
    20022131            if ref[6+im] > 0.:
    20032132                DS.append((ref[5+im]-ref[7+im])/ref[6+im])
    2004     Page.SetFocus()
     2133#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    20052134    G2frame.G2plotNB.status.DestroyChildren()
    20062135    DS.sort()
     
    21222251        Page.figure.clf()
    21232252        Plot = Page.figure.gca()
     2253        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    21242254    except ValueError:
    21252255        newPlot = True
     
    21312261        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    21322262   
    2133     Page.SetFocus()
     2263#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    21342264    G2frame.G2plotNB.status.DestroyChildren()
    21352265    if G2frame.Contour:
     
    22772407        Page.figure.clf()
    22782408        Plot = Page.figure.gca()
     2409        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    22792410    except ValueError:
    22802411        newPlot = True
     
    22852416   
    22862417    Page.Choice = None
    2287     Page.SetFocus()
     2418#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    22882419    G2frame.G2plotNB.status.DestroyChildren()
    22892420    Plot.set_title(Title)
     
    23572488        Page.figure.clf()
    23582489        Plot = Page.figure.gca()
     2490        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    23592491    except ValueError:
    23602492        newPlot = True
     
    23652497   
    23662498    Page.Choice = None
    2367     Page.SetFocus()
     2499#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    23682500    G2frame.G2plotNB.status.DestroyChildren()
    23692501    Plot.set_title(Title)
     
    24522584            xylim = Plot.get_xlim(),Plot.get_ylim()
    24532585        Page.figure.clf()
    2454         Plot = Page.figure.gca()
     2586        Plot = Page.figure.gca()
     2587        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    24552588    except ValueError:
    24562589        newPlot = True
     
    24632596    Page.Choice = (' key press','d: lower contour max','u: raise contour max','o: reset contour max',
    24642597        'i: interpolation method','s: color scheme')
    2465     Page.SetFocus()
     2598#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    24662599    G2frame.G2plotNB.status.DestroyChildren()
    24672600    Nxy = Z.shape
     
    25212654        Page.figure.clf()
    25222655        Plot = Page.figure.gca()
     2656        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    25232657    except ValueError:
    25242658        newPlot = True
     
    25292663   
    25302664    Page.Choice = None
    2531     Page.SetFocus()
     2665#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    25322666    G2frame.G2plotNB.status.DestroyChildren()
    25332667    Plot.set_title('Strain')
     
    25782712        Page.figure.clf()
    25792713        Plot = Page.figure.gca()          #get a fresh plot after clf()
     2714        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    25802715    except ValueError:
    25812716        newPlot = True
     
    25862721        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    25872722    Page.Choice = None
    2588     Page.SetFocus()
     2723#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    25892724    PatternId = G2frame.PatternId
    25902725    data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Models'))
     
    26342769        Page.figure.clf()
    26352770        Plot = Page.figure.gca()
     2771        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    26362772    except ValueError:
    26372773        Plot = G2frame.G2plotNB.addMpl('Powder Lines').gca()
     
    26412777       
    26422778    Page.Choice = None
    2643     Page.SetFocus()
     2779#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    26442780    Plot.set_title('Powder Pattern Lines')
    26452781    Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14)
     
    26632799################################################################################
    26642800           
    2665 def PlotPeakWidths(G2frame):
     2801def PlotPeakWidths(G2frame,TreeItemText=None):
    26662802    ''' Plotting of instrument broadening terms as function of 2-theta
    26672803    Seen when "Instrument Parameters" chosen from powder pattern data tree
     
    26712807#    gamFW = lambda s,g: np.exp(np.log(s**5+2.69269*s**4*g+2.42843*s**3*g**2+4.47163*s**2*g**3+0.07842*s*g**4+g**5)/5.)
    26722808#    gamFW2 = lambda s,g: math.sqrt(s**2+(0.4654996*g)**2)+.5345004*g  #Ubaldo Bafile - private communication
     2809    if TreeItemText:
     2810        G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,TreeItemText)
     2811    else:
     2812        TreeItemText = G2frame.PatternTree.GetItemText(G2frame.PatternId)
    26732813    PatternId = G2frame.PatternId
    26742814    limitID = G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits')
     
    27002840        Page.figure.clf()
    27012841        Plot = Page.figure.gca()
     2842        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    27022843    except ValueError:
    27032844        Plot = G2frame.G2plotNB.addMpl('Peak Widths').gca()
    27042845        plotNum = G2frame.G2plotNB.plotList.index('Peak Widths')
    27052846        Page = G2frame.G2plotNB.nb.GetPage(plotNum)
     2847    G2frame.G2plotNB.registerReplot('Peak Widths',
     2848        ReplotRoutine=PlotPeakWidths,
     2849        ReplotKwArgs={'G2frame':G2frame, 'TreeItemText':TreeItemText})
     2850    G2frame.G2plotNB.status.SetStatusText('histogram: '+TreeItemText,1)
     2851    G2frame.G2plotNB.clearReplotFlag('Peak Widths')   
    27062852    Page.Choice = None
    2707     Page.SetFocus()
     2853#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    27082854   
    27092855    Page.canvas.SetToolTipString('')
     
    30553201        if not Page.IsShown():
    30563202            Page.Show()
     3203        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    30573204    except ValueError:
    30583205        if '3D' in SHData['PlotType']:
     
    30653212
    30663213    Page.Choice = None
    3067     Page.SetFocus()
     3214#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    30683215    G2frame.G2plotNB.status.SetFields(['',''])   
    30693216    PH = np.array(SHData['PFhkl'])
     
    32103357        if not Page.IsShown():
    32113358            Page.Show()
     3359        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    32123360    except ValueError:
    32133361        Plot = G2frame.G2plotNB.addMpl('Modulation').gca()
     
    32173365        Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress)
    32183366   
    3219     Page.SetFocus()
     3367#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    32203368    General = data['General']
    32213369    cx,ct,cs,cia = General['AtomPtrs']
     
    33493497        if not Page.IsShown():
    33503498            Page.Show()
     3499        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    33513500    except ValueError:
    33523501        Plot = G2frame.G2plotNB.addMpl('Covariance').gca()
     
    33573506    Page.Choice = ['s: to change colors']
    33583507    Page.keyPress = OnPlotKeyPress
    3359     Page.SetFocus()
     3508#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    33603509    G2frame.G2plotNB.status.SetFields(['',''])   
    33613510    acolor = mpl.cm.get_cmap(G2frame.VcovColor)
     
    34183567        if not Page.IsShown():
    34193568            Page.Show()
     3569        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    34203570    except ValueError:
    34213571        Plot = G2frame.G2plotNB.addMpl('Torsion').gca()
     
    34253575        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    34263576   
    3427     Page.SetFocus()
     3577#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    34283578    G2frame.G2plotNB.status.SetFields(['','Use mouse LB to identify torsion atoms'])
    34293579    Plot.plot(X,torsion,'b+')
     
    35013651        if not Page.IsShown():
    35023652            Page.Show()
     3653        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    35033654    except ValueError:
    35043655        Plot = G2frame.G2plotNB.addMpl('Ramachandran').gca()
     
    35113662    Page.Choice = ['s: to change colors']
    35123663    Page.keyPress = OnPlotKeyPress
    3513     Page.SetFocus()
     3664#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    35143665    G2frame.G2plotNB.status.SetFields(['','Use mouse LB to identify phi/psi atoms'])
    35153666    acolor = mpl.cm.get_cmap(G2frame.RamaColor)
     
    35883739    def Draw():
    35893740        global Title,xLabel,yLabel
    3590         Page.SetFocus()
     3741        G2frame.G2plotNB.RaisePageNoRefresh(Page)
    35913742        G2frame.G2plotNB.status.SetStatusText(  \
    35923743            'press L to toggle lines, S to select X axis, T to change titles (reselect column to show?)',1)
     
    36713822       
    36723823    Draw()
    3673     G2frame.G2plotNB.nb.SetSelection(plotNum) # raises plot tab
     3824    G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    36743825               
    36753826################################################################################
     
    40514202            Page.figure.clf()
    40524203            Plot = Page.figure.gca()          #get a fresh plot after clf()
     4204        if not event:                       #event from GUI TextCtrl - don't want focus to change to plot!!!
     4205            G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    40534206    except ValueError:
    40544207        Plot = G2frame.G2plotNB.addMpl('2D Powder Image').gca()
     
    40614214        xylim = []
    40624215    Page.Choice = None
    4063     if not event:                       #event from GUI TextCtrl - don't want focus to change to plot!!!
    4064         Page.SetFocus()
     4216#    if not event:                       #event from GUI TextCtrl - don't want focus to change to plot!!!
     4217#        G2frame.G2plotNB.RaisePageNoRefresh(Page)
    40654218    Title = G2frame.PatternTree.GetItemText(G2frame.Image)[4:]
    40664219    G2frame.G2plotNB.status.DestroyChildren()
     
    42924445        Page.figure.clf()
    42934446        Plot = Page.figure.gca()          #get a fresh plot after clf()
     4447        if not event:
     4448            G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    42944449       
    42954450    except ValueError:
     
    43014456        view = False
    43024457    Page.Choice = None
    4303     if not event:
    4304         Page.SetFocus()
     4458#    if not event:
     4459#        G2frame.G2plotNB.RaisePageNoRefresh(Page)
    43054460       
    43064461    Data = G2frame.PatternTree.GetItemPyData(
     
    43584513        Page.figure.clf()
    43594514        Plot = Page.figure.gca()          #get a fresh plot after clf()
     4515        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    43604516       
    43614517    except ValueError:
     
    43674523        view = False
    43684524    Page.Choice = None
    4369     Page.SetFocus()
     4525#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    43704526       
    43714527    Data = G2frame.PatternTree.GetItemPyData(
     
    54635619        plotNum = G2frame.G2plotNB.plotList.index(generalData['Name'])
    54645620        Page = G2frame.G2plotNB.nb.GetPage(plotNum)
     5621        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    54655622    except ValueError:
    54665623        Plot = G2frame.G2plotNB.addOgl(generalData['Name'])
     
    54705627        view = False
    54715628        altDown = False
    5472     G2frame.G2plotNB.nb.SetSelection(plotNum) # make sure plot tab is raised for wx >2.8
    54735629    Font = Page.GetFont()
    5474     Page.SetFocus()
     5630#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    54755631    Page.Choice = None
    54765632    if mapData.get('Flip',False):
     
    57665922        plotNum = G2frame.G2plotNB.plotList.index('Rigid body')
    57675923        Page = G2frame.G2plotNB.nb.GetPage(plotNum)       
     5924        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    57685925    except ValueError:
    57695926        Plot = G2frame.G2plotNB.addOgl('Rigid body')
     
    57735930        view = False
    57745931        altDown = False
    5775     Page.SetFocus()
     5932#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    57765933    Font = Page.GetFont()
    57775934    Page.canvas.Bind(wx.EVT_MOUSEWHEEL, OnMouseWheel)
     
    61496306        plotNum = G2frame.G2plotNB.plotList.index('Layer')
    61506307        Page = G2frame.G2plotNB.nb.GetPage(plotNum)       
     6308        G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab
    61516309    except ValueError:
    61526310        Plot = G2frame.G2plotNB.addOgl('Layer')
     
    61596317    choice = [' save as:','jpeg','tiff','bmp']
    61606318    Page.keyPress = OnPlotKeyPress
    6161     Page.SetFocus()
     6319#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    61626320    Font = Page.GetFont()
    61636321    cb = wx.ComboBox(G2frame.G2plotNB.status,style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=choice)
Note: See TracChangeset for help on using the changeset viewer.