Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • c.trageser/bornagain
  • mlz/bornagain
2 results
Show changes
Commits on Source (42)
Showing
with 94 additions and 83 deletions
...@@ -12,6 +12,7 @@ native_Debian_clang: ...@@ -12,6 +12,7 @@ native_Debian_clang:
script: &native_scr script: &native_scr
- pwd - pwd
- export PYTHONPATH=$CI_PROJECT_DIR/build/lib - export PYTHONPATH=$CI_PROJECT_DIR/build/lib
- export MPLBACKEND=Agg
- mkdir build - mkdir build
- cd build - cd build
- cmake .. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBA_PY_PACKAGE=ON -DCMAKE_PREFIX_PATH="/home/build/Qt/6.2.3/gcc_64/lib/cmake" #-DWERROR=ON - cmake .. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBA_PY_PACKAGE=ON -DCMAKE_PREFIX_PATH="/home/build/Qt/6.2.3/gcc_64/lib/cmake" #-DWERROR=ON
......
...@@ -32,8 +32,8 @@ def get_sample(): ...@@ -32,8 +32,8 @@ def get_sample():
# Define composition of particles at specific positions # Define composition of particles at specific positions
particle = ba.Compound() particle = ba.Compound()
particle.addParticle(subparticle_1) particle.addComponent(subparticle_1)
particle.addParticle(subparticle_2) particle.addComponent(subparticle_2)
particle.translate(R3(0, 0, -10*nm)) particle.translate(R3(0, 0, -10*nm))
# Define particle layouts # Define particle layouts
......
...@@ -24,8 +24,8 @@ def get_sample(): ...@@ -24,8 +24,8 @@ def get_sample():
core = ba.Particle(material_Diff, ff_1) core = ba.Particle(material_Diff, ff_1)
shell = ba.Particle(material_Shell, ff_2) shell = ba.Particle(material_Shell, ff_2)
particle = ba.Compound() particle = ba.Compound()
particle.addParticle(shell) particle.addComponent(shell)
particle.addParticle(core, ba.R3(0,0,0.5*nm)) particle.addComponent(core, ba.R3(0,0,0.5*nm))
return std_samples.sas_sample_with_particle(particle) return std_samples.sas_sample_with_particle(particle)
......
...@@ -44,7 +44,7 @@ class CustomFormFactor(ba.IFormFactor): ...@@ -44,7 +44,7 @@ class CustomFormFactor(ba.IFormFactor):
sinc(qzhH)*(sinc(0.5*qyhL)*(sinc(qxhL)-0.5*sinc(0.5*qxhL))+\ sinc(qzhH)*(sinc(0.5*qyhL)*(sinc(qxhL)-0.5*sinc(0.5*qxhL))+\
sinc(0.5*qxhL)*sinc(qyhL)) sinc(0.5*qxhL)*sinc(qyhL))
def exec_spanZ(self, rotation): def spanZ(self, rotation):
return ba.Span(0, self.H) return ba.Span(0, self.H)
......
...@@ -29,8 +29,8 @@ def get_sample(): ...@@ -29,8 +29,8 @@ def get_sample():
# Define composition of particles at specific positions # Define composition of particles at specific positions
basis = ba.Compound() basis = ba.Compound()
basis.addParticle(particle_1) basis.addComponent(particle_1)
basis.addParticle(particle_2) basis.addComponent(particle_2)
# Define 2D lattices # Define 2D lattices
lattice = ba.HexagonalLattice2D(20*nm, 0) lattice = ba.HexagonalLattice2D(20*nm, 0)
......
...@@ -28,8 +28,8 @@ def get_sample(): ...@@ -28,8 +28,8 @@ def get_sample():
# Define composition of particles at specific positions # Define composition of particles at specific positions
basis = ba.Compound() basis = ba.Compound()
basis.addParticle(particle_1) basis.addComponent(particle_1)
basis.addParticle(particle_2) basis.addComponent(particle_2)
# Define 2D lattices # Define 2D lattices
lattice = ba.SquareLattice2D(a, 0*deg) lattice = ba.SquareLattice2D(a, 0*deg)
......
...@@ -39,7 +39,7 @@ def get_sample(): ...@@ -39,7 +39,7 @@ def get_sample():
position_2 = 1.0/3*(bas_a + 2*bas_b + 2*bas_c) position_2 = 1.0/3*(bas_a + 2*bas_b + 2*bas_c)
positions = [position_0, position_1, position_2] positions = [position_0, position_1, position_2]
basis = ba.Compound() basis = ba.Compound()
basis.addParticles(inner_particle, positions) basis.addComponents(inner_particle, positions)
# Define crystals # Define crystals
crystal = ba.Crystal(basis, lattice, position_variance) crystal = ba.Crystal(basis, lattice, position_variance)
......
...@@ -37,8 +37,8 @@ def get_sample(): ...@@ -37,8 +37,8 @@ def get_sample():
position_0 = R3(0, 0, 0) position_0 = R3(0, 0, 0)
position_1 = 1.0/3*(2*bas_a + bas_b + bas_c) position_1 = 1.0/3*(2*bas_a + bas_b + bas_c)
basis = ba.Compound() basis = ba.Compound()
basis.addParticle(inner_particle1, position_0) basis.addComponent(inner_particle1, position_0)
basis.addParticle(inner_particle2, position_1) basis.addComponent(inner_particle2, position_1)
# Define crystals # Define crystals
crystal = ba.Crystal(basis, lattice, position_variance) crystal = ba.Crystal(basis, lattice, position_variance)
......
...@@ -414,7 +414,7 @@ void set_FormFactor(std::variant<ParticleItem*, MesocrystalItem*> parent, const ...@@ -414,7 +414,7 @@ void set_FormFactor(std::variant<ParticleItem*, MesocrystalItem*> parent, const
} else if (const auto* f = dynamic_cast<const Bipyramid4*>(ff)) { } else if (const auto* f = dynamic_cast<const Bipyramid4*>(ff)) {
auto* item = addFormFactorItem<Bipyramid4Item>(parent); auto* item = addFormFactorItem<Bipyramid4Item>(parent);
item->setLength(f->length()); item->setLength(f->length());
item->setHeight(f->height()); item->setBaseHeight(f->base_height());
item->setHeightRatio(f->heightRatio()); item->setHeightRatio(f->heightRatio());
item->setAlpha(Units::rad2deg(f->alpha())); item->setAlpha(Units::rad2deg(f->alpha()));
} else if (const auto* f = dynamic_cast<const Cylinder*>(ff)) { } else if (const auto* f = dynamic_cast<const Cylinder*>(ff)) {
...@@ -502,12 +502,12 @@ void set_FormFactor(std::variant<ParticleItem*, MesocrystalItem*> parent, const ...@@ -502,12 +502,12 @@ void set_FormFactor(std::variant<ParticleItem*, MesocrystalItem*> parent, const
} else if (const auto* f = dynamic_cast<const TruncatedSphere*>(ff)) { } else if (const auto* f = dynamic_cast<const TruncatedSphere*>(ff)) {
auto* item = addFormFactorItem<TruncatedSphereItem>(parent); auto* item = addFormFactorItem<TruncatedSphereItem>(parent);
item->setRadius(f->radius()); item->setRadius(f->radius());
item->setHeight(f->height()); item->setUntruncatedHeight(f->untruncated_height());
item->setRemovedTop(f->removedTop()); item->setRemovedTop(f->removedTop());
} else if (const auto* f = dynamic_cast<const TruncatedSpheroid*>(ff)) { } else if (const auto* f = dynamic_cast<const TruncatedSpheroid*>(ff)) {
auto* item = addFormFactorItem<TruncatedSpheroidItem>(parent); auto* item = addFormFactorItem<TruncatedSpheroidItem>(parent);
item->setRadius(f->radius()); item->setRadius(f->radius());
item->setHeight(f->height()); item->setUntruncatedHeight(f->untruncated_height());
item->setHeightFlattening(f->heightFlattening()); item->setHeightFlattening(f->heightFlattening());
item->setRemovedTop(f->removedTop()); item->setRemovedTop(f->removedTop());
} else if (const auto* f = dynamic_cast<const CantellatedCube*>(ff)) { } else if (const auto* f = dynamic_cast<const CantellatedCube*>(ff)) {
...@@ -619,7 +619,7 @@ void copyParticle(const IParticle* iparticle, MaterialModel& matItems, ...@@ -619,7 +619,7 @@ void copyParticle(const IParticle* iparticle, MaterialModel& matItems,
addToParent(item); addToParent(item);
for (const auto* p : particleComposition->particles()) for (const auto* p : particleComposition->particles())
copyParticle(p, matItems, [=](ItemWithParticles* p) { item->addParticle(p); }); copyParticle(p, matItems, [=](ItemWithParticles* p) { item->addParticleItem(p); });
} }
} }
...@@ -645,21 +645,21 @@ SampleItem* itemizeSample(const MultiLayer& sample, const QString& nodeName) ...@@ -645,21 +645,21 @@ SampleItem* itemizeSample(const MultiLayer& sample, const QString& nodeName)
const LayerInterface* top_interface = const LayerInterface* top_interface =
layerIndex == 0 ? nullptr : sample.layerInterface(layerIndex - 1); layerIndex == 0 ? nullptr : sample.layerInterface(layerIndex - 1);
auto* layerItem = result->addLayer(); auto* layerItem = result->createLayerItemAt();
layerItem->setMaterial(findMaterialItem(matItems, layer)); layerItem->setMaterial(findMaterialItem(matItems, layer));
set_LayerItem(layerItem, layer, top_interface); set_LayerItem(layerItem, layer, top_interface);
// iterate over particle layouts // iterate over particle layouts
for (const auto* layout : layer->layouts()) { for (const auto* layout : layer->layouts()) {
auto* layoutItem = layerItem->addLayout(); auto* layoutItem = layerItem->addLayoutItem();
layoutItem->setOwnDensity(layout->totalParticleSurfaceDensity()); layoutItem->setOwnDensity(layout->totalParticleSurfaceDensity());
set_Interference(layoutItem, layout->interferenceFunction()); set_Interference(layoutItem, layout->interferenceFunction());
// create particles/particle compositions // create particles/particle compositions
for (const IParticle* particle : layout->particles()) for (const IParticle* particle : layout->particles())
copyParticle(particle, matItems, copyParticle(particle, matItems,
[=](ItemWithParticles* p) { layoutItem->addParticle(p); }); [=](ItemWithParticles* p) { layoutItem->addParticleItem(p); });
} }
} }
......
...@@ -134,7 +134,7 @@ void ParameterTreeBuilder::addSample() ...@@ -134,7 +134,7 @@ void ParameterTreeBuilder::addSample()
addInterference(label, layout); addInterference(label, layout);
for (auto* p : layout->particles()) for (auto* p : layout->particles())
addParticle(label, p, true); addItemWithParticles(label, p, true);
} }
} }
} }
...@@ -241,9 +241,10 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, ...@@ -241,9 +241,10 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel,
} }
} }
ParameterLabelItem* ParameterTreeBuilder::addParticle(ParameterLabelItem* parentLabel, ParameterLabelItem* ParameterTreeBuilder::addItemWithParticles(ParameterLabelItem* parentLabel,
ItemWithParticles* p, bool enableAbundance, ItemWithParticles* p,
bool enablePosition) bool enableAbundance,
bool enablePosition)
{ {
auto* label = addLabel<ItemWithParticlesCatalog>(parentLabel, p); auto* label = addLabel<ItemWithParticlesCatalog>(parentLabel, p);
...@@ -260,11 +261,11 @@ ParameterLabelItem* ParameterTreeBuilder::addParticle(ParameterLabelItem* parent ...@@ -260,11 +261,11 @@ ParameterLabelItem* ParameterTreeBuilder::addParticle(ParameterLabelItem* parent
addParameterItem(ffLabel, *d); addParameterItem(ffLabel, *d);
} else if (const auto* particleComposition = dynamic_cast<const CompoundItem*>(p)) { } else if (const auto* particleComposition = dynamic_cast<const CompoundItem*>(p)) {
for (auto* p : particleComposition->particles()) for (auto* p : particleComposition->particles())
addParticle(label, p, false); addItemWithParticles(label, p, false);
} else if (const auto* coreShell = dynamic_cast<const CoreAndShellItem*>(p)) { } else if (const auto* coreShell = dynamic_cast<const CoreAndShellItem*>(p)) {
auto* l = addParticle(label, coreShell->core(), false); auto* l = addItemWithParticles(label, coreShell->core(), false);
l->setTitle(l->title() + " (Core)"); l->setTitle(l->title() + " (Core)");
l = addParticle(label, coreShell->shell(), false, false); l = addItemWithParticles(label, coreShell->shell(), false, false);
l->setTitle(l->title() + " (Shell)"); l->setTitle(l->title() + " (Shell)");
} else if (auto* meso = dynamic_cast<MesocrystalItem*>(p)) { } else if (auto* meso = dynamic_cast<MesocrystalItem*>(p)) {
addParameterItem(label, meso->vectorA()); addParameterItem(label, meso->vectorA());
...@@ -276,7 +277,7 @@ ParameterLabelItem* ParameterTreeBuilder::addParticle(ParameterLabelItem* parent ...@@ -276,7 +277,7 @@ ParameterLabelItem* ParameterTreeBuilder::addParticle(ParameterLabelItem* parent
for (auto* d : outerShape->geometryProperties()) for (auto* d : outerShape->geometryProperties())
addParameterItem(ffLabel, *d); addParameterItem(ffLabel, *d);
auto* l = addParticle(label, meso->basisParticle(), false); auto* l = addItemWithParticles(label, meso->basisParticle(), false);
l->setTitle(l->title() + " (Basis particle)"); l->setTitle(l->title() + " (Basis particle)");
} }
......
...@@ -61,8 +61,8 @@ private: ...@@ -61,8 +61,8 @@ private:
void addInterference(ParameterLabelItem* layoutLabel, const ParticleLayoutItem* layout); void addInterference(ParameterLabelItem* layoutLabel, const ParticleLayoutItem* layout);
//! Returns the top label which was created for the particle //! Returns the top label which was created for the particle
ParameterLabelItem* addParticle(ParameterLabelItem* parentLabel, ItemWithParticles* p, ParameterLabelItem* addItemWithParticles(ParameterLabelItem* parentLabel, ItemWithParticles* p,
bool enableAbundance, bool enablePosition = true); bool enableAbundance, bool enablePosition = true);
void addLattice(ParameterLabelItem* parentLabel, const Interference2DAbstractLatticeItem* itf); void addLattice(ParameterLabelItem* parentLabel, const Interference2DAbstractLatticeItem* itf);
void addRotation(ParameterLabelItem* parentLabel, ItemWithParticles* p); void addRotation(ParameterLabelItem* parentLabel, ItemWithParticles* p);
......
...@@ -95,7 +95,7 @@ void CompoundItem::readFrom(QXmlStreamReader* r) ...@@ -95,7 +95,7 @@ void CompoundItem::readFrom(QXmlStreamReader* r)
// particle // particle
} else if (tag == Tag::Particle) { } else if (tag == Tag::Particle) {
addParticle(nullptr).readFrom(r, m_materialModel); addParticleItem(nullptr).readFrom(r, m_materialModel);
XML::gotoEndElementOfTag(r, tag); XML::gotoEndElementOfTag(r, tag);
} else } else
...@@ -111,16 +111,16 @@ std::unique_ptr<Compound> CompoundItem::createCompound() const ...@@ -111,16 +111,16 @@ std::unique_ptr<Compound> CompoundItem::createCompound() const
auto* p = ps.currentItem(); auto* p = ps.currentItem();
if (auto* particleItem = dynamic_cast<ParticleItem*>(p)) { if (auto* particleItem = dynamic_cast<ParticleItem*>(p)) {
if (auto P_particle = particleItem->createParticle()) if (auto P_particle = particleItem->createParticle())
P_composition->addParticle(*P_particle); P_composition->addComponent(*P_particle);
} else if (auto* coreShellItem = dynamic_cast<CoreAndShellItem*>(p)) { } else if (auto* coreShellItem = dynamic_cast<CoreAndShellItem*>(p)) {
if (auto P_particle_coreshell = coreShellItem->createCoreAndShell()) if (auto P_particle_coreshell = coreShellItem->createCoreAndShell())
P_composition->addParticle(*P_particle_coreshell); P_composition->addComponent(*P_particle_coreshell);
} else if (auto* compositionItem = dynamic_cast<CompoundItem*>(p)) { } else if (auto* compositionItem = dynamic_cast<CompoundItem*>(p)) {
if (auto P_child_composition = compositionItem->createCompound()) if (auto P_child_composition = compositionItem->createCompound())
P_composition->addParticle(*P_child_composition); P_composition->addComponent(*P_child_composition);
} else if (auto* mesocrystalItem = dynamic_cast<MesocrystalItem*>(p)) { } else if (auto* mesocrystalItem = dynamic_cast<MesocrystalItem*>(p)) {
if (auto P_meso = mesocrystalItem->createMesocrystal()) if (auto P_meso = mesocrystalItem->createMesocrystal())
P_composition->addParticle(*P_meso); P_composition->addComponent(*P_meso);
} }
} }
...@@ -139,7 +139,8 @@ QVector<ItemWithParticles*> CompoundItem::particles() const ...@@ -139,7 +139,8 @@ QVector<ItemWithParticles*> CompoundItem::particles() const
return output; return output;
} }
SelectionProperty<ItemWithParticlesCatalog>& CompoundItem::addParticle(ItemWithParticles* particle) SelectionProperty<ItemWithParticlesCatalog>&
CompoundItem::addParticleItem(ItemWithParticles* particle)
{ {
SelectionProperty<ItemWithParticlesCatalog> newParticleSelection; SelectionProperty<ItemWithParticlesCatalog> newParticleSelection;
newParticleSelection.setCurrentItem(particle); newParticleSelection.setCurrentItem(particle);
...@@ -147,7 +148,7 @@ SelectionProperty<ItemWithParticlesCatalog>& CompoundItem::addParticle(ItemWithP ...@@ -147,7 +148,7 @@ SelectionProperty<ItemWithParticlesCatalog>& CompoundItem::addParticle(ItemWithP
return m_particleSelections.back(); return m_particleSelections.back();
} }
void CompoundItem::removeParticle(ItemWithParticles* particle) void CompoundItem::removeParticleItem(ItemWithParticles* particle)
{ {
for (size_t i = 0; i < m_particleSelections.size(); i++) for (size_t i = 0; i < m_particleSelections.size(); i++)
if (m_particleSelections[i].currentItem() == particle) if (m_particleSelections[i].currentItem() == particle)
......
...@@ -26,14 +26,14 @@ class CompoundItem : public ItemWithParticles { ...@@ -26,14 +26,14 @@ class CompoundItem : public ItemWithParticles {
public: public:
CompoundItem(const MaterialModel* materials); CompoundItem(const MaterialModel* materials);
void serialize(Streamer& s) override; void serialize(Streamer& s) override;
void writeTo(QXmlStreamWriter* w) const; void writeTo(QXmlStreamWriter* w) const override;
void readFrom(QXmlStreamReader* r); void readFrom(QXmlStreamReader* r) override;
std::unique_ptr<Compound> createCompound() const; std::unique_ptr<Compound> createCompound() const;
QVector<ItemWithParticles*> particles() const; QVector<ItemWithParticles*> particles() const;
SelectionProperty<ItemWithParticlesCatalog>& addParticle(ItemWithParticles* particle); SelectionProperty<ItemWithParticlesCatalog>& addParticleItem(ItemWithParticles* particle);
void removeParticle(ItemWithParticles* particle); void removeParticleItem(ItemWithParticles* particle);
QVector<ItemWithParticles*> containedItemsWithParticles() const override; QVector<ItemWithParticles*> containedItemsWithParticles() const override;
......
...@@ -26,8 +26,8 @@ class CoreAndShellItem : public ItemWithParticles { ...@@ -26,8 +26,8 @@ class CoreAndShellItem : public ItemWithParticles {
public: public:
CoreAndShellItem(const MaterialModel* materials); CoreAndShellItem(const MaterialModel* materials);
void serialize(Streamer& s) override; void serialize(Streamer& s) override;
void writeTo(QXmlStreamWriter* w) const; void writeTo(QXmlStreamWriter* w) const override;
void readFrom(QXmlStreamReader* r); void readFrom(QXmlStreamReader* r) override;
std::unique_ptr<CoreAndShell> createCoreAndShell() const; std::unique_ptr<CoreAndShell> createCoreAndShell() const;
......
...@@ -20,22 +20,24 @@ ...@@ -20,22 +20,24 @@
namespace { namespace {
namespace Tag { namespace Tag {
const QString Length("Length");
const QString Width("Width");
const QString Height("Height");
const QString Alpha("Alpha"); const QString Alpha("Alpha");
const QString Radius("Radius"); const QString Asymmetry("Asymmetry");
const QString BaseEdge("BaseEdge"); const QString BaseEdge("BaseEdge");
const QString HeightRatio("HeightRatio"); const QString BaseHeight("BaseHeight");
const QString Edge("Edge"); const QString Edge("Edge");
const QString Height("Height");
const QString HeightFlattening("HeightFlattening");
const QString HeightRatio("HeightRatio");
const QString Length("Length");
const QString Radius("Radius");
const QString RadiusX("RadiusX"); const QString RadiusX("RadiusX");
const QString RadiusY("RadiusY"); const QString RadiusY("RadiusY");
const QString Asymmetry("Asymmetry");
const QString RemovedLength("RemovedLength"); const QString RemovedLength("RemovedLength");
const QString RemovedTop("RemovedTop"); const QString RemovedTop("RemovedTop");
const QString HeightFlattening("HeightFlattening");
const QString SliceBottom("SliceBottom"); const QString SliceBottom("SliceBottom");
const QString SliceTop("SliceTop"); const QString SliceTop("SliceTop");
const QString UntruncatedHeight("UntruncatedHeight");
const QString Width("Width");
} // namespace Tag } // namespace Tag
} // namespace } // namespace
...@@ -382,7 +384,8 @@ Bipyramid4Item::Bipyramid4Item() ...@@ -382,7 +384,8 @@ Bipyramid4Item::Bipyramid4Item()
m_length.init("Length", "Side length of the common square base", 12.0, Unit::nanometer, m_length.init("Length", "Side length of the common square base", 12.0, Unit::nanometer,
"length"); "length");
m_height.init("Height", "Height of the lower pyramid", 16.0, Unit::nanometer, "height"); m_base_height.init("Base height", "Height of the lower pyramid", 16.0, Unit::nanometer,
"base_height");
m_heightRatio.init("Height ratio", "Ratio of heights of top to bottom pyramids", 0.7, m_heightRatio.init("Height ratio", "Ratio of heights of top to bottom pyramids", 0.7,
Unit::unitless, 3, RealLimits::lowerLimited(0.0), "heightRatio"); Unit::unitless, 3, RealLimits::lowerLimited(0.0), "heightRatio");
...@@ -393,8 +396,8 @@ Bipyramid4Item::Bipyramid4Item() ...@@ -393,8 +396,8 @@ Bipyramid4Item::Bipyramid4Item()
std::unique_ptr<IFormFactor> Bipyramid4Item::createFormFactor() const std::unique_ptr<IFormFactor> Bipyramid4Item::createFormFactor() const
{ {
return std::make_unique<Bipyramid4>(m_length.value(), m_height.value(), m_heightRatio.value(), return std::make_unique<Bipyramid4>(m_length.value(), m_base_height.value(),
m_alpha.value() * Units::deg); m_heightRatio.value(), m_alpha.value() * Units::deg);
} }
void Bipyramid4Item::serialize(Streamer& s) void Bipyramid4Item::serialize(Streamer& s)
...@@ -415,7 +418,7 @@ void Bipyramid4Item::writeTo(QXmlStreamWriter* w) const ...@@ -415,7 +418,7 @@ void Bipyramid4Item::writeTo(QXmlStreamWriter* w) const
XML::writeAttribute(w, XML::Attrib::version, uint(1)); XML::writeAttribute(w, XML::Attrib::version, uint(1));
m_length.writeTo(w, Tag::Length); m_length.writeTo(w, Tag::Length);
m_height.writeTo(w, Tag::Height); m_base_height.writeTo(w, Tag::BaseHeight);
m_heightRatio.writeTo(w, Tag::HeightRatio); m_heightRatio.writeTo(w, Tag::HeightRatio);
m_alpha.writeTo(w, Tag::Alpha); m_alpha.writeTo(w, Tag::Alpha);
} }
...@@ -430,8 +433,8 @@ void Bipyramid4Item::readFrom(QXmlStreamReader* r) ...@@ -430,8 +433,8 @@ void Bipyramid4Item::readFrom(QXmlStreamReader* r)
if (tag == Tag::Length) if (tag == Tag::Length)
m_length.readFrom(r, tag); m_length.readFrom(r, tag);
else if (tag == Tag::Height) else if (tag == Tag::BaseHeight)
m_height.readFrom(r, tag); m_base_height.readFrom(r, tag);
else if (tag == Tag::HeightRatio) else if (tag == Tag::HeightRatio)
m_heightRatio.readFrom(r, tag); m_heightRatio.readFrom(r, tag);
else if (tag == Tag::Alpha) else if (tag == Tag::Alpha)
...@@ -1307,14 +1310,15 @@ void TruncatedCubeItem::readFrom(QXmlStreamReader* r) ...@@ -1307,14 +1310,15 @@ void TruncatedCubeItem::readFrom(QXmlStreamReader* r)
TruncatedSphereItem::TruncatedSphereItem() TruncatedSphereItem::TruncatedSphereItem()
{ {
m_radius.init("Radius", "Radius of the truncated sphere", 8.0, Unit::nanometer, "radius"); m_radius.init("Radius", "Radius of the truncated sphere", 8.0, Unit::nanometer, "radius");
m_height.init("Height", "Height of the truncated sphere", 16.0, Unit::nanometer, "height"); m_untruncated_height.init("UntruncatedHeight", "Height before top removal", 16.0,
Unit::nanometer, "untruncated_height");
m_removedTop.init("Delta height", "Height of the removed top cap", 16.0, Unit::nanometer, m_removedTop.init("Delta height", "Height of the removed top cap", 16.0, Unit::nanometer,
"removedTop"); "removedTop");
} }
std::unique_ptr<IFormFactor> TruncatedSphereItem::createFormFactor() const std::unique_ptr<IFormFactor> TruncatedSphereItem::createFormFactor() const
{ {
return std::make_unique<TruncatedSphere>(m_radius.value(), m_height.value(), return std::make_unique<TruncatedSphere>(m_radius.value(), m_untruncated_height.value(),
m_removedTop.value()); m_removedTop.value());
} }
...@@ -1335,7 +1339,7 @@ void TruncatedSphereItem::writeTo(QXmlStreamWriter* w) const ...@@ -1335,7 +1339,7 @@ void TruncatedSphereItem::writeTo(QXmlStreamWriter* w) const
XML::writeAttribute(w, XML::Attrib::version, uint(1)); XML::writeAttribute(w, XML::Attrib::version, uint(1));
m_radius.writeTo(w, Tag::Radius); m_radius.writeTo(w, Tag::Radius);
m_height.writeTo(w, Tag::Height); m_untruncated_height.writeTo(w, Tag::UntruncatedHeight);
m_removedTop.writeTo(w, Tag::RemovedTop); m_removedTop.writeTo(w, Tag::RemovedTop);
} }
...@@ -1349,8 +1353,8 @@ void TruncatedSphereItem::readFrom(QXmlStreamReader* r) ...@@ -1349,8 +1353,8 @@ void TruncatedSphereItem::readFrom(QXmlStreamReader* r)
if (tag == Tag::Radius) if (tag == Tag::Radius)
m_radius.readFrom(r, tag); m_radius.readFrom(r, tag);
else if (tag == Tag::Height) else if (tag == Tag::UntruncatedHeight)
m_height.readFrom(r, tag); m_untruncated_height.readFrom(r, tag);
else if (tag == Tag::RemovedTop) else if (tag == Tag::RemovedTop)
m_removedTop.readFrom(r, tag); m_removedTop.readFrom(r, tag);
else else
...@@ -1363,7 +1367,8 @@ void TruncatedSphereItem::readFrom(QXmlStreamReader* r) ...@@ -1363,7 +1367,8 @@ void TruncatedSphereItem::readFrom(QXmlStreamReader* r)
TruncatedSpheroidItem::TruncatedSpheroidItem() TruncatedSpheroidItem::TruncatedSpheroidItem()
{ {
m_radius.init("Radius", "Radius of the truncated spheroid", 8.0, Unit::nanometer, "radius"); m_radius.init("Radius", "Radius of the truncated spheroid", 8.0, Unit::nanometer, "radius");
m_height.init("Height", "Height of the truncated spheroid", 16.0, Unit::nanometer, "height"); m_untruncated_height.init("UntruncatedHeight", "Height before top removal", 16.0,
Unit::nanometer, "untruncated_height");
m_heightFlattening.init( m_heightFlattening.init(
"Height flattening", "Height flattening",
"Ratio of the height of the corresponding full spheroid to its diameter", 2.0, "Ratio of the height of the corresponding full spheroid to its diameter", 2.0,
...@@ -1375,7 +1380,7 @@ TruncatedSpheroidItem::TruncatedSpheroidItem() ...@@ -1375,7 +1380,7 @@ TruncatedSpheroidItem::TruncatedSpheroidItem()
std::unique_ptr<IFormFactor> TruncatedSpheroidItem::createFormFactor() const std::unique_ptr<IFormFactor> TruncatedSpheroidItem::createFormFactor() const
{ {
return std::make_unique<TruncatedSpheroid>(m_radius.value(), m_height.value(), return std::make_unique<TruncatedSpheroid>(m_radius.value(), m_untruncated_height.value(),
m_heightFlattening.value(), m_removedTop.value()); m_heightFlattening.value(), m_removedTop.value());
} }
...@@ -1397,7 +1402,7 @@ void TruncatedSpheroidItem::writeTo(QXmlStreamWriter* w) const ...@@ -1397,7 +1402,7 @@ void TruncatedSpheroidItem::writeTo(QXmlStreamWriter* w) const
XML::writeAttribute(w, XML::Attrib::version, uint(1)); XML::writeAttribute(w, XML::Attrib::version, uint(1));
m_radius.writeTo(w, Tag::Radius); m_radius.writeTo(w, Tag::Radius);
m_height.writeTo(w, Tag::Height); m_untruncated_height.writeTo(w, Tag::UntruncatedHeight);
m_heightFlattening.writeTo(w, Tag::HeightFlattening); m_heightFlattening.writeTo(w, Tag::HeightFlattening);
m_removedTop.writeTo(w, Tag::RemovedTop); m_removedTop.writeTo(w, Tag::RemovedTop);
} }
...@@ -1412,8 +1417,8 @@ void TruncatedSpheroidItem::readFrom(QXmlStreamReader* r) ...@@ -1412,8 +1417,8 @@ void TruncatedSpheroidItem::readFrom(QXmlStreamReader* r)
if (tag == Tag::Radius) if (tag == Tag::Radius)
m_radius.readFrom(r, tag); m_radius.readFrom(r, tag);
else if (tag == Tag::Height) else if (tag == Tag::UntruncatedHeight)
m_height.readFrom(r, tag); m_untruncated_height.readFrom(r, tag);
else if (tag == Tag::HeightFlattening) else if (tag == Tag::HeightFlattening)
m_heightFlattening.readFrom(r, tag); m_heightFlattening.readFrom(r, tag);
else if (tag == Tag::RemovedTop) else if (tag == Tag::RemovedTop)
......
...@@ -165,13 +165,13 @@ public: ...@@ -165,13 +165,13 @@ public:
std::unique_ptr<IFormFactor> createFormFactor() const override; std::unique_ptr<IFormFactor> createFormFactor() const override;
void setLength(double v) { m_length.setValue(v); } void setLength(double v) { m_length.setValue(v); }
void setHeight(double v) { m_height.setValue(v); } void setBaseHeight(double v) { m_base_height.setValue(v); }
void setHeightRatio(double v) { m_heightRatio.setValue(v); } void setHeightRatio(double v) { m_heightRatio.setValue(v); }
void setAlpha(double v) { m_alpha.setValue(v); } void setAlpha(double v) { m_alpha.setValue(v); }
DoubleProperties geometryProperties() override DoubleProperties geometryProperties() override
{ {
return {&m_length, &m_height, &m_heightRatio, &m_alpha}; return {&m_length, &m_base_height, &m_heightRatio, &m_alpha};
} }
void serialize(Streamer& s) override; void serialize(Streamer& s) override;
void writeTo(QXmlStreamWriter* w) const override; void writeTo(QXmlStreamWriter* w) const override;
...@@ -179,7 +179,7 @@ public: ...@@ -179,7 +179,7 @@ public:
protected: protected:
DoubleProperty m_length; DoubleProperty m_length;
DoubleProperty m_height; DoubleProperty m_base_height;
DoubleProperty m_heightRatio; DoubleProperty m_heightRatio;
DoubleProperty m_alpha; DoubleProperty m_alpha;
}; };
...@@ -511,17 +511,20 @@ public: ...@@ -511,17 +511,20 @@ public:
std::unique_ptr<IFormFactor> createFormFactor() const override; std::unique_ptr<IFormFactor> createFormFactor() const override;
void setRadius(double v) { m_radius.setValue(v); } void setRadius(double v) { m_radius.setValue(v); }
void setHeight(double v) { m_height.setValue(v); } void setUntruncatedHeight(double v) { m_untruncated_height.setValue(v); }
void setRemovedTop(double v) { m_removedTop.setValue(v); } void setRemovedTop(double v) { m_removedTop.setValue(v); }
DoubleProperties geometryProperties() override { return {&m_radius, &m_height, &m_removedTop}; } DoubleProperties geometryProperties() override
{
return {&m_radius, &m_untruncated_height, &m_removedTop};
}
void serialize(Streamer& s) override; void serialize(Streamer& s) override;
void writeTo(QXmlStreamWriter* w) const override; void writeTo(QXmlStreamWriter* w) const override;
void readFrom(QXmlStreamReader* r) override; void readFrom(QXmlStreamReader* r) override;
protected: protected:
DoubleProperty m_radius; DoubleProperty m_radius;
DoubleProperty m_height; DoubleProperty m_untruncated_height;
DoubleProperty m_removedTop; DoubleProperty m_removedTop;
}; };
...@@ -531,13 +534,13 @@ public: ...@@ -531,13 +534,13 @@ public:
std::unique_ptr<IFormFactor> createFormFactor() const override; std::unique_ptr<IFormFactor> createFormFactor() const override;
void setRadius(double v) { m_radius.setValue(v); } void setRadius(double v) { m_radius.setValue(v); }
void setHeight(double v) { m_height.setValue(v); } void setUntruncatedHeight(double v) { m_untruncated_height.setValue(v); }
void setHeightFlattening(double v) { m_heightFlattening.setValue(v); } void setHeightFlattening(double v) { m_heightFlattening.setValue(v); }
void setRemovedTop(double v) { m_removedTop.setValue(v); } void setRemovedTop(double v) { m_removedTop.setValue(v); }
DoubleProperties geometryProperties() override DoubleProperties geometryProperties() override
{ {
return {&m_radius, &m_height, &m_heightFlattening, &m_removedTop}; return {&m_radius, &m_untruncated_height, &m_heightFlattening, &m_removedTop};
} }
void serialize(Streamer& s) override; void serialize(Streamer& s) override;
void writeTo(QXmlStreamWriter* w) const override; void writeTo(QXmlStreamWriter* w) const override;
...@@ -545,7 +548,7 @@ public: ...@@ -545,7 +548,7 @@ public:
protected: protected:
DoubleProperty m_radius; DoubleProperty m_radius;
DoubleProperty m_height; DoubleProperty m_untruncated_height;
DoubleProperty m_heightFlattening; DoubleProperty m_heightFlattening;
DoubleProperty m_removedTop; DoubleProperty m_removedTop;
}; };
......
...@@ -110,13 +110,13 @@ QVector<ParticleLayoutItem*> LayerItem::layouts() const ...@@ -110,13 +110,13 @@ QVector<ParticleLayoutItem*> LayerItem::layouts() const
return QVector<ParticleLayoutItem*>(m_layouts.begin(), m_layouts.end()); return QVector<ParticleLayoutItem*>(m_layouts.begin(), m_layouts.end());
} }
ParticleLayoutItem* LayerItem::addLayout() ParticleLayoutItem* LayerItem::addLayoutItem()
{ {
m_layouts.emplace_back(new ParticleLayoutItem(m_materialModel)); m_layouts.emplace_back(new ParticleLayoutItem(m_materialModel));
return m_layouts.back(); return m_layouts.back();
} }
void LayerItem::removeLayout(ParticleLayoutItem* layout) void LayerItem::removeLayoutItem(ParticleLayoutItem* layout)
{ {
m_layouts.delete_element(layout); m_layouts.delete_element(layout);
} }
...@@ -205,7 +205,7 @@ void LayerItem::readFrom(QXmlStreamReader* r) ...@@ -205,7 +205,7 @@ void LayerItem::readFrom(QXmlStreamReader* r)
// particle layout // particle layout
} else if (tag == Tag::Layout) { } else if (tag == Tag::Layout) {
addLayout()->readFrom(r); addLayoutItem()->readFrom(r);
XML::gotoEndElementOfTag(r, tag); XML::gotoEndElementOfTag(r, tag);
} else } else
......
...@@ -51,8 +51,8 @@ public: ...@@ -51,8 +51,8 @@ public:
void setNumSlices(uint v) { m_numSlices = v; } void setNumSlices(uint v) { m_numSlices = v; }
QVector<ParticleLayoutItem*> layouts() const; QVector<ParticleLayoutItem*> layouts() const;
ParticleLayoutItem* addLayout(); ParticleLayoutItem* addLayoutItem();
void removeLayout(ParticleLayoutItem* layout); void removeLayoutItem(ParticleLayoutItem* layout);
QColor color() const { return m_color; } QColor color() const { return m_color; }
void setColor(const QColor& c) { m_color = c; } void setColor(const QColor& c) { m_color = c; }
......
...@@ -33,8 +33,8 @@ class MesocrystalItem : public ItemWithParticles { ...@@ -33,8 +33,8 @@ class MesocrystalItem : public ItemWithParticles {
public: public:
explicit MesocrystalItem(const MaterialModel* materials); explicit MesocrystalItem(const MaterialModel* materials);
void serialize(Streamer& s) override; void serialize(Streamer& s) override;
void writeTo(QXmlStreamWriter* w) const; void writeTo(QXmlStreamWriter* w) const override;
void readFrom(QXmlStreamReader* r); void readFrom(QXmlStreamReader* r) override;
std::unique_ptr<Mesocrystal> createMesocrystal() const; std::unique_ptr<Mesocrystal> createMesocrystal() const;
......
...@@ -28,8 +28,8 @@ class ParticleItem : public ItemWithMaterial, public ItemWithParticles { ...@@ -28,8 +28,8 @@ class ParticleItem : public ItemWithMaterial, public ItemWithParticles {
public: public:
ParticleItem(const MaterialModel* materials); ParticleItem(const MaterialModel* materials);
void serialize(Streamer& s) override; void serialize(Streamer& s) override;
void writeTo(QXmlStreamWriter* w) const; void writeTo(QXmlStreamWriter* w) const override;
void readFrom(QXmlStreamReader* r); void readFrom(QXmlStreamReader* r) override;
std::unique_ptr<Particle> createParticle() const; std::unique_ptr<Particle> createParticle() const;
......