Changeset 880


Ignore:
Timestamp:
Apr 3, 2013 5:05:21 PM (9 years ago)
Author:
toby
Message:

Implement read for Reimport

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r865 r880  
    6060[ wxID_ATOMSEDITADD, wxID_ATOMSEDITINSERT, wxID_ATOMSEDITDELETE, wxID_ATOMSREFINE,
    6161    wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSVIEWADD, wxID_ATOMVIEWINSERT,
    62     wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,wxID_RBAPPEND,wxID_ATOMSREIMPORT,
     62    wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,wxID_RBAPPEND,
    6363    wxID_ASSIGNATMS2RB
    64 ] = [wx.NewId() for item in range(14)]
     64] = [wx.NewId() for item in range(13)]
    6565
    6666[ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR,
     
    11441144        self.AtomEdit.Append(id=wxID_RELOADDRAWATOMS, kind=wx.ITEM_NORMAL,text='Reload draw atoms',
    11451145            help='Reload atom drawing list')
    1146         self.AtomEdit.Append(id=wxID_ATOMSREIMPORT, kind=wx.ITEM_NORMAL,text='Reimport atoms',
     1146        submenu = wx.Menu()
     1147        self.AtomEdit.AppendMenu(wx.ID_ANY, 'Reimport atoms', submenu,
    11471148            help='Reimport atoms from file; sequence must match')
     1149        # setup a cascade menu for the formats that have been defined
     1150        self.ReImportMenuId = {}  # points to readers for each menu entry
     1151        for reader in self.G2frame.ImportPhaseReaderlist:
     1152            item = submenu.Append(
     1153                wx.ID_ANY,help=reader.longFormatName,
     1154                kind=wx.ITEM_NORMAL,text='reimport coordinates from '+reader.formatName+' file')
     1155            self.ReImportMenuId[item.GetId()] = reader
     1156        item = submenu.Append(
     1157            wx.ID_ANY,
     1158            help='Reimport coordinates, try to determine format from file',
     1159            kind=wx.ITEM_NORMAL,
     1160            text='guess format from file')
     1161        self.ReImportMenuId[item.GetId()] = None # try all readers
     1162
    11481163        self.AtomCompute.Append(id=wxID_ATOMSDISAGL, kind=wx.ITEM_NORMAL,text='Distances && Angles',
    11491164            help='Compute distances & angles for selected atoms')
  • trunk/GSASIIphsGUI.py

    r879 r880  
    15111511               
    15121512    def OnReImport(event):
    1513 # sort of the right idea but don't want new tree entry!
    1514 #        G2frame._Add_ImportMenu_Phase(G2frame.dataFrame.AtomEdit)
    15151513        print 'reimport atoms from file to be developed'
     1514        reqrdr = G2frame.dataFrame.ReImportMenuId.get(event.GetId())
     1515        rdlist = G2frame.OnImportGeneric(reqrdr,
     1516                                         G2frame.ImportPhaseReaderlist,
     1517                                         'phase')
     1518        if len(rdlist) == 0: return
     1519        # for now rdlist is only expected to have one element
     1520        # for now always use the first phase for when multiple phases are ever implemented
     1521        # but it would be better to loop until we find a phase that matches the one in data
     1522        for rd in rdlist:
     1523            # rd contains all info for a phase
     1524            PhaseName = rd.Phase['General']['Name']
     1525            print 'Read phase '+str(PhaseName)+' from file '+str(G2frame.lastimport)
     1526            print rd.Phase['Atoms']
     1527            return
    15161528                       
    15171529################################################################################
     
    43044316            G2frame.dataFrame.Bind(wx.EVT_MENU, OnReloadDrawAtoms, id=G2gd.wxID_RELOADDRAWATOMS)
    43054317            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDistAngle, id=G2gd.wxID_ATOMSDISAGL)
    4306             G2frame.dataFrame.Bind(wx.EVT_MENU, OnReImport, id=G2gd.wxID_ATOMSREIMPORT)
     4318            for id in G2frame.dataFrame.ReImportMenuId:
     4319                G2frame.dataFrame.Bind(wx.EVT_MENU, OnReImport, id=id)
     4320           
    43074321            FillAtomsGrid(Atoms)
    43084322        elif text == 'General':
Note: See TracChangeset for help on using the changeset viewer.