Changeset 739
- Timestamp:
- Aug 27, 2012 4:04:20 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r736 r739 19 19 import GSASIIpath 20 20 GSASIIpath.SetVersionNumber("$Revision$") 21 import GSASIImath as G2mth 21 22 import GSASIIIO as G2IO 22 23 import GSASIIplot as G2plt … … 92 93 ] = [wx.NewId() for item in range(4)] 93 94 94 [ wxID_RESTRAINTADD,wxID_PWDANALYSIS, wxID_RESTSELPHASE,wxID_RESTDELETE, 95 ] = [wx.NewId() for item in range(4)] 95 [ wxID_RESTRAINTADD,wxID_PWDANALYSIS, wxID_RESTSELPHASE,wxID_RESTDELETE, wxID_RESRCHANGEVAL, 96 wxID_RESTCHANGEESD, 97 ] = [wx.NewId() for item in range(6)] 96 98 97 99 [ wxID_SAVESEQSEL, … … 290 292 self.RestraintEdit.Append(id=wxID_RESTRAINTADD, kind=wx.ITEM_NORMAL,text='Add restraints', 291 293 help='Add restraints') 294 self.RestraintEdit.Append(id=wxID_RESRCHANGEVAL, kind=wx.ITEM_NORMAL,text='Change value', 295 help='Change observed value') 296 self.RestraintEdit.Append(id=wxID_RESTCHANGEESD, kind=wx.ITEM_NORMAL,text='Change esd', 297 help='Change esd in observed value') 292 298 self.RestraintEdit.Append(id=wxID_RESTDELETE, kind=wx.ITEM_NORMAL,text='Delete restraints', 293 299 help='Delete selected restraints') … … 627 633 def _init_ctrls(self, parent,name=None,size=None,pos=None): 628 634 wx.Frame.__init__(self,parent=parent, 629 style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT ^ wx.CLOSE_BOX,635 style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX | wx.FRAME_FLOAT_ON_PARENT , 630 636 size=size,pos=pos,title='GSAS-II data display') 631 637 self._init_menus() … … 655 661 self.DestroyChildren() 656 662 663 ################################################################################ 664 ##### GSNotebook 665 ################################################################################ 666 657 667 class GSNoteBook(wx.Notebook): 658 668 def __init__(self, parent, name='',size = None): … … 669 679 return page 670 680 681 ################################################################################ 682 ##### GSGrid 683 ################################################################################ 684 671 685 class GSGrid(wg.Grid): 672 686 def __init__(self, parent, name=''): … … 685 699 return None 686 700 701 ################################################################################ 702 ##### Table 703 ################################################################################ 704 687 705 class Table(wg.PyGridTableBase): 688 706 def __init__(self, data=[], rowLabels=None, colLabels=None, types = None): … … 818 836 innerSetValue(row, col, value) 819 837 838 ################################################################################ 839 ##### Notebook 840 ################################################################################ 841 820 842 def UpdateNotebook(G2frame,data): 821 843 if data: … … 827 849 G2frame.dataDisplay.AppendText('Notebook entry @ '+time.ctime()+"\n") 828 850 851 ################################################################################ 852 ##### Controls 853 ################################################################################ 854 829 855 def UpdateControls(G2frame,data): 830 856 #patch … … 984 1010 G2frame.dataFrame.setSizePosLeft(mainSizer.Fit(G2frame.dataFrame)) 985 1011 1012 ################################################################################ 1013 ##### Comments 1014 ################################################################################ 1015 986 1016 def UpdateComments(G2frame,data): 987 1017 G2frame.dataFrame.SetLabel('Comments') … … 994 1024 G2frame.dataDisplay.AppendText(line+'\n') 995 1025 1026 ################################################################################ 1027 ##### Sequential Results 1028 ################################################################################ 1029 996 1030 def UpdateSeqResults(G2frame,data): 997 1031 """ … … 1134 1168 G2frame.dataFrame.setSizePosLeft([700,350]) 1135 1169 1170 ################################################################################ 1171 ##### Constraints 1172 ################################################################################ 1173 1136 1174 def UpdateConstraints(G2frame,data): 1137 1175 '''Called when Constraints tree item is selected. … … 1620 1658 print 'Unexpected contraint warning:\n',warnmsg 1621 1659 1660 ################################################################################ 1661 ##### Restraints 1662 ################################################################################ 1663 1622 1664 def UpdateRestraints(G2frame,data,Phases,phaseName): 1623 1665 if not len(Phases): … … 1696 1738 def UpdateBondRestr(bondRestData): 1697 1739 1698 def ChangeCell(event): 1699 r,c = event.GetRow(),event.GetCol() 1700 if r >= 0 and c >= 0: 1701 bondList[r][c+2] = table[r][c] 1702 1740 def OnColSort(event): 1741 r,c = event.GetRow(),event.GetCol() 1742 if r < 0 and c == 0: 1743 names = G2mth.sortArray(table,0) 1744 bonds = [] 1745 for name in names: 1746 idx = table.index(name) 1747 bonds.append(bondList[idx]) 1748 bondRestData['Bonds'] = bonds 1749 UpdateBondRestr(bondRestData) 1750 1751 def OnChangeValue(event): 1752 rows = Bonds.GetSelectedRows() 1753 if not rows: 1754 return 1755 Bonds.ClearSelection() 1756 val = bondList[rows[0]][4] 1757 dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new value for bond',val,[0.,5.]) 1758 if dlg.ShowModal() == wx.ID_OK: 1759 parm = dlg.GetValue() 1760 for r in rows: 1761 bondList[r][4] = parm 1762 dlg.Destroy() 1763 UpdateBondRestr(bondRestData) 1764 1765 def OnChangeEsd(event): 1766 rows = Bonds.GetSelectedRows() 1767 if not rows: 1768 return 1769 Bonds.ClearSelection() 1770 val = bondList[rows[0]][5] 1771 dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new esd for bond',val,[0.,1.]) 1772 if dlg.ShowModal() == wx.ID_OK: 1773 parm = dlg.GetValue() 1774 for r in rows: 1775 bondList[r][5] = parm 1776 dlg.Destroy() 1777 UpdateBondRestr(bondRestData) 1778 1703 1779 def OnDeleteRestraint(event): 1704 1780 rows = Bonds.GetSelectedRows() 1781 if not rows: 1782 return 1705 1783 Bonds.ClearSelection() 1706 1784 rows.sort() … … 1733 1811 Bonds.SetReadOnly(r,c,True) 1734 1812 Bonds.SetCellStyle(r,c,VERY_LIGHT_GREY,True) 1735 Bonds.Bind(wg.EVT_GRID_ CELL_CHANGE, ChangeCell)1813 Bonds.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK,OnColSort) 1736 1814 G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=wxID_RESTDELETE) 1815 G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=wxID_RESRCHANGEVAL) 1816 G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=wxID_RESTCHANGEESD) 1737 1817 mainSizer.Add(Bonds,0,) 1738 1818 else: … … 1747 1827 1748 1828 def UpdateAngleRestr(angleRestData): 1749 1750 def ChangeCell(event): 1751 r,c = event.GetRow(),event.GetCol() 1752 if r >= 0 and c >= 0: 1753 angleList[r][c+2] = table[r][c] 1754 1829 1830 def OnColSort(event): 1831 r,c = event.GetRow(),event.GetCol() 1832 if r < 0 and c == 0: 1833 names = G2mth.sortArray(table,0) 1834 angles = [] 1835 for name in names: 1836 idx = table.index(name) 1837 angles.append(angleList[idx]) 1838 angleRestData['Angles'] = angles 1839 UpdateAngleRestr(angleRestData) 1840 1841 def OnChangeValue(event): 1842 rows = Angles.GetSelectedRows() 1843 if not rows: 1844 return 1845 Angles.ClearSelection() 1846 val = angleList[rows[0]][4] 1847 dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new value for angle',val,[0.,360.]) 1848 if dlg.ShowModal() == wx.ID_OK: 1849 parm = dlg.GetValue() 1850 for r in rows: 1851 angleList[r][4] = parm 1852 dlg.Destroy() 1853 UpdateAngleRestr(angleRestData) 1854 1855 def OnChangeEsd(event): 1856 rows = Angles.GetSelectedRows() 1857 if not rows: 1858 return 1859 Angles.ClearSelection() 1860 val = angleList[rows[0]][5] 1861 dlg = G2phG.SingleFloatDialog(G2frame,'New value','Enter new esd for angle',val,[0.,5.]) 1862 if dlg.ShowModal() == wx.ID_OK: 1863 parm = dlg.GetValue() 1864 for r in rows: 1865 angleList[r][5] = parm 1866 dlg.Destroy() 1867 UpdateAngleRestr(angleRestData) 1868 1755 1869 def OnDeleteRestraint(event): 1756 1870 rows = Angles.GetSelectedRows() 1871 if not rows: 1872 return 1757 1873 rows.sort() 1758 1874 rows.reverse() … … 1785 1901 Angles.SetReadOnly(r,c,True) 1786 1902 Angles.SetCellStyle(r,c,VERY_LIGHT_GREY,True) 1787 Angles.Bind(wg.EVT_GRID_ CELL_CHANGE, ChangeCell)1903 Angles.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK,OnColSort) 1788 1904 G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=wxID_RESTDELETE) 1905 G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=wxID_RESRCHANGEVAL) 1906 G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=wxID_RESTCHANGEESD) 1789 1907 mainSizer.Add(Angles,0,) 1790 1908 else: … … 1799 1917 1800 1918 def UpdatePlaneRestr(planeRestData): 1801 1802 def ChangeCell(event):1803 r,c = event.GetRow(),event.GetCol()1804 if r >= 0 and c >= 0:1805 planeList[r][c+2] = table[r][c]1806 1919 1920 items = G2frame.dataFrame.RestraintEdit.GetMenuItems() 1921 for item in items: 1922 if item.GetLabel() in ['Change value']: 1923 item.Enable(False) 1924 1807 1925 def OnDeleteRestraint(event): 1808 1926 rows = Planes.GetSelectedRows() 1927 if not rows: 1928 return 1809 1929 rows.sort() 1810 1930 rows.reverse() … … 1842 1962 Planes.SetReadOnly(r,c,True) 1843 1963 Planes.SetCellStyle(r,c,VERY_LIGHT_GREY,True) 1844 Planes.Bind(wg.EVT_GRID_CELL_CHANGE, ChangeCell)1845 1964 G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=wxID_RESTDELETE) 1846 1965 mainSizer.Add(Planes,0,) … … 1857 1976 def UpdateChiralRestr(chiralRestData): 1858 1977 1859 def ChangeCell(event):1860 r,c = event.GetRow(),event.GetCol()1861 if r >= 0 and c >= 0:1862 volumeList[r][c+2] = table[r][c]1863 1864 1978 def OnDeleteRestraint(event): 1865 1979 rows = Volumes.GetSelectedRows() 1980 if not rows: 1981 return 1866 1982 rows.sort() 1867 1983 rows.reverse() … … 1894 2010 Volumes.SetReadOnly(r,c,True) 1895 2011 Volumes.SetCellStyle(r,c,VERY_LIGHT_GREY,True) 1896 Volumes.Bind(wg.EVT_GRID_CELL_CHANGE, ChangeCell)1897 2012 G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=wxID_RESTDELETE) 1898 2013 mainSizer.Add(Volumes,0,) … … 1952 2067 G2frame.dataDisplay.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, OnPageChanged) 1953 2068 2069 ################################################################################ 2070 ##### Main PWDR panel 2071 ################################################################################ 2072 1954 2073 def UpdatePWHKPlot(G2frame,kind,item): 1955 2074 … … 1992 2111 G2plt.PlotSngl(G2frame,newPlot=True) 1993 2112 2113 ################################################################################ 2114 ##### HKLF controls 2115 ################################################################################ 2116 1994 2117 def UpdateHKLControls(G2frame,data): 1995 2118 … … 2084 2207 G2frame.dataFrame.setSizePosLeft(mainSizer.Fit(G2frame.dataFrame)) 2085 2208 2209 ################################################################################ 2210 ##### Pattern tree routines 2211 ################################################################################ 2212 2086 2213 def GetPatternTreeDataNames(G2frame,dataTypes): 2087 2214 names = []
Note: See TracChangeset
for help on using the changeset viewer.