Ignore:
Timestamp:
May 31, 2016 4:48:18 PM (6 years ago)
Author:
vondreele
Message:

add FindAllNeighbors? to G2math for finding all symm equiv neighbors
add bond & angle pseudovariables for seq results - not finished
fix float problems for outChannels & LRazimuth - should be int

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIexprGUI.py

    r2298 r2301  
    3535import GSASIIpy3 as G2py3
    3636import GSASIIobj as G2obj
     37import GSASIImath as G2mth
     38
     39# Define a short name for convenience
     40WACV = wx.ALIGN_CENTER_VERTICAL
    3741
    3842def IndexParmDict(parmDict,wildcard):
     
    678682           
    679683#==========================================================================
    680 #class BondDialog(wx.Dialog):
     684class BondDialog(wx.Dialog):
    681685    '''A wx.Dialog that allows a user to select a bond length to be evaluated.
    682686    What needs to be done here? Need phase info for atoms
     
    687691    Use existing bond & esd calculate routines
    688692    '''
     693    def __init__(self, parent, Phases, parmDict, exprObj=None,
     694                 header='Enter restraint expression here',
     695                 wintitle='Expression Editor',
     696                 VarLabel=None,depVarDict=None,
     697                 ExtraButton=None,usedVars=[]):
     698        wx.Dialog.__init__(self,parent,wx.ID_ANY,wintitle,
     699            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
     700        self.panel = wx.Panel(self)         #just a dummy - gets destroyed in Draw!
     701        self.Phases = Phases
     702        self.parmDict = parmDict
     703        self.header = header
     704        self.pName = Phases.keys()[0]
     705        DisAglCtls = {}
     706        dlg = G2gd.DisAglDialog(self.panel,DisAglCtls,self.Phases[self.pName]['General'],Reset=False)
     707        if dlg.ShowModal() == wx.ID_OK:
     708            Phases[self.pName]['General']['DisAglCtls'] = dlg.GetData()
     709        dlg.Destroy()
     710        self.Oatom = ''
     711        self.Tatom = ''
     712       
     713        self.Draw()
     714       
     715    def Draw(self):
     716       
     717        def OnPhase(event):
     718            Obj = event.GetEventObject()
     719            self.pName = Obj.GetValue()
     720            self.Oatom = ''
     721            DisAglCtls = {}
     722            dlg = G2gd.DisAglDialog(self.panel,DisAglCtls,self.Phases[self.pName]['General'],Reset=False)
     723            if dlg.ShowModal() == wx.ID_OK:
     724                self.Phases[self.pName]['General']['DisAglCtls'] = dlg.GetData()
     725            dlg.Destroy()
     726            self.Draw()
     727           
     728        def OnOrigAtom(event):
     729            Obj = event.GetEventObject()
     730            self.Oatom = Obj.GetValue()
     731            self.Draw()
     732           
     733        def OnTargAtom(event):
     734            Obj = event.GetEventObject()
     735            self.Tatom = Obj.GetValue()
     736            self.Draw()
     737
     738        self.panel.Destroy()
     739        self.panel = wx.Panel(self)
     740        mainSizer = wx.BoxSizer(wx.VERTICAL)
     741        mainSizer.Add(wx.StaticText(self.panel,label=self.header),0,WACV)
     742        pNames = self.Phases.keys()
     743        phaseSizer = wx.BoxSizer(wx.HORIZONTAL)
     744        phaseSizer.Add(wx.StaticText(self.panel,label=' Select phase: '),0,WACV)
     745        phase = wx.ComboBox(self.panel,value=self.pName,choices=pNames,
     746            style=wx.CB_READONLY|wx.CB_DROPDOWN)
     747        phase.Bind(wx.EVT_COMBOBOX,OnPhase)
     748        phaseSizer.Add(phase,0,WACV)
     749        mainSizer.Add(phaseSizer)
     750        Phase = self.Phases[self.pName]
     751        cx,ct = Phase['General']['AtomPtrs'][:2]
     752        Atoms = Phase['Atoms']
     753        aNames = [atom[ct-1] for atom in Atoms]
     754        atomSizer = wx.BoxSizer(wx.HORIZONTAL)
     755        atomSizer.Add(wx.StaticText(self.panel,label=' Origin atom: '),0,WACV)
     756        origAtom = wx.ComboBox(self.panel,value=self.Oatom,choices=aNames,
     757            style=wx.CB_READONLY|wx.CB_DROPDOWN)
     758        origAtom.Bind(wx.EVT_COMBOBOX,OnOrigAtom)
     759        atomSizer.Add(origAtom,0,WACV)
     760        atomSizer.Add(wx.StaticText(self.panel,label=' distance to: '),0,WACV)
     761        neigh = []
     762        if self.Oatom:
     763#            GSASIIpath.IPyBreak()
     764            neigh = G2mth.FindAllNeighbors(Phase,self.Oatom,aNames)
     765        bNames = ['',]
     766        if neigh:
     767            bNames = [item[0]+' d=%.3f'%(item[1]) for item in neigh[0]]
     768        targAtom = wx.ComboBox(self.panel,value=self.Tatom,choices=bNames,
     769            style=wx.CB_READONLY|wx.CB_DROPDOWN)
     770        targAtom.Bind(wx.EVT_COMBOBOX,OnTargAtom)
     771        atomSizer.Add(targAtom,0,WACV)
     772       
     773        mainSizer.Add(atomSizer)
     774
     775
     776        OkBtn = wx.Button(self.panel,-1,"Ok")
     777        OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
     778        cancelBtn = wx.Button(self.panel,-1,"Cancel")
     779        cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
     780        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
     781        btnSizer.Add((20,20),1)
     782        btnSizer.Add(OkBtn)
     783        btnSizer.Add((20,20),1)
     784        btnSizer.Add(cancelBtn)
     785        btnSizer.Add((20,20),1)
     786       
     787        mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
     788        self.panel.SetSizer(mainSizer)
     789        self.panel.Fit()
     790        self.Fit()
     791
     792    def GetSelection(self):
     793        exprObj = G2obj.ExpressionObj()
     794        exprObj.LoadExpression(
     795            self.expr,
     796            self.exprVarLst,
     797            self.varSelect,
     798            self.varName,
     799            self.varValue,
     800            self.varRefflag,
     801            )
     802        if self.depVarDict:
     803            exprObj.SetDepVar(self.dependentVar)
     804        return exprObj
     805
     806    def OnOk(self,event):
     807        parent = self.GetParent()
     808        parent.Raise()
     809        self.EndModal(wx.ID_OK)
     810
     811    def OnCancel(self,event):
     812        parent = self.GetParent()
     813        parent.Raise()
     814        self.EndModal(wx.ID_CANCEL)       
     815           
    689816#==========================================================================
    690 #class AngleDialog(wx.Dialog):
     817class AngleDialog(wx.Dialog):
    691818    '''A wx.Dialog that allows a user to select a bond angle to be evaluated.
    692819    What needs to be done here? Need phase info for atom
     
    697824    Use existing angle & esd calculate routines
    698825    '''
     826    def __init__(self, parent, Phases, parmDict, exprObj=None,
     827                 header='Enter restraint expression here',
     828                 wintitle='Expression Editor',
     829                 VarLabel=None,depVarDict=None,
     830                 ExtraButton=None,usedVars=[]):
     831        wx.Dialog.__init__(self,parent,wx.ID_ANY,wintitle,
     832            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
     833        self.panel = wx.Panel(self)         #just a dummy - gets destroyed in Draw!
     834        self.Phases = Phases
     835        self.parmDict = parmDict
     836        self.header = header
     837        self.pName = Phases.keys()[0]
     838        self.Oatom = ''
     839       
     840        self.Draw()
     841
     842    def Draw(self):
     843       
     844        def OnPhase(event):
     845            Obj = event.GetEventObject()
     846            self.pName = Obj.GetValue()
     847            self.Draw()
     848           
     849        def OnOrigAtom(event):
     850            Obj = event.GetEventObject()
     851            self.Oatom = Obj.GetValue()
     852            self.Draw()
     853           
     854
     855        self.panel.Destroy()
     856        self.panel = wx.Panel(self)
     857        mainSizer = wx.BoxSizer(wx.VERTICAL)
     858        mainSizer.Add(wx.StaticText(self.panel,label=self.header),0,WACV)
     859        pNames = self.Phases.keys()
     860        phaseSizer = wx.BoxSizer(wx.HORIZONTAL)
     861        phaseSizer.Add(wx.StaticText(self.panel,label=' Select phase: '),0,WACV)
     862        phase = wx.ComboBox(self.panel,value=self.pName,choices=pNames,
     863            style=wx.CB_READONLY|wx.CB_DROPDOWN)
     864        phase.Bind(wx.EVT_COMBOBOX,OnPhase)
     865        phaseSizer.Add(phase,0,WACV)
     866        mainSizer.Add(phaseSizer)
     867        Phase = self.Phases[self.pName]
     868        cx,ct = Phase['General']['AtomPtrs'][:2]
     869        Atoms = Phase['Atoms']
     870        aNames = [atom[ct-1] for atom in Atoms]
     871#        GSASIIpath.IPyBreak()
     872        atomSizer = wx.BoxSizer(wx.HORIZONTAL)
     873        atomSizer.Add(wx.StaticText(self.panel,label=' Origin atom: '),0,WACV)
     874        origAtom = wx.ComboBox(self.panel,value=self.Oatom,choices=aNames,
     875            style=wx.CB_READONLY|wx.CB_DROPDOWN)
     876        origAtom.Bind(wx.EVT_COMBOBOX,OnOrigAtom)
     877        atomSizer.Add(origAtom,0,WACV)
     878       
     879        mainSizer.Add(atomSizer)
     880
     881
     882        OkBtn = wx.Button(self.panel,-1,"Ok")
     883        OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
     884        cancelBtn = wx.Button(self.panel,-1,"Cancel")
     885        cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
     886        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
     887        btnSizer.Add((20,20),1)
     888        btnSizer.Add(OkBtn)
     889        btnSizer.Add((20,20),1)
     890        btnSizer.Add(cancelBtn)
     891        btnSizer.Add((20,20),1)
     892       
     893        mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
     894        self.panel.SetSizer(mainSizer)
     895        self.panel.Fit()
     896        self.Fit()
     897
     898    def GetSelection(self):
     899        return []
     900
     901    def OnOk(self,event):
     902        parent = self.GetParent()
     903        parent.Raise()
     904        self.EndModal(wx.ID_OK)
     905
     906    def OnCancel(self,event):
     907        parent = self.GetParent()
     908        parent.Raise()
     909        self.EndModal(wx.ID_CANCEL)       
     910                   
    699911       
    700912if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.