Changeset 2531


Ignore:
Timestamp:
Nov 17, 2016 11:43:57 AM (5 years ago)
Author:
toby
Message:

reopen tree items after a refinement

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2528 r2531  
    249249#        if GSASIIpath.GetConfigValue('debug'): # allow exceptions for debugging
    250250#            item = parent.Append(help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL,
    251 #                text='Debug graphics refresh')
    252 #            self.Bind(wx.EVT_MENU, self.TestResetPlot, id=item.GetId())
     251#                text='tree test')
     252#            self.Bind(wx.EVT_MENU, self.TreeTest, id=item.GetId())
    253253
    254254    def _init_Imports(self):
     
    37503750        dlg.ShowModal()
    37513751        dlg.Destroy()
    3752        
     3752
    37533753    def OnRefine(self,event):
    37543754        '''Perform a refinement.
     
    37893789        Rw = 100.00
    37903790        self.SaveTreeSetting()
     3791        self.PatternTree.SaveExposedItems()       
    37913792        try:
    37923793            OK,Msg = G2stMn.Refine(self.GSASprojectfile,dlg)    #Msg is Rvals dict if Ok=True
     
    38093810                    self.HKL = []
    38103811                    G2IO.ProjFileOpen(self,False)
     3812                    self.PatternTree.RestoreExposedItems()       
    38113813                    self.ResetPlots()
    38123814            finally:
     
    39003902                             warnmsg+'\nRefinement not possible')
    39013903            return
     3904        self.PatternTree.SaveExposedItems()       
    39023905        dlg = wx.ProgressDialog('Residual for histogram 0','Powder profile Rwp =',101.0,
    39033906            style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT,
     
    39233926                        self.G2plotNB.clear()
    39243927                    G2IO.ProjFileOpen(self,False)
     3928                    self.PatternTree.RestoreExposedItems()
    39253929                    self.ResetPlots()
    39263930                    Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequential results')
  • trunk/GSASIIctrls.py

    r2527 r2531  
    220220        else:
    221221            return size,imagefile,None
     222
     223    def SaveExposedItems(self):
     224        '''Traverse the top level tree items and save names of exposed (expanded) tree items.
     225        Done before a refinement.
     226        '''
     227        self.ExposedItems = []
     228        item, cookie = self.GetFirstChild(self.root)
     229        while item:
     230            name = self.GetItemText(item)
     231            if self.IsExpanded(item): self.ExposedItems.append(name)
     232            item, cookie = self.GetNextChild(self.root, cookie)
     233        print 'exposed:',self.ExposedItems
     234
     235    def RestoreExposedItems(self):
     236        '''Traverse the top level tree items and restore exposed (expanded) tree items
     237        back to their previous state (done after a reload of the tree after a refinement)
     238        '''
     239        item, cookie = self.GetFirstChild(self.root)
     240        while item:
     241            name = self.GetItemText(item)
     242            if name in self.ExposedItems: self.Expand(item)
     243            item, cookie = self.GetNextChild(self.root, cookie)
    222244
    223245################################################################################
Note: See TracChangeset for help on using the changeset viewer.