From bfe5f368950d086808a4177824016259f9ff4192 Mon Sep 17 00:00:00 2001 From: Walter Van Herck <w.van.herck@fz-juelich.de> Date: Fri, 26 Jan 2018 17:27:58 +0100 Subject: [PATCH] Removed axes units from IHistogram --- Core/Fitting/FitSuite.cpp | 3 -- Core/Instrument/IHistogram.cpp | 10 ---- Core/Instrument/IHistogram.h | 9 +--- Core/Simulation/Simulation2D.cpp | 17 +------ auto/Wrap/libBornAgainCore.py | 22 --------- auto/Wrap/libBornAgainCore_wrap.cpp | 73 ----------------------------- 6 files changed, 3 insertions(+), 131 deletions(-) diff --git a/Core/Fitting/FitSuite.cpp b/Core/Fitting/FitSuite.cpp index b63f23034bb..346640c57d8 100644 --- a/Core/Fitting/FitSuite.cpp +++ b/Core/Fitting/FitSuite.cpp @@ -125,7 +125,6 @@ IHistogram* FitSuite::getRealData(size_t i_item) const { std::unique_ptr<IHistogram> result(IHistogram::createHistogram( m_impl->fitObjects()->getRealData(i_item))); - result->setAxesUnits(m_impl->fitObjects()->getDefaultAxesUnits()); return result.release(); } @@ -133,7 +132,6 @@ IHistogram* FitSuite::getSimulationData(size_t i_item) const { std::unique_ptr<IHistogram> result(IHistogram::createHistogram( m_impl->fitObjects()->getSimulationData(i_item))); - result->setAxesUnits(m_impl->fitObjects()->getDefaultAxesUnits()); return result.release(); } @@ -141,7 +139,6 @@ IHistogram* FitSuite::getChiSquaredMap(size_t i_item) const { std::unique_ptr<IHistogram> result(IHistogram::createHistogram( m_impl->fitObjects()->getChiSquaredMap(i_item))); - result->setAxesUnits(m_impl->fitObjects()->getDefaultAxesUnits()); return result.release(); } diff --git a/Core/Instrument/IHistogram.cpp b/Core/Instrument/IHistogram.cpp index 6f71a50c3cd..645c5c15d77 100644 --- a/Core/Instrument/IHistogram.cpp +++ b/Core/Instrument/IHistogram.cpp @@ -387,13 +387,3 @@ void IHistogram::load(const std::string& filename) const std::unique_ptr<IHistogram> hist(IntensityDataIOFactory::readIntensityData(filename)); copyContentFrom(*hist); } - -void IHistogram::setAxesUnits(const std::string& name) -{ - m_axes_units = name; -} - -std::string IHistogram::axesUnits() const -{ - return m_axes_units; -} diff --git a/Core/Instrument/IHistogram.h b/Core/Instrument/IHistogram.h index cdf876ad3dd..1f5403e6328 100644 --- a/Core/Instrument/IHistogram.h +++ b/Core/Instrument/IHistogram.h @@ -95,10 +95,10 @@ public: //! Returns x-axis bin index for given globalbin. For 1D histograms returned value conicide //! with globalbin value. - size_t getXaxisIndex(size_t i) const; + size_t getXaxisIndex(size_t i) const; //! Returns y-axis bin index for given globalbin (for 2D histograms). - size_t getYaxisIndex(size_t i) const; + size_t getYaxisIndex(size_t i) const; //! @brief Returns the value on x-axis corresponding to the global bin index. //! @param globalbin The global bin index @@ -210,10 +210,6 @@ public: //! Only bin content will be loaded, histogram axes remain the same. void load(const std::string& filename); - //! Sets axes units - void setAxesUnits(const std::string& name); - std::string axesUnits() const; - protected: void check_x_axis() const; void check_y_axis() const; @@ -222,7 +218,6 @@ protected: std::vector<double> getDataVector(DataType dataType) const; void copyContentFrom(const IHistogram& other); OutputData<CumulativeValue> m_data; - std::string m_axes_units; }; #endif // IHISTOGRAM_H diff --git a/Core/Simulation/Simulation2D.cpp b/Core/Simulation/Simulation2D.cpp index 15d03355c1f..94e3d727a03 100644 --- a/Core/Simulation/Simulation2D.cpp +++ b/Core/Simulation/Simulation2D.cpp @@ -23,7 +23,6 @@ namespace { IDetector2D* Detector2D(Instrument& instrument); -const IDetector2D* Detector2D(const Instrument& instrument); } Simulation2D::Simulation2D(const MultiLayer& p_sample) @@ -85,13 +84,7 @@ OutputData<double>* Simulation2D::getDetectorIntensity(AxesUnits units_type) con Histogram2D* Simulation2D::getIntensityData(AxesUnits units_type) const { std::unique_ptr<OutputData<double>> data(getDetectorIntensity(units_type)); - std::unique_ptr<Histogram2D> result(new Histogram2D(*data)); - - if (units_type == AxesUnits::DEFAULT) - units_type = Detector2D(m_instrument)->defaultAxesUnits(); - - result->setAxesUnits(DetectorFunctions::detectorUnitsName(units_type)); - return result.release(); + return new Histogram2D(*data); } std::unique_ptr<IComputation> Simulation2D::generateSingleThreadedComputation(size_t start, @@ -177,12 +170,4 @@ IDetector2D* Detector2D(Instrument& instrument) "Error in Simulation2D: wrong detector type"); return p_detector; } -const IDetector2D* Detector2D(const Instrument& instrument) -{ - const IDetector2D* p_detector = dynamic_cast<const IDetector2D*>(instrument.getDetector()); - if (!p_detector) - throw std::runtime_error( - "Error in Simulation2D: wrong detector type"); - return p_detector; -} } diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py index 3c0f28dc129..babda0ebd48 100644 --- a/auto/Wrap/libBornAgainCore.py +++ b/auto/Wrap/libBornAgainCore.py @@ -17506,28 +17506,6 @@ class IHistogram(_object): """ return _libBornAgainCore.IHistogram_load(self, filename) - - def setAxesUnits(self, name): - """ - setAxesUnits(IHistogram self, std::string const & name) - - void IHistogram::setAxesUnits(const std::string &name) - - Sets axes units. - - """ - return _libBornAgainCore.IHistogram_setAxesUnits(self, name) - - - def axesUnits(self): - """ - axesUnits(IHistogram self) -> std::string - - std::string IHistogram::axesUnits() const - - """ - return _libBornAgainCore.IHistogram_axesUnits(self) - IHistogram_swigregister = _libBornAgainCore.IHistogram_swigregister IHistogram_swigregister(IHistogram) diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp index 981dae40c17..a4f255d7b1c 100644 --- a/auto/Wrap/libBornAgainCore_wrap.cpp +++ b/auto/Wrap/libBornAgainCore_wrap.cpp @@ -81070,65 +81070,6 @@ fail: } -SWIGINTERN PyObject *_wrap_IHistogram_setAxesUnits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - IHistogram *arg1 = (IHistogram *) 0 ; - std::string *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 = SWIG_OLDOBJ ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:IHistogram_setAxesUnits",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IHistogram, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IHistogram_setAxesUnits" "', argument " "1"" of type '" "IHistogram *""'"); - } - arg1 = reinterpret_cast< IHistogram * >(argp1); - { - std::string *ptr = (std::string *)0; - res2 = SWIG_AsPtr_std_string(obj1, &ptr); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IHistogram_setAxesUnits" "', argument " "2"" of type '" "std::string const &""'"); - } - if (!ptr) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IHistogram_setAxesUnits" "', argument " "2"" of type '" "std::string const &""'"); - } - arg2 = ptr; - } - (arg1)->setAxesUnits((std::string const &)*arg2); - resultobj = SWIG_Py_Void(); - if (SWIG_IsNewObj(res2)) delete arg2; - return resultobj; -fail: - if (SWIG_IsNewObj(res2)) delete arg2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_IHistogram_axesUnits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - IHistogram *arg1 = (IHistogram *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - std::string result; - - if (!PyArg_ParseTuple(args,(char *)"O:IHistogram_axesUnits",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IHistogram, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IHistogram_axesUnits" "', argument " "1"" of type '" "IHistogram const *""'"); - } - arg1 = reinterpret_cast< IHistogram * >(argp1); - result = ((IHistogram const *)arg1)->axesUnits(); - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *IHistogram_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; @@ -121894,20 +121835,6 @@ static PyMethodDef SwigMethods[] = { "Loads histogram from file, the shape of array in file should match Following formats are available: *.txt, *.tif, *.int (*.txt.gz, *.tif.gz, *.int.gz) Only bin content will be loaded, histogram axes remain the same. \n" "\n" ""}, - { (char *)"IHistogram_setAxesUnits", _wrap_IHistogram_setAxesUnits, METH_VARARGS, (char *)"\n" - "IHistogram_setAxesUnits(IHistogram self, std::string const & name)\n" - "\n" - "void IHistogram::setAxesUnits(const std::string &name)\n" - "\n" - "Sets axes units. \n" - "\n" - ""}, - { (char *)"IHistogram_axesUnits", _wrap_IHistogram_axesUnits, METH_VARARGS, (char *)"\n" - "IHistogram_axesUnits(IHistogram self) -> std::string\n" - "\n" - "std::string IHistogram::axesUnits() const\n" - "\n" - ""}, { (char *)"IHistogram_swigregister", IHistogram_swigregister, METH_VARARGS, NULL}, { (char *)"new_Histogram1D", _wrap_new_Histogram1D, METH_VARARGS, (char *)"\n" "Histogram1D(int nbinsx, double xlow, double xup)\n" -- GitLab