From 00404dd64a027a3a7b4dba306c38fb1ea26dac49 Mon Sep 17 00:00:00 2001 From: Walter Van Herck <w.van.herck@fz-juelich.de> Date: Mon, 8 Jul 2019 11:00:31 +0200 Subject: [PATCH] Remove explicit choice of SSCA approximation and related enum --- Core/Aggregate/ILayout.cpp | 4 +- Core/Aggregate/ILayout.h | 14 +--- Core/Aggregate/ParticleLayout.cpp | 2 - Core/Export/SampleToPython.cpp | 8 --- .../SizeDistributionModelsBuilder.cpp | 2 - Examples/Demos/simul_demo_cyl_SSCA.py | 2 - Examples/Demos/simul_demo_movie3.py | 1 - .../experiment_at_galaxi/sample_builder.py | 1 - .../ApproximationSSCA.py | 1 - GUI/coregui/Models/GUIDomainSampleVisitor.cpp | 13 ---- GUI/coregui/Models/ParticleLayoutItem.cpp | 4 -- GUI/coregui/Models/ParticleLayoutItem.h | 1 - GUI/coregui/Models/TransformToDomain.cpp | 7 -- auto/Wrap/libBornAgainCore.py | 26 ------- auto/Wrap/libBornAgainCore_wrap.cpp | 70 ------------------- 15 files changed, 4 insertions(+), 152 deletions(-) diff --git a/Core/Aggregate/ILayout.cpp b/Core/Aggregate/ILayout.cpp index e16677e573f..d77d99454c6 100644 --- a/Core/Aggregate/ILayout.cpp +++ b/Core/Aggregate/ILayout.cpp @@ -14,4 +14,6 @@ #include "ILayout.h" -ILayout::~ILayout() =default; +ILayout::ILayout() : m_weight(1.0) {} + +ILayout::~ILayout() = default; diff --git a/Core/Aggregate/ILayout.h b/Core/Aggregate/ILayout.h index c3cde085ea5..a019229c787 100644 --- a/Core/Aggregate/ILayout.h +++ b/Core/Aggregate/ILayout.h @@ -31,9 +31,7 @@ class IInterferenceFunction; class BA_CORE_API_ ILayout : public ISample { public: - enum EInterferenceApproximation { DA, SSCA }; - - ILayout() : m_weight(1.0), me_approx(DA) {} + ILayout(); virtual ~ILayout(); virtual ILayout* clone() const = 0; @@ -63,18 +61,8 @@ public: //! Sets the relative weight of this layout void setWeight(double weight) { m_weight = weight; } - //! Gets the used approximation for particles and interference functions - EInterferenceApproximation getApproximation() const { return me_approx; } - - //! Sets the used approximation for particles and interference functions - void setApproximation(EInterferenceApproximation approximation) { me_approx = approximation; } - protected: double m_weight; - -private: - //! Approximation used for combining particles and interference functions - EInterferenceApproximation me_approx; }; #endif // ILAYOUT_H diff --git a/Core/Aggregate/ParticleLayout.cpp b/Core/Aggregate/ParticleLayout.cpp index 9992bfc7530..17a686d85fb 100644 --- a/Core/Aggregate/ParticleLayout.cpp +++ b/Core/Aggregate/ParticleLayout.cpp @@ -72,7 +72,6 @@ ParticleLayout* ParticleLayout::clone() const p_result->setTotalParticleSurfaceDensity(totalParticleSurfaceDensity()); p_result->setWeight(weight()); - p_result->setApproximation(getApproximation()); return p_result; } @@ -92,7 +91,6 @@ ParticleLayout* ParticleLayout::cloneWithOffset(double offset) const p_result->setAndRegisterInterferenceFunction(mP_interference_function->clone()); p_result->setTotalParticleSurfaceDensity(totalParticleSurfaceDensity()); - p_result->setApproximation(getApproximation()); p_result->setWeight(weight()); return p_result; diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp index d9c5cad239e..599a0904c6c 100644 --- a/Core/Export/SampleToPython.cpp +++ b/Core/Export/SampleToPython.cpp @@ -504,14 +504,6 @@ std::string SampleToPython::defineParticleLayouts() const if (auto p_iff = INodeUtils::OnlyChildOfType<IInterferenceFunction>(*particleLayout)) result << indent() << it->second << ".setInterferenceFunction(" << m_label->labelInterferenceFunction(p_iff) << ")\n"; - - switch (particleLayout->getApproximation()) { - case ILayout::DA: - break; - case ILayout::SSCA: - result << indent() << it->second << ".setApproximation(ba.ILayout.SSCA)\n"; - break; - } result << indent() << it->second << ".setWeight(" << particleLayout->weight() << ")\n"; result << indent() << it->second << ".setTotalParticleSurfaceDensity(" diff --git a/Core/StandardSamples/SizeDistributionModelsBuilder.cpp b/Core/StandardSamples/SizeDistributionModelsBuilder.cpp index 0b222404714..72045a04cd4 100644 --- a/Core/StandardSamples/SizeDistributionModelsBuilder.cpp +++ b/Core/StandardSamples/SizeDistributionModelsBuilder.cpp @@ -155,7 +155,6 @@ MultiLayer* SizeDistributionSSCAModelBuilder::buildSample() const particle_layout.addParticle(cylinder1, 0.8); particle_layout.addParticle(cylinder2, 0.2); particle_layout.setInterferenceFunction(interference); - particle_layout.setApproximation(ILayout::SSCA); Layer air_layer(m_ambience); air_layer.addLayout(particle_layout); @@ -201,7 +200,6 @@ MultiLayer* CylindersInSSCABuilder::buildSample() const particle_layout.addParticle(particle_collection); particle_layout.setInterferenceFunction(interference_function); - particle_layout.setApproximation(ILayout::SSCA); air_layer.addLayout(particle_layout); diff --git a/Examples/Demos/simul_demo_cyl_SSCA.py b/Examples/Demos/simul_demo_cyl_SSCA.py index 05df95378a3..da571fdcd36 100644 --- a/Examples/Demos/simul_demo_cyl_SSCA.py +++ b/Examples/Demos/simul_demo_cyl_SSCA.py @@ -34,8 +34,6 @@ def RunSimulation(): # set coupling between size and space interference.setKappa(2) particle_layout.setInterferenceFunction(interference) - # particle_layout.setApproximation(ILayout.SSCA) - particle_layout.setApproximation(ILayout.DA) # air layer with particles and substrate form multi layer air_layer = Layer(mAir) diff --git a/Examples/Demos/simul_demo_movie3.py b/Examples/Demos/simul_demo_movie3.py index aeeb6850dde..cfaa260730d 100644 --- a/Examples/Demos/simul_demo_movie3.py +++ b/Examples/Demos/simul_demo_movie3.py @@ -39,7 +39,6 @@ def RunSimulation(): # set coupling between size and space interference.setKappa(kappa) particle_layout.setInterferenceFunction(interference) - particle_layout.setApproximation(ILayout.SSCA) # air layer with particles and substrate form multi layer air_layer = Layer(mAir) diff --git a/Examples/python/fitting/ex03_ExtendedExamples/experiment_at_galaxi/sample_builder.py b/Examples/python/fitting/ex03_ExtendedExamples/experiment_at_galaxi/sample_builder.py index 78d811461fa..9a3dfffe63d 100644 --- a/Examples/python/fitting/ex03_ExtendedExamples/experiment_at_galaxi/sample_builder.py +++ b/Examples/python/fitting/ex03_ExtendedExamples/experiment_at_galaxi/sample_builder.py @@ -74,7 +74,6 @@ class SampleBuilder: layout = ba.ParticleLayout() layout.addParticle(part_coll, 1.0) layout.setInterferenceFunction(interference) - layout.setApproximation(ba.ILayout.SSCA) layout.setTotalParticleSurfaceDensity(1) # roughness diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py index f84533a2109..cbd381ccb1a 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py @@ -37,7 +37,6 @@ def get_sample(): particle_layout.addParticle(cylinder1, 0.8) particle_layout.addParticle(cylinder2, 0.2) particle_layout.setInterferenceFunction(interference) - particle_layout.setApproximation(ba.ILayout.SSCA) air_layer = ba.Layer(m_ambience) air_layer.addLayout(particle_layout) diff --git a/GUI/coregui/Models/GUIDomainSampleVisitor.cpp b/GUI/coregui/Models/GUIDomainSampleVisitor.cpp index 1e2da44e649..a8f73eb053f 100644 --- a/GUI/coregui/Models/GUIDomainSampleVisitor.cpp +++ b/GUI/coregui/Models/GUIDomainSampleVisitor.cpp @@ -87,19 +87,6 @@ void GUIDomainSampleVisitor::visit(const ParticleLayout* p_sample) } else { p_layout_item = m_sampleModel->insertNewItem(Constants::ParticleLayoutType); } - - ComboProperty approx_prop; - approx_prop << Constants::LAYOUT_DA << Constants::LAYOUT_SSCA; - ILayout::EInterferenceApproximation approx = p_sample->getApproximation(); - switch (approx) { - case ILayout::DA: - approx_prop.setValue(Constants::LAYOUT_DA); - break; - case ILayout::SSCA: - approx_prop.setValue(Constants::LAYOUT_SSCA); - break; - } - p_layout_item->setItemValue(ParticleLayoutItem::P_APPROX, approx_prop.variant()); p_layout_item->setItemValue(ParticleLayoutItem::P_TOTAL_DENSITY, p_sample->totalParticleSurfaceDensity()); p_layout_item->setItemValue(ParticleLayoutItem::P_WEIGHT, p_sample->weight()); diff --git a/GUI/coregui/Models/ParticleLayoutItem.cpp b/GUI/coregui/Models/ParticleLayoutItem.cpp index 0127b564460..28d20e6df45 100644 --- a/GUI/coregui/Models/ParticleLayoutItem.cpp +++ b/GUI/coregui/Models/ParticleLayoutItem.cpp @@ -47,7 +47,6 @@ const QString weight_tooltip = "Should be used when multiple layouts define different domains in the sample."; } // namespace -const QString ParticleLayoutItem::P_APPROX = "Approximation"; const QString ParticleLayoutItem::P_TOTAL_DENSITY = QString::fromStdString(BornAgain::TotalParticleDensity); const QString ParticleLayoutItem::P_WEIGHT = QString::fromStdString(BornAgain::Weight); @@ -58,9 +57,6 @@ ParticleLayoutItem::ParticleLayoutItem() : SessionGraphicsItem(Constants::Partic { setToolTip(QStringLiteral("A layout of particles")); - ComboProperty approx = ComboProperty() << Constants::LAYOUT_DA << Constants::LAYOUT_SSCA; - addProperty(P_APPROX, approx.variant()) - ->setToolTip(QStringLiteral("Approximation used to distribute the particles")); addProperty(P_TOTAL_DENSITY, 0.01)->setToolTip(density_tooltip); getItem(P_TOTAL_DENSITY)->setDecimals(10); addProperty(P_WEIGHT, 1.0)->setToolTip(weight_tooltip); diff --git a/GUI/coregui/Models/ParticleLayoutItem.h b/GUI/coregui/Models/ParticleLayoutItem.h index 8578e824ee0..ffcc62b8310 100644 --- a/GUI/coregui/Models/ParticleLayoutItem.h +++ b/GUI/coregui/Models/ParticleLayoutItem.h @@ -20,7 +20,6 @@ class BA_CORE_API_ ParticleLayoutItem : public SessionGraphicsItem { public: - static const QString P_APPROX; static const QString P_TOTAL_DENSITY; static const QString P_WEIGHT; static const QString T_PARTICLES; diff --git a/GUI/coregui/Models/TransformToDomain.cpp b/GUI/coregui/Models/TransformToDomain.cpp index ec5ac209f3f..845b72fed1f 100644 --- a/GUI/coregui/Models/TransformToDomain.cpp +++ b/GUI/coregui/Models/TransformToDomain.cpp @@ -115,13 +115,6 @@ TransformToDomain::createLayerRoughness(const SessionItem& roughnessItem) std::unique_ptr<ParticleLayout> TransformToDomain::createParticleLayout(const SessionItem& item) { auto P_layout = std::make_unique<ParticleLayout>(); - auto prop = item.getItemValue(ParticleLayoutItem::P_APPROX).value<ComboProperty>(); - QString approximation = prop.getValue(); - if (approximation == Constants::LAYOUT_DA) { - P_layout->setApproximation(ILayout::DA); - } else if (approximation == Constants::LAYOUT_SSCA) { - P_layout->setApproximation(ILayout::SSCA); - } auto total_density = item.getItemValue(ParticleLayoutItem::P_TOTAL_DENSITY).value<double>(); auto layout_weight = item.getItemValue(ParticleLayoutItem::P_WEIGHT).value<double>(); P_layout->setTotalParticleSurfaceDensity(total_density); diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py index d8e1db33aac..6cf09c254f8 100644 --- a/auto/Wrap/libBornAgainCore.py +++ b/auto/Wrap/libBornAgainCore.py @@ -19141,8 +19141,6 @@ class ILayout(ISample): def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") __repr__ = _swig_repr - DA = _libBornAgainCore.ILayout_DA - SSCA = _libBornAgainCore.ILayout_SSCA __swig_destroy__ = _libBornAgainCore.delete_ILayout __del__ = lambda self: None @@ -19256,30 +19254,6 @@ class ILayout(ISample): """ return _libBornAgainCore.ILayout_setWeight(self, weight) - - def getApproximation(self): - """ - getApproximation(ILayout self) -> ILayout::EInterferenceApproximation - - EInterferenceApproximation ILayout::getApproximation() const - - Gets the used approximation for particles and interference functions. - - """ - return _libBornAgainCore.ILayout_getApproximation(self) - - - def setApproximation(self, approximation): - """ - setApproximation(ILayout self, ILayout::EInterferenceApproximation approximation) - - void ILayout::setApproximation(EInterferenceApproximation approximation) - - Sets the used approximation for particles and interference functions. - - """ - return _libBornAgainCore.ILayout_setApproximation(self, approximation) - ILayout_swigregister = _libBornAgainCore.ILayout_swigregister ILayout_swigregister(ILayout) diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp index 8a282d87ac0..9cfe2292d51 100644 --- a/auto/Wrap/libBornAgainCore_wrap.cpp +++ b/auto/Wrap/libBornAgainCore_wrap.cpp @@ -89455,58 +89455,6 @@ fail: } -SWIGINTERN PyObject *_wrap_ILayout_getApproximation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - ILayout *arg1 = (ILayout *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - ILayout::EInterferenceApproximation result; - - if (!PyArg_ParseTuple(args,(char *)"O:ILayout_getApproximation",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ILayout, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ILayout_getApproximation" "', argument " "1"" of type '" "ILayout const *""'"); - } - arg1 = reinterpret_cast< ILayout * >(argp1); - result = (ILayout::EInterferenceApproximation)((ILayout const *)arg1)->getApproximation(); - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ILayout_setApproximation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - ILayout *arg1 = (ILayout *) 0 ; - ILayout::EInterferenceApproximation arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:ILayout_setApproximation",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ILayout, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ILayout_setApproximation" "', argument " "1"" of type '" "ILayout *""'"); - } - arg1 = reinterpret_cast< ILayout * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ILayout_setApproximation" "', argument " "2"" of type '" "ILayout::EInterferenceApproximation""'"); - } - arg2 = static_cast< ILayout::EInterferenceApproximation >(val2); - (arg1)->setApproximation(arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *ILayout_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; @@ -133971,22 +133919,6 @@ static PyMethodDef SwigMethods[] = { "Sets the relative weight of this layout. \n" "\n" ""}, - { (char *)"ILayout_getApproximation", _wrap_ILayout_getApproximation, METH_VARARGS, (char *)"\n" - "ILayout_getApproximation(ILayout self) -> ILayout::EInterferenceApproximation\n" - "\n" - "EInterferenceApproximation ILayout::getApproximation() const\n" - "\n" - "Gets the used approximation for particles and interference functions. \n" - "\n" - ""}, - { (char *)"ILayout_setApproximation", _wrap_ILayout_setApproximation, METH_VARARGS, (char *)"\n" - "ILayout_setApproximation(ILayout self, ILayout::EInterferenceApproximation approximation)\n" - "\n" - "void ILayout::setApproximation(EInterferenceApproximation approximation)\n" - "\n" - "Sets the used approximation for particles and interference functions. \n" - "\n" - ""}, { (char *)"ILayout_swigregister", ILayout_swigregister, METH_VARARGS, NULL}, { (char *)"delete_IAbstractParticle", _wrap_delete_IAbstractParticle, METH_VARARGS, (char *)"\n" "delete_IAbstractParticle(IAbstractParticle self)\n" @@ -144362,8 +144294,6 @@ SWIG_init(void) { SWIG_Python_SetConstant(d, "IHistogram_AVERAGE",SWIG_From_int(static_cast< int >(IHistogram::AVERAGE))); SWIG_Python_SetConstant(d, "IHistogram_STANDARD_ERROR",SWIG_From_int(static_cast< int >(IHistogram::STANDARD_ERROR))); SWIG_Python_SetConstant(d, "IHistogram_NENTRIES",SWIG_From_int(static_cast< int >(IHistogram::NENTRIES))); - SWIG_Python_SetConstant(d, "ILayout_DA",SWIG_From_int(static_cast< int >(ILayout::DA))); - SWIG_Python_SetConstant(d, "ILayout_SSCA",SWIG_From_int(static_cast< int >(ILayout::SSCA))); SWIG_Python_SetConstant(d, "MillerIndexOrientation_QX",SWIG_From_int(static_cast< int >(MillerIndexOrientation::QX))); SWIG_Python_SetConstant(d, "MillerIndexOrientation_QY",SWIG_From_int(static_cast< int >(MillerIndexOrientation::QY))); SWIG_Python_SetConstant(d, "MillerIndexOrientation_QZ",SWIG_From_int(static_cast< int >(MillerIndexOrientation::QZ))); -- GitLab