From 2d81843681ff7c6be94a5b60064e2a981f4b2e5a Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 9 Jul 2021 12:15:07 +0200 Subject: [PATCH 1/4] clang-format --- GUI/Models/GUIDomainSampleVisitor.cpp | 9 +++++---- GUI/Models/ItemWithParticles.cpp | 2 +- GUI/Models/ItemWithParticles.h | 4 ++-- GUI/Models/MaterialItemUtils.cpp | 2 +- GUI/Models/MesoCrystalItem.cpp | 5 +++-- GUI/Models/MesoCrystalItem.h | 2 +- GUI/Models/ParticleCompositionItem.cpp | 8 ++++---- GUI/Models/ParticleCoreShellItem.cpp | 3 +-- GUI/Models/ParticleItem.cpp | 7 ++++--- GUI/Models/ParticleLayoutItem.cpp | 9 +++++---- GUI/Models/SampleValidator.cpp | 12 ++++++------ .../RealSpaceWidgets/RealSpaceBuilder.cpp | 4 ++-- GUI/Views/SampleDesigner/DesignerScene.cpp | 10 +++++----- Resample/Coherence/FFTerm.cpp | 2 +- Resample/FFCompute/ComputeBA.cpp | 4 ++-- Resample/FFCompute/ComputeBAPol.cpp | 4 ++-- Resample/FFCompute/ComputeBAPol.h | 4 ++-- Resample/FFCompute/ComputeDWBA.cpp | 4 ++-- Resample/FFCompute/ComputeDWBAPol.cpp | 4 ++-- Resample/FFCompute/ComputeDWBAPol.h | 4 ++-- Resample/FFCompute/IComputePol.cpp | 2 +- Resample/FFCompute/IComputePol.h | 4 ++-- Resample/FFCompute/IComputeScalar.cpp | 2 +- Resample/FFCompute/IComputeScalar.h | 1 + Tests/UnitTests/GUI/TestComponentUtils.cpp | 18 ++++++------------ 25 files changed, 64 insertions(+), 66 deletions(-) diff --git a/GUI/Models/GUIDomainSampleVisitor.cpp b/GUI/Models/GUIDomainSampleVisitor.cpp index c440f23bd07..c317b3ab792 100644 --- a/GUI/Models/GUIDomainSampleVisitor.cpp +++ b/GUI/Models/GUIDomainSampleVisitor.cpp @@ -571,14 +571,15 @@ ExternalProperty GUIDomainSampleVisitor::createMaterialFromDomain(const Material return GUI::Model::MaterialItemUtils::materialProperty(*materialItem); } -template <typename T> T* GUIDomainSampleVisitor::CreateIParticle(SessionItem* parent, - const IParticle*) +template <typename T> +T* GUIDomainSampleVisitor::CreateIParticle(SessionItem* parent, const IParticle*) { return m_sampleModel->insertItem<T>(parent, -1); } -template <> ParticleItem* GUIDomainSampleVisitor::CreateIParticle(SessionItem* parent, - const IParticle* particle) +template <> +ParticleItem* GUIDomainSampleVisitor::CreateIParticle(SessionItem* parent, + const IParticle* particle) { if (parent->hasModelType<ParticleCoreShellItem>()) { const ParticleCoreShell* coreshell = diff --git a/GUI/Models/ItemWithParticles.cpp b/GUI/Models/ItemWithParticles.cpp index 342495b0091..82de8ded1ff 100644 --- a/GUI/Models/ItemWithParticles.cpp +++ b/GUI/Models/ItemWithParticles.cpp @@ -91,7 +91,7 @@ ItemWithParticles::ItemWithParticles(const QString& model_type, const QString& a } } else { getItem(P_ABUNDANCE)->setEnabled(true); - if (isShellParticle()) + if (isShellParticle()) item<VectorItem>(P_POSITION)->setEnabled(true); } }); diff --git a/GUI/Models/ItemWithParticles.h b/GUI/Models/ItemWithParticles.h index 1c7f4c9f969..baa31017353 100644 --- a/GUI/Models/ItemWithParticles.h +++ b/GUI/Models/ItemWithParticles.h @@ -15,8 +15,8 @@ #ifndef BORNAGAIN_GUI_MODELS_ITEMWITHPARTICLES_H #define BORNAGAIN_GUI_MODELS_ITEMWITHPARTICLES_H -#include "GUI/Models/ExternalProperty.h" #include "Base/Vector/Vectors3D.h" +#include "GUI/Models/ExternalProperty.h" #include "GUI/Models/SessionGraphicsItem.h" class RotationItem; @@ -36,7 +36,7 @@ public: const kvector_t position() const; void setPosition(const kvector_t& position); - VectorItem* positionItem() const; + VectorItem* positionItem() const; TransformationItem* createTransformationItem(); void setTransformation(RotationItem* transformation); diff --git a/GUI/Models/MaterialItemUtils.cpp b/GUI/Models/MaterialItemUtils.cpp index b8306bd2541..bacf951a54f 100644 --- a/GUI/Models/MaterialItemUtils.cpp +++ b/GUI/Models/MaterialItemUtils.cpp @@ -28,8 +28,8 @@ #include <boost/polymorphic_cast.hpp> using boost::polymorphic_cast; -#include <random> #include <deque> +#include <random> QColor GUI::Model::MaterialItemUtils::suggestMaterialColor(const QString& name) { diff --git a/GUI/Models/MesoCrystalItem.cpp b/GUI/Models/MesoCrystalItem.cpp index a7466092ee2..de50dbd2de3 100644 --- a/GUI/Models/MesoCrystalItem.cpp +++ b/GUI/Models/MesoCrystalItem.cpp @@ -65,8 +65,9 @@ MesoCrystalItem::MesoCrystalItem() addProperty<VectorItem>(P_VECTOR_B)->setToolTip(lattice_vector2_tooltip); addProperty<VectorItem>(P_VECTOR_C)->setToolTip(lattice_vector3_tooltip); - registerTag(T_BASIS_PARTICLE, 0, 1, {ParticleItem::M_TYPE, ParticleCoreShellItem::M_TYPE, - ParticleCompositionItem::M_TYPE, MesoCrystalItem::M_TYPE}); + registerTag(T_BASIS_PARTICLE, 0, 1, + {ParticleItem::M_TYPE, ParticleCoreShellItem::M_TYPE, + ParticleCompositionItem::M_TYPE, MesoCrystalItem::M_TYPE}); setDefaultTag(T_BASIS_PARTICLE); } diff --git a/GUI/Models/MesoCrystalItem.h b/GUI/Models/MesoCrystalItem.h index fe458946e3a..9a109801808 100644 --- a/GUI/Models/MesoCrystalItem.h +++ b/GUI/Models/MesoCrystalItem.h @@ -15,8 +15,8 @@ #ifndef BORNAGAIN_GUI_MODELS_MESOCRYSTALITEM_H #define BORNAGAIN_GUI_MODELS_MESOCRYSTALITEM_H -#include "GUI/Models/ItemWithParticles.h" #include "Base/Vector/Vectors3D.h" +#include "GUI/Models/ItemWithParticles.h" #include "Sample/Lattice/Lattice3D.h" class FormFactorItem; diff --git a/GUI/Models/ParticleCompositionItem.cpp b/GUI/Models/ParticleCompositionItem.cpp index 0f79826e522..072efce852a 100644 --- a/GUI/Models/ParticleCompositionItem.cpp +++ b/GUI/Models/ParticleCompositionItem.cpp @@ -37,13 +37,13 @@ const QString ParticleCompositionItem::T_PARTICLES = "Particle Tag"; const QString ParticleCompositionItem::M_TYPE = "ParticleComposition"; ParticleCompositionItem::ParticleCompositionItem() - : SessionGraphicsItem(M_TYPE), - ItemWithParticles(M_TYPE, abundance_tooltip, position_tooltip) + : SessionGraphicsItem(M_TYPE), ItemWithParticles(M_TYPE, abundance_tooltip, position_tooltip) { setToolTip("Composition of particles with fixed positions"); - registerTag(T_PARTICLES, 0, -1, {ParticleItem::M_TYPE, ParticleCoreShellItem::M_TYPE, - ParticleCompositionItem::M_TYPE, MesoCrystalItem::M_TYPE}); + registerTag(T_PARTICLES, 0, -1, + {ParticleItem::M_TYPE, ParticleCoreShellItem::M_TYPE, + ParticleCompositionItem::M_TYPE, MesoCrystalItem::M_TYPE}); setDefaultTag(T_PARTICLES); } diff --git a/GUI/Models/ParticleCoreShellItem.cpp b/GUI/Models/ParticleCoreShellItem.cpp index b4572b83baa..ae4b2e28378 100644 --- a/GUI/Models/ParticleCoreShellItem.cpp +++ b/GUI/Models/ParticleCoreShellItem.cpp @@ -38,8 +38,7 @@ const QString ParticleCoreShellItem::T_SHELL = "Shell tag"; const QString ParticleCoreShellItem::M_TYPE = "ParticleCoreShell"; ParticleCoreShellItem::ParticleCoreShellItem() - : SessionGraphicsItem(M_TYPE), - ItemWithParticles(M_TYPE, abundance_tooltip, position_tooltip) + : SessionGraphicsItem(M_TYPE), ItemWithParticles(M_TYPE, abundance_tooltip, position_tooltip) { setToolTip("A particle with a core/shell geometry"); diff --git a/GUI/Models/ParticleItem.cpp b/GUI/Models/ParticleItem.cpp index f4b0f1f995c..2242beeaa78 100644 --- a/GUI/Models/ParticleItem.cpp +++ b/GUI/Models/ParticleItem.cpp @@ -38,8 +38,9 @@ const QString ParticleItem::P_FORM_FACTOR = "Form Factor"; const QString ParticleItem::M_TYPE = "Particle"; ParticleItem::ParticleItem() - : SessionGraphicsItem(M_TYPE), ItemWithMaterial(M_TYPE), - ItemWithParticles(M_TYPE, abundance_tooltip, position_tooltip) + : SessionGraphicsItem(M_TYPE) + , ItemWithMaterial(M_TYPE) + , ItemWithParticles(M_TYPE, abundance_tooltip, position_tooltip) { addGroupProperty(P_FORM_FACTOR, "Form Factor"); @@ -95,7 +96,7 @@ bool ParticleItem::isShellParticle() const return false; return parent()->hasModelType<ParticleCoreShellItem>() - && ParticleCoreShellItem::isShellTagName(parent()->tagFromItem(this)); + && ParticleCoreShellItem::isShellTagName(parent()->tagFromItem(this)); } //! Returns true if this particle is directly connected to a ParticleLayout diff --git a/GUI/Models/ParticleLayoutItem.cpp b/GUI/Models/ParticleLayoutItem.cpp index 26a4c4cfcbb..d6297f819d3 100644 --- a/GUI/Models/ParticleLayoutItem.cpp +++ b/GUI/Models/ParticleLayoutItem.cpp @@ -63,8 +63,9 @@ ParticleLayoutItem::ParticleLayoutItem() : SessionGraphicsItem(M_TYPE) getItem(P_TOTAL_DENSITY)->setDecimals(10); addProperty(P_WEIGHT, 1.0)->setToolTip(weight_tooltip); - registerTag(T_PARTICLES, 0, -1, {ParticleItem::M_TYPE, ParticleCoreShellItem::M_TYPE, - ParticleCompositionItem::M_TYPE, MesoCrystalItem::M_TYPE}); + registerTag(T_PARTICLES, 0, -1, + {ParticleItem::M_TYPE, ParticleCoreShellItem::M_TYPE, + ParticleCompositionItem::M_TYPE, MesoCrystalItem::M_TYPE}); setDefaultTag(T_PARTICLES); registerTag( T_INTERFERENCE, 0, 1, @@ -91,7 +92,7 @@ double ParticleLayoutItem::totalDensity() const void ParticleLayoutItem::setTotalDensity(double total_density) { - + setItemValue(P_TOTAL_DENSITY, total_density); } @@ -102,7 +103,7 @@ double ParticleLayoutItem::weight() const void ParticleLayoutItem::setWeight(double weight) { - + setItemValue(P_WEIGHT, weight); } diff --git a/GUI/Models/SampleValidator.cpp b/GUI/Models/SampleValidator.cpp index 2698bb535ee..a8a4710a592 100644 --- a/GUI/Models/SampleValidator.cpp +++ b/GUI/Models/SampleValidator.cpp @@ -49,14 +49,14 @@ void SampleValidator::validateItem(const SessionItem* item) if (item->hasModelType<MultiLayerItem>()) { diagnosis = validateMultiLayerItem(polymorphic_downcast<const MultiLayerItem*>(item)); } else if (item->hasModelType<ParticleLayoutItem>()) { - diagnosis = validateParticleLayoutItem - (polymorphic_downcast<const ParticleLayoutItem*>(item)); + diagnosis = + validateParticleLayoutItem(polymorphic_downcast<const ParticleLayoutItem*>(item)); } else if (item->hasModelType<ParticleCoreShellItem>()) { - diagnosis = validateParticleCoreShellItem - (polymorphic_cast<const ParticleCoreShellItem*>(item)); + diagnosis = + validateParticleCoreShellItem(polymorphic_cast<const ParticleCoreShellItem*>(item)); } else if (item->hasModelType<ParticleCompositionItem>()) { - diagnosis = validateParticleCompositionItem - (polymorphic_cast<const ParticleCompositionItem*>(item)); + diagnosis = + validateParticleCompositionItem(polymorphic_cast<const ParticleCompositionItem*>(item)); } if (!diagnosis.isEmpty()) { m_valid_sample = false; diff --git a/GUI/Views/RealSpaceWidgets/RealSpaceBuilder.cpp b/GUI/Views/RealSpaceWidgets/RealSpaceBuilder.cpp index 264f6223372..ee202e98d53 100644 --- a/GUI/Views/RealSpaceWidgets/RealSpaceBuilder.cpp +++ b/GUI/Views/RealSpaceWidgets/RealSpaceBuilder.cpp @@ -33,8 +33,8 @@ #include <QDebug> namespace { -std::unique_ptr<IInterferenceFunction> GetInterferenceFunction -(const ParticleLayoutItem& layoutItem); +std::unique_ptr<IInterferenceFunction> +GetInterferenceFunction(const ParticleLayoutItem& layoutItem); } RealSpaceBuilder::RealSpaceBuilder(QWidget* parent) : QWidget(parent) {} diff --git a/GUI/Views/SampleDesigner/DesignerScene.cpp b/GUI/Views/SampleDesigner/DesignerScene.cpp index 5e1e24e4358..11b14b0fd74 100644 --- a/GUI/Views/SampleDesigner/DesignerScene.cpp +++ b/GUI/Views/SampleDesigner/DesignerScene.cpp @@ -362,23 +362,23 @@ void DesignerScene::onEstablishedConnection(NodeEditorConnection* connection_ptr QString tag; if (parentItem->hasModelType<ParticleLayoutItem>()) { if (connection->inputPort()->getPortType() == NodeEditorPort::INTERFERENCE) { - polymorphic_downcast<ParticleLayoutItem*>(parentItem)->setInterference - (polymorphic_downcast<InterferenceFunctionItem*>(childItem)); + polymorphic_downcast<ParticleLayoutItem*>(parentItem) + ->setInterference(polymorphic_downcast<InterferenceFunctionItem*>(childItem)); return; } } else if ((parentItem->hasModelType<ParticleCoreShellItem>() || parentItem->hasModelType<ParticleCompositionItem>() || parentItem->hasModelType<MesoCrystalItem>()) && connection->inputPort()->getPortType() == NodeEditorPort::TRANSFORMATION) { - polymorphic_cast<ItemWithParticles*>(parentItem)->setTransformation - (polymorphic_downcast<RotationItem*>(childItem)); + polymorphic_cast<ItemWithParticles*>(parentItem) + ->setTransformation(polymorphic_downcast<RotationItem*>(childItem)); return; } else if (parentItem->hasModelType<ParticleCoreShellItem>()) { ParticleCoreShellItem* parent = polymorphic_cast<ParticleCoreShellItem*>(parentItem); ParticleItem* child = dynamic_cast<ParticleItem*>(childItem); if (parentView->getInputPortIndex(connection->inputPort()) == 0) { parent->setCore(child); - return; + return; } else if (parentView->getInputPortIndex(connection->inputPort()) == 1) { parent->setShell(child); return; diff --git a/Resample/Coherence/FFTerm.cpp b/Resample/Coherence/FFTerm.cpp index 8ad08d91dbc..50b767b685d 100644 --- a/Resample/Coherence/FFTerm.cpp +++ b/Resample/Coherence/FFTerm.cpp @@ -14,8 +14,8 @@ #include "Resample/Coherence/FFTerm.h" #include "Base/Utils/Assert.h" -#include "Resample/FFCompute/IComputeScalar.h" #include "Resample/FFCompute/IComputePol.h" +#include "Resample/FFCompute/IComputeScalar.h" CoherentFFTerm::CoherentFFTerm(IComputeFF* computer) : m_computer(computer) {} diff --git a/Resample/FFCompute/ComputeBA.cpp b/Resample/FFCompute/ComputeBA.cpp index 86b19402b82..6bc0780f685 100644 --- a/Resample/FFCompute/ComputeBA.cpp +++ b/Resample/FFCompute/ComputeBA.cpp @@ -26,8 +26,8 @@ ComputeBA* ComputeBA::clone() const } complex_t ComputeBA::computeFF(const WavevectorInfo& wavevectors, - const std::unique_ptr<const IFlux>&, - const std::unique_ptr<const IFlux>&) const + const std::unique_ptr<const IFlux>&, + const std::unique_ptr<const IFlux>&) const { return m_ff->theFF(wavevectors); } diff --git a/Resample/FFCompute/ComputeBAPol.cpp b/Resample/FFCompute/ComputeBAPol.cpp index eeb87dfb666..47df67a00dd 100644 --- a/Resample/FFCompute/ComputeBAPol.cpp +++ b/Resample/FFCompute/ComputeBAPol.cpp @@ -26,8 +26,8 @@ ComputeBAPol* ComputeBAPol::clone() const } Eigen::Matrix2cd ComputeBAPol::computePolFF(const WavevectorInfo& wavevectors, - const std::unique_ptr<const IFlux>&, - const std::unique_ptr<const IFlux>&) const + const std::unique_ptr<const IFlux>&, + const std::unique_ptr<const IFlux>&) const { Eigen::Matrix2cd ff_BA = m_ff->thePolFF(wavevectors); Eigen::Matrix2cd result; diff --git a/Resample/FFCompute/ComputeBAPol.h b/Resample/FFCompute/ComputeBAPol.h index 9411f825dc5..fbc5a83d3fd 100644 --- a/Resample/FFCompute/ComputeBAPol.h +++ b/Resample/FFCompute/ComputeBAPol.h @@ -39,8 +39,8 @@ public: //! Calculates and returns a polarized form factor calculation in BA Eigen::Matrix2cd computePolFF(const WavevectorInfo& wavevectors, - const std::unique_ptr<const IFlux>&, - const std::unique_ptr<const IFlux>&) const override; + const std::unique_ptr<const IFlux>&, + const std::unique_ptr<const IFlux>&) const override; }; #endif // BORNAGAIN_RESAMPLE_FFCOMPUTE_COMPUTEBAPOL_H diff --git a/Resample/FFCompute/ComputeDWBA.cpp b/Resample/FFCompute/ComputeDWBA.cpp index fb22dbc4755..18f26b0128d 100644 --- a/Resample/FFCompute/ComputeDWBA.cpp +++ b/Resample/FFCompute/ComputeDWBA.cpp @@ -27,8 +27,8 @@ ComputeDWBA* ComputeDWBA::clone() const } complex_t ComputeDWBA::computeFF(const WavevectorInfo& wavevectors, - const std::unique_ptr<const IFlux>& inFlux, - const std::unique_ptr<const IFlux>& outFlux) const + const std::unique_ptr<const IFlux>& inFlux, + const std::unique_ptr<const IFlux>& outFlux) const { // Retrieve the two different incoming wavevectors in the layer cvector_t k_i_T = wavevectors.getKi(); diff --git a/Resample/FFCompute/ComputeDWBAPol.cpp b/Resample/FFCompute/ComputeDWBAPol.cpp index 1cd7a983cfd..df44f01f405 100644 --- a/Resample/FFCompute/ComputeDWBAPol.cpp +++ b/Resample/FFCompute/ComputeDWBAPol.cpp @@ -38,8 +38,8 @@ ComputeDWBAPol* ComputeDWBAPol::clone() const } Eigen::Matrix2cd ComputeDWBAPol::computePolFF(const WavevectorInfo& wavevectors, - const std::unique_ptr<const IFlux>& inFlux, - const std::unique_ptr<const IFlux>& outFlux) const + const std::unique_ptr<const IFlux>& inFlux, + const std::unique_ptr<const IFlux>& outFlux) const { // the required wavevectors inside the layer for // different eigenmodes and in- and outgoing wavevector; diff --git a/Resample/FFCompute/ComputeDWBAPol.h b/Resample/FFCompute/ComputeDWBAPol.h index 8bcd73ddc92..e250387a532 100644 --- a/Resample/FFCompute/ComputeDWBAPol.h +++ b/Resample/FFCompute/ComputeDWBAPol.h @@ -38,8 +38,8 @@ public: //! Returns the coherent sum of the four DWBA terms for polarized scattering. Eigen::Matrix2cd computePolFF(const WavevectorInfo& wavevectors, - const std::unique_ptr<const IFlux>& inFlux, - const std::unique_ptr<const IFlux>& outFlux) const override; + const std::unique_ptr<const IFlux>& inFlux, + const std::unique_ptr<const IFlux>& outFlux) const override; friend class TestPolarizedDWBATerms; }; diff --git a/Resample/FFCompute/IComputePol.cpp b/Resample/FFCompute/IComputePol.cpp index f9e3729b6e3..1c00e8c842b 100644 --- a/Resample/FFCompute/IComputePol.cpp +++ b/Resample/FFCompute/IComputePol.cpp @@ -13,8 +13,8 @@ // ************************************************************************************************ #include "Resample/FFCompute/IComputePol.h" -#include "Base/Utils/Assert.h" #include "Base/Pixel/SimulationElement.h" +#include "Base/Utils/Assert.h" #include "Resample/Flux/IFlux.h" // required by VS19 compiler #include "Resample/Fresnel/IFresnelMap.h" #include "Sample/Material/WavevectorInfo.h" diff --git a/Resample/FFCompute/IComputePol.h b/Resample/FFCompute/IComputePol.h index 15f9ed5a3d5..35ffacac675 100644 --- a/Resample/FFCompute/IComputePol.h +++ b/Resample/FFCompute/IComputePol.h @@ -35,8 +35,8 @@ public: Eigen::Matrix2cd coherentPolFF(const SimulationElement& sim_element) const; //! Returns scattering amplitude for matrix interactions virtual Eigen::Matrix2cd computePolFF(const WavevectorInfo& wavevectors, - const std::unique_ptr<const IFlux>& inFlux, - const std::unique_ptr<const IFlux>& outFlux) const = 0; + const std::unique_ptr<const IFlux>& inFlux, + const std::unique_ptr<const IFlux>& outFlux) const = 0; protected: IComputePol(const IFormFactor& ff, size_t i_layer) : IComputeFF(ff, i_layer) {} diff --git a/Resample/FFCompute/IComputeScalar.cpp b/Resample/FFCompute/IComputeScalar.cpp index 78faf173cc9..f8f8a8a4454 100644 --- a/Resample/FFCompute/IComputeScalar.cpp +++ b/Resample/FFCompute/IComputeScalar.cpp @@ -13,8 +13,8 @@ // ************************************************************************************************ #include "Resample/FFCompute/IComputeScalar.h" -#include "Base/Utils/Assert.h" #include "Base/Pixel/SimulationElement.h" +#include "Base/Utils/Assert.h" #include "Resample/Flux/IFlux.h" // required by VS19 compiler #include "Resample/Fresnel/IFresnelMap.h" #include "Sample/Material/WavevectorInfo.h" diff --git a/Resample/FFCompute/IComputeScalar.h b/Resample/FFCompute/IComputeScalar.h index 14fd60c75b6..38e4b5acb03 100644 --- a/Resample/FFCompute/IComputeScalar.h +++ b/Resample/FFCompute/IComputeScalar.h @@ -36,6 +36,7 @@ public: const std::unique_ptr<const IFlux>& inFlux, const std::unique_ptr<const IFlux>& outFlux) const = 0; complex_t coherentFF(const SimulationElement& sim_element) const; + protected: IComputeScalar(const IFormFactor& ff, size_t i_layer) : IComputeFF(ff, i_layer) {} }; diff --git a/Tests/UnitTests/GUI/TestComponentUtils.cpp b/Tests/UnitTests/GUI/TestComponentUtils.cpp index 876f015ab91..673e709015f 100644 --- a/Tests/UnitTests/GUI/TestComponentUtils.cpp +++ b/Tests/UnitTests/GUI/TestComponentUtils.cpp @@ -24,12 +24,8 @@ TEST_F(TestComponentUtils, test_componentItems) QList<const SessionItem*> expectedList = QList<const SessionItem*>() - << particle->materialItem() - << particle->abundanceItem() - << particle->positionItem() - << group - << ffCylinder->radiusItem() - << ffCylinder->heightItem(); + << particle->materialItem() << particle->abundanceItem() << particle->positionItem() + << group << ffCylinder->radiusItem() << ffCylinder->heightItem(); auto itemList = GUI::Model::ComponentUtils::componentItems(*particle); EXPECT_EQ(itemList.size(), 6); @@ -46,12 +42,10 @@ TEST_F(TestComponentUtils, test_componentItemsFFChange) particle->setFormFactorType<FullSphereItem>(); FullSphereItem* sphereItem = dynamic_cast<FullSphereItem*>(particle->formFactor()); - QList<const SessionItem*> expectedList = QList<const SessionItem*>() - << particle->materialItem() - << particle->abundanceItem() - << particle->positionItem() - << group - << sphereItem->radiusItem(); + QList<const SessionItem*> expectedList = + QList<const SessionItem*>() + << particle->materialItem() << particle->abundanceItem() << particle->positionItem() + << group << sphereItem->radiusItem(); auto itemList = GUI::Model::ComponentUtils::componentItems(*particle); EXPECT_EQ(itemList.size(), 5); -- GitLab From 3a4b7f83d68f5d06c59d4e1ae115f57eab99287c Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 9 Jul 2021 12:07:49 +0200 Subject: [PATCH 2/4] more compact --- Core/Computation/DWBASingleComputation.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Core/Computation/DWBASingleComputation.cpp b/Core/Computation/DWBASingleComputation.cpp index 7cd87052fd4..158d6f5a145 100644 --- a/Core/Computation/DWBASingleComputation.cpp +++ b/Core/Computation/DWBASingleComputation.cpp @@ -30,10 +30,8 @@ DWBASingleComputation::DWBASingleComputation(const ProcessedSample& sample, // , m_layout_comps(std::move(makeLayoutComputation)) { const bool polarized = sample.containsMagneticMaterial() || forcePolarized; - for (const ProcessedLayout& layout : sample.layouts()) { - auto* p = new ParticleLayoutComputation(layout, options, polarized); - m_layout_comps.emplace_back(p); - } + for (const ProcessedLayout& layout : sample.layouts()) + m_layout_comps.emplace_back(new ParticleLayoutComputation(layout, options, polarized)); } DWBASingleComputation::~DWBASingleComputation() = default; -- GitLab From 4b38d3cccbf2ccb963612428973020b8193a6e28 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 9 Jul 2021 12:09:21 +0200 Subject: [PATCH 3/4] standard local var names --- Core/Computation/DWBASingleComputation.cpp | 14 +++++++------- Core/Computation/DWBASingleComputation.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Core/Computation/DWBASingleComputation.cpp b/Core/Computation/DWBASingleComputation.cpp index 158d6f5a145..ac48bf437ff 100644 --- a/Core/Computation/DWBASingleComputation.cpp +++ b/Core/Computation/DWBASingleComputation.cpp @@ -36,23 +36,23 @@ DWBASingleComputation::DWBASingleComputation(const ProcessedSample& sample, DWBASingleComputation::~DWBASingleComputation() = default; -void DWBASingleComputation::setProgressHandler(ProgressHandler* p_progress) +void DWBASingleComputation::setProgressHandler(ProgressHandler* progress) { - m_progress_counter = std::make_unique<DelayedProgressCounter>(p_progress, 100); + m_progress_counter = std::make_unique<DelayedProgressCounter>(progress, 100); } -void DWBASingleComputation::compute(SimulationElement& elem) const +void DWBASingleComputation::compute(SimulationElement& ele) const { - elem.setFresnelMap(m_fresnel_map); + ele.setFresnelMap(m_fresnel_map); for (auto& layout_comp : m_layout_comps) - layout_comp->compute(elem); + layout_comp->compute(ele); if (m_roughness_comp) - m_roughness_comp->compute(elem); + m_roughness_comp->compute(ele); if (m_spec_comp) - m_spec_comp->compute(elem); + m_spec_comp->compute(ele); if (m_progress_counter) m_progress_counter->stepProgress(); diff --git a/Core/Computation/DWBASingleComputation.h b/Core/Computation/DWBASingleComputation.h index f1992d7b785..834e7fc661f 100644 --- a/Core/Computation/DWBASingleComputation.h +++ b/Core/Computation/DWBASingleComputation.h @@ -45,9 +45,9 @@ public: DWBASingleComputation(const DWBASingleComputation&) = delete; ~DWBASingleComputation(); - void setProgressHandler(ProgressHandler* p_progress); + void setProgressHandler(ProgressHandler* progress); - void compute(SimulationElement& elem) const; + void compute(SimulationElement& ele) const; private: const IFresnelMap* const m_fresnel_map; -- GitLab From de7afabe7fcca8b82ce2c41e83c68e81edc20cfc Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 9 Jul 2021 12:12:21 +0200 Subject: [PATCH 4/4] ctd --- Core/Computation/GISASSpecularComputation.h | 2 +- .../Computation/ParticleLayoutComputation.cpp | 4 ++-- Core/Computation/ParticleLayoutComputation.h | 2 +- .../RoughMultiLayerComputation.cpp | 12 +++++----- Core/Computation/RoughMultiLayerComputation.h | 2 +- Core/Term/SpecularComputationTerm.cpp | 24 +++++++++---------- Core/Term/SpecularComputationTerm.h | 8 +++---- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Core/Computation/GISASSpecularComputation.h b/Core/Computation/GISASSpecularComputation.h index 1f6d3777a2e..6de66465eb5 100644 --- a/Core/Computation/GISASSpecularComputation.h +++ b/Core/Computation/GISASSpecularComputation.h @@ -30,7 +30,7 @@ class GISASSpecularComputation final { public: GISASSpecularComputation(const IFresnelMap* p_fresnel_map); - void compute(SimulationElement& elem) const; + void compute(SimulationElement& ele) const; private: const IFresnelMap* m_fresnel_map; diff --git a/Core/Computation/ParticleLayoutComputation.cpp b/Core/Computation/ParticleLayoutComputation.cpp index 9d676efa815..9bbfa8ab78e 100644 --- a/Core/Computation/ParticleLayoutComputation.cpp +++ b/Core/Computation/ParticleLayoutComputation.cpp @@ -56,7 +56,7 @@ ParticleLayoutComputation::ParticleLayoutComputation(const ProcessedLayout& layo ParticleLayoutComputation::~ParticleLayoutComputation() = default; -void ParticleLayoutComputation::compute(SimulationElement& elem) const +void ParticleLayoutComputation::compute(SimulationElement& ele) const { - elem.addIntensity(m_interparticle_strategy->evaluate(elem) * m_layout.surfaceDensity()); + ele.addIntensity(m_interparticle_strategy->evaluate(ele) * m_layout.surfaceDensity()); } diff --git a/Core/Computation/ParticleLayoutComputation.h b/Core/Computation/ParticleLayoutComputation.h index 7d298fdfdef..c6878ab1735 100644 --- a/Core/Computation/ParticleLayoutComputation.h +++ b/Core/Computation/ParticleLayoutComputation.h @@ -40,7 +40,7 @@ public: bool polarized); ~ParticleLayoutComputation(); - void compute(SimulationElement& elem) const; + void compute(SimulationElement& ele) const; private: const ProcessedLayout& m_layout; diff --git a/Core/Computation/RoughMultiLayerComputation.cpp b/Core/Computation/RoughMultiLayerComputation.cpp index 4de81fca348..bc20ce2f31a 100644 --- a/Core/Computation/RoughMultiLayerComputation.cpp +++ b/Core/Computation/RoughMultiLayerComputation.cpp @@ -46,13 +46,13 @@ RoughMultiLayerComputation::RoughMultiLayerComputation(const ProcessedSample* p_ { } -void RoughMultiLayerComputation::compute(SimulationElement& elem) const +void RoughMultiLayerComputation::compute(SimulationElement& ele) const { - if (elem.getAlphaMean() < 0.0) + if (ele.getAlphaMean() < 0.0) return; const size_t n_slices = m_sample->numberOfSlices(); - kvector_t q = elem.meanQ(); - double wavelength = elem.wavelength(); + kvector_t q = ele.meanQ(); + double wavelength = ele.wavelength(); double autocorr(0.0); complex_t crosscorr(0.0, 0.0); @@ -61,7 +61,7 @@ void RoughMultiLayerComputation::compute(SimulationElement& elem) const for (size_t i = 0; i + 1 < n_slices; i++) { rterm[i] = get_refractive_term(i, wavelength); - sterm[i] = get_sum8terms(i, elem); + sterm[i] = get_sum8terms(i, ele); } for (size_t i = 0; i + 1 < n_slices; i++) { const LayerRoughness* rough = m_sample->avgeSlice(i + 1).topRoughness(); @@ -80,7 +80,7 @@ void RoughMultiLayerComputation::compute(SimulationElement& elem) const } } //! @TODO clarify complex vs double - elem.addIntensity((autocorr + crosscorr.real()) * M_PI / 4. / wavelength / wavelength); + ele.addIntensity((autocorr + crosscorr.real()) * M_PI / 4. / wavelength / wavelength); } complex_t RoughMultiLayerComputation::get_refractive_term(size_t ilayer, double wavelength) const diff --git a/Core/Computation/RoughMultiLayerComputation.h b/Core/Computation/RoughMultiLayerComputation.h index 7eb5b877e64..25c0493cb13 100644 --- a/Core/Computation/RoughMultiLayerComputation.h +++ b/Core/Computation/RoughMultiLayerComputation.h @@ -33,7 +33,7 @@ class RoughMultiLayerComputation final { public: RoughMultiLayerComputation(const ProcessedSample* p_sample); - void compute(SimulationElement& elem) const; + void compute(SimulationElement& ele) const; private: const ProcessedSample* m_sample; diff --git a/Core/Term/SpecularComputationTerm.cpp b/Core/Term/SpecularComputationTerm.cpp index 01924cf9905..6b7a2eb00d5 100644 --- a/Core/Term/SpecularComputationTerm.cpp +++ b/Core/Term/SpecularComputationTerm.cpp @@ -34,13 +34,13 @@ void SpecularComputationTerm::setProgressHandler(ProgressHandler* p_progress) m_progress_counter = std::make_unique<DelayedProgressCounter>(p_progress, 100); } -void SpecularComputationTerm::computeIntensity(SpecularSimulationElement& elem, +void SpecularComputationTerm::computeIntensity(SpecularSimulationElement& ele, const SliceStack& slices) const { - if (!elem.isCalculated()) + if (!ele.isCalculated()) return; - eval(elem, slices); + eval(ele, slices); if (m_progress_counter) m_progress_counter->stepProgress(); @@ -57,11 +57,11 @@ SpecularScalarTerm::SpecularScalarTerm(const MultiLayer& multilayer) SpecularScalarTerm::~SpecularScalarTerm() = default; -void SpecularScalarTerm::eval(SpecularSimulationElement& elem, const SliceStack& slices) const +void SpecularScalarTerm::eval(SpecularSimulationElement& ele, const SliceStack& slices) const { const auto coeff = - std::get<complex_t>(m_strategy->computeTopLayerR(slices, elem.produceKz(slices))); - elem.setIntensity(std::norm(coeff)); + std::get<complex_t>(m_strategy->computeTopLayerR(slices, ele.produceKz(slices))); + ele.setIntensity(std::norm(coeff)); } // ************************************************************************************************ @@ -70,10 +70,10 @@ void SpecularScalarTerm::eval(SpecularSimulationElement& elem, const SliceStack& namespace { -double matrix_intensity(const SpecularSimulationElement& elem, const Eigen::Matrix2cd& R) +double matrix_intensity(const SpecularSimulationElement& ele, const Eigen::Matrix2cd& R) { - const auto& polarization = elem.polarizationHandler().getPolarization(); - const auto& analyzer = elem.polarizationHandler().getAnalyzerOperator(); + const auto& polarization = ele.polarizationHandler().getPolarization(); + const auto& analyzer = ele.polarizationHandler().getAnalyzerOperator(); const complex_t result = (polarization * R.adjoint() * analyzer * R).trace(); @@ -89,9 +89,9 @@ SpecularMatrixTerm::SpecularMatrixTerm(const MultiLayer& multilayer) SpecularMatrixTerm::~SpecularMatrixTerm() = default; -void SpecularMatrixTerm::eval(SpecularSimulationElement& elem, const SliceStack& slices) const +void SpecularMatrixTerm::eval(SpecularSimulationElement& ele, const SliceStack& slices) const { const auto coeff = - std::get<Eigen::Matrix2cd>(m_strategy->computeTopLayerR(slices, elem.produceKz(slices))); - elem.setIntensity(matrix_intensity(elem, coeff)); + std::get<Eigen::Matrix2cd>(m_strategy->computeTopLayerR(slices, ele.produceKz(slices))); + ele.setIntensity(matrix_intensity(ele, coeff)); } diff --git a/Core/Term/SpecularComputationTerm.h b/Core/Term/SpecularComputationTerm.h index 26b823b7238..19390aab735 100644 --- a/Core/Term/SpecularComputationTerm.h +++ b/Core/Term/SpecularComputationTerm.h @@ -47,10 +47,10 @@ public: SpecularComputationTerm& operator=(const SpecularComputationTerm& other) = delete; void setProgressHandler(ProgressHandler* p_progress); - void computeIntensity(SpecularSimulationElement& elem, const SliceStack& slices) const; + void computeIntensity(SpecularSimulationElement& ele, const SliceStack& slices) const; protected: - virtual void eval(SpecularSimulationElement& elem, const SliceStack& slices) const = 0; + virtual void eval(SpecularSimulationElement& ele, const SliceStack& slices) const = 0; const std::unique_ptr<ISpecularStrategy> m_strategy; @@ -69,7 +69,7 @@ public: private: ~SpecularScalarTerm() override; - void eval(SpecularSimulationElement& elem, const SliceStack& slices) const override; + void eval(SpecularSimulationElement& ele, const SliceStack& slices) const override; }; //! Computes the specular scattering for a magnetic sample @@ -83,7 +83,7 @@ public: private: ~SpecularMatrixTerm() override; - void eval(SpecularSimulationElement& elem, const SliceStack& slices) const override; + void eval(SpecularSimulationElement& ele, const SliceStack& slices) const override; }; #endif // BORNAGAIN_CORE_TERM_SPECULARCOMPUTATIONTERM_H -- GitLab