From 2bd405e57fce5454d96427d8a94c1ad8cf421dab Mon Sep 17 00:00:00 2001 From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de> Date: Wed, 23 Nov 2022 19:04:45 +0100 Subject: [PATCH] add Tag --- GUI/Model/Descriptor/AxisProperty.cpp | 20 ++++-- GUI/Model/Descriptor/DoubleProperty.cpp | 8 +-- GUI/Model/Descriptor/DoubleProperty.h | 4 +- GUI/Model/Device/BackgroundItems.cpp | 12 +++- GUI/Model/Device/BeamItems.cpp | 19 ++++-- GUI/Model/Device/FootprintItems.cpp | 15 ++++- GUI/Model/Device/InstrumentItems.cpp | 28 +++++--- GUI/Model/Device/RectangularDetectorItem.cpp | 34 +++++++--- GUI/Model/Device/ResolutionFunctionItems.cpp | 15 ++++- GUI/Model/Sample/CompoundItem.cpp | 13 +++- GUI/Model/Sample/CoreAndShellItem.cpp | 16 +++-- GUI/Model/Sample/InterferenceItems.cpp | 67 +++++++++++++------- GUI/Model/Sample/Lattice2DItems.cpp | 30 ++++++--- GUI/Model/Sample/LayerItem.cpp | 30 ++++++--- GUI/Model/Sample/LayerRoughnessItems.cpp | 17 +++-- GUI/Model/Sample/MesocrystalItem.cpp | 10 ++- GUI/Model/Sample/MultiLayerItem.cpp | 26 ++++++-- GUI/Model/Sample/ParticleItem.cpp | 10 ++- GUI/Model/Sample/ParticleLayoutItem.cpp | 15 ++++- GUI/Model/Sample/ProfileItems.cpp | 34 ++++++---- GUI/Model/Sample/RotationItems.cpp | 25 ++++++-- 21 files changed, 318 insertions(+), 130 deletions(-) diff --git a/GUI/Model/Descriptor/AxisProperty.cpp b/GUI/Model/Descriptor/AxisProperty.cpp index f41c9de05aa..aef84f281b7 100644 --- a/GUI/Model/Descriptor/AxisProperty.cpp +++ b/GUI/Model/Descriptor/AxisProperty.cpp @@ -12,10 +12,20 @@ // // ************************************************************************************************ -#include "GUI/Model/Descriptor/AxisProperty.h" #include "Base/Util/Assert.h" +#include "GUI/Model/Descriptor/AxisProperty.h" #include "GUI/Support/XML/Serialize.h" +namespace { +namespace Tag { + +const QString Nbins("Nbins"); +const QString Min("Min"); +const QString Max("Max"); + +} +} + using std::variant; AxisProperty::AxisProperty() {} @@ -41,11 +51,11 @@ std::unique_ptr<FixedBinAxis> AxisProperty::createAxis(double scaleFactor) const } void AxisProperty::rwAxisProperty(Streamer& s, const QString& tag) -{ +{ s.start(tag); s.assertVersion(0); - Serialize::rwValue(s, "nbins", m_nbins); - Serialize::rwProperty(s, m_min); - Serialize::rwProperty(s, m_max); + Serialize::rwValue(s, Tag::Nbins, m_nbins); + Serialize::rwProperty(s, Tag::Min, m_min); + Serialize::rwProperty(s, Tag::Max, m_max); s.finish(tag); } diff --git a/GUI/Model/Descriptor/DoubleProperty.cpp b/GUI/Model/Descriptor/DoubleProperty.cpp index d137b24d858..61308be399b 100644 --- a/GUI/Model/Descriptor/DoubleProperty.cpp +++ b/GUI/Model/Descriptor/DoubleProperty.cpp @@ -64,21 +64,21 @@ bool DoubleProperty::isInitialized() const return !m_uid.isEmpty(); } -void Serialize::rwProperty(Streamer& s, DoubleProperty& d) +void Serialize::rwProperty(Streamer& s, const QString& tag, DoubleProperty& d) { if (QXmlStreamWriter* w = s.xmlWriter()) { - w->writeStartElement(d.persistentTag()); + w->writeStartElement(tag); GUI::Session::XML::writeAttribute(w, XML::Tags::Value, d.get()); w->writeAttribute(XML::Tags::Id, d.uid()); GUI::Session::XML::writeAttribute(w, XML::Tags::Decimals, d.decimals()); w->writeEndElement(); } else if (QXmlStreamReader* r = s.xmlReader()) { r->readNextStartElement(); - s.assertCurrentTag(d.persistentTag()); + s.assertCurrentTag(tag); d.set(r->attributes().value(XML::Tags::Value).toDouble()); d.setUid(r->attributes().value(XML::Tags::Id).toString()); d.setDecimals(r->attributes().value(XML::Tags::Decimals).toUInt()); - s.gotoEndElementOfTag(d.persistentTag()); + s.gotoEndElementOfTag(tag); } else ASSERT(0); } diff --git a/GUI/Model/Descriptor/DoubleProperty.h b/GUI/Model/Descriptor/DoubleProperty.h index 5176933f13b..05d7a8b6d07 100644 --- a/GUI/Model/Descriptor/DoubleProperty.h +++ b/GUI/Model/Descriptor/DoubleProperty.h @@ -65,7 +65,7 @@ public: double get() const { return m_value; } //! Persistent tag for serializing. - QString persistentTag() const { return m_persistentTag; } +// QString persistentTag() const { return m_persistentTag; } //! Unique id of this double property. QString uid() const { return m_uid; } @@ -100,7 +100,7 @@ private: }; namespace Serialize { -void rwProperty(Streamer& s, DoubleProperty& d); +void rwProperty(Streamer& s, const QString &tag, DoubleProperty& d); } // namespace Serialize // clang-format off diff --git a/GUI/Model/Device/BackgroundItems.cpp b/GUI/Model/Device/BackgroundItems.cpp index 23a45a11227..7e4fdc148ee 100644 --- a/GUI/Model/Device/BackgroundItems.cpp +++ b/GUI/Model/Device/BackgroundItems.cpp @@ -12,12 +12,20 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Descriptor/DoubleDescriptor.h" +#include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Support/XML/Serialize.h" #include "Sim/Background/ConstantBackground.h" #include "Sim/Background/PoissonBackground.h" +namespace { +namespace Tag { + +const QString BackgroundValue("BackgroundValue"); + +} +} + ConstantBackgroundItem::ConstantBackgroundItem() { m_backgroundValue.init("Background value", "Constant background value", 0.0, "counts/pixel", 3, @@ -32,7 +40,7 @@ std::unique_ptr<IBackground> ConstantBackgroundItem::createBackground() const void ConstantBackgroundItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_backgroundValue); + Serialize::rwProperty(s, Tag::BackgroundValue, m_backgroundValue); } std::unique_ptr<IBackground> PoissonBackgroundItem::createBackground() const diff --git a/GUI/Model/Device/BeamItems.cpp b/GUI/Model/Device/BeamItems.cpp index 5200ad2732b..1c4ee4d80dc 100644 --- a/GUI/Model/Device/BeamItems.cpp +++ b/GUI/Model/Device/BeamItems.cpp @@ -12,12 +12,12 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/BeamItems.h" #include "Base/Axis/IAxis.h" #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" #include "GUI/Model/CatDevice/FootprintItemCatalog.h" #include "GUI/Model/Device/BeamAngleItems.h" +#include "GUI/Model/Device/BeamItems.h" #include "GUI/Model/Device/BeamWavelengthItem.h" #include "GUI/Model/Device/FootprintItems.h" #include "GUI/Model/Device/PointwiseAxisItem.h" @@ -26,6 +26,15 @@ namespace { +namespace Tag { + +const QString Intensity("Intensity"); +const QString Wavelength("Wavelength"); +const QString AzimuthalAngle("AzimuthalAngle"); +const QString InclinationAngle("InclinationAngle"); + +} + // defines wavelength limits according to given maximum q value RealLimits getLimits(double max_q) { @@ -48,10 +57,10 @@ BeamItem::BeamItem() void BeamItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_intensity); - Serialize::rwClass(s, "wavelength", *m_wavelengthItem); - Serialize::rwClass(s, "azimuth", *m_azimuthalAngleItem); - Serialize::rwClass(s, "inclination", *m_inclinationAngleItem); + Serialize::rwProperty(s, Tag::Intensity, m_intensity); + Serialize::rwClass(s, Tag::Wavelength, *m_wavelengthItem); + Serialize::rwClass(s, Tag::AzimuthalAngle, *m_azimuthalAngleItem); + Serialize::rwClass(s, Tag::InclinationAngle, *m_inclinationAngleItem); } double BeamItem::wavelength() const diff --git a/GUI/Model/Device/FootprintItems.cpp b/GUI/Model/Device/FootprintItems.cpp index 959575bb6d7..1249221b824 100644 --- a/GUI/Model/Device/FootprintItems.cpp +++ b/GUI/Model/Device/FootprintItems.cpp @@ -12,11 +12,20 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/FootprintItems.h" #include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintSquare.h" +#include "GUI/Model/Device/FootprintItems.h" #include "GUI/Support/XML/Serialize.h" +namespace { +namespace Tag { + +const QString GaussianFootprint("GaussianFootprint"); +const QString SquareFootprint("SquareFootprint"); + +} +} + std::unique_ptr<IFootprintFactor> FootprintNoneItem::createFootprint() const { return {}; @@ -31,7 +40,7 @@ FootprintGaussianItem::FootprintGaussianItem(double value) void FootprintGaussianItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_gaussianFootprintValue); + Serialize::rwProperty(s, Tag::GaussianFootprint, m_gaussianFootprintValue); } std::unique_ptr<IFootprintFactor> FootprintGaussianItem::createFootprint() const @@ -48,7 +57,7 @@ FootprintSquareItem::FootprintSquareItem(double value) void FootprintSquareItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_squareFootprintValue); + Serialize::rwProperty(s, Tag::SquareFootprint, m_squareFootprintValue); } std::unique_ptr<IFootprintFactor> FootprintSquareItem::createFootprint() const diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp index 6ac7170ea7e..737254e2cc7 100644 --- a/GUI/Model/Device/InstrumentItems.cpp +++ b/GUI/Model/Device/InstrumentItems.cpp @@ -12,7 +12,6 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/InstrumentItems.h" #include "Base/Const/Units.h" #include "Base/Pixel/RectangularPixel.h" #include "Device/Beam/Beam.h" @@ -28,6 +27,7 @@ #include "GUI/Model/Device/BeamWavelengthItem.h" #include "GUI/Model/Device/DetectorItems.h" #include "GUI/Model/Device/Instrument.h" +#include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Model/Device/PointwiseAxisItem.h" #include "GUI/Model/Device/RectangularDetectorItem.h" #include "GUI/Model/Device/SphericalDetectorItem.h" @@ -42,6 +42,18 @@ namespace { +namespace Tag { + +const QString Id("Id"); +const QString Name("Name"); +const QString Description("Description"); +const QString WithPolarizerAnalyzer("WithPolarizerAnalyzer"); +const QString AnalyzerEfficiency("AnalyzerEfficiency"); +const QString AnalyzerTotalTransmission("AnalyzerTotalTransmission"); +const QString Beam("Beam"); + +} + void setBeamDistribution(ParameterDistribution::WhichParameter which, const BeamDistributionItem& item, ISimulation& simulation) { @@ -150,16 +162,16 @@ T* InstrumentItem::beam() const void InstrumentItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwValue(s, "id", m_id); - Serialize::rwValue(s, "name", m_name); - Serialize::rwValue(s, "description", m_description); - Serialize::rwValue(s, "pa", m_withPolarizerAnalyzer); + Serialize::rwValue(s, Tag::Id, m_id); + Serialize::rwValue(s, Tag::Name, m_name); + Serialize::rwValue(s, Tag::Description, m_description); + Serialize::rwValue(s, Tag::WithPolarizerAnalyzer, m_withPolarizerAnalyzer); Serialize::rwProperty(s, m_polarization); Serialize::rwProperty(s, m_analyzerDirection); - Serialize::rwProperty(s, m_analyzerEfficiency); - Serialize::rwProperty(s, m_analyzerTotalTransmission); + Serialize::rwProperty(s, Tag::AnalyzerEfficiency, m_analyzerEfficiency); + Serialize::rwProperty(s, Tag::AnalyzerTotalTransmission, m_analyzerTotalTransmission); Serialize::rwSelected<BackgroundItemCatalog>(s, m_backgroundItem); - Serialize::rwClass(s, "beam", *m_beamItem); + Serialize::rwClass(s, Tag::Beam, *m_beamItem); } // ************************************************************************************************ diff --git a/GUI/Model/Device/RectangularDetectorItem.cpp b/GUI/Model/Device/RectangularDetectorItem.cpp index 4bae528a74f..2d019de94a6 100644 --- a/GUI/Model/Device/RectangularDetectorItem.cpp +++ b/GUI/Model/Device/RectangularDetectorItem.cpp @@ -12,10 +12,10 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/RectangularDetectorItem.h" #include "Device/Detector/RectangularDetector.h" #include "GUI/Model/CatDevice/ResolutionFunctionItemCatalog.h" #include "GUI/Model/Device/AxesItems.h" +#include "GUI/Model/Device/RectangularDetectorItem.h" #include "GUI/Model/Device/ResolutionFunctionItems.h" #include "GUI/Support/XML/Serialize.h" #include "GUI/Support/XML/UtilXML.h" @@ -24,6 +24,20 @@ namespace { +namespace Tag { + +const QString Masks("Masks"); +const QString XSize("XSize"); +const QString YSize("YSize"); +const QString Alignment("Alignment"); +const QString Width("Width"); +const QString Height("Height"); +const QString u0("u0"); +const QString v0("v0"); +const QString Distance("Distance"); + +} + const double default_detector_width = 20.0; const double default_detector_height = 20.0; const double default_detector_distance = 1000.0; @@ -101,20 +115,20 @@ void RectangularDetectorItem::serialize(Streamer& s) s.assertVersion(0); // base class members - Serialize::rwClass(s, "masks", m_maskItems); + Serialize::rwClass(s, Tag::Masks, m_maskItems); Serialize::rwSelected<ResolutionFunctionItemCatalog>(s, m_resolutionFunction); // own members - Serialize::rwValue(s, "xSize", m_xSize); - Serialize::rwValue(s, "ySize", m_ySize); - Serialize::rwProperty(s, m_width); - Serialize::rwProperty(s, m_height); - Serialize::rwValue(s, "alignment", alignment); + Serialize::rwValue(s, Tag::XSize, m_xSize); + Serialize::rwValue(s, Tag::YSize, m_ySize); + Serialize::rwProperty(s, Tag::Width, m_width); + Serialize::rwProperty(s, Tag::Height, m_height); + Serialize::rwValue(s, Tag::Alignment, alignment); Serialize::rwProperty(s, m_normalVector); Serialize::rwProperty(s, m_directionVector); - Serialize::rwProperty(s, m_u0); - Serialize::rwProperty(s, m_v0); - Serialize::rwProperty(s, m_distance); + Serialize::rwProperty(s, Tag::u0, m_u0); + Serialize::rwProperty(s, Tag::v0, m_v0); + Serialize::rwProperty(s, Tag::Distance, m_distance); if (s.xmlReader()) { setDetectorAlignment(static_cast<RectangularDetector::EDetectorArrangement>(alignment)); diff --git a/GUI/Model/Device/ResolutionFunctionItems.cpp b/GUI/Model/Device/ResolutionFunctionItems.cpp index 0d7fd46dbae..ca75c6ff65e 100644 --- a/GUI/Model/Device/ResolutionFunctionItems.cpp +++ b/GUI/Model/Device/ResolutionFunctionItems.cpp @@ -12,10 +12,19 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/ResolutionFunctionItems.h" #include "Device/Resolution/ResolutionFunction2DGaussian.h" +#include "GUI/Model/Device/ResolutionFunctionItems.h" #include "GUI/Support/XML/Serialize.h" +namespace { +namespace Tag { + +const QString SigmaX("SigmaX"); +const QString SigmaY("SigmaY"); + +} +} + std::unique_ptr<IResolutionFunction2D> ResolutionFunctionNoneItem::createResolutionFunction(double) const { @@ -45,6 +54,6 @@ void ResolutionFunction2DGaussianItem::setUnit(const std::variant<QString, Unit> void ResolutionFunction2DGaussianItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_sigmaX); - Serialize::rwProperty(s, m_sigmaY); + Serialize::rwProperty(s, Tag::SigmaX, m_sigmaX); + Serialize::rwProperty(s, Tag::SigmaY, m_sigmaY); } diff --git a/GUI/Model/Sample/CompoundItem.cpp b/GUI/Model/Sample/CompoundItem.cpp index 2d39cd3272e..a8db6731daa 100644 --- a/GUI/Model/Sample/CompoundItem.cpp +++ b/GUI/Model/Sample/CompoundItem.cpp @@ -12,9 +12,9 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/CompoundItem.h" #include "GUI/Model/CatSample/ItemWithParticlesCatalog.h" #include "GUI/Model/CatSample/RotationItemCatalog.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" @@ -26,6 +26,13 @@ namespace { +namespace Tag { + +const QString Abundance("Abundance"); +const QString Particles("Particles"); + +} + const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" "total number of particles in the layout"; @@ -45,10 +52,10 @@ CompoundItem::CompoundItem(const MaterialItems* materials) void CompoundItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_abundance); + Serialize::rwProperty(s, Tag::Abundance, m_abundance); Serialize::rwProperty(s, m_position); Serialize::rwSelected<RotationItemCatalog>(s, m_rotation); - Serialize::rwCatalogized<ItemWithParticlesCatalog>(s, "Particles", m_particles, m_materials); + Serialize::rwCatalogized<ItemWithParticlesCatalog>(s, Tag::Particles, m_particles, m_materials); } std::unique_ptr<Compound> CompoundItem::createCompound() const diff --git a/GUI/Model/Sample/CoreAndShellItem.cpp b/GUI/Model/Sample/CoreAndShellItem.cpp index 3bcbe2aa5ec..885a13da964 100644 --- a/GUI/Model/Sample/CoreAndShellItem.cpp +++ b/GUI/Model/Sample/CoreAndShellItem.cpp @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/CoreAndShellItem.h" #include "GUI/Model/Descriptor/DoubleDescriptor.h" +#include "GUI/Model/Sample/CoreAndShellItem.h" #include "GUI/Model/Sample/MaterialItems.h" #include "GUI/Model/Sample/ParticleItem.h" #include "GUI/Support/Type/VariantUtil.h" @@ -24,6 +24,14 @@ namespace { +namespace Tag { + +const QString Abundance("Abundance"); +const QString Core("Core"); +const QString Shell("Shell"); + +} + const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" "total number of particles in the layout"; @@ -41,10 +49,10 @@ CoreAndShellItem::CoreAndShellItem(const MaterialItems* materials) void CoreAndShellItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_abundance); + Serialize::rwProperty(s, Tag::Abundance, m_abundance); Serialize::rwProperty(s, m_position); - Serialize::rwOptional(s, "core", m_core, m_materials); - Serialize::rwOptional(s, "shell", m_shell, m_materials); + Serialize::rwOptional(s, Tag::Core, m_core, m_materials); + Serialize::rwOptional(s, Tag::Shell, m_shell, m_materials); } std::unique_ptr<CoreAndShell> CoreAndShellItem::createCoreAndShell() const diff --git a/GUI/Model/Sample/InterferenceItems.cpp b/GUI/Model/Sample/InterferenceItems.cpp index aca2c5987d1..5b4bbd11140 100644 --- a/GUI/Model/Sample/InterferenceItems.cpp +++ b/GUI/Model/Sample/InterferenceItems.cpp @@ -12,15 +12,34 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/InterferenceItems.h" #include "Base/Const/Units.h" #include "GUI/Model/CatSample/Lattice2DItemCatalog.h" #include "GUI/Model/CatSample/ProfileItemCatalogs.h" +#include "GUI/Model/Sample/InterferenceItems.h" #include "GUI/Model/Sample/Lattice2DItems.h" #include "GUI/Model/Sample/ProfileItems.h" #include "GUI/Support/XML/Serialize.h" #include "Sample/Aggregate/Interferences.h" +namespace { +namespace Tag { + +const QString PositionVariance("PositionVariance"); +const QString Length("Length"); +const QString RotationAngle("RotationAngle"); +const QString IntegrateOverXi("IntegrateOverXi"); +const QString DampingLength("DampingLength"); +const QString DomainSize("DomainSize"); +const QString DomainSize1("DomainSize1"); +const QString DomainSize2("DomainSize2"); +const QString Radius("Radius"); +const QString Density("Density"); +const QString PeakDistance("PeakDistance"); +const QString Kappa("Kappa"); + +} +} + InterferenceItem::InterferenceItem() { m_positionVariance.init("PositionVariance", "Variance of the position in each dimension", 0.0, @@ -35,7 +54,7 @@ DoubleDescriptor InterferenceItem::positionVariance() const void InterferenceItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_positionVariance); + Serialize::rwProperty(s, Tag::PositionVariance, m_positionVariance); } // --------------------------------------------------------------------------------------------- // @@ -82,9 +101,9 @@ SelectionDescriptor<Profile1DItem*> Interference1DLatticeItem::decayFunction() c void Interference1DLatticeItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_positionVariance); - Serialize::rwProperty(s, m_length); - Serialize::rwProperty(s, m_rotationAngle); + Serialize::rwProperty(s, Tag::PositionVariance, m_positionVariance); + Serialize::rwProperty(s, Tag::Length, m_length); + Serialize::rwProperty(s, Tag::RotationAngle, m_rotationAngle); Serialize::rwSelected<Profile1DItemCatalog>(s, m_decayFunction); } @@ -142,8 +161,8 @@ std::unique_ptr<IInterference> Interference2DLatticeItem::createInterference() c void Interference2DLatticeItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_positionVariance); - Serialize::rwValue(s, "integrate", m_xiIntegration); + Serialize::rwProperty(s, Tag::PositionVariance, m_positionVariance); + Serialize::rwValue(s, Tag::IntegrateOverXi, m_xiIntegration); Serialize::rwSelected<Lattice2DItemCatalog>(s, m_latticeType); Serialize::rwSelected<Profile2DItemCatalog>(s, m_decayFunction); } @@ -193,12 +212,12 @@ std::unique_ptr<IInterference> Interference2DParacrystalItem::createInterference void Interference2DParacrystalItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_positionVariance); - Serialize::rwValue(s, "integrate", m_xiIntegration); + Serialize::rwProperty(s, Tag::PositionVariance, m_positionVariance); + Serialize::rwValue(s, Tag::IntegrateOverXi, m_xiIntegration); Serialize::rwSelected<Lattice2DItemCatalog>(s, m_latticeType); - Serialize::rwProperty(s, m_dampingLength); - Serialize::rwProperty(s, m_domainSize1); - Serialize::rwProperty(s, m_domainSize2); + Serialize::rwProperty(s, Tag::DampingLength, m_dampingLength); + Serialize::rwProperty(s, Tag::DomainSize1, m_domainSize1); + Serialize::rwProperty(s, Tag::DomainSize2, m_domainSize2); Serialize::rwSelected<Profile2DItemCatalog>(s, m_pdf1); Serialize::rwSelected<Profile2DItemCatalog>(s, m_pdf2); } @@ -275,11 +294,11 @@ std::unique_ptr<IInterference> InterferenceFinite2DLatticeItem::createInterferen void InterferenceFinite2DLatticeItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_positionVariance); - Serialize::rwValue(s, "integrate", m_xiIntegration); + Serialize::rwProperty(s, Tag::PositionVariance, m_positionVariance); + Serialize::rwValue(s, Tag::IntegrateOverXi, m_xiIntegration); Serialize::rwSelected<Lattice2DItemCatalog>(s, m_latticeType); - Serialize::rwValue(s, "domainsize1", m_domainSize1); - Serialize::rwValue(s, "domainsize2", m_domainSize2); + Serialize::rwValue(s, Tag::DomainSize1, m_domainSize1); + Serialize::rwValue(s, Tag::DomainSize1, m_domainSize2); } // --------------------------------------------------------------------------------------------- // @@ -301,9 +320,9 @@ std::unique_ptr<IInterference> InterferenceHardDiskItem::createInterference() co void InterferenceHardDiskItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_positionVariance); - Serialize::rwProperty(s, m_radius); - Serialize::rwProperty(s, m_density); + Serialize::rwProperty(s, Tag::PositionVariance, m_positionVariance); + Serialize::rwProperty(s, Tag::Radius, m_radius); + Serialize::rwProperty(s, Tag::Density, m_density); } DoubleDescriptor InterferenceHardDiskItem::density() const @@ -346,11 +365,11 @@ std::unique_ptr<IInterference> InterferenceRadialParacrystalItem::createInterfer void InterferenceRadialParacrystalItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_positionVariance); - Serialize::rwProperty(s, m_peakDistance); - Serialize::rwProperty(s, m_dampingLength); - Serialize::rwProperty(s, m_domainSize); - Serialize::rwProperty(s, m_kappa); + Serialize::rwProperty(s, Tag::PositionVariance, m_positionVariance); + Serialize::rwProperty(s, Tag::PeakDistance, m_peakDistance); + Serialize::rwProperty(s, Tag::DampingLength, m_dampingLength); + Serialize::rwProperty(s, Tag::DomainSize, m_domainSize); + Serialize::rwProperty(s, Tag::Kappa, m_kappa); Serialize::rwSelected<Profile1DItemCatalog>(s, m_pdf); } diff --git a/GUI/Model/Sample/Lattice2DItems.cpp b/GUI/Model/Sample/Lattice2DItems.cpp index 7332d18dcaf..f4c8af9be64 100644 --- a/GUI/Model/Sample/Lattice2DItems.cpp +++ b/GUI/Model/Sample/Lattice2DItems.cpp @@ -12,12 +12,24 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/Lattice2DItems.h" #include "Base/Const/Units.h" #include "Base/Util/Assert.h" +#include "GUI/Model/Sample/Lattice2DItems.h" #include "GUI/Support/XML/Serialize.h" #include "Sample/Lattice/Lattice2D.h" +namespace { +namespace Tag { + +const QString LatticeRotationAngle("LatticeRotationAngle"); +const QString Length("Length"); +const QString Length1("Length1"); +const QString Length2("Length2"); +const QString Angle("Angle"); + +} +} + Lattice2DItem::Lattice2DItem() { m_latticeRotationAngle.init( @@ -60,10 +72,10 @@ std::unique_ptr<Lattice2D> BasicLattice2DItem::createLattice() const void BasicLattice2DItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_latticeRotationAngle); - Serialize::rwProperty(s, m_length1); - Serialize::rwProperty(s, m_length2); - Serialize::rwProperty(s, m_angle); + Serialize::rwProperty(s, Tag::LatticeRotationAngle, m_latticeRotationAngle); + Serialize::rwProperty(s, Tag::Length1, m_length1); + Serialize::rwProperty(s, Tag::Length2, m_length2); + Serialize::rwProperty(s, Tag::Angle, m_angle); } DoubleDescriptor BasicLattice2DItem::latticeLength1() const @@ -112,8 +124,8 @@ std::unique_ptr<Lattice2D> SquareLattice2DItem::createLattice() const void SquareLattice2DItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_latticeRotationAngle); - Serialize::rwProperty(s, m_length); + Serialize::rwProperty(s, Tag::LatticeRotationAngle, m_latticeRotationAngle); + Serialize::rwProperty(s, Tag::Length, m_length); } DoubleDescriptor SquareLattice2DItem::latticeLength() const @@ -142,8 +154,8 @@ std::unique_ptr<Lattice2D> HexagonalLattice2DItem::createLattice() const void HexagonalLattice2DItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_latticeRotationAngle); - Serialize::rwProperty(s, m_length); + Serialize::rwProperty(s, Tag::LatticeRotationAngle, m_latticeRotationAngle); + Serialize::rwProperty(s, Tag::Length, m_length); } DoubleDescriptor HexagonalLattice2DItem::latticeLength() const diff --git a/GUI/Model/Sample/LayerItem.cpp b/GUI/Model/Sample/LayerItem.cpp index 7eaac86fef5..903d1587bb7 100644 --- a/GUI/Model/Sample/LayerItem.cpp +++ b/GUI/Model/Sample/LayerItem.cpp @@ -12,9 +12,9 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/LayerItem.h" #include "GUI/Model/Sample/CompoundItem.h" #include "GUI/Model/Sample/CoreAndShellItem.h" +#include "GUI/Model/Sample/LayerItem.h" #include "GUI/Model/Sample/MesocrystalItem.h" #include "GUI/Model/Sample/MultiLayerItem.h" #include "GUI/Model/Sample/ParticleItem.h" @@ -23,6 +23,18 @@ namespace { +namespace Tag { + +const QString Name("Name"); +const QString Color("Color"); +const QString MaterialId("MaterialId"); +const QString NumSlices("NumSlices"); +const QString Thickness("Thickness"); +const QString Roughness("Roughness"); +const QString Layouts("Layouts"); + +} + QVector<ItemWithMaterial*> layoutItemsWithMaterial(ParticleLayoutItem* layout) { QVector<ItemWithMaterial*> result; @@ -130,13 +142,13 @@ void LayerItem::removeLayout(ParticleLayoutItem* layout) } void LayerItem::serialize(Streamer& s) -{ +{ s.assertVersion(0); - Serialize::rwValue(s, "Name", m_name); - Serialize::rwValue(s, "Color", m_color); - Serialize::rwValue(s, "MaterialIdentifier", m_materialIdentifier); - Serialize::rwValue(s, "NumSlices", m_numSlices); - Serialize::rwProperty(s, m_thickness); - Serialize::rwOptional(s, "Roughness", m_topRoughness); - Serialize::rwVector(s, "Layouts", m_layouts, m_materialItems); + Serialize::rwValue(s, Tag::Name, m_name); + Serialize::rwValue(s, Tag::Color, m_color); + Serialize::rwValue(s, Tag::MaterialId, m_materialIdentifier); + Serialize::rwValue(s, Tag::NumSlices, m_numSlices); + Serialize::rwProperty(s, Tag::Thickness, m_thickness); + Serialize::rwOptional(s, Tag::Roughness, m_topRoughness); + Serialize::rwVector(s, Tag::Layouts, m_layouts, m_materialItems); } diff --git a/GUI/Model/Sample/LayerRoughnessItems.cpp b/GUI/Model/Sample/LayerRoughnessItems.cpp index e950ad085ba..7796dc43dd6 100644 --- a/GUI/Model/Sample/LayerRoughnessItems.cpp +++ b/GUI/Model/Sample/LayerRoughnessItems.cpp @@ -12,16 +12,19 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/LayerRoughnessItems.h" #include "GUI/Model/Descriptor/DoubleDescriptor.h" +#include "GUI/Model/Sample/LayerRoughnessItems.h" #include "GUI/Support/XML/Serialize.h" namespace { namespace Tag { -const QString Uid("Uid"); -} // namespace Tag -} // namespace +const QString Sigma("Sigma"); +const QString Hurst("Hurst"); +const QString LateralCorrelationLength("LateralCorrelationLength"); + +} +} LayerBasicRoughnessItem::LayerBasicRoughnessItem() { @@ -53,7 +56,7 @@ DoubleDescriptor LayerBasicRoughnessItem::lateralCorrelationLength() const void LayerBasicRoughnessItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_sigma); - Serialize::rwProperty(s, m_hurst); - Serialize::rwProperty(s, m_lateralCorrelationLength); + Serialize::rwProperty(s, Tag::Sigma, m_sigma); + Serialize::rwProperty(s, Tag::Hurst, m_hurst); + Serialize::rwProperty(s, Tag::LateralCorrelationLength, m_lateralCorrelationLength); } diff --git a/GUI/Model/Sample/MesocrystalItem.cpp b/GUI/Model/Sample/MesocrystalItem.cpp index 3c5a0f974db..a8b302b7571 100644 --- a/GUI/Model/Sample/MesocrystalItem.cpp +++ b/GUI/Model/Sample/MesocrystalItem.cpp @@ -12,13 +12,13 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/MesocrystalItem.h" #include "GUI/Model/CatSample/FormFactorItemCatalog.h" #include "GUI/Model/CatSample/ItemWithParticlesCatalog.h" #include "GUI/Model/CatSample/RotationItemCatalog.h" #include "GUI/Model/Sample/CompoundItem.h" #include "GUI/Model/Sample/CoreAndShellItem.h" #include "GUI/Model/Sample/FormFactorItems.h" +#include "GUI/Model/Sample/MesocrystalItem.h" #include "GUI/Model/Sample/ParticleItem.h" #include "GUI/Support/XML/Serialize.h" #include "GUI/Util/Error.h" @@ -31,6 +31,12 @@ namespace { +namespace Tag { + +const QString Abundance("Abundance"); + +} + const QString abundance_tooltip = "Proportion of this type of mesocrystal normalized to the \n" "total number of particles in the layout"; @@ -57,7 +63,7 @@ MesocrystalItem::MesocrystalItem(const MaterialItems* materials) void MesocrystalItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_abundance); + Serialize::rwProperty(s, Tag::Abundance, m_abundance); Serialize::rwProperty(s, m_position); Serialize::rwSelected<RotationItemCatalog>(s, m_rotation); Serialize::rwProperty(s, m_vectorA); diff --git a/GUI/Model/Sample/MultiLayerItem.cpp b/GUI/Model/Sample/MultiLayerItem.cpp index 6d970dc03e8..a3c764f675d 100644 --- a/GUI/Model/Sample/MultiLayerItem.cpp +++ b/GUI/Model/Sample/MultiLayerItem.cpp @@ -12,12 +12,24 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/MultiLayerItem.h" #include "GUI/Model/Sample/LayerItem.h" +#include "GUI/Model/Sample/MultiLayerItem.h" #include "GUI/Support/XML/Backup.h" #include "GUI/Support/XML/Serialize.h" #include <QXmlStreamWriter> +namespace { +namespace Tag { + +const QString Name("Name"); +const QString Description("Description"); +const QString CrossCorrelationLength("CrossCorrelationLength"); +const QString Materials("Materials"); +const QString Layers("Layers"); + +} +} + MultiLayerItem::MultiLayerItem() { m_name = "Sample"; @@ -142,14 +154,14 @@ void MultiLayerItem::readContentFrom(QXmlStreamReader* reader) } void MultiLayerItem::serialize(Streamer& s) -{ +{ s.assertVersion(0); - Serialize::rwValue(s, "Name", m_name); - Serialize::rwValue(s, "Description", m_description); - Serialize::rwProperty(s, m_crossCorrelationLength); + Serialize::rwValue(s, Tag::Name, m_name); + Serialize::rwValue(s, Tag::Description, m_description); + Serialize::rwProperty(s, Tag::CrossCorrelationLength, m_crossCorrelationLength); Serialize::rwProperty(s, m_externalField); - Serialize::rwClass(s, "Materials", m_materials); - Serialize::rwVector(s, "Layers", m_layers, &m_materials); + Serialize::rwClass(s, Tag::Materials, m_materials); + Serialize::rwVector(s, Tag::Layers, m_layers, &m_materials); if (s.xmlReader()) { // set non-stored infos diff --git a/GUI/Model/Sample/ParticleItem.cpp b/GUI/Model/Sample/ParticleItem.cpp index 11879beea13..c5ed7dc525e 100644 --- a/GUI/Model/Sample/ParticleItem.cpp +++ b/GUI/Model/Sample/ParticleItem.cpp @@ -12,12 +12,12 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/ParticleItem.h" #include "GUI/Model/CatSample/FormFactorItemCatalog.h" #include "GUI/Model/CatSample/RotationItemCatalog.h" #include "GUI/Model/Sample/CoreAndShellItem.h" #include "GUI/Model/Sample/FormFactorItems.h" #include "GUI/Model/Sample/MaterialItem.h" +#include "GUI/Model/Sample/ParticleItem.h" #include "GUI/Support/XML/Serialize.h" #include "Sample/Particle/IFormFactor.h" #include "Sample/Particle/Particle.h" @@ -25,6 +25,12 @@ namespace { +namespace Tag { + +const QString Abundance("Abundance"); + +} + const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" "total number of particles in the layout"; @@ -45,7 +51,7 @@ void ParticleItem::serialize(Streamer& s) { s.assertVersion(0); Serialize::rwValue(s, "MaterialIdentifier", m_materialIdentifier); - Serialize::rwProperty(s, m_abundance); + Serialize::rwProperty(s, Tag::Abundance, m_abundance); Serialize::rwProperty(s, m_position); Serialize::rwSelected<RotationItemCatalog>(s, m_rotation); Serialize::rwSelected<FormFactorItemCatalog>(s, m_formFactor); diff --git a/GUI/Model/Sample/ParticleLayoutItem.cpp b/GUI/Model/Sample/ParticleLayoutItem.cpp index 58630c56e51..117cb44db51 100644 --- a/GUI/Model/Sample/ParticleLayoutItem.cpp +++ b/GUI/Model/Sample/ParticleLayoutItem.cpp @@ -12,7 +12,6 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/ParticleLayoutItem.h" #include "GUI/Model/CatSample/InterferenceItemCatalog.h" #include "GUI/Model/CatSample/ItemWithParticlesCatalog.h" #include "GUI/Model/Sample/CompoundItem.h" @@ -20,8 +19,18 @@ #include "GUI/Model/Sample/Lattice2DItems.h" #include "GUI/Model/Sample/MesocrystalItem.h" #include "GUI/Model/Sample/ParticleItem.h" +#include "GUI/Model/Sample/ParticleLayoutItem.h" #include "GUI/Support/XML/Serialize.h" +namespace { +namespace Tag { + +const QString OwnDensity("OwnDensity"); +const QString Particles("Particles"); + +} +} + ParticleLayoutItem::ParticleLayoutItem(const MaterialItems* materials) : m_materials(materials) { @@ -124,7 +133,7 @@ bool ParticleLayoutItem::totalDensityIsDefinedByInterference() const void ParticleLayoutItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_ownDensity); + Serialize::rwProperty(s, Tag::OwnDensity, m_ownDensity); Serialize::rwSelected<InterferenceItemCatalog>(s, m_interference); - Serialize::rwCatalogized<ItemWithParticlesCatalog>(s, "Particles", m_particles, m_materials); + Serialize::rwCatalogized<ItemWithParticlesCatalog>(s, Tag::Particles, m_particles, m_materials); } diff --git a/GUI/Model/Sample/ProfileItems.cpp b/GUI/Model/Sample/ProfileItems.cpp index f1210eda24b..e5687f98566 100644 --- a/GUI/Model/Sample/ProfileItems.cpp +++ b/GUI/Model/Sample/ProfileItems.cpp @@ -12,10 +12,22 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/ProfileItems.h" #include "Base/Const/Units.h" +#include "GUI/Model/Sample/ProfileItems.h" #include "GUI/Support/XML/Serialize.h" +namespace { +namespace Tag { + +const QString Omega("Omega"); +const QString OmegaX("OmegaX"); +const QString OmegaY("OmegaY"); +const QString Eta("Eta"); +const QString Gamma("Gamma"); + +} +} + Profile1DItem::Profile1DItem() { m_omega.init("Omega", "Half-width of the distribution", 1.0, Unit::nanometer, "omega"); @@ -24,7 +36,7 @@ Profile1DItem::Profile1DItem() void Profile1DItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_omega); + Serialize::rwProperty(s, Tag::Omega, m_omega); } DoubleDescriptor Profile1DItem::omega() const @@ -88,8 +100,8 @@ std::unique_ptr<IProfile1D> Profile1DVoigtItem::createProfile() const void Profile1DVoigtItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_omega); - Serialize::rwProperty(s, m_eta); + Serialize::rwProperty(s, Tag::Omega, m_omega); + Serialize::rwProperty(s, Tag::Eta, m_eta); } DoubleDescriptor Profile1DVoigtItem::eta() const @@ -119,9 +131,9 @@ Profile2DItem::Profile2DItem() void Profile2DItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_omegaX); - Serialize::rwProperty(s, m_omegaY); - Serialize::rwProperty(s, m_gamma); + Serialize::rwProperty(s, Tag::OmegaX, m_omegaX); + Serialize::rwProperty(s, Tag::OmegaY, m_omegaY); + Serialize::rwProperty(s, Tag::Gamma, m_gamma); } DoubleDescriptor Profile2DItem::omegaX() const @@ -203,10 +215,10 @@ std::unique_ptr<IProfile2D> Profile2DVoigtItem::createProfile() const void Profile2DVoigtItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_omegaX); - Serialize::rwProperty(s, m_omegaY); - Serialize::rwProperty(s, m_gamma); - Serialize::rwProperty(s, m_eta); + Serialize::rwProperty(s, Tag::OmegaX, m_omegaX); + Serialize::rwProperty(s, Tag::OmegaY, m_omegaY); + Serialize::rwProperty(s, Tag::Gamma, m_gamma); + Serialize::rwProperty(s, Tag::Eta, m_eta); } DoubleDescriptor Profile2DVoigtItem::eta() const diff --git a/GUI/Model/Sample/RotationItems.cpp b/GUI/Model/Sample/RotationItems.cpp index 8733fdecc60..ff31f527f02 100644 --- a/GUI/Model/Sample/RotationItems.cpp +++ b/GUI/Model/Sample/RotationItems.cpp @@ -12,12 +12,23 @@ // // ************************************************************************************************ -#include "GUI/Model/Sample/RotationItems.h" #include "Base/Const/Units.h" #include "Base/Vector/RotMatrix.h" +#include "GUI/Model/Sample/RotationItems.h" #include "GUI/Support/XML/Serialize.h" #include "Sample/Scattering/Rotations.h" +namespace { +namespace Tag { + +const QString Angle("Angle"); +const QString Alpha("Alpha"); +const QString Beta("Beta"); +const QString Gamma("Gamma"); + +} +} + using namespace Units; // ---------------------------------------------------------------------------- @@ -40,7 +51,7 @@ XRotationItem::XRotationItem() void XRotationItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_angle); + Serialize::rwProperty(s, Tag::Angle, m_angle); } unique_ptr<IRotation> XRotationItem::createRotation() const @@ -63,7 +74,7 @@ YRotationItem::YRotationItem() void YRotationItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_angle); + Serialize::rwProperty(s, Tag::Angle, m_angle); } unique_ptr<IRotation> YRotationItem::createRotation() const @@ -86,7 +97,7 @@ ZRotationItem::ZRotationItem() void ZRotationItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_angle); + Serialize::rwProperty(s, Tag::Angle, m_angle); } unique_ptr<IRotation> ZRotationItem::createRotation() const @@ -111,9 +122,9 @@ EulerRotationItem::EulerRotationItem() void EulerRotationItem::serialize(Streamer& s) { s.assertVersion(0); - Serialize::rwProperty(s, m_alpha); - Serialize::rwProperty(s, m_beta); - Serialize::rwProperty(s, m_gamma); + Serialize::rwProperty(s, Tag::Alpha, m_alpha); + Serialize::rwProperty(s, Tag::Beta, m_beta); + Serialize::rwProperty(s, Tag::Gamma, m_gamma); } unique_ptr<IRotation> EulerRotationItem::createRotation() const -- GitLab