File: ParticleCatalog.cpp

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (83 lines) | stat: -rw-r--r-- 2,784 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/Model/Sample/ParticleCatalog.cpp
//! @brief     Implements class ParticleCatalog.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2021
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#include "GUI/Model/Sample/ParticleCatalog.h"
#include "Base/Util/Assert.h"
#include "GUI/Model/Sample/CompoundItem.h"
#include "GUI/Model/Sample/CoreAndShellItem.h"
#include "GUI/Model/Sample/MesocrystalItem.h"
#include "GUI/Model/Sample/ParticleItem.h"

ItemWithParticles* ParticleCatalog::create(Type type, const MaterialsSet* materials)
{
    ASSERT(materials);

    switch (type) {
    case Type::Particle:
        return new ParticleItem(materials);
    case Type::Composition:
        return new CompoundItem(materials);
    case Type::CoreShell:
        return new CoreAndShellItem(materials);
    case Type::Mesocrystal:
        return new MesocrystalItem(materials);
    default:
        ASSERT_NEVER;
    }
}

QVector<ParticleCatalog::Type> ParticleCatalog::types()
{
    return {Type::Particle, Type::Composition, Type::CoreShell, Type::Mesocrystal};
}

QVector<ParticleCatalog::Type> ParticleCatalog::assemblyTypes()
{
    return {Type::Composition, Type::CoreShell, Type::Mesocrystal};
}

UiInfo ParticleCatalog::uiInfo(Type type)
{
    switch (type) {
    case Type::Particle:
        return {"Particle", "", ""}; // particle is not on UI, only its form factor
    case Type::Composition:
        return {"Particle Composition", "Composition of particles with fixed positions",
                ":/images/struct/Compound_64x64.png"};
    case Type::CoreShell:
        return {"Core shell particle", "A particle with a core/shell geometry",
                ":/images/struct/CoreAndShell_64x64.png"};
    case Type::Mesocrystal:
        return {"Meso Crystal", "A 3D crystal structure of nanoparticles",
                ":/images/struct/Mesocrystal_64x64.png"};
    default:
        ASSERT_NEVER;
    }
}

ParticleCatalog::Type ParticleCatalog::type(const ItemWithParticles* item)
{
    ASSERT(item);

    if (dynamic_cast<const ParticleItem*>(item))
        return Type::Particle;
    if (dynamic_cast<const CompoundItem*>(item))
        return Type::Composition;
    if (dynamic_cast<const MesocrystalItem*>(item))
        return Type::Mesocrystal;
    if (dynamic_cast<const CoreAndShellItem*>(item))
        return Type::CoreShell;

    ASSERT_NEVER;
}