Skip to content
Snippets Groups Projects
Commit f44474f4 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Revert "DetectorItem takes ownership of masks and projections, and serializes them"

This reverts commit e323b204.
parent c4109ead
No related branches found
No related tags found
1 merge request!2428Revert big refactoring of the last four days; to be redone more systematically
......@@ -35,6 +35,8 @@ namespace Tag {
const QString BaseData("BaseData");
const QString Gradient("Gradient");
const QString Interpolation("Interpolation");
const QString MaskContainer("MaskContainer");
const QString ProjectionContainer("ProjectionContainer");
const QString ZAxis("ZAxis");
} // namespace Tag
......@@ -275,6 +277,24 @@ void Data2DItem::writeTo(QXmlStreamWriter* w) const
w->writeStartElement(Tag::ZAxis);
m_z_axis->writeTo(w);
w->writeEndElement();
// masks and projections
if (m_model) {
if (const auto* mi = m_model->set()) {
w->writeStartElement(Tag::MaskContainer);
mi->writeTo(w);
w->writeEndElement();
}
}
// projections
if (m_proj_model) {
if (const auto* pi = m_proj_model->set()) {
w->writeStartElement(Tag::ProjectionContainer);
pi->writeTo(w);
w->writeEndElement();
}
}
}
void Data2DItem::readFrom(QXmlStreamReader* r)
......@@ -305,6 +325,16 @@ void Data2DItem::readFrom(QXmlStreamReader* r)
m_z_axis->readFrom(r);
XML::gotoEndElementOfTag(r, tag);
// masks
} else if (tag == Tag::MaskContainer) {
getOrCreateModel()->set()->readFrom(r);
XML::gotoEndElementOfTag(r, tag);
// projections
} else if (tag == Tag::ProjectionContainer) {
getOrCreateProjectionModel()->set()->readFrom(r);
XML::gotoEndElementOfTag(r, tag);
} else
r->skipCurrentElement();
}
......
......@@ -30,16 +30,13 @@ const QString ExpandResolutionFuncGroupbox("ExpandResolutionFuncGroupbox");
const QString AlphaAxis("AlphaAxis");
const QString PhiAxis("PhiAxis");
const QString ResolutionFunction("ResolutionFunction");
const QString MaskContainer("MaskContainer");
const QString ProjectionContainer("ProjectionContainer");
} // namespace Tag
} // namespace
DetectorItem::DetectorItem()
: m_masks(std::make_unique<MasksSet>())
, m_prjns(std::make_unique<MasksSet>())
{
m_phi_axis.initWidth("Span (deg)", "Full width in phi direction", 4.0,
RealLimits::limited(0, 180));
......@@ -106,16 +103,6 @@ void DetectorItem::writeTo(QXmlStreamWriter* w) const
{
XML::writeAttribute(w, XML::Attrib::version, uint(2));
// phi axis
w->writeStartElement(Tag::PhiAxis);
m_phi_axis.writeTo(w);
w->writeEndElement();
// alpha axis
w->writeStartElement(Tag::AlphaAxis);
m_alpha_axis.writeTo(w);
w->writeEndElement();
// resolution function
w->writeStartElement(Tag::ResolutionFunction);
m_resolution_function.writeTo(w);
......@@ -126,14 +113,14 @@ void DetectorItem::writeTo(QXmlStreamWriter* w) const
XML::writeAttribute(w, XML::Attrib::value, expandResolutionFunc);
w->writeEndElement();
// masks and projections
w->writeStartElement(Tag::MaskContainer);
m_masks->writeTo(w);
// phi axis
w->writeStartElement(Tag::PhiAxis);
m_phi_axis.writeTo(w);
w->writeEndElement();
// projections
w->writeStartElement(Tag::ProjectionContainer);
m_prjns->writeTo(w);
// alpha axis
w->writeStartElement(Tag::AlphaAxis);
m_alpha_axis.writeTo(w);
w->writeEndElement();
}
......@@ -145,18 +132,8 @@ void DetectorItem::readFrom(QXmlStreamReader* r)
while (r->readNextStartElement()) {
QString tag = r->name().toString();
// phi axis
if (tag == Tag::PhiAxis) {
m_phi_axis.readFrom(r);
XML::gotoEndElementOfTag(r, tag);
// alpha axis
} else if (tag == Tag::AlphaAxis) {
m_alpha_axis.readFrom(r);
XML::gotoEndElementOfTag(r, tag);
// resolution function
} else if (tag == Tag::ResolutionFunction) {
// resolution function
if (tag == Tag::ResolutionFunction) {
m_resolution_function.readFrom(r);
XML::gotoEndElementOfTag(r, tag);
......@@ -165,14 +142,16 @@ void DetectorItem::readFrom(QXmlStreamReader* r)
XML::readAttribute(r, XML::Attrib::value, &expandResolutionFunc);
XML::gotoEndElementOfTag(r, tag);
// masks
} else if (tag == Tag::MaskContainer) {
m_masks->readFrom(r);
// x size
// phi axis
} else if (tag == Tag::PhiAxis) {
m_phi_axis.readFrom(r);
XML::gotoEndElementOfTag(r, tag);
// projections
} else if (tag == Tag::ProjectionContainer) {
m_prjns->readFrom(r);
// alpha axis
} else if (tag == Tag::AlphaAxis) {
m_alpha_axis.readFrom(r);
XML::gotoEndElementOfTag(r, tag);
} else
......
......@@ -55,13 +55,12 @@ public:
private:
std::unique_ptr<IResolutionFunction2D> createResolutionFunction() const;
SpanProperty m_phi_axis;
SpanProperty m_alpha_axis;
//! for creation of domain detector; only filled and relevant in jobs
std::unique_ptr<MasksSet> m_masks; // without serializtion
PolyItem<ResolutionFunctionItemCatalog> m_resolution_function;
std::unique_ptr<MasksSet> m_masks;
std::unique_ptr<MasksSet> m_prjns; //!< projections
SpanProperty m_phi_axis;
SpanProperty m_alpha_axis;
};
template <typename T> T* DetectorItem::setResolutionFunctionType()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment