Changeset 3962


Ignore:
Timestamp:
May 9, 2019 1:59:10 PM (2 years ago)
Author:
toby
Message:

rework updating of plots after a refinement

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3932 r3962  
    46224622       
    46234623    def ResetPlots(self):
    4624         '''This reloads the current tree item, often drawing a plot. It refreshes any plots
    4625         that have registered a refresh routine (see G2plotNB.RegisterRedrawRoutine)
    4626         and deletes all plots that have not been refreshed and
    4627         require one (see G2plotNB.SetNoDelete).
     4624        '''This reloads the current tree item, often drawing a plot. It
     4625        also refreshes any plots that have registered a refresh routine
     4626        (see G2plotNB.RegisterRedrawRoutine) and deletes all plots that
     4627        have not been refreshed and require one (see G2plotNB.SetNoDelete).
    46284628        '''
    4629         lastRaisedPlotTab = self.G2plotNB.lastRaisedPlotTab # save the current plot tab
    4630         self.G2plotNB.lastRaisedPlotTab = None
    4631         #print ('lastRaisedPlotTab='+lastRaisedPlotTab)
    46324629        for lbl,win in zip(self.G2plotNB.plotList,self.G2plotNB.panelList):
    46334630            win.plotInvalid = True  # mark all current plots as invalid so we can tell what has been updated
     
    46374634        for txt in oldPath:
    46384635            Id = GetGPXtreeItemId(self, Id, txt)
    4639         self.PickIdText = None  #forces reload of page
     4636        pltText = None
     4637        self.PickIdText = None   # forces reload of page when selected
    46404638        if Id:
    46414639            self.PickId = Id
    46424640            self.GPXtree.SelectItem(Id)
    4643         wx.CallLater(100,self.CleanupOldPlots,lastRaisedPlotTab) # wait for plotting to catch up before cleanup
    4644    
    4645     def CleanupOldPlots(self,lastRaisedPlotTab):
    4646         '''Called after a refinement to update plots and delete plots that show obsoleted information
    4647         '''
    4648         # update other self-updating plots
     4641            # selection above appears to trigger a tree event (all platforms?),
     4642            # but if not call SelectDataTreeItem(self,Id)
     4643            wx.Yield()
     4644            time.sleep(0.1)
     4645            pltNumber = self.G2plotNB.nb.GetSelection()
     4646            pltText = self.G2plotNB.nb.GetPageText(pltNumber)
     4647        # update plots where a routine is supplied
    46494648        for lbl,win in zip(self.G2plotNB.plotList,self.G2plotNB.panelList):
    46504649            if win.plotInvalid and win.replotFunction:
     
    46604659                        print(msg)
    46614660                        GSASIIpath.IPyBreak()
    4662         # delete any remaining plots that have not been updated and need a refresh (win.plotRequiresRedraw)
     4661        # delete any remaining plots unless they have been
     4662        # updated (win.plotInvalid is False) or are tagged as not
     4663        # needing a refresh (win.plotRequiresRedraw is False)
    46634664        for lbl,win in zip(self.G2plotNB.plotList,self.G2plotNB.panelList):
    46644665            if win.plotInvalid and win.plotRequiresRedraw:
     
    46664667                    print('Closing out-of-date plot',lbl)
    46674668                self.G2plotNB.Delete(lbl)
    4668         # put the previously last-raised plot tab on top, if present. If not, use the one corresponding to
    4669         # the last tree item to be selected
    4670         wx.CallAfter(self.G2plotNB.RaiseLastPage,lastRaisedPlotTab,self.G2plotNB.lastRaisedPlotTab)
     4669        # put the previously last-raised plot tab on top, if present.
     4670        # Search by label text, since tab number may have changed
     4671        for i in range(self.G2plotNB.nb.GetPageCount()):
     4672            if self.G2plotNB.nb.GetPageText(i) == pltText:
     4673                self.G2plotNB.nb.SetSelection(i)
     4674                break
    46714675       
    46724676    def OnSeqRefine(self,event):
     
    46784682            self.OnRefine(event)
    46794683            return
    4680         plotHist = self.GPXtree.GetItemText(self.PatternId)
     4684        #plotHist = self.GPXtree.GetItemText(self.PatternId)
    46814685        Id = GetGPXtreeItemId(self,self.root,'Sequential results')
    46824686        if not Id:
     
    47404744                    self.GPXtree.RestoreExposedItems()
    47414745                    self.ResetPlots()
    4742                     self.PatternId = GetGPXtreeItemId(self,self.root,plotHist)
    4743                     SelectDataTreeItem(self,self.PatternId)
     4746                    #self.PatternId = GetGPXtreeItemId(self,self.root,plotHist)
     4747                    #SelectDataTreeItem(self,self.PatternId)
    47444748                    sId = GetGPXtreeItemId(self,self.root,'Sequential results')
    47454749                    SelectDataTreeItem(self,sId)
  • trunk/GSASIIimgGUI.py

    r3926 r3962  
    32653265            'Mask File',
    32663266            )
    3267     def __init__(self,parent,parms=None,IMfileList=None):
     3267    def __init__(self,parent,parms=None,IMfileList=None,readFileList=None):
    32683268        self.G2frame = parent.G2frame
     3269        dlg = None
     3270        pth = ''
    32693271        wx.Dialog.__init__(self,parent,style=wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE)
    3270         if parms:
     3272        if readFileList:
     3273            self.parms,self.IMfileList = self.ReadFiles(readFileList)
     3274        elif parms:
    32713275            self.parms = parms # list of values by column
    32723276            self.IMfileList = IMfileList # list of .imctrl file names for each entry in table
  • trunk/GSASIIpath.py

    r3960 r3962  
    779779        global pdbBreak
    780780        pdbBreak = pdb.set_trace
    781         global IPyBreak
    782         IPyBreak = IPyBreak_base
     781        try:
     782            import IPython
     783            global IPyBreak
     784            IPyBreak = IPyBreak_base
     785        except:
     786            pass
    783787
    784788def TestSPG(fpth):
  • trunk/GSASIIplot.py

    r3961 r3962  
    542542            raise ValueError('Plot not found')
    543543
    544     def RaiseLastPage(self,lastRaisedPlotTab,treeItemPlot):
    545         '''Raises either the Last tab clicked on or what is drawn by the selected tree item
    546         This is called after a refinement is completed by :meth:`GSASIIdataGUI.GSASII.ResetPlots`
    547         '''
    548         plotNum = None
    549         if lastRaisedPlotTab in self.plotList:
    550             plotNum = self.plotList.index(lastRaisedPlotTab)
    551         elif treeItemPlot in self.plotList:
    552             plotNum = self.plotList.index(treeItemPlot)
    553         if plotNum is not None:
    554             wx.CallAfter(self.SetSelectionNoRefresh,plotNum)
     544    # def RaiseLastPage(self,lastRaisedPlotTab,treeItemPlot):
     545    #     '''Raises either the Last tab clicked on or what is drawn by the selected tree item
     546    #     This is called after a refinement is completed by :meth:`GSASIIdataGUI.GSASII.ResetPlots`
     547    #     '''
     548    #     plotNum = None
     549    #     if lastRaisedPlotTab in self.plotList:
     550    #         plotNum = self.plotList.index(lastRaisedPlotTab)
     551    #     elif treeItemPlot in self.plotList:
     552    #         plotNum = self.plotList.index(treeItemPlot)
     553    #     if plotNum is not None:
     554    #         wx.CallAfter(self.SetSelectionNoRefresh,plotNum)
    555555
    556556    def FindPlotTab(self,label,Type,newImage=True,publish=None):
     
    17561756            G2frame.PatternId = pId
    17571757        else:
     1758            if GSASIIpath.GetConfigValue('debug'): print('PatternName not found',PatternName)
    17581759            return
    17591760    if PickName == PatternName:
     
    17641765            G2frame.PickId = pId
    17651766        else:
     1767            if GSASIIpath.GetConfigValue('debug'): print('PickName not found',PickName)
    17661768            return
    17671769    elif GSASIIpath.GetConfigValue('debug'):
     
    27552757        G2frame.Bind(wx.EVT_MENU, onMovePeak, id=G2frame.dataWindow.movePeak.GetId())
    27562758    # save information needed to reload from tree and redraw
    2757     kwargs={'PatternName':G2frame.GPXtree.GetItemText(G2frame.PatternId)}
    2758     if G2frame.PickId:
    2759         kwargs['PickName'] = G2frame.GPXtree.GetItemText(G2frame.PickId)
    2760     #G2frame.G2plotNB.RegisterRedrawRoutine('Powder Patterns',ReplotPattern,
    2761     G2frame.G2plotNB.RegisterRedrawRoutine(G2frame.G2plotNB.lastRaisedPlotTab,ReplotPattern,
    2762                                            (G2frame,newPlot,plotType),kwargs)
     2759    if not refineMode:
     2760        kwargs={'PatternName':G2frame.GPXtree.GetItemText(G2frame.PatternId)}
     2761        if G2frame.PickId:
     2762            kwargs['PickName'] = G2frame.GPXtree.GetItemText(G2frame.PickId)
     2763        G2frame.G2plotNB.RegisterRedrawRoutine(G2frame.G2plotNB.lastRaisedPlotTab,ReplotPattern,
     2764                                            (G2frame,newPlot,plotType),kwargs)
    27632765    # now start plotting
    27642766    G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar
     
    53285330    W = []
    53295331    if 'C' in Parms['Type'][0]:
     5332        Plot.figure.suptitle(TreeItemText)
    53305333        Plot.set_title('Instrument and sample peak widths')
    53315334        Plot.set_xlabel(r'$Q, \AA^{-1}$',fontsize=14)
Note: See TracChangeset for help on using the changeset viewer.