diff --git a/Base/Axis/Frame.cpp b/Base/Axis/Frame.cpp index 09319d037d724e6ea3303d14ca10676cac3e82e6..20ba70f85bf868701f37d52e05461cf7894d11c4 100644 --- a/Base/Axis/Frame.cpp +++ b/Base/Axis/Frame.cpp @@ -138,11 +138,15 @@ bool Frame::hasSameSizes(const Frame& o) const return true; } -Frame* Frame::plottableFrame() const +Frame* Frame::plottableFrame(std::vector<std::string> labels) const { + ASSERT(labels.size() == rank() || labels.size() == 0); std::vector<const Scale*> outaxes; - for (const Scale* s : m_axes) - outaxes.emplace_back(new Scale(s->plottableScale())); + for (size_t k = 0; k < rank(); ++k) { + Scale* s = + new Scale(labels.size() ? axis(k).plottableScale(labels[k]) : axis(k).plottableScale()); + outaxes.emplace_back(s); + } return new Frame(std::move(outaxes)); } diff --git a/Base/Axis/Frame.h b/Base/Axis/Frame.h index 81980accae22d938c0265bc0fcce50c2f5413abe..79f3677663b20ed620b2eb099e66221f096830d2 100644 --- a/Base/Axis/Frame.h +++ b/Base/Axis/Frame.h @@ -81,7 +81,7 @@ public: std::vector<const Scale*> clonedAxes() const; #endif // SWIG - Frame* plottableFrame() const; + Frame* plottableFrame(std::vector<std::string> labels = {}) const; Frame* flat() const; protected: diff --git a/Base/Axis/Scale.cpp b/Base/Axis/Scale.cpp index bffb817b647d234f49a683589d416f35b372d571..2840a35db2eefca811cd257e1b710174e9132aad 100644 --- a/Base/Axis/Scale.cpp +++ b/Base/Axis/Scale.cpp @@ -218,3 +218,8 @@ Scale Scale::plottableScale() const } return *this; } + +Scale Scale::plottableScale(const std::string /*label*/) const +{ + return *this; +} diff --git a/Base/Axis/Scale.h b/Base/Axis/Scale.h index d5525e6b73822857ba6fae60abde35425fb1a6a8..4c92816ecbe5e471c068893b6f3bc84d431f7bb9 100644 --- a/Base/Axis/Scale.h +++ b/Base/Axis/Scale.h @@ -78,6 +78,7 @@ public: std::string unit() const; Scale plottableScale() const; + Scale plottableScale(const std::string label) const; protected: Coordinate m_coord; diff --git a/Device/Data/Datafield.cpp b/Device/Data/Datafield.cpp index 31388e900ca8163b9d2101b2aaab1592fe36bf0a..67ec26a902c11a47d0046257815501f02babecbf 100644 --- a/Device/Data/Datafield.cpp +++ b/Device/Data/Datafield.cpp @@ -342,9 +342,9 @@ Datafield* Datafield::create_yProjection(int xbinlow, int xbinup) const return new Datafield({yAxis().clone()}, out); } -Datafield Datafield::plottableField() const +Datafield Datafield::plottableField(std::vector<std::string> labels) const { - return {title(), frame().plottableFrame(), m_values, m_errSigmas}; + return {title(), frame().plottableFrame(labels), m_values, m_errSigmas}; } Datafield Datafield::flat() const diff --git a/Device/Data/Datafield.h b/Device/Data/Datafield.h index f868e52c3251879e7e7dbac71009594c5ba5ab5f..a29b7b31c4569e077a1a1f08b384ca8d119fbd23 100644 --- a/Device/Data/Datafield.h +++ b/Device/Data/Datafield.h @@ -87,7 +87,7 @@ public: //... modifiers - Datafield plottableField() const; + Datafield plottableField(std::vector<std::string> labels = {}) const; Datafield flat() const; //! Multiplies contents by constant factor, e.g. to shift curves in log plot diff --git a/auto/Wrap/libBornAgainBase.py b/auto/Wrap/libBornAgainBase.py index f7c4d7cc5c0a5ecc30df9488109a7bfc5e5b4103..dc181a45e813d9c9942fb1d7d65049c931cbd40a 100644 --- a/auto/Wrap/libBornAgainBase.py +++ b/auto/Wrap/libBornAgainBase.py @@ -1941,9 +1941,12 @@ class Scale(object): r"""unit(Scale self) -> std::string""" return _libBornAgainBase.Scale_unit(self) - def plottableScale(self): - r"""plottableScale(Scale self) -> Scale""" - return _libBornAgainBase.Scale_plottableScale(self) + def plottableScale(self, *args): + r""" + plottableScale(Scale self) -> Scale + plottableScale(Scale self, std::string const label) -> Scale + """ + return _libBornAgainBase.Scale_plottableScale(self, *args) __swig_destroy__ = _libBornAgainBase.delete_Scale # Register Scale in _libBornAgainBase: @@ -2031,9 +2034,9 @@ class Frame(object): r"""__eq__(Frame self, Frame arg2) -> bool""" return _libBornAgainBase.Frame___eq__(self, arg2) - def plottableFrame(self): - r"""plottableFrame(Frame self) -> Frame""" - return _libBornAgainBase.Frame_plottableFrame(self) + def plottableFrame(self, *args): + r"""plottableFrame(Frame self, vector_string_t labels={}) -> Frame""" + return _libBornAgainBase.Frame_plottableFrame(self, *args) def flat(self): r"""flat(Frame self) -> Frame""" diff --git a/auto/Wrap/libBornAgainBase_wrap.cpp b/auto/Wrap/libBornAgainBase_wrap.cpp index c0bd9efe97559e4875fd56c7a92ddad984f5a729..9cd34e9fcf681ea7af57ae4f7bb07c54d2af7f1c 100644 --- a/auto/Wrap/libBornAgainBase_wrap.cpp +++ b/auto/Wrap/libBornAgainBase_wrap.cpp @@ -26636,16 +26636,14 @@ fail: } -SWIGINTERN PyObject *_wrap_Scale_plottableScale(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_Scale_plottableScale__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; Scale *arg1 = (Scale *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; SwigValueWrapper< Scale > result; - if (!args) SWIG_fail; - swig_obj[0] = args; + if ((nobjs < 1) || (nobjs > 1)) 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 *""'"); @@ -26669,6 +26667,87 @@ fail: } +SWIGINTERN PyObject *_wrap_Scale_plottableScale__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + Scale *arg1 = (Scale *) 0 ; + std::string arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + SwigValueWrapper< Scale > result; + + if ((nobjs < 2) || (nobjs > 2)) 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); + { + std::string *ptr = (std::string *)0; + int res = SWIG_AsPtr_std_string(swig_obj[1], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "Scale_plottableScale" "', argument " "2"" of type '" "std::string const""'"); + } + arg2 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; + } + { + try { + result = ((Scale const *)arg1)->plottableScale(arg2); + } 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] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "Scale_plottableScale", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 1) { + int _v = 0; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Scale, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Scale_plottableScale__SWIG_0(self, argc, argv); + } + } + if (argc == 2) { + 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_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Scale_plottableScale__SWIG_1(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() const\n" + " Scale::plottableScale(std::string const) const\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_delete_Scale(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Scale *arg1 = (Scale *) 0 ; @@ -27619,16 +27698,55 @@ fail: } -SWIGINTERN PyObject *_wrap_Frame_plottableFrame(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_Frame_plottableFrame__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; Frame *arg1 = (Frame *) 0 ; + std::vector< std::string,std::allocator< std::string > > arg2 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; Frame *result = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; + 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 '" "Frame_plottableFrame" "', argument " "1"" of type '" "Frame const *""'"); + } + arg1 = reinterpret_cast< Frame * >(argp1); + { + std::vector< std::string,std::allocator< std::string > > *ptr = (std::vector< std::string,std::allocator< std::string > > *)0; + int res = swig::asptr(swig_obj[1], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "Frame_plottableFrame" "', argument " "2"" of type '" "std::vector< std::string,std::allocator< std::string > >""'"); + } + arg2 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; + } + { + try { + result = (Frame *)((Frame const *)arg1)->plottableFrame(arg2); + } 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(SWIG_as_voidptr(result), SWIGTYPE_p_Frame, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Frame_plottableFrame__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + Frame *arg1 = (Frame *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + Frame *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 '" "Frame_plottableFrame" "', argument " "1"" of type '" "Frame const *""'"); @@ -27652,6 +27770,46 @@ fail: } +SWIGINTERN PyObject *_wrap_Frame_plottableFrame(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "Frame_plottableFrame", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 1) { + int _v = 0; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Frame, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Frame_plottableFrame__SWIG_1(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< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Frame_plottableFrame__SWIG_0(self, argc, argv); + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Frame_plottableFrame'.\n" + " Possible C/C++ prototypes are:\n" + " Frame::plottableFrame(std::vector< std::string,std::allocator< std::string > >) const\n" + " Frame::plottableFrame() const\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_Frame_flat(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Frame *arg1 = (Frame *) 0 ; @@ -30207,7 +30365,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_O, "Scale_plottableScale(Scale self) -> Scale"}, + { "Scale_plottableScale", _wrap_Scale_plottableScale, METH_VARARGS, "\n" + "Scale_plottableScale(Scale self) -> Scale\n" + "Scale_plottableScale(Scale self, std::string const label) -> 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}, @@ -30234,7 +30395,7 @@ static PyMethodDef SwigMethods[] = { { "Frame_toGlobalIndex", _wrap_Frame_toGlobalIndex, METH_VARARGS, "Frame_toGlobalIndex(Frame self, std::vector< unsigned int,std::allocator< unsigned int > > const & axes_indices) -> size_t"}, { "Frame_hasSameSizes", _wrap_Frame_hasSameSizes, METH_VARARGS, "Frame_hasSameSizes(Frame self, Frame arg2) -> bool"}, { "Frame___eq__", _wrap_Frame___eq__, METH_VARARGS, "Frame___eq__(Frame self, Frame arg2) -> bool"}, - { "Frame_plottableFrame", _wrap_Frame_plottableFrame, METH_O, "Frame_plottableFrame(Frame self) -> Frame"}, + { "Frame_plottableFrame", _wrap_Frame_plottableFrame, METH_VARARGS, "Frame_plottableFrame(Frame self, vector_string_t labels={}) -> Frame"}, { "Frame_flat", _wrap_Frame_flat, METH_O, "Frame_flat(Frame self) -> Frame"}, { "Frame_swigregister", Frame_swigregister, METH_O, NULL}, { "Frame_swiginit", Frame_swiginit, METH_VARARGS, NULL}, diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index dfcd0aba3b7e5ed930fd49c00629e60f775f73b7..2869c7ef8c3d8924d2a5b589efbbd9e54fefb26d 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -2140,9 +2140,9 @@ class Datafield(object): r"""minVal(Datafield self) -> double""" return _libBornAgainDevice.Datafield_minVal(self) - def plottableField(self): - r"""plottableField(Datafield self) -> Datafield""" - return _libBornAgainDevice.Datafield_plottableField(self) + def plottableField(self, *args): + r"""plottableField(Datafield self, vector_string_t labels={}) -> Datafield""" + return _libBornAgainDevice.Datafield_plottableField(self, *args) def flat(self): r"""flat(Datafield self) -> Datafield""" diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index 86304ce4acc348c9eb6d0770ec6d41d62d504c48..684cbd50450a5743dc716bce2f62806020a47d91 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -30160,16 +30160,55 @@ fail: } -SWIGINTERN PyObject *_wrap_Datafield_plottableField(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_Datafield_plottableField__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; Datafield *arg1 = (Datafield *) 0 ; + std::vector< std::string,std::allocator< std::string > > arg2 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; SwigValueWrapper< Datafield > result; - if (!args) SWIG_fail; - swig_obj[0] = args; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Datafield, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Datafield_plottableField" "', argument " "1"" of type '" "Datafield const *""'"); + } + arg1 = reinterpret_cast< Datafield * >(argp1); + { + std::vector< std::string,std::allocator< std::string > > *ptr = (std::vector< std::string,std::allocator< std::string > > *)0; + int res = swig::asptr(swig_obj[1], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "Datafield_plottableField" "', argument " "2"" of type '" "std::vector< std::string,std::allocator< std::string > >""'"); + } + arg2 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; + } + { + try { + result = ((Datafield const *)arg1)->plottableField(arg2); + } 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 Datafield(result)), SWIGTYPE_p_Datafield, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Datafield_plottableField__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + Datafield *arg1 = (Datafield *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + SwigValueWrapper< Datafield > result; + + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Datafield, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Datafield_plottableField" "', argument " "1"" of type '" "Datafield const *""'"); @@ -30193,6 +30232,46 @@ fail: } +SWIGINTERN PyObject *_wrap_Datafield_plottableField(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "Datafield_plottableField", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 1) { + int _v = 0; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Datafield, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Datafield_plottableField__SWIG_1(self, argc, argv); + } + } + if (argc == 2) { + int _v = 0; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Datafield, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = swig::asptr(argv[1], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Datafield_plottableField__SWIG_0(self, argc, argv); + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Datafield_plottableField'.\n" + " Possible C/C++ prototypes are:\n" + " Datafield::plottableField(std::vector< std::string,std::allocator< std::string > >) const\n" + " Datafield::plottableField() const\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_Datafield_flat(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Datafield *arg1 = (Datafield *) 0 ; @@ -41417,7 +41496,7 @@ static PyMethodDef SwigMethods[] = { { "Datafield_flatVector", _wrap_Datafield_flatVector, METH_O, "Datafield_flatVector(Datafield self) -> vdouble1d_t"}, { "Datafield_maxVal", _wrap_Datafield_maxVal, METH_O, "Datafield_maxVal(Datafield self) -> double"}, { "Datafield_minVal", _wrap_Datafield_minVal, METH_O, "Datafield_minVal(Datafield self) -> double"}, - { "Datafield_plottableField", _wrap_Datafield_plottableField, METH_O, "Datafield_plottableField(Datafield self) -> Datafield"}, + { "Datafield_plottableField", _wrap_Datafield_plottableField, METH_VARARGS, "Datafield_plottableField(Datafield self, vector_string_t labels={}) -> Datafield"}, { "Datafield_flat", _wrap_Datafield_flat, METH_O, "Datafield_flat(Datafield self) -> Datafield"}, { "Datafield_scale", _wrap_Datafield_scale, METH_VARARGS, "Datafield_scale(Datafield self, double factor)"}, { "Datafield_crop", _wrap_Datafield_crop, METH_VARARGS, "\n"