16 #include "Base/Util/Assert.h"
21 #include "Sample/Material/MaterialFactoryFuncs.h"
24 #include <QXmlStreamReader>
30 const QString Color(
"Color");
31 const QString
Id(
"Id");
32 const QString Name(
"Name");
33 const QString Delta(
"Delta");
34 const QString Beta(
"Beta");
35 const QString Sld(
"Sld");
36 const QString Magnetization(
"Magnetization");
42 #define m_delta std::get<Refractive>(m_data).delta
43 #define m_beta std::get<Refractive>(m_data).beta
45 #define m_real std ::get<complex_t>(m_data).real()
46 #define m_imag std ::get<complex_t>(m_data).imag()
52 m_id = QUuid::createUuid().toString();
57 , m_name(
other.m_name)
59 , m_color(
other.m_color)
60 , m_data(
other.m_data)
61 , m_magnetization(
other.m_magnetization)
87 const auto setter = [=](
double v) {
95 "Delta",
"Delta of refractive index (n = 1 - delta + i*beta)", 3, RealLimits::limitless(),
104 const auto setter = [=](
double v) {
112 "Beta",
"Beta of refractive index (n = 1 - delta + i*beta)", 3, RealLimits::limitless(),
121 const auto setter = [=](
double v) {
123 std::get<complex_t>(
m_data).real(v);
129 "SLD, real",
"Real part of SLD (SLD = real - i*imag), AA^{-2}", 3, RealLimits::limitless(),
138 const auto setter = [=](
double v) {
140 std::get<complex_t>(
m_data).imag(v);
146 "SLD, imaginary",
"Imaginary part of SLD (SLD = real - i*imag), AA^{-2}", 3,
156 d.
x.
set = [=](
double v) {
165 d.
y.
set = [=](
double v) {
174 d.
z.
set = [=](
double v) {
188 return std::holds_alternative<Refractive>(
m_data);
217 m_id = QUuid::createUuid().toString();
250 return std::make_unique<Material>(
253 return std::make_unique<Material>(
287 if (reader->attributes().hasAttribute(Tags::Delta)) {
318 m_data = complex_t(val1, val2);
324 if (
operator!=(
other)) {
335 return "material/" +
identifier() +
"/" + lastPart;
346 if (std::get<Refractive>(
m_data) != std::get<Refractive>(
other.m_data))
348 }
else if (std::get<complex_t>(
m_data) != std::get<complex_t>(
other.m_data))
Defines class DeserializationException.
Defines class MaterialItem.
@ other
The unit has no enum value defined in here (e.g. when defined as an explicit string)
Defines class VectorDescriptor.
static DeserializationException tooOld()
static DeserializationException tooNew()
Describes properties of a double value which are necessary to allow GUI representation,...
function< void(double)> set
function to set the value
function< double()> get
function to get the current value
function< QString()> path
Path describing this value. Used e.g. for undo/redo.
QString uidForDescriptor(const QString &lastPart) const
Returns a unique identifier for descriptors.
bool hasRefractiveIndex() const
void serialize(Streamer &s)
void createNewIdentifier()
void setScatteringLengthDensity(complex_t sld)
Turns material into SLD based material.
void readContentFrom(QXmlStreamReader *reader)
bool operator!=(const MaterialItem &other) const
QString matItemName() const
void setIdentifier(const QString &id)
std::variant< Refractive, complex_t > m_data
void setMagnetization(const R3 &magnetization)
void updateFrom(const MaterialItem &other)
Updates content from the other material.
bool operator==(const MaterialItem &other) const
Compares all contents. The inactive contents (e.g. SLD in case of refractive) are not taken into acco...
QString identifier() const
void setRefractiveIndex(double delta, double beta)
Turns material into refractive index material.
std::unique_ptr< Material > createMaterial() const
void setMatItemName(const QString &name)
VectorDescriptor magnetizationVector()
void setColor(const QColor &color)
void writeContentTo(QXmlStreamWriter *writer) const
Supports serialization to or deserialization from QXmlStream.
QXmlStreamReader * xmlReader()
Returns stream reader or nullptr.
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Describes properties of a 3D vector, consisting of three double values.
function< QString()> uid
unique id describing this value. Used e.g. for undo/redo
QString const & name(EShape k)
void readAttribute(QXmlStreamReader *reader, const QString &attributeName, double *d)
constexpr auto Version("Version")
void writeAttribute(QXmlStreamWriter *writer, const QString &attributeName, const QVariant &variant)
Write the variant's value as an attribute.
void rwValue(Streamer &s, const QString &tag, bool &val)