Example #1
0
 def updateDisplay(self):
     c=self.searchCrystal()
     if c:
         hkl=parseHKL(str(self.reflex.text()))
         if hkl:
             h, k, l=hkl
             v=c.hkl2Reziprocal(h, k, l)
             Q=v.norm()
             self.infoQ.setText('%.2f'%Q)
             if Q>0.0:
                 d=1.0/Q
                 self.infoD.setText('%.2f'%d)
                 v*=d
                 v2, b=Projector.normal2scattered(v)
                 if b:
                     self.info2T.setText('%.2f'%(180.0-math.degrees(math.acos(v2.x()))))
                 else:
                     self.info2T.setText('')
                 for n, w1, w2 in ((0, self.axX, self.axMX), (1, self.axY, self.axMY), (2, self.axZ, self.axMZ)):
                     ang=math.degrees(math.acos(max(-1, min(1, v[n]))))
                     w1.setText('%.2f'%ang)
                     w2.setText('%.2f'%(180.0-ang))
                     
             self.diffOrders.setText('')
             for r in c.getReflectionList():
                 if r.h==h and r.k==k and r.l==l:
                     t=''
                     for n in r.orders:
                         if n>=r.lowestDiffOrder and n<=r.highestDiffOrder:
                             t+='%i, '%n
                     if len(t)>0:
                         self.diffOrders.setText(t[:-2])
                     break
 def indexChanged(self):
     index=self.axisChooser.currentIndex()
     if (self.axisEdit.isVisible() ^ (index>=3)):
         self.axisEdit.setVisible(index>=3)
         self.update()
     
     axis=None
     if index in (0, 1, 2):
         axis=Vec3D(0, 0, 0)
         axis[index]=1
     elif index in (3, 4, 5):
         s=str(self.axisEdit.text())
         axis=parseHKL(s)
     c=self.searchCrystal()
     if c and axis:
         axis=Vec3D(axis)
         if index in (0, 1, 2, 3):
             c.setRotationAxis(axis, Crystal.LabSystem)
         elif index==4:
             c.setRotationAxis(axis, Crystal.DirectSpace)
         elif index==5:
             c.setRotationAxis(axis, Crystal.ReziprocalSpace)