Changeset 3781


Ignore:
Timestamp:
Jan 13, 2019 5:33:03 PM (3 years ago)
Author:
toby
Message:

Add seq. results exports to main Export menu; enable/disable export items depending on sequential mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3779 r3781  
    552552    def testSeqRefineMode(self):
    553553        '''Returns the list of histograms included in a sequential refinement or
    554         an empty list if a standard (non-sequential) refinement.
     554        an empty list if a standard (non-sequential) refinement.
     555        Also sets Menu item status depending on mode
    555556        '''
    556557        cId = GetGPXtreeItemId(self,self.root, 'Controls')
     
    558559            controls = self.GPXtree.GetItemPyData(cId)
    559560            seqSetting = controls.get('Seq Data',[])
    560             if seqSetting:
    561                 for item in self.Refine:
    562                     item.SetText('Se&quential refine')
    563             else:
    564                 for item in self.Refine:
    565                     item.SetText('&Refine')
    566             return seqSetting
     561        else:
     562            seqSetting = None
     563           
     564        if seqSetting:
     565            for item in self.Refine:
     566                item.SetText('Se&quential refine')
     567            seqMode = True
    567568        else:
    568569            for item in self.Refine:
    569570                item.SetText('&Refine')
    570             return None
     571            seqMode = False
     572        for menu in self.ExportSeq:
     573            for item in menu.GetMenuItems():
     574                menu.Enable(item.Id,seqMode)
     575        for menu in self.ExportNonSeq:
     576            for item in menu.GetMenuItems():
     577                menu.Enable(item.Id,not seqMode)
     578        return seqSetting
     579
    571580       
    572581    def PreviewFile(self,filename):
     
    25182527        projectmenu = wx.Menu()
    25192528        item = menu.AppendSubMenu(projectmenu,'Entire project as','Export entire project')
    2520 
     2529        self.ExportNonSeq.append(projectmenu)
     2530       
    25212531        phasemenu = wx.Menu()
    25222532        item = menu.AppendSubMenu(phasemenu,'Phase as','Export phase or sometimes phases')
     
    25342544        item = menu.AppendSubMenu(mapmenu,'Maps as','Export density map(s)')
    25352545
     2546        # sequential exports are handled differently; N.B. enabled in testSeqRefineMode
     2547        seqPhasemenu = wx.Menu()
     2548        item = menu.AppendSubMenu(seqPhasemenu,'Sequential phases','Export phases from sequential fit')
     2549        self.ExportSeq.append(seqPhasemenu)
     2550        seqHistmenu = wx.Menu()
     2551        item = menu.AppendSubMenu(seqHistmenu,'Sequential histograms','Export histograms from sequential fit')
     2552        self.ExportSeq.append(seqHistmenu)
     2553       
    25362554        # find all the exporter files
    25372555        if not self.exporterlist: # this only needs to be done once
     
    25622580                self.Bind(wx.EVT_MENU, obj.Exporter, id=item.GetId())
    25632581                self.ExportLookup[item.GetId()] = typ # lookup table for submenu item
     2582            for lbl,submenu in (('Phase',seqPhasemenu),
     2583                        ('Powder',seqHistmenu),
     2584                        ):
     2585                if lbl.lower() in obj.exporttype:
     2586                    try:
     2587                        obj.Writer
     2588                    except AttributeError:
     2589                        continue
     2590                    # define a unique event handler for this menu item
     2591                    def seqMenuItemEventHandler(event,obj=obj,typ=lbl):
     2592                        'This handler has the needed exporter/type embedded'
     2593                        # lookup sequential table
     2594                        Id = GetGPXtreeItemId(self,self.root,'Sequential results')
     2595                        if not Id:
     2596                            print('Error in Seq seqMenuItemEventHandler for ',typ,'without Seq Res table')
     2597                            return
     2598                        data = self.GPXtree.GetItemPyData(Id)
     2599                        G2IO.ExportSequential(self,data,obj,typ)
     2600                    if 'mode' in inspect.getargspec(obj.Writer)[0]:
     2601                        item = submenu.Append(wx.ID_ANY,obj.formatName,obj.longFormatName)
     2602                        self.Bind(wx.EVT_MENU, seqMenuItemEventHandler, item)
     2603                        #                    self.SeqExportLookup[item.GetId()] = (obj,lbl) # lookup table for submenu item
     2604                        # Bind is in UpdateSeqResults
     2605
    25642606        item = imagemenu.Append(wx.ID_ANY,'Multiple image controls and masks',
    25652607            'Export image controls and masks for multiple images')
     
    26952737        self.MakePDF = []
    26962738        self.Refine = []
     2739        self.ExportSeq = []
     2740        self.ExportNonSeq = []
    26972741        #self.ExportPattern = []
    26982742        self.ExportPeakList = []
     
    49775021        # fill sequential Export menu
    49785022        # for an exporter to be used for sequential exports, it must have a Writer method and
    4979         # that Writer method must offer a mode argument.
     5023        # that Writer method must offer a mode argument.
     5024        #============================================================
     5025        # N.B. this largely duplicates menu items now in Export
     5026        #============================================================
    49805027        self.SeqExportLookup = {}
    49815028        self.SequentialEx = wx.Menu(title='')
     
    66616708        if vals is None:
    66626709            print('Error: Id not found. This should not happen!')
     6710            return
    66636711        G2IO.ExportSequential(G2frame,data,*vals)
    66646712
Note: See TracChangeset for help on using the changeset viewer.