From c71b2bb2247af5c5591bcabf62681b7e6c873388 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Mon, 4 Dec 2023 10:01:54 +0100 Subject: [PATCH 1/3] GUI SpanPropertyForm: rm coupling of span and width (#856) --- GUI/View/Device/SpanPropertyForm.cpp | 19 ++++++++----------- auto/Wrap/libBornAgainDevice.py | 6 +++--- auto/Wrap/libBornAgainDevice_wrap.cpp | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/GUI/View/Device/SpanPropertyForm.cpp b/GUI/View/Device/SpanPropertyForm.cpp index f003b492d36..06c547a0119 100644 --- a/GUI/View/Device/SpanPropertyForm.cpp +++ b/GUI/View/Device/SpanPropertyForm.cpp @@ -42,24 +42,21 @@ SpanPropertyForm::SpanPropertyForm(QWidget* parent, const QString& groupTitle, m_centerSpinBox = GUI::Util::createDoubleSpinBoxRow(layout, spanProperty->center()); connect(m_widthSpinBox, &DoubleSpinBox::baseValueChanged, [this](double v) { - if (m_spanProperty->width() != v) { + if (v < 0) { + m_spanProperty->setWidth(0); + m_widthSpinBox->updateValue(); + } else { + if (m_spanProperty->width() == v) + return; m_spanProperty->setWidth(v); - emit dataChanged(); - if (m_spanProperty->center() < v) { - m_spanProperty->setCenter(v); - m_centerSpinBox->updateValue(); - } - } + } + emit dataChanged(); }); connect(m_centerSpinBox, &DoubleSpinBox::baseValueChanged, [this](double v) { if (m_spanProperty->center() != v) { m_spanProperty->setCenter(v); emit dataChanged(); - if (m_spanProperty->width() > v) { - m_spanProperty->setWidth(v); - m_widthSpinBox->updateValue(); - } } }); } diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index 94fef054950..0ebbebc171b 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -2714,9 +2714,9 @@ class Detector2D(IDetector): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr - def __init__(self, phi_full_width, alpha_full_width, n_phi, n_alpha, center_phi, center_alpha): - r"""__init__(Detector2D self, double phi_full_width, double alpha_full_width, size_t n_phi, size_t n_alpha, double center_phi, double center_alpha) -> Detector2D""" - _libBornAgainDevice.Detector2D_swiginit(self, _libBornAgainDevice.new_Detector2D(phi_full_width, alpha_full_width, n_phi, n_alpha, center_phi, center_alpha)) + def __init__(self, phi_span, alpha_span, n_phi, n_alpha, phi_center, alpha_center): + r"""__init__(Detector2D self, double phi_span, double alpha_span, size_t n_phi, size_t n_alpha, double phi_center, double alpha_center) -> Detector2D""" + _libBornAgainDevice.Detector2D_swiginit(self, _libBornAgainDevice.new_Detector2D(phi_span, alpha_span, n_phi, n_alpha, phi_center, alpha_center)) __swig_destroy__ = _libBornAgainDevice.delete_Detector2D def clone(self): diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index 33aafff29ae..52d182f8508 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -42453,7 +42453,7 @@ static PyMethodDef SwigMethods[] = { { "IDetector_setRegionOfInterest", _wrap_IDetector_setRegionOfInterest, METH_VARARGS, "IDetector_setRegionOfInterest(IDetector self, double xlow, double ylow, double xup, double yup)"}, { "IDetector_clippedFrame", _wrap_IDetector_clippedFrame, METH_O, "IDetector_clippedFrame(IDetector self) -> Frame"}, { "IDetector_swigregister", IDetector_swigregister, METH_O, NULL}, - { "new_Detector2D", _wrap_new_Detector2D, METH_VARARGS, "new_Detector2D(double phi_full_width, double alpha_full_width, size_t n_phi, size_t n_alpha, double center_phi, double center_alpha) -> Detector2D"}, + { "new_Detector2D", _wrap_new_Detector2D, METH_VARARGS, "new_Detector2D(double phi_span, double alpha_span, size_t n_phi, size_t n_alpha, double phi_center, double alpha_center) -> Detector2D"}, { "delete_Detector2D", _wrap_delete_Detector2D, METH_O, "delete_Detector2D(Detector2D self)"}, { "Detector2D_clone", _wrap_Detector2D_clone, METH_O, "Detector2D_clone(Detector2D self) -> Detector2D"}, { "Detector2D_className", _wrap_Detector2D_className, METH_O, "Detector2D_className(Detector2D self) -> std::string"}, -- GitLab From d15914d374df8d51c68d6a2d1966e5b01f179bb5 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Mon, 4 Dec 2023 10:07:27 +0100 Subject: [PATCH 2/3] deduplicate enforcing v>=0 --- GUI/View/Device/SpanPropertyForm.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/GUI/View/Device/SpanPropertyForm.cpp b/GUI/View/Device/SpanPropertyForm.cpp index 06c547a0119..530031a63a4 100644 --- a/GUI/View/Device/SpanPropertyForm.cpp +++ b/GUI/View/Device/SpanPropertyForm.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/View/Device/SpanPropertyForm.h" +#include "Base/Util/Assert.h" #include "GUI/Model/Descriptor/SpanProperty.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Numeric/DoubleSpinBox.h" @@ -42,14 +43,10 @@ SpanPropertyForm::SpanPropertyForm(QWidget* parent, const QString& groupTitle, m_centerSpinBox = GUI::Util::createDoubleSpinBoxRow(layout, spanProperty->center()); connect(m_widthSpinBox, &DoubleSpinBox::baseValueChanged, [this](double v) { - if (v < 0) { - m_spanProperty->setWidth(0); - m_widthSpinBox->updateValue(); - } else { - if (m_spanProperty->width() == v) - return; - m_spanProperty->setWidth(v); - } + ASSERT(v >= 0); // spin box should have got limits from property + if (m_spanProperty->width() == v) + return; + m_spanProperty->setWidth(v); emit dataChanged(); }); -- GitLab From 4bb57a3c822ecf80562f274c38923c5db73adf6b Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Mon, 4 Dec 2023 10:11:49 +0100 Subject: [PATCH 3/3] clang-format --- GUI/View/Device/SpanPropertyForm.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GUI/View/Device/SpanPropertyForm.cpp b/GUI/View/Device/SpanPropertyForm.cpp index 530031a63a4..43d7ac611d0 100644 --- a/GUI/View/Device/SpanPropertyForm.cpp +++ b/GUI/View/Device/SpanPropertyForm.cpp @@ -43,11 +43,11 @@ SpanPropertyForm::SpanPropertyForm(QWidget* parent, const QString& groupTitle, m_centerSpinBox = GUI::Util::createDoubleSpinBoxRow(layout, spanProperty->center()); connect(m_widthSpinBox, &DoubleSpinBox::baseValueChanged, [this](double v) { - ASSERT(v >= 0); // spin box should have got limits from property - if (m_spanProperty->width() == v) - return; - m_spanProperty->setWidth(v); - emit dataChanged(); + ASSERT(v >= 0); // spin box should have got limits from property + if (m_spanProperty->width() == v) + return; + m_spanProperty->setWidth(v); + emit dataChanged(); }); connect(m_centerSpinBox, &DoubleSpinBox::baseValueChanged, [this](double v) { -- GitLab