@@ -2874,6 +2874,7 @@ def SaveVectorRB(event):
28742874 filename = os .path .splitext (filename )[0 ]+ '.vecbody' # set extension
28752875 fp = open (filename ,'w' )
28762876 fp .write ('Name: ' + data ['Vector' ][rbid ]['RBname' ]+ '\n ' )
2877+ fp .write ('symAxis: ' + str (data ['Vector' ][rbid ]['symAxis' ])+ '\n ' )
28772878 fp .write ('Trans: ' )
28782879 for i in data ['Vector' ][rbid ]['VectMag' ]:
28792880 fp .write (str (i )+ " " )
@@ -2909,7 +2910,13 @@ def ReadVectorRB(event):
29092910 + l + '\n invalid file' ,parent = G2frame )
29102911 return
29112912 name = l .split (':' )[1 ].strip ()
2912- trans = fp .readline ().strip ().split (':' )[1 ].split ()
2913+ l = fp .readline ().strip ()
2914+ if 'symAxis' in l :
2915+ symAxis = eval (l .strip ().split (':' )[1 ])
2916+ l = fp .readline ().strip ()
2917+ else :
2918+ symAxis = [0 ,0 ,1 ]
2919+ trans = l .strip ().split (':' )[1 ].split ()
29132920 vecMag = [float (i ) for i in trans ]
29142921 ntrans = len (trans )
29152922 vecs = [[] for i in range (ntrans )]
@@ -2937,10 +2944,9 @@ def ReadVectorRB(event):
29372944 if 'RBname' in data ['Vector' ][key ]]
29382945 name = G2obj .MakeUniqueLabel (name ,namelist )
29392946 data ['Vector' ][rbid ] = {'RBname' :name ,'VectMag' :vecMag ,
2940- 'rbXYZ' :np .zeros ((natoms ,3 )),
2941- 'rbRef' :[0 ,1 ,2 ,False ],'VectRef' :ntrans * [False ],
2942- 'rbTypes' :types ,
2943- 'rbVect' :vecs ,'useCount' :0 }
2947+ 'rbRef' :[0 ,1 ,2 ,False ],'rbXYZ' :np .zeros ((natoms ,3 )),
2948+ 'symAxis' :symAxis ,'VectRef' :ntrans * [False ],
2949+ 'rbTypes' :types ,'rbVect' :vecs ,'useCount' :0 }
29442950 data ['RBIds' ]['Vector' ].append (rbid )
29452951 UpdateVectorRB ()
29462952
@@ -3226,57 +3232,39 @@ def OnPlotRB(event):
32263232
32273233 def rbRefAtmSizer (rbid ,rbData ):
32283234
3229- def OnRefSel (event ):
3235+ def OnSymRadioSet (event ):
3236+ '''Set the polar axis for the sp. harm. as
3237+ RBdata['Spin'][RBId]['symAxis'].
3238+ '''
32303239 Obj = event .GetEventObject ()
3231- iref = Indx [Obj .GetId ()]
3232- sel = Obj .GetValue ()
3233- rbData ['rbRef' ][iref ] = atNames .index (sel )
3234- FillRefChoice (rbid ,rbData )
3240+ axis = ([1 ,0 ,0 ],[0 ,1 ,0 ],[0 ,0 ,1 ],[1 ,1 ,0 ],[1 ,1 ,1 ])[Obj .GetSelection ()]
3241+ rbData ['symAxis' ] = axis
32353242
32363243 refAtmSizer = wx .BoxSizer (wx .HORIZONTAL )
3237- atNames = [name + str ( i ) for i , name in enumerate ( rbData [ 'rbTypes' ]) ]
3238- rbRef = rbData .get ('rbRef ' ,[0 ,1 , 2 , False ])
3239- rbData ['rbRef' ] = rbRef
3244+ choices = [' x ' , ' y ' , ' z ' , 'x+y' , 'x+y+z' ]
3245+ rbData [ 'symAxis' ] = rbData .get ('symAxis ' ,[0 ,0 , 1 ]) #set default as 'z', if needed
3246+ symax = dict ( zip ([ str ( x ) for x in [[ 1 , 0 , 0 ],[ 0 , 1 , 0 ],[ 0 , 0 , 1 ],[ 1 , 1 , 0 ],[ 1 , 1 , 1 ]]], choices ))[ str ( rbData ['symAxis' ])]
32403247 if rbData ['useCount' ]:
32413248 refAtmSizer .Add (wx .StaticText (VectorRBDisplay ,- 1 ,
3242- 'Orientation reference atoms A-B-C: %s, %s, %s' % (atNames [rbRef [0 ]], \
3243- atNames [rbRef [1 ]],atNames [rbRef [2 ]])),0 )
3249+ 'RB polar axis is aligned along: %s' % symax ),WACV ,0 )
32443250 else :
3245- refAtmSizer .Add (wx .StaticText (VectorRBDisplay ,- 1 ,
3246- 'Orientation reference atoms A-B-C: ' ),0 ,WACV )
3247- for i in range (3 ):
3248- choices = [atNames [j ] for j in refChoice [rbid ][i ]]
3249- refSel = wx .ComboBox (VectorRBDisplay ,- 1 ,value = '' ,
3250- choices = choices ,style = wx .CB_READONLY | wx .CB_DROPDOWN )
3251- refSel .SetValue (atNames [rbRef [i ]])
3252- refSel .Bind (wx .EVT_COMBOBOX , OnRefSel )
3253- Indx [refSel .GetId ()] = i
3254- refAtmSizer .Add (refSel ,0 ,WACV )
3255- refHelpInfo = '''
3256- * The "Orientation Reference" control defines the Cartesian
3257- axes for rigid bodies with the three atoms, A, B and C.
3258- The vector from B to A defines the x-axis and the y axis is placed
3259- in the plane defined by B to A and C to A. A,B,C must not be collinear.
3260- '''
3261- hlp = G2G .HelpButton (VectorRBDisplay ,refHelpInfo ,wrap = 400 )
3262- refAtmSizer .Add (hlp ,0 ,wx .LEFT | wx .RIGHT | wx .ALIGN_CENTER_VERTICAL ,2 )
3251+ symRadioSet = wx .RadioBox (VectorRBDisplay ,choices = choices ,label = 'RB polar axis is aligned along:' )
3252+ symRadioSet .SetStringSelection (symax )
3253+ symRadioSet .Bind (wx .EVT_RADIOBOX , OnSymRadioSet )
3254+ refAtmSizer .Add (symRadioSet )
3255+ # refHelpInfo = '''
3256+ # * The "Orientation Reference" control defines the Cartesian
3257+ # axes for rigid bodies with the three atoms, A, B and C.
3258+ # The vector from B to A defines the x-axis and the y axis is placed
3259+ # in the plane defined by B to A and C to A. A,B,C must not be collinear.
3260+ # '''
3261+ # hlp = G2G.HelpButton(VectorRBDisplay,refHelpInfo,wrap=400)
3262+ # refAtmSizer.Add(hlp,0,wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL,2)
32633263 return refAtmSizer
32643264
32653265 def rbVectMag (rbid ,imag ,rbData ):
32663266
3267- def OnRBVectorMag (event ):
3268- event .Skip ()
3269- Obj = event .GetEventObject ()
3270- rbid ,imag = Indx [Obj .GetId ()]
3271- try :
3272- val = float (Obj .GetValue ())
3273- if val <= 0. :
3274- raise ValueError
3275- rbData ['VectMag' ][imag ] = val
3276- except ValueError :
3277- pass
3278- Obj .SetValue ('%8.4f' % (val ))
3279- wx .CallAfter (UpdateVectorRB ,VectorRB .GetScrollPos (wx .VERTICAL ))
3267+ def OnRBVectorMag (invalid ,value ,tc ):
32803268 G2plt .PlotRigidBody (G2frame ,'Vector' ,AtInfo ,data ['Vector' ][rbid ],plotDefaults )
32813269
32823270 def OnRBVectorRef (event ):
@@ -3286,12 +3274,7 @@ def OnRBVectorRef(event):
32863274
32873275 magSizer = wx .BoxSizer (wx .HORIZONTAL )
32883276 magSizer .Add (wx .StaticText (VectorRBDisplay ,- 1 ,'Translation magnitude: ' ),0 ,WACV )
3289- magValue = wx .TextCtrl (VectorRBDisplay ,- 1 ,'%8.4f' % (rbData ['VectMag' ][imag ]),
3290- style = wx .TE_PROCESS_ENTER )
3291- Indx [magValue .GetId ()] = [rbid ,imag ]
3292- magValue .Bind (wx .EVT_TEXT_ENTER ,OnRBVectorMag )
3293- magValue .Bind (wx .EVT_KILL_FOCUS ,OnRBVectorMag )
3294- magSizer .Add (magValue ,0 ,WACV )
3277+ magSizer .Add (G2G .ValidatedTxtCtrl (VectorRBDisplay ,rbData ['VectMag' ],imag ,OnLeave = OnRBVectorMag ),0 ,WACV )
32953278 magSizer .Add ((5 ,0 ),)
32963279 magref = wx .CheckBox (VectorRBDisplay ,label = ' Refine?' )
32973280 magref .SetValue (rbData ['VectRef' ][imag ])
@@ -3629,7 +3612,7 @@ def OnPlotRB(event):
36293612 Indx [stripH .GetId ()] = rbid
36303613 nameSizer .Add (stripH ,0 ,WACV )
36313614 nameSizer .Add (wx .StaticText (ResidueRBDisplay ,- 1 ,' body type #' +
3632- str (data ['RBIds' ]['Residue' ].index (rbid ))),0 ,WACV )
3615+ str (data ['RBIds' ]['Residue' ].index (rbid ))),0 ,WACV )
36333616 nameSizer .Add ((- 1 ,- 1 ),1 ,wx .EXPAND ,1 )
36343617 return nameSizer
36353618
0 commit comments