Skip to content
Snippets Groups Projects
ParticleItem.cpp 2.43 KiB
Newer Older
  • Learn to ignore specific revisions
  • //  ************************************************************************************************
    
    //  BornAgain: simulate and fit reflection and scattering
    
    //! @file      GUI/Model/Sample/ParticleItem.cpp
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    //! @brief     Implements class ParticleItem
    
    //! @homepage  http://www.bornagainproject.org
    
    //! @license   GNU General Public License v3 or higher (see COPYING)
    
    //! @copyright Forschungszentrum Jülich GmbH 2018
    //! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
    
    //  ************************************************************************************************
    
    #include "GUI/Model/Sample/ParticleItem.h"
    #include "GUI/Model/Group/GroupItem.h"
    
    Wuttke, Joachim's avatar
    Wuttke, Joachim committed
    #include "GUI/Model/Job/JobItem.h"
    #include "GUI/Model/Job/JobModelFunctions.h"
    
    #include "GUI/Model/Material/MaterialItem.h"
    
    #include "GUI/Model/Sample/FormFactorItems.h"
    #include "GUI/Model/Sample/ParticleCoreShellItem.h"
    #include "GUI/Model/Sample/ParticleLayoutItem.h"
    #include "GUI/Model/Session/SessionItemUtils.h"
    #include "GUI/Model/Types/VectorItem.h"
    
    Wuttke, Joachim's avatar
    Wuttke, Joachim committed
    #include "Sample/Particle/Particle.h"
    
    #include "Sample/Scattering/IFormFactor.h"
    
    namespace {
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n"
                                      "total number of particles in the layout";
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    const QString position_tooltip = "Relative position of the particle's reference point \n"
                                     "in the coordinate system of the parent (nm)";
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    } // namespace
    
        : SessionItem(M_TYPE)
    
    Wuttke, Joachim's avatar
    Wuttke, Joachim committed
        , ItemWithMaterial(M_TYPE)
        , ItemWithParticles(M_TYPE, abundance_tooltip, position_tooltip)
    
        addGroupProperty(P_FORM_FACTOR, formFactorGroupInfo());
    
        setDefaultTagTransformation();
    
    std::unique_ptr<Particle> ParticleItem::createParticle() const
    {
    
        auto& ffItem = groupItem<FormFactorItem>(P_FORM_FACTOR);
    
    Matthias Puchner's avatar
    Matthias Puchner committed
        auto domainMaterial = materialItem()->createMaterial();
    
        auto particle = std::make_unique<Particle>(*domainMaterial, *ffItem.createFormFactor());
    
        particle->setAbundance(abundance());
    
        setTransformationInfo(particle.get());
    
        return particle;
    
    Matthias Puchner's avatar
    Matthias Puchner committed
    void ParticleItem::setFormFactor(const QString& model_type)
    
    Matthias Puchner's avatar
    Matthias Puchner committed
        setGroupProperty(P_FORM_FACTOR, model_type);
    
    }
    
    FormFactorItem* ParticleItem::formFactor() const
    {
    
        return dynamic_cast<FormFactorItem*>(getGroupItem(P_FORM_FACTOR));
    
    }
    
    GroupItem* ParticleItem::formFactorItem() const
    {
        return item<GroupItem>(P_FORM_FACTOR);
    }