From 01fba3e1d8b13d5f372479d9048954459c445c4b Mon Sep 17 00:00:00 2001 From: Waruna Wickramasingha Date: Mon, 21 Oct 2024 09:57:56 +0100 Subject: [PATCH 1/4] 38063 sample transmission calculators DoubleSpinBoxes avoid commas --- Framework/DataHandling/src/RotateSampleShape.cpp | 4 ++-- .../v6.12.0/Framework/Algorithms/Bugfixes/38063.rst | 1 + .../SampleTransmissionCalculator/stc_view.py | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst diff --git a/Framework/DataHandling/src/RotateSampleShape.cpp b/Framework/DataHandling/src/RotateSampleShape.cpp index cc76b73b7194..4d107472cb8b 100644 --- a/Framework/DataHandling/src/RotateSampleShape.cpp +++ b/Framework/DataHandling/src/RotateSampleShape.cpp @@ -76,14 +76,14 @@ void RotateSampleShape::exec() { g_log.warning() << "Empty goniometer created; will always return an " "identity rotation matrix.\n"; - const auto sampleShapeRotation = gon.getR(); + const auto &sampleShapeRotation = gon.getR(); if (sampleShapeRotation == Kernel::Matrix(3, 3, true)) { // If the resulting rotationMatrix is Identity, ignore the calculatrion g_log.warning("Rotation matrix set via RotateSampleShape is an Identity matrix. Ignored rotating sample shape"); return; } - const auto oldRotation = ei->run().getGoniometer().getR(); + const auto &oldRotation = ei->run().getGoniometer().getR(); auto newSampleShapeRot = sampleShapeRotation * oldRotation; if (isMeshShape) { auto meshShape = std::dynamic_pointer_cast(ei->sample().getShapePtr()); diff --git a/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst b/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst new file mode 100644 index 000000000000..d2c5d7be186a --- /dev/null +++ b/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst @@ -0,0 +1 @@ +- Fixed a bug in :ref:`sample_transmission_calculator` (Interfaces > General > Sample Transmission Calculator) interface to restrict entering commas mixed with decimal point in the double spin boxes for Low, Width and High fields \ No newline at end of file diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py index d9ad9f06d136..4265068cf195 100644 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py @@ -36,6 +36,17 @@ def __init__(self, parent=None): "Or 0,100,10000,200,20000: from 0 rebin in steps of 100 to 10,000 then steps of 200 to 20,000." ) + self.single_high_spin_box.textChanged.connect(self._double_spinbox_textChanged) + self.single_low_spin_box.textChanged.connect(self._double_spinbox_textChanged) + self.single_width_spin_box.textChanged.connect(self._double_spinbox_textChanged) + + def _double_spinbox_textChanged(self, text): + if "," in text: + text = text.replace(",", ".") + oldState = self.sender().blockSignals(True) + self.sender().setValue(float(text)) + self.sender().blockSignals(oldState) + def get_input_dict(self): input_dict = { "binning_type": self.binning_type_combo_box.currentIndex(), From fb91670c078d60eb8773e54e7a9d685ba1fb5cf0 Mon Sep 17 00:00:00 2001 From: Waruna Wickramasingha Date: Mon, 21 Oct 2024 10:16:51 +0100 Subject: [PATCH 2/4] updated stc_view to handle .. --- .../mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py index 4265068cf195..f3abcdb717ff 100644 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py @@ -43,6 +43,7 @@ def __init__(self, parent=None): def _double_spinbox_textChanged(self, text): if "," in text: text = text.replace(",", ".") + text = text.replace("..", ".") oldState = self.sender().blockSignals(True) self.sender().setValue(float(text)) self.sender().blockSignals(oldState) From 458b71577fd69e512d0038543e923c6b5ed6a21a Mon Sep 17 00:00:00 2001 From: Waruna Wickramasingha Date: Thu, 31 Oct 2024 12:07:40 +0000 Subject: [PATCH 3/4] updated comma behaviour in samp trans calc double spin boxes --- .../SampleTransmissionCalculator/stc_view.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py index f3abcdb717ff..0faa2cabd240 100644 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/SampleTransmissionCalculator/stc_view.py @@ -43,9 +43,10 @@ def __init__(self, parent=None): def _double_spinbox_textChanged(self, text): if "," in text: text = text.replace(",", ".") - text = text.replace("..", ".") oldState = self.sender().blockSignals(True) + self.isEditing = True self.sender().setValue(float(text)) + self.sender().lineEdit().setText(f"{self.sender().value():.1f}") self.sender().blockSignals(oldState) def get_input_dict(self): From 1dab00c3e4ade60665618b3c61f2e70583cff079 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:10:34 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst b/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst index d2c5d7be186a..6fe28f083b44 100644 --- a/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst +++ b/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/38063.rst @@ -1 +1 @@ -- Fixed a bug in :ref:`sample_transmission_calculator` (Interfaces > General > Sample Transmission Calculator) interface to restrict entering commas mixed with decimal point in the double spin boxes for Low, Width and High fields \ No newline at end of file +- Fixed a bug in :ref:`sample_transmission_calculator` (Interfaces > General > Sample Transmission Calculator) interface to restrict entering commas mixed with decimal point in the double spin boxes for Low, Width and High fields