Changeset 4490
- Timestamp:
- Jun 17, 2020 12:58:02 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIddataGUI.py
r4416 r4490 137 137 UseList[G2frame.hist][name][2][2] = Obj.GetValue() 138 138 139 def OnLGmixVal(event):140 event.Skip()141 Obj = event.GetEventObject()142 hist,name = Indx[Obj.GetId()]143 try:144 value = float(Obj.GetValue())145 UseList[G2frame.hist][name][1][2] = value146 # if 0 <= value <= 1:147 # UseList[G2frame.hist][name][1][2] = value148 # else:149 # raise ValueError150 except ValueError:151 pass152 Obj.SetValue("%.4f"%(UseList[G2frame.hist][name][1][2])) #reset in case of error153 154 139 def OnSizeType(event): 155 140 Obj = event.GetEventObject() … … 166 151 UseList[G2frame.hist]['Size'][2][pid] = Obj.GetValue() 167 152 168 def OnSizeVal(event):169 event.Skip()170 Obj = event.GetEventObject()171 hist,pid = Indx[Obj.GetId()]172 if UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':173 try:174 size = float(Obj.GetValue())175 if pid < 3 and size < 0.001: #10A lower limit!176 raise ValueError177 UseList[G2frame.hist]['Size'][4][pid] = size178 except ValueError:179 pass180 Obj.SetValue("%.5f"%(UseList[G2frame.hist]['Size'][4][pid])) #reset in case of error181 wx.CallAfter(UpdateDData,G2frame,DData,data,G2frame.hist)182 else:183 try:184 size = float(Obj.GetValue())185 if size < 0.001: #10A lower limit!186 raise ValueError187 UseList[G2frame.hist]['Size'][1][pid] = size188 except ValueError:189 pass190 Obj.SetValue("%.5f"%(UseList[G2frame.hist]['Size'][1][pid])) #reset in case of error191 wx.CallAfter(G2plt.PlotSizeStrainPO,G2frame,data,hist)192 193 153 def OnStrainType(event): 194 154 Obj = event.GetEventObject() … … 204 164 else: 205 165 UseList[G2frame.hist]['Mustrain'][2][pid] = Obj.GetValue() 206 207 def OnStrainVal(event):208 event.Skip()209 Snames = G2spc.MustrainNames(SGData)210 Obj = event.GetEventObject()211 hist,pid = Indx[Obj.GetId()]212 try:213 strain = float(Obj.GetValue())214 if UseList[G2frame.hist]['Mustrain'][0] == 'generalized':215 if '4' in Snames[pid] and strain < 0:216 raise ValueError217 UseList[G2frame.hist]['Mustrain'][4][pid] = strain218 else:219 if strain <= 0:220 raise ValueError221 UseList[G2frame.hist]['Mustrain'][1][pid] = strain222 except ValueError:223 pass224 if UseList[G2frame.hist]['Mustrain'][0] == 'generalized':225 Obj.SetValue("%.1f"%(UseList[G2frame.hist]['Mustrain'][4][pid])) #reset in case of error226 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))227 else:228 Obj.SetValue("%.1f"%(UseList[G2frame.hist]['Mustrain'][1][pid])) #reset in case of error229 wx.CallAfter(G2plt.PlotSizeStrainPO,G2frame,data,hist)230 166 231 167 def OnStrainAxis(event): … … 246 182 def OnResetStrain(event): 247 183 Obj = event.GetEventObject() 248 Obj.SetValue(False)249 184 item,name = Indx[Obj.GetId()] 250 185 if name == 'isotropic': … … 310 245 return axis 311 246 247 def OnNewValue(invalid,value,tc): 248 G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist) 249 250 def OnNewValueReDraw(invalid,value,tc): 251 G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist) 252 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 253 312 254 def TopSizer(name,choices,parm,OnType): 313 255 topSizer = wx.BoxSizer(wx.HORIZONTAL) … … 319 261 return topSizer 320 262 321 def LGmixSizer(name, OnVal,OnRef):263 def LGmixSizer(name,Limits,OnRef): 322 264 lgmixSizer = wx.BoxSizer(wx.HORIZONTAL) 323 265 lgmixRef = wx.CheckBox(DData,wx.ID_ANY,label='LGmix') … … 327 269 lgmixRef.Bind(wx.EVT_CHECKBOX, OnRef) 328 270 lgmixSizer.Add(lgmixRef,0,WACV|wx.LEFT,5) 329 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 330 lgmixVal = wx.TextCtrl(DData,wx.ID_ANY, 331 '%.4f'%(UseList[G2frame.hist][name][1][2]),style=wx.TE_PROCESS_ENTER) 332 Indx[lgmixVal.GetId()] = [G2frame.hist,name] 333 lgmixVal.Bind(wx.EVT_TEXT_ENTER,OnVal) 334 lgmixVal.Bind(wx.EVT_KILL_FOCUS,OnVal) 271 lgmixVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist][name][1],2, 272 nDig=(10,3),min=Limits[0],max=Limits[1]) 335 273 lgmixSizer.Add(lgmixVal,0,WACV|wx.LEFT,5) 336 274 return lgmixSizer … … 338 276 def ResetSizer(name,OnReset): 339 277 resetSizer = wx.BoxSizer(wx.HORIZONTAL) 340 reset = wx. CheckBox(DData,wx.ID_ANY,label='Reset?')278 reset = wx.Button(DData,wx.ID_ANY,label='Reset?') 341 279 reset.thisown = False 342 reset.SetValue(False)343 280 Indx[reset.GetId()] = [G2frame.hist,name] 344 reset.Bind(wx.EVT_ CHECKBOX,OnReset)345 resetSizer.Add(reset,0,WACV |wx.TOP|wx.LEFT,5)281 reset.Bind(wx.EVT_BUTTON,OnReset) 282 resetSizer.Add(reset,0,WACV) 346 283 return resetSizer 347 284 348 def IsoSizer(name,parm,fmt, OnVal,OnRef):285 def IsoSizer(name,parm,fmt,Limits,OnRef): 349 286 isoSizer = wx.BoxSizer(wx.HORIZONTAL) 350 287 sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=name) … … 354 291 sizeRef.Bind(wx.EVT_CHECKBOX, OnRef) 355 292 isoSizer.Add(sizeRef,0,WACV|wx.LEFT,5) 356 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 357 sizeVal = wx.TextCtrl(DData,wx.ID_ANY, 358 fmt%(UseList[G2frame.hist][parm][1][0]),style=wx.TE_PROCESS_ENTER) 359 Indx[sizeVal.GetId()] = [G2frame.hist,0] 360 sizeVal.Bind(wx.EVT_TEXT_ENTER,OnVal) 361 sizeVal.Bind(wx.EVT_KILL_FOCUS,OnVal) 293 sizeVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist][parm][1],0, 294 nDig=fmt,min=Limits[0],max=Limits[1],OnLeave=OnNewValue) 362 295 isoSizer.Add(sizeVal,0,WACV) 363 296 return isoSizer … … 373 306 return uniSizer 374 307 375 def UniDataSizer(parmName,parm,fmt, OnVal,OnRef):308 def UniDataSizer(parmName,parm,fmt,Limits,OnRef): 376 309 dataSizer = wx.BoxSizer(wx.HORIZONTAL) 377 310 parms = zip([' Equatorial '+parmName,' Axial '+parmName], 378 UseList[G2frame.hist][parm][ 1],UseList[G2frame.hist][parm][2],range(2))379 for Pa, val,ref,Id in parms:311 UseList[G2frame.hist][parm][2],range(2)) 312 for Pa,ref,Id in parms: 380 313 sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa) 381 314 sizeRef.thisown = False … … 384 317 sizeRef.Bind(wx.EVT_CHECKBOX, OnRef) 385 318 dataSizer.Add(sizeRef,0,WACV|wx.LEFT,5) 386 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 387 sizeVal = wx.TextCtrl(DData,wx.ID_ANY,fmt%(val),style=wx.TE_PROCESS_ENTER) 388 Indx[sizeVal.GetId()] = [G2frame.hist,Id] 389 sizeVal.Bind(wx.EVT_TEXT_ENTER,OnVal) 390 sizeVal.Bind(wx.EVT_KILL_FOCUS,OnVal) 391 dataSizer.Add(sizeVal,0,WACV|wx.BOTTOM,5) 319 sizeVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist][parm][1], 320 Id,fmt,min=Limits[0],max=Limits[1],OnLeave=OnNewValue) 321 dataSizer.Add(sizeVal,0,WACV) 392 322 return dataSizer 393 323 … … 396 326 UseList[G2frame.hist]['Size'][5],range(6)) 397 327 dataSizer = wx.BoxSizer(wx.VERTICAL) 398 # dataSizer = wx.FlexGridSizer(0,6,5,5)399 328 matrixSizer = wx.FlexGridSizer(0,6,5,5) 400 329 Sij = [] 401 for Pa,val,ref, id in parms:330 for Pa,val,ref,Id in parms: 402 331 sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa) 403 332 sizeRef.thisown = False 404 333 sizeRef.SetValue(ref) 405 Indx[sizeRef.GetId()] = [G2frame.hist, id]334 Indx[sizeRef.GetId()] = [G2frame.hist,Id] 406 335 sizeRef.Bind(wx.EVT_CHECKBOX, OnSizeRef) 407 # dataSizer.Add(sizeRef,0,WACV)408 336 matrixSizer.Add(sizeRef,0,WACV) 409 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 410 sizeVal = wx.TextCtrl(DData,wx.ID_ANY,'%.3f'%(val),style=wx.TE_PROCESS_ENTER) 337 if Id < 3: 338 sizeVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Size'][4], 339 Id,nDig=(10,3),min=0.,max=4.,OnLeave=OnNewValueReDraw) 340 else: 341 sizeVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Size'][4], 342 Id,nDig=(10,3),OnLeave=OnNewValueReDraw) 411 343 # Create Sij matrix 412 344 Sij += [val] 413 Indx[sizeVal.GetId()] = [G2frame.hist,id]414 sizeVal.Bind(wx.EVT_TEXT_ENTER,OnSizeVal)415 sizeVal.Bind(wx.EVT_KILL_FOCUS,OnSizeVal)416 # dataSizer.Add(sizeVal,0,WACV)417 345 matrixSizer.Add(sizeVal,0,WACV) 418 346 dataSizer.Add(matrixSizer, 0, WACV) … … 442 370 onumb += 1 443 371 muMean = G2spc.MuShklMean(SGData,Amat,UseList[G2frame.hist]['Mustrain'][4]) 444 parms = zip(Snames,UseList[G2frame.hist]['Mustrain'][ 4],UseList[G2frame.hist]['Mustrain'][5],range(numb))372 parms = zip(Snames,UseList[G2frame.hist]['Mustrain'][5],range(numb)) 445 373 dataSizer = wx.FlexGridSizer(0,6,5,5) 446 for Pa, val,ref,Id in parms:374 for Pa,ref,Id in parms: 447 375 strainRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa) 448 376 strainRef.thisown = False … … 451 379 strainRef.Bind(wx.EVT_CHECKBOX, OnStrainRef) 452 380 dataSizer.Add(strainRef,0,WACV) 453 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 454 strainVal = wx.TextCtrl(DData,wx.ID_ANY,'%.1f'%(val),style=wx.TE_PROCESS_ENTER) 455 Indx[strainVal.GetId()] = [G2frame.hist,Id] 456 strainVal.Bind(wx.EVT_TEXT_ENTER,OnStrainVal) 457 strainVal.Bind(wx.EVT_KILL_FOCUS,OnStrainVal) 381 strainVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Mustrain'][4], 382 Id,nDig=(10,2),OnLeave=OnNewValueReDraw) 458 383 dataSizer.Add(strainVal,0,WACV) 459 384 dataSizer.Add(wx.StaticText(DData,label=' Mean mustrain %.1f'%muMean),0,WACV) … … 467 392 UseList[G2frame.hist]['HStrain'][1][pid] = Obj.GetValue() 468 393 469 def OnHstrainVal(event):470 event.Skip()471 Obj = event.GetEventObject()472 hist,pid = Indx[Obj.GetId()]473 try:474 strain = float(Obj.GetValue())475 UseList[G2frame.hist]['HStrain'][0][pid] = strain476 except ValueError:477 pass478 Obj.SetValue("%.3g"%(UseList[G2frame.hist]['HStrain'][0][pid])) #reset in case of error479 480 394 hstrainSizer = wx.FlexGridSizer(0,6,5,5) 481 395 Hsnames = G2spc.HStrainNames(SGData) 482 parms = zip(Hsnames,UseList[G2frame.hist]['HStrain'][ 0],UseList[G2frame.hist]['HStrain'][1],range(len(Hsnames)))483 for Pa, val,ref,Id in parms:396 parms = zip(Hsnames,UseList[G2frame.hist]['HStrain'][1],range(len(Hsnames))) 397 for Pa,ref,Id in parms: 484 398 hstrainRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa) 485 399 hstrainRef.thisown = False … … 488 402 hstrainRef.Bind(wx.EVT_CHECKBOX, OnHstrainRef) 489 403 hstrainSizer.Add(hstrainRef,0,WACV|wx.LEFT,5) 490 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 491 hstrainVal = wx.TextCtrl(DData,wx.ID_ANY,'%.3g'%(val),style=wx.TE_PROCESS_ENTER) 492 Indx[hstrainVal.GetId()] = [G2frame.hist,Id] 493 hstrainVal.Bind(wx.EVT_TEXT_ENTER,OnHstrainVal) 494 hstrainVal.Bind(wx.EVT_KILL_FOCUS,OnHstrainVal) 404 hstrainVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['HStrain'][0],Id,nDig=(10,3,'g')) 495 405 hstrainSizer.Add(hstrainVal,0,WACV) 496 406 return hstrainSizer … … 535 445 def SHDataSizer(POData): 536 446 537 def OnODFValue(invalid,value,tc):538 G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)539 540 447 ODFSizer = wx.FlexGridSizer(0,8,2,2) 541 448 ODFkeys = list(POData[5].keys()) … … 543 450 for odf in ODFkeys: 544 451 ODFSizer.Add(wx.StaticText(DData,wx.ID_ANY,odf),0,WACV) 545 ODFval = G2G.ValidatedTxtCtrl(DData,POData[5],odf,nDig=(8,3),typeHint=float,OnLeave=On ODFValue)452 ODFval = G2G.ValidatedTxtCtrl(DData,POData[5],odf,nDig=(8,3),typeHint=float,OnLeave=OnNewValue) 546 453 ODFSizer.Add(ODFval,0,WACV|wx.LEFT,5) 547 454 return ODFSizer … … 882 789 def OnResetSize(event): 883 790 Obj = event.GetEventObject() 884 Obj.SetValue(False)885 791 item,name = Indx[Obj.GetId()] 886 792 if name == 'isotropic': … … 972 878 isoSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 973 879 'Size',OnSizeType),0,WACV) 974 isoSizer.Add(LGmixSizer('Size', OnLGmixVal,OnLGmixRef))880 isoSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 975 881 isoSizer.Add(ResetSizer('isotropic',OnResetSize),0,WACV) 976 882 bottomSizer.Add(isoSizer) 977 bottomSizer.Add(IsoSizer(u'size(\xb5m): ','Size', '%.3f',978 OnSizeVal,OnSizeRef),0,WACV|wx.BOTTOM,5)883 bottomSizer.Add(IsoSizer(u'size(\xb5m): ','Size',(10,4), 884 [0.,4.],OnSizeRef),0,WACV|wx.BOTTOM,5) 979 885 elif UseList[G2frame.hist]['Size'][0] == 'uniaxial': 980 886 uniSizer = wx.BoxSizer(wx.HORIZONTAL) 981 887 uniSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 982 888 'Size',OnSizeType),0,WACV) 983 uniSizer.Add(LGmixSizer('Size', OnLGmixVal,OnLGmixRef))889 uniSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 984 890 uniSizer.Add(ResetSizer('uniaxial',OnResetSize),0,WACV) 985 891 bottomSizer.Add(UniSizer('Size',OnSizeAxis),0,WACV) 986 892 bottomSizer.Add(uniSizer) 987 bottomSizer.Add(UniDataSizer(u'size(\xb5m): ','Size', '%.3f',OnSizeVal,OnSizeRef)893 bottomSizer.Add(UniDataSizer(u'size(\xb5m): ','Size',(10,3),[0.,4.],OnSizeRef) 988 894 ,0,WACV|wx.BOTTOM,5) 989 895 elif UseList[G2frame.hist]['Size'][0] == 'ellipsoidal': … … 991 897 ellSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 992 898 'Size',OnSizeType),0,WACV) 993 ellSizer.Add(LGmixSizer('Size', OnLGmixVal,OnLGmixRef))899 ellSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 994 900 ellSizer.Add(ResetSizer('ellipsoidal',OnResetSize),0,WACV) 995 901 bottomSizer.Add(ellSizer) … … 1000 906 isoSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 1001 907 'Mustrain',OnStrainType),0,WACV) 1002 isoSizer.Add(LGmixSizer('Mustrain', OnLGmixVal,OnLGmixRef))908 isoSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 1003 909 isoSizer.Add(ResetSizer('isotropic',OnResetStrain),0,WACV) 1004 910 bottomSizer.Add(isoSizer) 1005 bottomSizer.Add(IsoSizer(' microstrain: ','Mustrain', '%.1f',1006 OnStrainVal,OnStrainRef),0,WACV|wx.BOTTOM,5)911 bottomSizer.Add(IsoSizer(' microstrain: ','Mustrain',(10,1), 912 [0.,1.e5],OnStrainRef),0,WACV|wx.BOTTOM,5) 1007 913 elif UseList[G2frame.hist]['Mustrain'][0] == 'uniaxial': 1008 914 uniSizer = wx.BoxSizer(wx.HORIZONTAL) 1009 915 uniSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 1010 916 'Mustrain',OnStrainType),0,WACV) 1011 uniSizer.Add(LGmixSizer('Mustrain', OnLGmixVal,OnLGmixRef))917 uniSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 1012 918 uniSizer.Add(ResetSizer('uniaxial',OnResetStrain),0,WACV) 1013 919 bottomSizer.Add(uniSizer) 1014 920 bottomSizer.Add(UniSizer('Mustrain',OnStrainAxis),0,WACV) 1015 bottomSizer.Add(UniDataSizer('mustrain: ','Mustrain', '%.1f',OnStrainVal,OnStrainRef)921 bottomSizer.Add(UniDataSizer('mustrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef) 1016 922 ,0,WACV|wx.BOTTOM,5) 1017 923 elif UseList[G2frame.hist]['Mustrain'][0] == 'generalized': … … 1019 925 genSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 1020 926 'Mustrain',OnStrainType),0,WACV) 1021 genSizer.Add(LGmixSizer('Mustrain', OnLGmixVal,OnLGmixRef))927 genSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 1022 928 genSizer.Add(ResetSizer('generalized',OnResetStrain),0,WACV) 1023 929 bottomSizer.Add(genSizer)
Note: See TracChangeset
for help on using the changeset viewer.