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] 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