From be11b2188bf73fb532947b646626fbc8659583b1 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Tue, 5 Nov 2024 13:04:26 +0100
Subject: [PATCH 1/3] init axis properties in constructor

---
 GUI/Model/Descriptor/AxisProperty.cpp      | 11 ++++-------
 GUI/Model/Descriptor/AxisProperty.h        |  4 ++--
 GUI/Model/Detector/DetectorItem.cpp        |  4 ++--
 GUI/Model/Detector/OffspecDetectorItem.cpp | 11 ++---------
 GUI/Model/Sim/InstrumentItems.cpp          |  6 +-----
 5 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/GUI/Model/Descriptor/AxisProperty.cpp b/GUI/Model/Descriptor/AxisProperty.cpp
index 8496d6f5215..815856d1bf0 100644
--- a/GUI/Model/Descriptor/AxisProperty.cpp
+++ b/GUI/Model/Descriptor/AxisProperty.cpp
@@ -27,14 +27,11 @@ const QString ExpandGroupbox("ExpandGroupbox"); // obsolete since v22.0
 } // namespace
 
 
-AxisProperty::AxisProperty() = default;
-
-AxisProperty::AxisProperty(const QString& name, const QString& unit)
+AxisProperty::AxisProperty(const QString& name, const QString& unit, double start_min,
+                           double start_max, const RealLimits& limits)
 {
-    initMin(name + "_min (" + unit + ")", name + "_min (" + unit + ")", -1.,
-            RealLimits::limitless(), 3);
-    initMax(name + "_max (" + unit + ")", name + "_max (" + unit + ")", +1.,
-            RealLimits::limitless(), 3);
+    initMin("Min (" + unit + ")", "Lower edge of first " + name + "-bin", start_min, limits, 3);
+    initMax("Max (" + unit + ")", "Upper edge of last " + name + "-bin", start_max, limits, 3);
 }
 
 void AxisProperty::initMin(const QString& label, const QString& tooltip, double value,
diff --git a/GUI/Model/Descriptor/AxisProperty.h b/GUI/Model/Descriptor/AxisProperty.h
index 90f2b09df02..87ff5bb1d7d 100644
--- a/GUI/Model/Descriptor/AxisProperty.h
+++ b/GUI/Model/Descriptor/AxisProperty.h
@@ -28,8 +28,8 @@
 
 class AxisProperty {
 public:
-    AxisProperty();
-    AxisProperty(const QString& name, const QString& unit);
+    AxisProperty(const QString& name, const QString& unit, double start_min, double start_max,
+                 const RealLimits& limits);
 
     DoubleProperty& min() { return m_min; }
     const DoubleProperty& min() const { return m_min; }
diff --git a/GUI/Model/Detector/DetectorItem.cpp b/GUI/Model/Detector/DetectorItem.cpp
index c44162912f9..7360a936c2f 100644
--- a/GUI/Model/Detector/DetectorItem.cpp
+++ b/GUI/Model/Detector/DetectorItem.cpp
@@ -37,8 +37,8 @@ const QString ProjectionContainer("ProjectionContainer");
 
 
 DetectorItem::DetectorItem()
-    : m_phi_axis("phi", "deg")
-    , m_alpha_axis("alpha", "deg")
+    : m_phi_axis("phi", "deg", -1, 1, RealLimits::limited(-90, 90))
+    , m_alpha_axis("alpha", "deg", 0, 2, RealLimits::limited(-90, 90))
     , m_masks(std::make_unique<MasksSet>())
     , m_prjns(std::make_unique<MasksSet>())
 {
diff --git a/GUI/Model/Detector/OffspecDetectorItem.cpp b/GUI/Model/Detector/OffspecDetectorItem.cpp
index af4f1332807..dd967577d5c 100644
--- a/GUI/Model/Detector/OffspecDetectorItem.cpp
+++ b/GUI/Model/Detector/OffspecDetectorItem.cpp
@@ -29,16 +29,9 @@ const QString BaseData("BaseData");
 } // namespace
 
 OffspecDetectorItem::OffspecDetectorItem()
+    : m_phi_axis("phi", "deg", -1, 1, RealLimits::limited(-90, 90))
+    , m_alpha_axis("alpha", "deg", 0, 2, RealLimits::limited(-90, 90))
 {
-    m_phi_axis.initMin("Min (deg)", "Lower edge of first phi-bin", -1.0,
-                       RealLimits::limited(-90, 90));
-    m_phi_axis.initMax("Max (deg)", "Upper edge of last phi-bin", 1.0,
-                       RealLimits::limited(-90, 90));
-
-    m_alpha_axis.initMin("Min (deg)", "Lower edge of first alpha-bin", 0.0,
-                         RealLimits::limited(-90, 90));
-    m_alpha_axis.initMax("Max (deg)", "Upper edge of last alpha-bin", 2.0,
-                         RealLimits::limited(-90, 90));
 }
 
 void OffspecDetectorItem::writeTo(QXmlStreamWriter* w) const
diff --git a/GUI/Model/Sim/InstrumentItems.cpp b/GUI/Model/Sim/InstrumentItems.cpp
index c7ba92c3e17..9cdbf791871 100644
--- a/GUI/Model/Sim/InstrumentItems.cpp
+++ b/GUI/Model/Sim/InstrumentItems.cpp
@@ -504,6 +504,7 @@ void SpecularInstrumentItem::readFrom(QXmlStreamReader* r)
 
 DepthprobeInstrumentItem::DepthprobeInstrumentItem()
     : ScanningInstrumentItem(1e8)
+    , m_z_axis("depth", "nm", -100, 100, RealLimits::limitless())
 {
     setName("Depthprobe");
 
@@ -511,11 +512,6 @@ DepthprobeInstrumentItem::DepthprobeInstrumentItem()
     axisItem->setMin(0.0);
     axisItem->setMax(1.0);
     axisItem->resize(500);
-
-    m_z_axis.initMin("Min (nm)", "Starting value below sample horizon", -100.0,
-                     RealLimits::limitless());
-    m_z_axis.initMax("Max (nm)", "Ending value above sample horizon", 100.0,
-                     RealLimits::limitless());
 }
 
 size_t DepthprobeInstrumentItem::axdim(int) const
-- 
GitLab


From c221bf2e133ccd4837fdbcd71c12f6459bed73ce Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Tue, 5 Nov 2024 13:08:55 +0100
Subject: [PATCH 2/3] rm public init methods from AxisProperty

---
 GUI/Model/Descriptor/AxisProperty.cpp | 18 ++++--------------
 GUI/Model/Descriptor/AxisProperty.h   |  5 -----
 auto/Wrap/libBornAgainDevice_wrap.cpp |  2 +-
 3 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/GUI/Model/Descriptor/AxisProperty.cpp b/GUI/Model/Descriptor/AxisProperty.cpp
index 815856d1bf0..4a499717f60 100644
--- a/GUI/Model/Descriptor/AxisProperty.cpp
+++ b/GUI/Model/Descriptor/AxisProperty.cpp
@@ -30,20 +30,10 @@ const QString ExpandGroupbox("ExpandGroupbox"); // obsolete since v22.0
 AxisProperty::AxisProperty(const QString& name, const QString& unit, double start_min,
                            double start_max, const RealLimits& limits)
 {
-    initMin("Min (" + unit + ")", "Lower edge of first " + name + "-bin", start_min, limits, 3);
-    initMax("Max (" + unit + ")", "Upper edge of last " + name + "-bin", start_max, limits, 3);
-}
-
-void AxisProperty::initMin(const QString& label, const QString& tooltip, double value,
-                           const RealLimits& limits, uint decimals)
-{
-    m_min.init(label, tooltip, value, decimals, limits, "min");
-}
-
-void AxisProperty::initMax(const QString& label, const QString& tooltip, double value,
-                           const RealLimits& limits, uint decimals)
-{
-    m_max.init(label, tooltip, value, decimals, limits, "max");
+    m_min.init("Min (" + unit + ")", "Lower edge of first " + name + "-bin", start_min, 3, limits,
+               "min");
+    m_max.init("Max (" + unit + ")", "Upper edge of last " + name + "-bin", start_max, 3, limits,
+               "max");
 }
 
 void AxisProperty::writeTo(QXmlStreamWriter* w) const
diff --git a/GUI/Model/Descriptor/AxisProperty.h b/GUI/Model/Descriptor/AxisProperty.h
index 87ff5bb1d7d..e73611726e5 100644
--- a/GUI/Model/Descriptor/AxisProperty.h
+++ b/GUI/Model/Descriptor/AxisProperty.h
@@ -37,11 +37,6 @@ public:
     DoubleProperty& max() { return m_max; }
     const DoubleProperty& max() const { return m_max; }
 
-    void initMin(const QString& label, const QString& tooltip, double value,
-                 const RealLimits& limits = RealLimits::nonnegative(), uint decimals = 3);
-    void initMax(const QString& label, const QString& tooltip, double value,
-                 const RealLimits& limits = RealLimits::nonnegative(), uint decimals = 3);
-
     uint nbins() const { return m_nbins; }
     void setNbins(uint v) { m_nbins = v; }
 
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index 07adfd1e633..1216c183292 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -5591,7 +5591,7 @@ SWIG_AsVal_std_complex_Sl_double_Sg_  (PyObject *o, std::complex<double>* val)
 
 
 SWIGINTERNINLINE PyObject*
-SWIG_From_std_complex_Sl_double_Sg_  (/*@SWIG:/home/ammar/.local/jcns/share/swig/4.2.1/typemaps/swigmacros.swg,104,%ifcplusplus@*/
+SWIG_From_std_complex_Sl_double_Sg_  (/*@SWIG:/usr/local/share/swig/4.2.1/typemaps/swigmacros.swg,104,%ifcplusplus@*/
 
 const std::complex<double>&
 
-- 
GitLab


From 362b97f453d4fbf2e225ee7713d682bc284d41bc Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Tue, 5 Nov 2024 13:34:29 +0100
Subject: [PATCH 3/3] rename argument

---
 GUI/Model/Descriptor/AxisProperty.cpp | 10 ++++------
 GUI/Model/Descriptor/AxisProperty.h   |  4 ++--
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/GUI/Model/Descriptor/AxisProperty.cpp b/GUI/Model/Descriptor/AxisProperty.cpp
index 4a499717f60..7985ed612df 100644
--- a/GUI/Model/Descriptor/AxisProperty.cpp
+++ b/GUI/Model/Descriptor/AxisProperty.cpp
@@ -27,13 +27,11 @@ const QString ExpandGroupbox("ExpandGroupbox"); // obsolete since v22.0
 } // namespace
 
 
-AxisProperty::AxisProperty(const QString& name, const QString& unit, double start_min,
-                           double start_max, const RealLimits& limits)
+AxisProperty::AxisProperty(const QString& name, const QString& unit, double _min, double _max,
+                           const RealLimits& limit)
 {
-    m_min.init("Min (" + unit + ")", "Lower edge of first " + name + "-bin", start_min, 3, limits,
-               "min");
-    m_max.init("Max (" + unit + ")", "Upper edge of last " + name + "-bin", start_max, 3, limits,
-               "max");
+    m_min.init("Min (" + unit + ")", "Lower edge of first " + name + "-bin", _min, 3, limit, "min");
+    m_max.init("Max (" + unit + ")", "Upper edge of last " + name + "-bin", _max, 3, limit, "max");
 }
 
 void AxisProperty::writeTo(QXmlStreamWriter* w) const
diff --git a/GUI/Model/Descriptor/AxisProperty.h b/GUI/Model/Descriptor/AxisProperty.h
index e73611726e5..0dc6729f038 100644
--- a/GUI/Model/Descriptor/AxisProperty.h
+++ b/GUI/Model/Descriptor/AxisProperty.h
@@ -28,8 +28,8 @@
 
 class AxisProperty {
 public:
-    AxisProperty(const QString& name, const QString& unit, double start_min, double start_max,
-                 const RealLimits& limits);
+    AxisProperty(const QString& name, const QString& unit, double _min, double _max,
+                 const RealLimits& limit);
 
     DoubleProperty& min() { return m_min; }
     const DoubleProperty& min() const { return m_min; }
-- 
GitLab