From 0d9e841bb6eebf00b26792c81bd4013e0ef11495 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Fri, 25 Aug 2023 13:16:59 +0200
Subject: [PATCH] + Scale::plottableScale

---
 Base/Axis/Scale.cpp                 | 11 ++++
 Base/Axis/Scale.h                   |  1 +
 auto/Wrap/libBornAgainBase.py       |  5 +-
 auto/Wrap/libBornAgainBase_wrap.cpp | 82 +++++++++++++++++++++++++++--
 4 files changed, 94 insertions(+), 5 deletions(-)

diff --git a/Base/Axis/Scale.cpp b/Base/Axis/Scale.cpp
index f893ffa78c0..331ed6485e1 100644
--- a/Base/Axis/Scale.cpp
+++ b/Base/Axis/Scale.cpp
@@ -262,3 +262,14 @@ Scale Scale::plottableScale(std::string label) const
     }
     return {label, outvector};
 }
+
+Scale Scale::plottableScale(const Coordinate& coord, const trafo_t& axTrafo) const
+{
+    std::vector<Bin1D> outvector;
+    for (const Bin1D b : m_bins) {
+        double bmi = axTrafo(b.lowerBound());
+        double bma = axTrafo(b.upperBound());
+        outvector.emplace_back(Bin1D::FromTo(bmi, bma));
+    }
+    return {coord.label(), outvector};
+}
diff --git a/Base/Axis/Scale.h b/Base/Axis/Scale.h
index 34919c46028..06dc8fd7b1b 100644
--- a/Base/Axis/Scale.h
+++ b/Base/Axis/Scale.h
@@ -87,6 +87,7 @@ public:
     std::string unit() const;
 
     Scale plottableScale(std::string label = "") const;
+    Scale plottableScale(const Coordinate& coord, const trafo_t& axTrafo) const;
 
 protected:
     std::vector<Bin1D> m_bins;
diff --git a/auto/Wrap/libBornAgainBase.py b/auto/Wrap/libBornAgainBase.py
index 38435769b70..08579f96532 100644
--- a/auto/Wrap/libBornAgainBase.py
+++ b/auto/Wrap/libBornAgainBase.py
@@ -1953,7 +1953,10 @@ class Scale(object):
         return _libBornAgainBase.Scale_unit(self)
 
     def plottableScale(self, *args):
-        r"""plottableScale(Scale self, std::string label="") -> Scale"""
+        r"""
+        plottableScale(Scale self, std::string label="") -> Scale
+        plottableScale(Scale self, Coordinate const & coord, trafo_t const & axTrafo) -> Scale
+        """
         return _libBornAgainBase.Scale_plottableScale(self, *args)
     __swig_destroy__ = _libBornAgainBase.delete_Scale
 
diff --git a/auto/Wrap/libBornAgainBase_wrap.cpp b/auto/Wrap/libBornAgainBase_wrap.cpp
index f890a30fc8f..7b565d0d236 100644
--- a/auto/Wrap/libBornAgainBase_wrap.cpp
+++ b/auto/Wrap/libBornAgainBase_wrap.cpp
@@ -26886,13 +26886,66 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_Scale_plottableScale__SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
+  PyObject *resultobj = 0;
+  Scale *arg1 = (Scale *) 0 ;
+  Coordinate *arg2 = 0 ;
+  trafo_t *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  void *argp3 = 0 ;
+  int res3 = 0 ;
+  SwigValueWrapper< Scale > result;
+  
+  if ((nobjs < 3) || (nobjs > 3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Scale, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Scale_plottableScale" "', argument " "1"" of type '" "Scale const *""'"); 
+  }
+  arg1 = reinterpret_cast< Scale * >(argp1);
+  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Coordinate,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Scale_plottableScale" "', argument " "2"" of type '" "Coordinate const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Scale_plottableScale" "', argument " "2"" of type '" "Coordinate const &""'"); 
+  }
+  arg2 = reinterpret_cast< Coordinate * >(argp2);
+  res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_std__functionT_double_fdoubleF_t,  0  | 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Scale_plottableScale" "', argument " "3"" of type '" "trafo_t const &""'"); 
+  }
+  if (!argp3) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Scale_plottableScale" "', argument " "3"" of type '" "trafo_t const &""'"); 
+  }
+  arg3 = reinterpret_cast< trafo_t * >(argp3);
+  {
+    try {
+      result = ((Scale const *)arg1)->plottableScale((Coordinate const &)*arg2,(trafo_t const &)*arg3);
+    } catch (const std::exception& ex) {
+      // message shown in the Python interpreter
+      const std::string msg {
+        "BornAgain C++ Exception: " + std::string(ex.what())
+      };
+      SWIG_exception(SWIG_RuntimeError, msg.c_str());
+    }
+  }
+  resultobj = SWIG_NewPointerObj((new Scale(result)), SWIGTYPE_p_Scale, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_Scale_plottableScale(PyObject *self, PyObject *args) {
   Py_ssize_t argc;
-  PyObject *argv[3] = {
+  PyObject *argv[4] = {
     0
   };
   
-  if (!(argc = SWIG_Python_UnpackTuple(args, "Scale_plottableScale", 0, 2, argv))) SWIG_fail;
+  if (!(argc = SWIG_Python_UnpackTuple(args, "Scale_plottableScale", 0, 3, argv))) SWIG_fail;
   --argc;
   if (argc == 1) {
     int _v = 0;
@@ -26916,12 +26969,30 @@ SWIGINTERN PyObject *_wrap_Scale_plottableScale(PyObject *self, PyObject *args)
       }
     }
   }
+  if (argc == 3) {
+    int _v = 0;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Scale, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_Coordinate, SWIG_POINTER_NO_NULL | 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_std__functionT_double_fdoubleF_t, SWIG_POINTER_NO_NULL | 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_Scale_plottableScale__SWIG_2(self, argc, argv);
+        }
+      }
+    }
+  }
   
 fail:
   SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Scale_plottableScale'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    Scale::plottableScale(std::string) const\n"
-    "    Scale::plottableScale() const\n");
+    "    Scale::plottableScale() const\n"
+    "    Scale::plottableScale(Coordinate const &,trafo_t const &) const\n");
   return 0;
 }
 
@@ -30591,7 +30662,10 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "Scale___eq__", _wrap_Scale___eq__, METH_VARARGS, "Scale___eq__(Scale self, Scale other) -> bool"},
 	 { "Scale_unit", _wrap_Scale_unit, METH_O, "Scale_unit(Scale self) -> std::string"},
-	 { "Scale_plottableScale", _wrap_Scale_plottableScale, METH_VARARGS, "Scale_plottableScale(Scale self, std::string label=\"\") -> Scale"},
+	 { "Scale_plottableScale", _wrap_Scale_plottableScale, METH_VARARGS, "\n"
+		"Scale_plottableScale(Scale self, std::string label=\"\") -> Scale\n"
+		"Scale_plottableScale(Scale self, Coordinate const & coord, trafo_t const & axTrafo) -> Scale\n"
+		""},
 	 { "delete_Scale", _wrap_delete_Scale, METH_O, "delete_Scale(Scale self)"},
 	 { "Scale_swigregister", Scale_swigregister, METH_O, NULL},
 	 { "Scale_swiginit", Scale_swiginit, METH_VARARGS, NULL},
-- 
GitLab