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

rework updating of plots after a refinement

File:
1 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)
Note: See TracChangeset for help on using the changeset viewer.