From 25414fffd0f53f351b4039e01e298c2fbcabe560 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Thu, 13 Apr 2023 12:41:55 +0200
Subject: [PATCH] Datafield: Frame-base c'tors now public

---
 Device/Data/Datafield.h               |  16 +--
 auto/Wrap/libBornAgainDevice.py       |   3 +
 auto/Wrap/libBornAgainDevice_wrap.cpp | 163 +++++++++++++++++++++++++-
 3 files changed, 169 insertions(+), 13 deletions(-)

diff --git a/Device/Data/Datafield.h b/Device/Data/Datafield.h
index a0bdcc7a620..8588b97f263 100644
--- a/Device/Data/Datafield.h
+++ b/Device/Data/Datafield.h
@@ -28,6 +28,14 @@ class Frame;
 
 class Datafield {
 public:
+    //! Constructor that takes ownership of supplied frame.
+    Datafield(const Frame* frame);
+    //! Constructor that takes ownership of supplied frame and initializes values.
+    Datafield(const Frame* frame, const std::vector<double>& values);
+    //! Constructor that takes ownership of supplied frame and initializes values and errorbars
+    Datafield(const Frame* frame, const std::vector<double>& values,
+              const std::vector<double>& errSigmas);
+
     //! Constructor that takes ownership of supplied axes.
     Datafield(const std::vector<const IAxis*>& axes);
     //! Constructor that takes ownership of supplied axes and initializes values.
@@ -128,14 +136,6 @@ public:
     Datafield* yProjection(double xlow, double xup) const;
 
 private:
-    //! Constructor that takes ownership of supplied frame.
-    Datafield(const Frame* frame);
-    //! Constructor that takes ownership of supplied frame and initializes values.
-    Datafield(const Frame* frame, const std::vector<double>& values);
-    //! Constructor that takes ownership of supplied frame and initializes values and errorbars
-    Datafield(const Frame* frame, const std::vector<double>& values,
-              const std::vector<double>& errSigmas);
-
     //! Creates projection along X. The projections is made by collecting the data in the range
     //! between [ybinlow, ybinup].
     Datafield* create_xProjection(int ybinlow, int ybinup) const;
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index 7ac833e959e..f036aa67cb7 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -2041,6 +2041,9 @@ class Datafield(object):
 
     def __init__(self, *args):
         r"""
+        __init__(Datafield self, Frame frame) -> Datafield
+        __init__(Datafield self, Frame frame, vdouble1d_t values) -> Datafield
+        __init__(Datafield self, Frame frame, vdouble1d_t values, vdouble1d_t errSigmas) -> Datafield
         __init__(Datafield self, std::vector< IAxis const *,std::allocator< IAxis const * > > const & axes) -> Datafield
         __init__(Datafield self, std::vector< IAxis const *,std::allocator< IAxis const * > > const & axes, vdouble1d_t values) -> Datafield
         __init__(Datafield self, std::vector< IAxis const *,std::allocator< IAxis const * > > const & axes, vdouble1d_t values, vdouble1d_t errSigmas) -> Datafield
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index 9ec90812305..809303b6893 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -27359,6 +27359,114 @@ SWIGINTERN PyObject *vector_R3_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject
 }
 
 SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
+  PyObject *resultobj = 0;
+  Frame *arg1 = (Frame *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  Datafield *result = 0 ;
+  
+  if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Frame, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Datafield" "', argument " "1"" of type '" "Frame const *""'"); 
+  }
+  arg1 = reinterpret_cast< Frame * >(argp1);
+  result = (Datafield *)new Datafield((Frame const *)arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
+  PyObject *resultobj = 0;
+  Frame *arg1 = (Frame *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  Datafield *result = 0 ;
+  
+  if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Frame, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Datafield" "', argument " "1"" of type '" "Frame const *""'"); 
+  }
+  arg1 = reinterpret_cast< Frame * >(argp1);
+  {
+    std::vector< double,std::allocator< double > > *ptr = (std::vector< double,std::allocator< double > > *)0;
+    res2 = swig::asptr(swig_obj[1], &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Datafield" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Datafield" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  result = (Datafield *)new Datafield((Frame const *)arg1,(std::vector< double,std::allocator< double > > const &)*arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
+  PyObject *resultobj = 0;
+  Frame *arg1 = (Frame *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  std::vector< double,std::allocator< double > > *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  int res3 = SWIG_OLDOBJ ;
+  Datafield *result = 0 ;
+  
+  if ((nobjs < 3) || (nobjs > 3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Frame, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Datafield" "', argument " "1"" of type '" "Frame const *""'"); 
+  }
+  arg1 = reinterpret_cast< Frame * >(argp1);
+  {
+    std::vector< double,std::allocator< double > > *ptr = (std::vector< double,std::allocator< double > > *)0;
+    res2 = swig::asptr(swig_obj[1], &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Datafield" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Datafield" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  {
+    std::vector< double,std::allocator< double > > *ptr = (std::vector< double,std::allocator< double > > *)0;
+    res3 = swig::asptr(swig_obj[2], &ptr);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_Datafield" "', argument " "3"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Datafield" "', argument " "3"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    arg3 = ptr;
+  }
+  result = (Datafield *)new Datafield((Frame const *)arg1,(std::vector< double,std::allocator< double > > const &)*arg2,(std::vector< double,std::allocator< double > > const &)*arg3);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  if (SWIG_IsNewObj(res3)) delete arg3;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  if (SWIG_IsNewObj(res3)) delete arg3;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_3(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   std::vector< IAxis const *,std::allocator< IAxis const * > > *arg1 = 0 ;
   void *argp1 = 0 ;
@@ -27382,7 +27490,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_4(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   std::vector< IAxis const *,std::allocator< IAxis const * > > *arg1 = 0 ;
   std::vector< double,std::allocator< double > > *arg2 = 0 ;
@@ -27421,7 +27529,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_5(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   std::vector< IAxis const *,std::allocator< IAxis const * > > *arg1 = 0 ;
   std::vector< double,std::allocator< double > > *arg2 = 0 ;
@@ -27475,7 +27583,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_3(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_6(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   Datafield *arg1 = 0 ;
   void *argp1 = 0 ;
@@ -27515,25 +27623,47 @@ SWIGINTERN PyObject *_wrap_new_Datafield(PyObject *self, PyObject *args) {
   --argc;
   if (argc == 1) {
     int _v = 0;
-    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t, SWIG_POINTER_NO_NULL | 0);
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Frame, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
       return _wrap_new_Datafield__SWIG_0(self, argc, argv);
     }
   }
+  if (argc == 1) {
+    int _v = 0;
+    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t, SWIG_POINTER_NO_NULL | 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_new_Datafield__SWIG_3(self, argc, argv);
+    }
+  }
   if (argc == 1) {
     int _v = 0;
     void *vptr = 0;
     int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Datafield, SWIG_POINTER_NO_NULL);
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_Datafield__SWIG_3(self, argc, argv);
+      return _wrap_new_Datafield__SWIG_6(self, argc, argv);
     }
   }
   if (argc == 2) {
     int _v = 0;
     int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t, SWIG_POINTER_NO_NULL | 0);
     _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = swig::asptr(argv[1], (std::vector< double,std::allocator< double > >**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_new_Datafield__SWIG_4(self, argc, argv);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v = 0;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Frame, 0);
+    _v = SWIG_CheckState(res);
     if (_v) {
       int res = swig::asptr(argv[1], (std::vector< double,std::allocator< double > >**)(0));
       _v = SWIG_CheckState(res);
@@ -27546,6 +27676,23 @@ SWIGINTERN PyObject *_wrap_new_Datafield(PyObject *self, PyObject *args) {
     int _v = 0;
     int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t, SWIG_POINTER_NO_NULL | 0);
     _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = swig::asptr(argv[1], (std::vector< double,std::allocator< double > >**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        int res = swig::asptr(argv[2], (std::vector< double,std::allocator< double > >**)(0));
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_new_Datafield__SWIG_5(self, argc, argv);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v = 0;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Frame, 0);
+    _v = SWIG_CheckState(res);
     if (_v) {
       int res = swig::asptr(argv[1], (std::vector< double,std::allocator< double > >**)(0));
       _v = SWIG_CheckState(res);
@@ -27562,6 +27709,9 @@ SWIGINTERN PyObject *_wrap_new_Datafield(PyObject *self, PyObject *args) {
 fail:
   SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_Datafield'.\n"
     "  Possible C/C++ prototypes are:\n"
+    "    Datafield::Datafield(Frame const *)\n"
+    "    Datafield::Datafield(Frame const *,std::vector< double,std::allocator< double > > const &)\n"
+    "    Datafield::Datafield(Frame const *,std::vector< double,std::allocator< double > > const &,std::vector< double,std::allocator< double > > const &)\n"
     "    Datafield::Datafield(std::vector< IAxis const *,std::allocator< IAxis const * > > const &)\n"
     "    Datafield::Datafield(std::vector< IAxis const *,std::allocator< IAxis const * > > const &,std::vector< double,std::allocator< double > > const &)\n"
     "    Datafield::Datafield(std::vector< IAxis const *,std::allocator< IAxis const * > > const &,std::vector< double,std::allocator< double > > const &,std::vector< double,std::allocator< double > > const &)\n"
@@ -38174,6 +38324,9 @@ static PyMethodDef SwigMethods[] = {
 	 { "vector_R3_swigregister", vector_R3_swigregister, METH_O, NULL},
 	 { "vector_R3_swiginit", vector_R3_swiginit, METH_VARARGS, NULL},
 	 { "new_Datafield", _wrap_new_Datafield, METH_VARARGS, "\n"
+		"Datafield(Frame frame)\n"
+		"Datafield(Frame frame, vdouble1d_t values)\n"
+		"Datafield(Frame frame, vdouble1d_t values, vdouble1d_t errSigmas)\n"
 		"Datafield(std::vector< IAxis const *,std::allocator< IAxis const * > > const & axes)\n"
 		"Datafield(std::vector< IAxis const *,std::allocator< IAxis const * > > const & axes, vdouble1d_t values)\n"
 		"Datafield(std::vector< IAxis const *,std::allocator< IAxis const * > > const & axes, vdouble1d_t values, vdouble1d_t errSigmas)\n"
-- 
GitLab