diff --git a/GUI/Model/Descriptor/AxisProperty.cpp b/GUI/Model/Descriptor/AxisProperty.cpp index 5184ce354964fb2858ba45f0df9bc07f82c577f2..b22729d1178469b570daab8bdae5942a3832dfc9 100644 --- a/GUI/Model/Descriptor/AxisProperty.cpp +++ b/GUI/Model/Descriptor/AxisProperty.cpp @@ -76,7 +76,7 @@ void AxisProperty::readFrom(QXmlStreamReader* r) // nbins if (tag == Tag::Nbins) { - XML::readAttribute(r, XML::Attrib::value, &m_nbins); + m_nbins = XML::readUIntAttribute(r, XML::Attrib::value); XML::gotoEndElementOfTag(r, tag); // min diff --git a/GUI/Model/Descriptor/DistributionItems.cpp b/GUI/Model/Descriptor/DistributionItems.cpp index e2f036473bd11c2ff08e5ddbe0d94b411db6cbde..70eaaaa028adce8f655eac7079a77145bd50583a 100644 --- a/GUI/Model/Descriptor/DistributionItems.cpp +++ b/GUI/Model/Descriptor/DistributionItems.cpp @@ -77,7 +77,7 @@ void DistributionItem::readFrom(QXmlStreamReader* r) // number of samples if (tag == Tag::NumberOfSamples) { - XML::readAttribute(r, XML::Attrib::value, &m_number_of_samples); + m_number_of_samples = XML::readUIntAttribute(r, XML::Attrib::value); XML::gotoEndElementOfTag(r, tag); // relative sampling width diff --git a/GUI/Model/Descriptor/SpanProperty.cpp b/GUI/Model/Descriptor/SpanProperty.cpp index 8bcff98e1611659ebcb307a7c2693ad1d4c1904b..00eb9b839f3560b8be38944b1f87ee12b2c3311e 100644 --- a/GUI/Model/Descriptor/SpanProperty.cpp +++ b/GUI/Model/Descriptor/SpanProperty.cpp @@ -72,7 +72,7 @@ void SpanProperty::readFrom(QXmlStreamReader* r) // nbins if (tag == Tag::Nbins) { - XML::readAttribute(r, XML::Attrib::value, &m_nbins); + m_nbins = XML::readUIntAttribute(r, XML::Attrib::value); XML::gotoEndElementOfTag(r, tag); // width diff --git a/GUI/Model/Mask/PointItem.cpp b/GUI/Model/Mask/PointItem.cpp index a87821d29968a38eaf1d7656a76c75bd46536b11..4a609cb63997a31ba1513deb13a5ee0006f249f4 100644 --- a/GUI/Model/Mask/PointItem.cpp +++ b/GUI/Model/Mask/PointItem.cpp @@ -33,8 +33,8 @@ void PointItem::setPosY(double val) void PointItem::writeTo(QXmlStreamWriter* w) const { - XML::writeAttribute(w, XML::Attrib::xPos, posX()); - XML::writeAttribute(w, XML::Attrib::yPos, posY()); + XML::writeAttribute(w, XML::Attrib::xPos, posX().value()); + XML::writeAttribute(w, XML::Attrib::yPos, posY().value()); XML::writeAttribute(w, XML::Attrib::version, uint(1)); } diff --git a/GUI/Model/Sample/InterferenceItems.cpp b/GUI/Model/Sample/InterferenceItems.cpp index a641caa1bf9c4bd3d5ec083cf00338eace197932..337e794b675de89d8ff76622368b7a0f176f263c 100644 --- a/GUI/Model/Sample/InterferenceItems.cpp +++ b/GUI/Model/Sample/InterferenceItems.cpp @@ -440,12 +440,12 @@ void InterferenceFinite2DLatticeItem::readFrom(QXmlStreamReader* r) // domain size 1 } else if (tag == Tag::DomainSize1) { - XML::readAttribute(r, XML::Attrib::value, &m_domain_size1); + m_domain_size1 = XML::readUIntAttribute(r, XML::Attrib::value); XML::gotoEndElementOfTag(r, tag); // domain size 2 } else if (tag == Tag::DomainSize2) { - XML::readAttribute(r, XML::Attrib::value, &m_domain_size2); + m_domain_size2 = XML::readUIntAttribute(r, XML::Attrib::value); XML::gotoEndElementOfTag(r, tag); } else diff --git a/GUI/Model/Sample/LayerItem.cpp b/GUI/Model/Sample/LayerItem.cpp index fca83a91d9f320c29cbd3baf9bd038016c7de1b4..d97f7eec4c279d6fff9e3a4a5aa3a90fa6538b7f 100644 --- a/GUI/Model/Sample/LayerItem.cpp +++ b/GUI/Model/Sample/LayerItem.cpp @@ -182,7 +182,7 @@ void LayerItem::readFrom(QXmlStreamReader* r) // number of slices } else if (tag == Tag::NumSlices) { - XML::readAttribute(r, XML::Attrib::value, &m_num_slices); + m_num_slices = XML::readUIntAttribute(r, XML::Attrib::value); XML::gotoEndElementOfTag(r, tag); // thickness diff --git a/GUI/Model/Sim/SimulationOptionsItem.cpp b/GUI/Model/Sim/SimulationOptionsItem.cpp index e195866f2d21c32650a2bfad64bae8a972234f2c..d01c7bc5174299611e1d6408680e64ec502d5624 100644 --- a/GUI/Model/Sim/SimulationOptionsItem.cpp +++ b/GUI/Model/Sim/SimulationOptionsItem.cpp @@ -114,7 +114,7 @@ void SimulationOptionsItem::readFrom(QXmlStreamReader* r) // number of threads } else if (tag == Tag::NumberOfThreads) { - XML::readAttribute(r, XML::Attrib::value, &m_number_of_threads); + m_number_of_threads = XML::readUIntAttribute(r, XML::Attrib::value); XML::gotoEndElementOfTag(r, tag); // computation method @@ -124,7 +124,7 @@ void SimulationOptionsItem::readFrom(QXmlStreamReader* r) // number of Monte Carlo points } else if (tag == Tag::NumberOfMonteCarloPoints) { - XML::readAttribute(r, XML::Attrib::value, &m_number_of_monte_carlo_points); + m_number_of_monte_carlo_points = XML::readUIntAttribute(r, XML::Attrib::value); XML::gotoEndElementOfTag(r, tag); // use average materials diff --git a/GUI/Model/Util/UtilXML.cpp b/GUI/Model/Util/UtilXML.cpp index 79ddb831bb525f6d6d425d4e6b436d7c9872d27d..60d528d83845a57c5fd0b47fe4f3a499f2189215 100644 --- a/GUI/Model/Util/UtilXML.cpp +++ b/GUI/Model/Util/UtilXML.cpp @@ -60,21 +60,6 @@ void XML::writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, writer->writeAttribute(attributeName, b ? "1" : "0"); } -void XML::writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, int d) -{ - writer->writeAttribute(attributeName, QString::number(d)); -} - -void XML::writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, size_t d) -{ - writer->writeAttribute(attributeName, QString::number(d)); -} - -void XML::writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, unsigned d) -{ - writer->writeAttribute(attributeName, QString::number(d)); -} - void XML::writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, double d) { writer->writeAttribute(attributeName, d == 0.0 ? "0" : QString::number(d, 'e', 12)); @@ -104,6 +89,7 @@ void XML::writeAttribute(QXmlStreamWriter* writer, const QString& attributeBaseN writeAttribute(writer, attributeBaseName + "Im", c.imag()); } + // ------------ read atribute ------------ unsigned XML::readUIntAttribute(QXmlStreamReader* reader, const QString& attributeName) diff --git a/GUI/Model/Util/UtilXML.h b/GUI/Model/Util/UtilXML.h index 50b7520f7fbdbeab57402a35224111b8240b8257..632721ec11f46a4168f8a6f95d3df67ef0f26729 100644 --- a/GUI/Model/Util/UtilXML.h +++ b/GUI/Model/Util/UtilXML.h @@ -45,14 +45,16 @@ const QString yPos("yPos"); void gotoEndElementOfTag(QXmlStreamReader* reader, const QString& tag); void writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, bool b); -void writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, int d); -void writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, size_t d); -void writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, unsigned d); void writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, double d); void writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, QString s); void writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, QColor c); void writeAttribute(QXmlStreamWriter* writer, const QString& attributeBaseName, const R3& vec); void writeAttribute(QXmlStreamWriter* writer, const QString& attributeBaseName, const complex_t& c); +template <typename T> +void writeAttribute(QXmlStreamWriter* writer, const QString& attributeName, T d) +{ + writer->writeAttribute(attributeName, QString::number(d)); +}; unsigned readUIntAttribute(QXmlStreamReader* reader, const QString& attributeName); diff --git a/Tests/Functional/Consistence/ConsistenceTests.cpp b/Tests/Functional/Consistence/ConsistenceTests.cpp index 0b71d7843c9c70ed12075dbfbe905ee4bb62dae5..194b0b7aea82bff7eb1403166214b4887f1769f2 100644 --- a/Tests/Functional/Consistence/ConsistenceTests.cpp +++ b/Tests/Functional/Consistence/ConsistenceTests.cpp @@ -66,7 +66,7 @@ TEST(Consistence, PolarizedScalarSpinFlip) auto simulation = test::makeSimulation::BasicYPolarizedSpecular(*sample, "PM", false); const Datafield result = simulation->simulate(); for (auto r : result.flatVector()) - EXPECT_EQ(r, 0); + EXPECT_TRUE(fabs(r) < 1e-31); // On most architectures, exactly 0, but not on s390 } TEST(Consistence, PolarizedScalarSpinFlipParticles) diff --git a/Tests/Suite/Common/TestSuite.h b/Tests/Suite/Common/TestSuite.h index 9548d7da8f6993f279d71c43671e82dde921c333..12709958889848919f65495a26fddb189e4f9f55 100644 --- a/Tests/Suite/Common/TestSuite.h +++ b/Tests/Suite/Common/TestSuite.h @@ -325,7 +325,7 @@ TEST(TESTNAME, TriangularRipple) TEST(TESTNAME, AsymRipple) { - const double eps = eps_direct_vs_python(5e-13, 8e-9); + const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9); std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createAsymRipple()); auto sim = test::makeSimulation::MiniGISAS(*sample); EXPECT_TRUE(runTest("AsymRipple", *sim, eps));