diff --git a/Core/Beam/FootprintGauss.cpp b/Core/Beam/FootprintGauss.cpp index 4b68695fee88ea6d2c2733bd18ce4d8202d303f0..55f740224f1849e1d791d87dd7b2a30a202f983e 100644 --- a/Core/Beam/FootprintGauss.cpp +++ b/Core/Beam/FootprintGauss.cpp @@ -17,9 +17,14 @@ #include "Core/Tools/MathFunctions.h" #include "Core/Tools/PyFmt.h" -FootprintGauss::FootprintGauss(double width_ratio) : IFootprintFactor(width_ratio) +FootprintGauss::FootprintGauss(const std::vector<double> P) + : IFootprintFactor({"FootprintGauss", "class_tooltip", {}}, P) +{ +} + +FootprintGauss::FootprintGauss(double width_ratio) + : FootprintGauss(std::vector<double>{width_ratio}) { - setName("FootprintGauss"); } FootprintGauss* FootprintGauss::clone() const diff --git a/Core/Beam/FootprintGauss.h b/Core/Beam/FootprintGauss.h index 6269eb195172bbe39cb43f4b7a4814a9e65dd377..95ff547961fc4fb924eba7ca2db5f3857131a8c8 100644 --- a/Core/Beam/FootprintGauss.h +++ b/Core/Beam/FootprintGauss.h @@ -25,6 +25,7 @@ class BA_CORE_API_ FootprintGauss : public IFootprintFactor { public: + FootprintGauss(const std::vector<double> P); FootprintGauss(double width_ratio); void accept(INodeVisitor* visitor) const override { visitor->visit(this); } diff --git a/Core/Beam/FootprintSquare.cpp b/Core/Beam/FootprintSquare.cpp index d49208f24a78863173fe12b6e92b563704a32d4c..5a6d6999321f2143dff6b19fe27306d3dfb5b241 100644 --- a/Core/Beam/FootprintSquare.cpp +++ b/Core/Beam/FootprintSquare.cpp @@ -18,9 +18,14 @@ #include <algorithm> #include <stdexcept> -FootprintSquare::FootprintSquare(double width_ratio) : IFootprintFactor(width_ratio) +FootprintSquare::FootprintSquare(const std::vector<double> P) + : IFootprintFactor({"FootprintSquare", "class_tooltip", {}}, P) +{ +} + +FootprintSquare::FootprintSquare(double width_ratio) + : FootprintSquare(std::vector<double>{width_ratio}) { - setName("FootprintSquare"); } FootprintSquare* FootprintSquare::clone() const diff --git a/Core/Beam/FootprintSquare.h b/Core/Beam/FootprintSquare.h index dfd2012de8108bae4f62ad332255934834924ae9..18af9212806f72272a22f77acef9b7f91c93b9c3 100644 --- a/Core/Beam/FootprintSquare.h +++ b/Core/Beam/FootprintSquare.h @@ -23,6 +23,7 @@ class BA_CORE_API_ FootprintSquare : public IFootprintFactor { public: + FootprintSquare(const std::vector<double> P); FootprintSquare(double width_ratio); void accept(INodeVisitor* visitor) const override { visitor->visit(this); } diff --git a/Core/Beam/IFootprintFactor.cpp b/Core/Beam/IFootprintFactor.cpp index 1393de32831b302f524c390d284097b181de41a1..4696d84b1aec726580ca5636eab04e58adc1c73e 100644 --- a/Core/Beam/IFootprintFactor.cpp +++ b/Core/Beam/IFootprintFactor.cpp @@ -13,20 +13,16 @@ // ************************************************************************** // #include "Core/Beam/IFootprintFactor.h" -#include "Core/Parametrization/RealParameter.h" #include <stdexcept> IFootprintFactor::IFootprintFactor(const NodeMeta& meta, const std::vector<double>& PValues) - : INode(meta, PValues) + : INode(nodeMetaUnion({{"BeamToSampleWidthRatio", "", "ratio of beam width to sample width", + 0, INF, 1.}}, meta), PValues), + m_width_ratio(m_P[0]) { -} - -IFootprintFactor::IFootprintFactor(double width_ratio) : m_width_ratio(width_ratio) -{ - if (m_width_ratio < 0.0) + if (m_P[0] < 0.0) throw std::runtime_error( - "Error in IFootprintFactor::IFootprintFactor: width ratio is negative"); - registerParameter("BeamToSampleWidthRatio", &m_width_ratio).setNonnegative(); + "Error in IFootprintFactor::setWidthRatio: width ratio is negative"); } IFootprintFactor::~IFootprintFactor() = default; @@ -36,5 +32,5 @@ void IFootprintFactor::setWidthRatio(double width_ratio) if (width_ratio < 0.0) throw std::runtime_error( "Error in IFootprintFactor::setWidthRatio: width ratio is negative"); - m_width_ratio = width_ratio; + m_P[0] = width_ratio; } diff --git a/Core/Beam/IFootprintFactor.h b/Core/Beam/IFootprintFactor.h index 3496ba7f7bb29ad802632b6a1216db31d7a1d531..b8acab2c1699b58ee03d9ae3b56f60a4b7834b74 100644 --- a/Core/Beam/IFootprintFactor.h +++ b/Core/Beam/IFootprintFactor.h @@ -28,7 +28,6 @@ class BA_CORE_API_ IFootprintFactor : public ICloneable, public INode { public: IFootprintFactor(const NodeMeta& meta, const std::vector<double>& PValues); - IFootprintFactor(double width_ratio); IFootprintFactor() = delete; virtual ~IFootprintFactor(); @@ -44,7 +43,7 @@ public: virtual std::string print() const = 0; protected: - double m_width_ratio; //! Beam to sample width ratio + const double& m_width_ratio; //! Beam to sample width ratio private: void initialize(); diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py index 0802af03241272c9fc5c7e3e6b5d3ae71b5085c9..f0ff2f1e019c1d1d0fb29302b72adcfcbbb8d66a 100644 --- a/auto/Wrap/libBornAgainCore.py +++ b/auto/Wrap/libBornAgainCore.py @@ -13906,13 +13906,14 @@ class FootprintGauss(IFootprintFactor): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr - def __init__(self, width_ratio): + def __init__(self, *args): r""" + __init__(FootprintGauss self, vdouble1d_t P) -> FootprintGauss __init__(FootprintGauss self, double width_ratio) -> FootprintGauss FootprintGauss::FootprintGauss(double width_ratio) """ - _libBornAgainCore.FootprintGauss_swiginit(self, _libBornAgainCore.new_FootprintGauss(width_ratio)) + _libBornAgainCore.FootprintGauss_swiginit(self, _libBornAgainCore.new_FootprintGauss(*args)) def accept(self, visitor): r""" @@ -13969,13 +13970,14 @@ class FootprintSquare(IFootprintFactor): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr - def __init__(self, width_ratio): + def __init__(self, *args): r""" + __init__(FootprintSquare self, vdouble1d_t P) -> FootprintSquare __init__(FootprintSquare self, double width_ratio) -> FootprintSquare FootprintSquare::FootprintSquare(double width_ratio) """ - _libBornAgainCore.FootprintSquare_swiginit(self, _libBornAgainCore.new_FootprintSquare(width_ratio)) + _libBornAgainCore.FootprintSquare_swiginit(self, _libBornAgainCore.new_FootprintSquare(*args)) def accept(self, visitor): r""" diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp index 39aa160401203e73fcd2680db19301c81e827d25..7f97debda405ee17829737656cb337ef46355bd1 100644 --- a/auto/Wrap/libBornAgainCore_wrap.cpp +++ b/auto/Wrap/libBornAgainCore_wrap.cpp @@ -86779,16 +86779,37 @@ SWIGINTERN PyObject *IFootprintFactor_swigregister(PyObject *SWIGUNUSEDPARM(self return SWIG_Py_Void(); } -SWIGINTERN PyObject *_wrap_new_FootprintGauss(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_FootprintGauss__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< double,std::allocator< double > > arg1 ; + FootprintGauss *result = 0 ; + + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + { + std::vector< double,std::allocator< double > > *ptr = (std::vector< double,std::allocator< double > > *)0; + int res = swig::asptr(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "new_FootprintGauss" "', argument " "1"" of type '" "std::vector< double,std::allocator< double > > const""'"); + } + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; + } + result = (FootprintGauss *)new FootprintGauss(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_FootprintGauss, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_FootprintGauss__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; double arg1 ; double val1 ; int ecode1 = 0 ; - PyObject *swig_obj[1] ; FootprintGauss *result = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; ecode1 = SWIG_AsVal_double(swig_obj[0], &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_FootprintGauss" "', argument " "1"" of type '" "double""'"); @@ -86802,6 +86823,42 @@ fail: } +SWIGINTERN PyObject *_wrap_new_FootprintGauss(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[2] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "new_FootprintGauss", 0, 1, argv))) SWIG_fail; + --argc; + if (argc == 1) { + int _v; + { + int res = SWIG_AsVal_double(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_FootprintGauss__SWIG_1(self, argc, argv); + } + } + if (argc == 1) { + int _v; + int res = swig::asptr(argv[0], (std::vector< double,std::allocator< double > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_FootprintGauss__SWIG_0(self, argc, argv); + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_FootprintGauss'.\n" + " Possible C/C++ prototypes are:\n" + " FootprintGauss::FootprintGauss(std::vector< double,std::allocator< double > > const)\n" + " FootprintGauss::FootprintGauss(double)\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_FootprintGauss_accept(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; FootprintGauss *arg1 = (FootprintGauss *) 0 ; @@ -86940,16 +86997,37 @@ SWIGINTERN PyObject *FootprintGauss_swiginit(PyObject *SWIGUNUSEDPARM(self), PyO return SWIG_Python_InitShadowInstance(args); } -SWIGINTERN PyObject *_wrap_new_FootprintSquare(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_FootprintSquare__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< double,std::allocator< double > > arg1 ; + FootprintSquare *result = 0 ; + + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + { + std::vector< double,std::allocator< double > > *ptr = (std::vector< double,std::allocator< double > > *)0; + int res = swig::asptr(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "new_FootprintSquare" "', argument " "1"" of type '" "std::vector< double,std::allocator< double > > const""'"); + } + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; + } + result = (FootprintSquare *)new FootprintSquare(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_FootprintSquare, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_FootprintSquare__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; double arg1 ; double val1 ; int ecode1 = 0 ; - PyObject *swig_obj[1] ; FootprintSquare *result = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; ecode1 = SWIG_AsVal_double(swig_obj[0], &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_FootprintSquare" "', argument " "1"" of type '" "double""'"); @@ -86963,6 +87041,42 @@ fail: } +SWIGINTERN PyObject *_wrap_new_FootprintSquare(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[2] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "new_FootprintSquare", 0, 1, argv))) SWIG_fail; + --argc; + if (argc == 1) { + int _v; + { + int res = SWIG_AsVal_double(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_FootprintSquare__SWIG_1(self, argc, argv); + } + } + if (argc == 1) { + int _v; + int res = swig::asptr(argv[0], (std::vector< double,std::allocator< double > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_FootprintSquare__SWIG_0(self, argc, argv); + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_FootprintSquare'.\n" + " Possible C/C++ prototypes are:\n" + " FootprintSquare::FootprintSquare(std::vector< double,std::allocator< double > > const)\n" + " FootprintSquare::FootprintSquare(double)\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_FootprintSquare_accept(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; FootprintSquare *arg1 = (FootprintSquare *) 0 ; @@ -128225,7 +128339,8 @@ static PyMethodDef SwigMethods[] = { "\n" ""}, { "IFootprintFactor_swigregister", IFootprintFactor_swigregister, METH_O, NULL}, - { "new_FootprintGauss", _wrap_new_FootprintGauss, METH_O, "\n" + { "new_FootprintGauss", _wrap_new_FootprintGauss, METH_VARARGS, "\n" + "FootprintGauss(vdouble1d_t P)\n" "new_FootprintGauss(double width_ratio) -> FootprintGauss\n" "FootprintGauss::FootprintGauss(double width_ratio)\n" "\n" @@ -128259,7 +128374,8 @@ static PyMethodDef SwigMethods[] = { { "delete_FootprintGauss", _wrap_delete_FootprintGauss, METH_O, "delete_FootprintGauss(FootprintGauss self)"}, { "FootprintGauss_swigregister", FootprintGauss_swigregister, METH_O, NULL}, { "FootprintGauss_swiginit", FootprintGauss_swiginit, METH_VARARGS, NULL}, - { "new_FootprintSquare", _wrap_new_FootprintSquare, METH_O, "\n" + { "new_FootprintSquare", _wrap_new_FootprintSquare, METH_VARARGS, "\n" + "FootprintSquare(vdouble1d_t P)\n" "new_FootprintSquare(double width_ratio) -> FootprintSquare\n" "FootprintSquare::FootprintSquare(double width_ratio)\n" "\n"