Add q to the fitting statusbar

This commit is contained in:
Valentin Valls 2019-05-16 14:23:51 +02:00
parent e56f15c4d5
commit cc0fff12db
1 changed files with 23 additions and 0 deletions

View File

@ -51,6 +51,8 @@ from ..utils import units
from ..helper.MarkerManager import MarkerManager
from ..helper import ProcessingWidget
from ..helper import model_transform
from ..utils import unitutils
from ... import units as core_units
_logger = logging.getLogger(__name__)
@ -61,6 +63,7 @@ class _StatusBar(qt.QStatusBar):
qt.QStatusBar.__init__(self, parent)
angleUnitModel = CalibrationContext.instance().getAngleUnit()
scatteringUnitModel = CalibrationContext.instance().getScatteringVectorUnit()
self.__position = QuantityLabel(self)
self.__position.setPrefix(u"<b>Pos</b>: ")
@ -68,12 +71,14 @@ class _StatusBar(qt.QStatusBar):
# TODO: Could it be done using a custom layout? Instead of setElasticSize
self.__position.setElasticSize(True)
self.addWidget(self.__position)
self.__pixel = QuantityLabel(self)
self.__pixel.setPrefix(u"<b>Pixel</b>: ")
self.__pixel.setFormatter(u"{value}")
self.__pixel.setFloatFormatter(u"{value: >4.3F}")
self.__pixel.setElasticSize(True)
self.addWidget(self.__pixel)
self.__chi = QuantityLabel(self)
self.__chi.setPrefix(u"<b>χ</b>: ")
self.__chi.setFormatter(u"{value: >4.3F}")
@ -83,6 +88,7 @@ class _StatusBar(qt.QStatusBar):
self.__chi.setUnitEditable(True)
self.__chi.setElasticSize(True)
self.addWidget(self.__chi)
self.__2theta = QuantityLabel(self)
self.__2theta.setPrefix(u"<b>2θ</b>: ")
self.__2theta.setFormatter(u"{value: >4.3F}")
@ -92,6 +98,15 @@ class _StatusBar(qt.QStatusBar):
self.__2theta.setElasticSize(True)
self.addWidget(self.__2theta)
self.__q = QuantityLabel(self)
self.__q.setPrefix(u"<b>q</b>: ")
self.__q.setFormatter(u"{value: >4.3F}")
self.__q.setInternalUnit(units.Unit.INV_ANGSTROM)
self.__q.setDisplayedUnitModel(scatteringUnitModel)
self.__q.setUnitEditable(True)
self.__q.setElasticSize(True)
self.addWidget(self.__q)
self.clearValues()
def clearValues(self):
@ -106,6 +121,14 @@ class _StatusBar(qt.QStatusBar):
self.__pixel.setValue(pixel)
self.__chi.setValue(chi)
self.__2theta.setValue(tth)
if not numpy.isnan(tth):
# NOTE: warelength could be updated, and the the display would not
# be updated. But here it is safe enougth.
wavelength = CalibrationContext.instance().getCalibrationModel().fittedGeometry().wavelength().value()
q = unitutils.from2ThRad(tth, core_units.Q_A, wavelength)
self.__q.setValue(q)
else:
self.__q.setValue(float("nan"))
class CalibrationState(qt.QObject):