Skip to content

Commit af0b63d

Browse files
committed
fix RB mouse rotations
1 parent 29452e6 commit af0b63d

2 files changed

Lines changed: 29 additions & 28 deletions

File tree

GSASII/GSASIIphsGUI.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,23 +1536,23 @@ def SetDrawingDefaults(drawingData):
15361536
for key in defaultDrawing:
15371537
if key not in drawingData: drawingData[key] = defaultDrawing[key]
15381538

1539-
def updateAddRBorientText(G2frame,testRBObj,Bmat):
1539+
def updateAddRBorientText(G2frame,testRBObj,Bmat,ifSlide=True):
15401540
'''Update all origin/orientation text on the Add RB panel or
15411541
on main RB Models page in response to Alt+mouse movement
15421542
'''
15431543
A,V = G2mth.Q2AVdeg(testRBObj['rbObj']['Orient'][0])
15441544
testRBObj['rbObj']['OrientVec'][0] = A
15451545
testRBObj['rbObj']['OrientVec'][1:] = np.inner(Bmat,V)
15461546
for i,val in enumerate(testRBObj['rbObj']['OrientVec']):
1547-
if G2frame.testRBObjSizers['OrientVecSiz'][i].GetClassName() != 'wxSpinButton':
1547+
if not ifSlide: #skip spin button
1548+
G2frame.testRBObjSizers['OrientVecSiz'][i+1].ChangeValue(val)
1549+
else:
15481550
G2frame.testRBObjSizers['OrientVecSiz'][i].ChangeValue(val)
15491551
# G2frame.testRBObjSizers['OrientVecSiz'][i].SetValue(val)
1550-
try:
1552+
if ifSlide: #from the addRB GUI
15511553
# G2frame.testRBObjSizers['OrientVecSiz'][4].SetValue(
15521554
G2frame.testRBObjSizers['OrientVecSiz'][4].ChangeValue(
15531555
int(10*testRBObj['rbObj']['OrientVec'][0]))
1554-
except:
1555-
pass
15561556
for i,sizer in enumerate(G2frame.testRBObjSizers['Xsizers']):
15571557
sizer.ChangeValue(testRBObj['rbObj']['Orig'][0][i])
15581558
# sizer.SetValue(testRBObj['rbObj']['Orig'][0][i])

GSASII/GSASIIplot.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6470,7 +6470,7 @@ def SetRBText():
64706470
page = getSelection()
64716471
if page:
64726472
if G2frame.phaseDisplay.GetPageText(page) == 'RB Models':
6473-
G2phG.updateAddRBorientText(G2frame,testRBObj,Bmat)
6473+
G2phG.updateAddRBorientText(G2frame,testRBObj,Bmat,ifSlide=False)
64746474
if pageCallback:
64756475
try:
64766476
pageCallback()
@@ -6659,6 +6659,27 @@ def SetRotation(newxy):
66596659
drawingData['viewDir'] = VD
66606660
SetViewDirText(VD)
66616661

6662+
def SetRBRotation(newxy):
6663+
#first get rotation vector in screen coords. & angle increment
6664+
oldxy = drawingData['oldxy']
6665+
if not len(oldxy): oldxy = list(newxy)
6666+
dxy = newxy-oldxy
6667+
if dxy[0] == dxy[1] == 0: return
6668+
drawingData['oldxy'] = list(newxy)
6669+
V = np.array([dxy[1],dxy[0],0.])
6670+
A = 0.1*np.sqrt(dxy[0]**2+dxy[1]**2)
6671+
if not A: return # nothing changed, nothing to do
6672+
# next transform vector back to xtal coordinates via inverse quaternion
6673+
# & make new quaternion
6674+
Q = rbObj['Orient'][0] #rotate RB to Cart
6675+
QC = drawingData['Quaternion'] #rotate Cart to drawing
6676+
V = G2mth.prodQVQ(G2mth.invQ(QC),V)
6677+
V = G2mth.prodQVQ(G2mth.invQ(Q),V)
6678+
DQ = G2mth.AVdeg2Q(A,V)
6679+
Q = G2mth.prodQQ(Q,DQ)
6680+
rbObj['Orient'][0][:] = Q
6681+
SetRBText()
6682+
66626683
def SetRotationZ(newxy):
66636684
#first get rotation vector (= view vector) in screen coords. & angle increment
66646685
View = GL.glGetIntegerv(GL.GL_VIEWPORT)
@@ -6685,26 +6706,6 @@ def SetRotationZ(newxy):
66856706
Q = G2mth.prodQQ(Q,Qy)
66866707
drawingData['Quaternion'] = Q
66876708

6688-
def SetRBRotation(newxy):
6689-
#first get rotation vector in screen coords. & angle increment
6690-
oldxy = drawingData['oldxy']
6691-
if not len(oldxy): oldxy = list(newxy)
6692-
dxy = newxy-oldxy
6693-
if dxy[0] == dxy[1] == 0: return
6694-
drawingData['oldxy'] = list(newxy)
6695-
V = np.array([dxy[1],dxy[0],0.])
6696-
A = 0.25*np.sqrt(dxy[0]**2+dxy[1]**2)
6697-
# next transform vector back to xtal coordinates via inverse quaternion
6698-
# & make new quaternion
6699-
Q = rbObj['Orient'][0] #rotate RB to Cart
6700-
QC = drawingData['Quaternion'] #rotate Cart to drawing
6701-
V = G2mth.prodQVQ(G2mth.invQ(QC),V)
6702-
V = G2mth.prodQVQ(G2mth.invQ(Q),V)
6703-
DQ = G2mth.AVdeg2Q(A,V)
6704-
Q = G2mth.prodQQ(Q,DQ)
6705-
rbObj['Orient'][0][:] = Q
6706-
SetRBText()
6707-
67086709
def SetRBRotationZ(newxy):
67096710
#first get rotation vector (= view vector) in screen coords. & angle increment
67106711
View = GL.glGetIntegerv(GL.GL_VIEWPORT)
@@ -6716,8 +6717,8 @@ def SetRBRotationZ(newxy):
67166717
drawingData['oldxy'] = list(newxy)
67176718
V = drawingData['viewDir']
67186719
A = [0,0]
6719-
A[0] = dxy[1]*.25
6720-
A[1] = dxy[0]*.25
6720+
A[0] = dxy[1]*.1
6721+
A[1] = dxy[0]*.1
67216722
if newxy[0] < cent[0]:
67226723
A[0] *= -1
67236724
if newxy[1] > cent[1]:

0 commit comments

Comments
 (0)