Changeset 807


Ignore:
Timestamp:
Nov 27, 2012 4:43:28 PM (13 years ago)
Author:
vondreele
Message:

add ability to move atoms on the plot
start on bond restraint adding GUI
add format to the SingleFloatDialog?
fix atom selection bug in PlotStructure?

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIgrid.py

    r796 r807  
    4949[ wxID_ATOMSEDITADD, wxID_ATOMSEDITINSERT, wxID_ATOMSEDITDELETE, wxID_ATOMSREFINE,
    5050    wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSVIEWADD, wxID_ATOMVIEWINSERT,
    51     wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,
    52 ] = [wx.NewId() for item in range(10)]
     51    wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,
     52] = [wx.NewId() for item in range(11)]
    5353
    5454[ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR,
     
    710710        self.AtomEdit.Append(id=wxID_ATOMVIEWINSERT, kind=wx.ITEM_NORMAL,text='Insert view point',
    711711            help='Select atom row to insert before; inserted as an H atom')
     712        self.AtomEdit.Append(id=wxID_ATOMMOVE, kind=wx.ITEM_NORMAL,text='Move atom to view point',
     713            help='Select single atom to move')
    712714        self.AtomEdit.Append(id=wxID_ATOMSEDITDELETE, kind=wx.ITEM_NORMAL,text='Delete atom',
    713715            help='Select atoms to delete first')
     
    18961898           
    18971899    def AddBondRestraint():
    1898         print 'Bond restraint'
     1900        General = phasedata['General']
     1901        cx,ct = General['AtomPtrs'][:2]
     1902        Atoms = phasedata['Atoms']
     1903        radiiDict = dict(zip(General['AtomTypes'],General['BondRadii']))
     1904        Names = ['all '+ name for name in General['AtomTypes']]
     1905        Types = [name for name in General['AtomTypes']]
     1906        Names += [atom[ct-1] for atom in Atoms]
     1907        Types += [atom[ct] for atom in Atoms]
     1908        Lists = {'origin':[],'target':[]}
     1909        for listName in ['origin','target']:
     1910            dlg = wx.MultiChoiceDialog(G2frame,'Bond restraint'+listName+' for '+General['Name'],
     1911                    'Select bond restraint '+listName+' atoms',Names)
     1912            if dlg.ShowModal() == wx.ID_OK:
     1913                sel = dlg.GetSelections()
     1914                for x in sel:
     1915                    Lists[listName].append([Names[x],Types[x]])
     1916        SGData = General['SGData']
     1917        Bonds = restrData['Bond']['Bonds']
    18991918
    19001919    def AddAngleRestraint():
     
    19511970            Bonds.ClearSelection()
    19521971            val = bondList[rows[0]][4]
    1953             dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new value for bond',val,[0.,5.])
     1972            dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new value for bond',val,[0.,5.],'%.4f')
    19541973            if dlg.ShowModal() == wx.ID_OK:
    19551974                parm = dlg.GetValue()
     
    19651984            Bonds.ClearSelection()
    19661985            val = bondList[rows[0]][5]
    1967             dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new esd for bond',val,[0.,1.])
     1986            dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new esd for bond',val,[0.,1.],'%.4f')
    19681987            if dlg.ShowModal() == wx.ID_OK:
    19691988                parm = dlg.GetValue()
     
    20412060            Angles.ClearSelection()
    20422061            val = angleList[rows[0]][4]
    2043             dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new value for angle',val,[0.,360.])
     2062            dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new value for angle',val,[0.,360.],'%.2f')
    20442063            if dlg.ShowModal() == wx.ID_OK:
    20452064                parm = dlg.GetValue()
     
    20552074            Angles.ClearSelection()
    20562075            val = angleList[rows[0]][5]
    2057             dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new esd for angle',val,[0.,5.])
     2076            dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new esd for angle',val,[0.,5.],'%.2f')
    20582077            if dlg.ShowModal() == wx.ID_OK:
    20592078                parm = dlg.GetValue()
  • TabularUnified trunk/GSASIIphsGUI.py

    r804 r807  
    244244class SingleFloatDialog(wx.Dialog):
    245245   
    246     def __init__(self,parent,title,prompt,value,limits=[0.,1.]):
     246    def __init__(self,parent,title,prompt,value,limits=[0.,1.],format='%.5g'):
    247247        wx.Dialog.__init__(self,parent,-1,title,
    248248            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
     
    251251        self.value = value
    252252        self.prompt = prompt
     253        self.format = format
    253254        self.Draw()
    254255       
     
    263264                val = self.value
    264265            self.value = val
    265             valItem.SetValue('%.5g'%(self.value))
     266            valItem.SetValue(self.format%(self.value))
    266267           
    267268        self.panel.Destroy()
     
    269270        mainSizer = wx.BoxSizer(wx.VERTICAL)
    270271        mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER)
    271         valItem = wx.TextCtrl(self.panel,-1,value='%.5g'%(self.value),style=wx.TE_PROCESS_ENTER)
     272        valItem = wx.TextCtrl(self.panel,-1,value=self.format%(self.value),style=wx.TE_PROCESS_ENTER)
    272273        mainSizer.Add(valItem,0,wx.ALIGN_CENTER)
    273274        valItem.Bind(wx.EVT_TEXT_ENTER,OnValItem)
     
    970971        atomData = data['Atoms']
    971972        DData = data['Drawing']
    972         Items = [G2gd.wxID_ATOMSEDITINSERT, G2gd.wxID_ATOMSEDITDELETE, G2gd.wxID_ATOMSREFINE,
    973             G2gd.wxID_ATOMSMODIFY, G2gd.wxID_ATOMSTRANSFORM, G2gd.wxID_ATOMVIEWINSERT]
     973        Items = [G2gd.wxID_ATOMSEDITINSERT,G2gd.wxID_ATOMSEDITDELETE,G2gd.wxID_ATOMSREFINE,
     974            G2gd.wxID_ATOMSMODIFY,G2gd.wxID_ATOMSTRANSFORM,G2gd.wxID_ATOMVIEWINSERT,G2gd.wxID_ATOMMOVE]
    974975        if atomData:
    975976            for item in Items:   
     
    978979            for item in Items:
    979980                G2frame.dataFrame.AtomsMenu.Enable(item,False)
    980         Items = [G2gd.wxID_ATOMVIEWINSERT, G2gd.wxID_ATOMSVIEWADD]
     981        Items = [G2gd.wxID_ATOMVIEWINSERT, G2gd.wxID_ATOMSVIEWADD,G2gd.wxID_ATOMMOVE]
    981982        if 'showABC' in data['Drawing']:
    982983            for item in Items:
     
    13711372            FillAtomsGrid()
    13721373        event.StopPropagation()
     1374
     1375    def OnAtomMove(event):
     1376        drawData = data['Drawing']
     1377        atomData = data['Atoms']
     1378        x,y,z = drawData['viewPoint'][0]
     1379        colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())]
     1380        cx = colLabels.index('x')
     1381        indx = Atoms.GetSelectedRows()
     1382        if len(indx) != 1:
     1383            print '**** ERROR - only one atom can be moved ****'
     1384        else:
     1385            atomData[indx[0]][cx:cx+3] = [x,y,z]
     1386            SetupGeneral()
     1387            FillAtomsGrid()
     1388            ID = atomData[indx[0]][-1]
     1389            DrawAtomsReplaceByID(data['Drawing'],atomData[indx[0]],ID)
     1390            G2plt.PlotStructure(G2frame,data)
     1391        event.StopPropagation()
    13731392           
    13741393    def AtomInsert(x,y,z):
     
    14301449            dlg.Destroy()
    14311450
    1432     def AtomModify(event):                  #intent to implement global modifications (+,-,*,/, etc.)?
     1451    def AtomModify(event):
    14331452        indx = Atoms.GetSelectedRows()
    14341453        if indx:
     
    17231742                bondData = restData[PhaseName]['Bond']
    17241743            except KeyError:
    1725                 bondData = {'wtFactor':1.0,'Bonds':[]}
     1744                bondData = {'wtFactor':1.0,'Bonds':[],'Use':True}
    17261745                restData[PhaseName] = {}
    17271746                restData[PhaseName]['Bond'] = bondData
     
    17321751                angleData = restData[PhaseName]['Angle']
    17331752            except KeyError:
    1734                 angleData = {'wtFactor':1.0,'Angles':[]}
     1753                angleData = {'wtFactor':1.0,'Angles':[],'Use':True}
    17351754                restData[PhaseName] = {}
    17361755                restData[PhaseName]['Angle'] = angleData
     
    17411760                planeData = restData[PhaseName]['Plane']
    17421761            except KeyError:
    1743                 planeData = {'wtFactor':1.0,'Planes':[]}
     1762                planeData = {'wtFactor':1.0,'Planes':[],'Use':True}
    17441763                restData[PhaseName] = {}
    17451764                restData[PhaseName]['Plane'] = planeData
     
    17501769                chiralData = restData[PhaseName]['Chiral']
    17511770            except KeyError:
    1752                 chiralData = {'wtFactor':1.0,'Volumes':[]}
     1771                chiralData = {'wtFactor':1.0,'Volumes':[],'Use':True}
    17531772                restData[PhaseName] = {}
    17541773                restData[PhaseName]['Chiral'] = chiralData
     
    41734192            for ind in Ind:
    41744193                mag,x,y,z,d = mapPeaks[ind]
    4175                 AtomAdd(x,y,z,'C',Name='M '+'%d'%(int(100*mag/peakMax)))
     4194                AtomAdd(x,y,z,'H',Name='M '+'%d'%(int(100*mag/peakMax)))
    41764195   
    41774196    def OnPeaksClear(event):
     
    44454464            G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomInsert, id=G2gd.wxID_ATOMSEDITINSERT)
    44464465            G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomViewInsert, id=G2gd.wxID_ATOMVIEWINSERT)
     4466            G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomMove, id=G2gd.wxID_ATOMMOVE)
    44474467            G2frame.dataFrame.Bind(wx.EVT_MENU, AtomDelete, id=G2gd.wxID_ATOMSEDITDELETE)
    44484468            G2frame.dataFrame.Bind(wx.EVT_MENU, AtomRefine, id=G2gd.wxID_ATOMSREFINE)
  • TabularUnified trunk/GSASIIplot.py

    r803 r807  
    26932693                G2frame.dataDisplay.GetPage(page).SelectRow(ind,Add)                 
    26942694            elif G2frame.dataDisplay.GetPageText(page) == 'Atoms':
    2695                 Id = drawAtoms[ind][-2]
     2695                Id = drawAtoms[ind][-3]
    26962696                for i,atom in enumerate(atomData):
    26972697                    if atom[-1] == Id:
Note: See TracChangeset for help on using the changeset viewer.