Changeset 92


Ignore:
Timestamp:
Jun 23, 2010 6:41:43 AM (12 years ago)
Author:
vondreel
Message:

more refactoring of UpdateUnitCellsGrid?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r91 r92  
    513513        ObjId = cellList.index(Obj.GetId())
    514514        try:
    515             if ibrav in [0,1,2]:
    516                 controls[6] = controls[7] = controls[8] = float(Obj.GetValue())
    517                 controls[9] = controls[10] = controls[11] = 90.0
    518             elif ibrav in [3,4,5,6]:
    519                 if ObjId == 0:
    520                     controls[6] = controls[7] = float(Obj.GetValue())
    521                 else:
    522                     controls[8] = float(Obj.GetValue())
    523                 controls[9] = controls[10] = controls[11] = 90.0
    524                 if ibrav in [3,4]:
    525                     controls[11] = 120.
    526             elif ibrav in [7,8,9,10]:
    527                 controls[6+ObjId] = float(Obj.GetValue())
    528                 controls[9] = controls[10] = controls[11] = 90.0
    529             elif ibrav in [11,12]:
    530                 controls[9] = controls[11] = 90.0
    531                 if ObjId != 3:
    532                     controls[6+ObjId] = float(Obj.GetValue())
    533                 else:
    534                     controls[10] = float(Obj.GetValue())
     515            value = max(1.0,float(Obj.GetValue()))
     516        except ValueError:
     517            if ObjId < 3:               #bad cell edge - reset
     518                value = controls[6+ObjId]
     519            else:                       #bad angle
     520                value = 90.
     521        if ibrav in [0,1,2]:
     522            controls[6] = controls[7] = controls[8] = value
     523            controls[9] = controls[10] = controls[11] = 90.0
     524            Obj.SetValue("%.5f"%(controls[6]))
     525        elif ibrav in [3,4,5,6]:
     526            if ObjId == 0:
     527                controls[6] = controls[7] = value
     528                Obj.SetValue("%.5f"%(controls[6]))
    535529            else:
    536                 controls[6+ObjId] = float(Obj.GetValue())
    537             controls[12] = G2lat.calc_V(G2lat.cell2A(controls[6:12]))
    538             UpdateUnitCellsGrid(self,data)
    539         except ValueError:
    540             Pass
     530                controls[8] = value
     531                Obj.SetValue("%.5f"%(controls[8]))
     532            controls[9] = controls[10] = controls[11] = 90.0
     533            if ibrav in [3,4]:
     534                controls[11] = 120.
     535        elif ibrav in [7,8,9,10]:
     536            controls[6+ObjId] = value
     537            Obj.SetValue("%.5f"%(controls[6+ObjId]))
     538            controls[9] = controls[10] = controls[11] = 90.0
     539        elif ibrav in [11,12]:
     540            controls[9] = controls[11] = 90.0
     541            if ObjId != 3:
     542                controls[6+ObjId] = value
     543                Obj.SetValue("%.5f"%(controls[6+ObjId]))
     544            else:
     545                controls[10] = value
     546                Obj.SetValue("%.3f"%(controls[6+ObjId]))
     547        else:
     548            controls[6+ObjId] = value
     549            if ObjId < 3:
     550                Obj.SetValue("%.5f"%(controls[6+ObjId]))
     551            else:
     552                Obj.SetValue("%.3f"%(controls[6+ObjId]))
     553        controls[12] = G2lat.calc_V(G2lat.cell2A(controls[6:12]))
     554        volVal.SetValue("%.3f"%(controls[12]))
    541555       
    542556    def OnRefineCell(event):
     
    675689        'Tetragonal-I','Tetragonal-P','Orthorhombic-F','Orthorhombic-I','Orthorhombic-C',
    676690        'Orthorhombic-P','Monoclinic-C','Monoclinic-P','Triclinic']
    677     cellGUIlist = [[[0,1,2],4,zip([" Unit cell: a = "," Vol = "],[True,False],[0,0])],
    678     [[3,4,5,6],6,zip([" Unit cell: a = "," c = "," Vol = "],[True,True,False],[0,2,0])],
    679     [[7,8,9,10],8,zip([" Unit cell: a = "," b = "," c = "," Vol = "],[True,True,True,False],[0,1,2,0])],
    680     [[11,12],10,zip([" Unit cell: a = "," b = "," c = "," beta = "," Vol = "],[True,True,True,True,False],[0,1,2,4,0])],
     691    cellGUIlist = [[[0,1,2],4,zip([" Unit cell: a = "," Vol = "],["%.5f","%.3f"],[True,False],[0,0])],
     692    [[3,4,5,6],6,zip([" Unit cell: a = "," c = "," Vol = "],["%.5f","%.5f","%.3f"],[True,True,False],[0,2,0])],
     693    [[7,8,9,10],8,zip([" Unit cell: a = "," b = "," c = "," Vol = "],["%.5f","%.5f","%.5f","%.3f"],
     694        [True,True,True,False],[0,1,2,0])],
     695    [[11,12],10,zip([" Unit cell: a = "," b = "," c = "," beta = "," Vol = "],
     696        ["%.5f","%.5f","%.5f","%.3f","%.3f"],[True,True,True,True,False],[0,1,2,4,0])],
    681697    [[13,],8,zip([" Unit cell: a = "," b = "," c = "," Vol = "," alpha = "," beta = "," gamma = "],
    682         [True,True,True,False,True,True,True],[0,1,2,0,3,4,6])]]
     698        ["%.5f","%.5f","%.5f","%.3f","%.3f","%.3f","%.3f"],
     699        [True,True,True,False,True,True,True],[0,1,2,0,3,4,5])]]
    683700   
    684701    self.dataFrame.SetLabel('Unit Cells List')
     
    738755    cellList = []
    739756    littleSizer = wx.FlexGridSizer(2,useGUI[1],5,5)
    740     for txt,ifEdit,Id in useGUI[2]:
     757    for txt,fmt,ifEdit,Id in useGUI[2]:
    741758        littleSizer.Add(wx.StaticText(self.dataDisplay,label=txt),0,wx.ALIGN_CENTER_VERTICAL)
    742759        if ifEdit:          #a,b,c,etc.
    743             cellVal = wx.TextCtrl(self.dataDisplay,value=("%.5f"%(controls[6+Id])),style=wx.TE_PROCESS_ENTER)
     760            cellVal = wx.TextCtrl(self.dataDisplay,value=(fmt%(controls[6+Id])),style=wx.TE_PROCESS_ENTER)
    744761            cellVal.Bind(wx.EVT_TEXT_ENTER,OnCellChange)       
    745762            littleSizer.Add(cellVal,0,wx.ALIGN_CENTER_VERTICAL)
    746763            cellList.append(cellVal.GetId())
    747764        else:               #volume
    748             littleSizer.Add(wx.TextCtrl(self.dataDisplay,value=("%.3f"%(controls[12])),style=wx.TE_READONLY),0,wx.ALIGN_CENTER_VERTICAL)
     765            volVal = wx.TextCtrl(self.dataDisplay,value=(fmt%(controls[12])),style=wx.TE_READONLY)
     766            littleSizer.Add(volVal,0,wx.ALIGN_CENTER_VERTICAL)
    749767    mainSizer.Add(littleSizer,0)
    750768    mainSizer.Layout()   
Note: See TracChangeset for help on using the changeset viewer.