1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Model/Detector/OffspecDetectorItem.cpp
//! @brief Implements class OffspecDetectorItem.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/Model/Detector/OffspecDetectorItem.h"
#include "Base/Const/Units.h"
#include "Device/Detector/OffspecDetector.h"
#include "GUI/Model/Util/UtilXML.h"
namespace {
namespace Tag {
const QString AlphaAxis("AlphaAxis");
const QString PhiAxis("PhiAxis");
const QString BaseData("BaseData");
} // namespace Tag
} // namespace
OffspecDetectorItem::OffspecDetectorItem()
{
m_phi_axis.setProperties("phi", "deg", -1, 1, RealLimits::limited(-90, 90));
m_alpha_axis.setProperties("alpha", "deg", 0, 2, RealLimits::limited(-90, 90));
}
void OffspecDetectorItem::writeTo(QXmlStreamWriter* w) const
{
XML::writeTaggedElement(w, Tag::PhiAxis, m_phi_axis);
XML::writeTaggedElement(w, Tag::AlphaAxis, m_alpha_axis);
}
void OffspecDetectorItem::readFrom(QXmlStreamReader* r)
{
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::PhiAxis)
XML::readTaggedElement(r, tag, m_phi_axis);
else if (tag == Tag::AlphaAxis)
XML::readTaggedElement(r, tag, m_alpha_axis);
else
r->skipCurrentElement();
}
}
std::unique_ptr<OffspecDetector> OffspecDetectorItem::createOffspecDetector() const
{
const int n_x = m_phi_axis.nbins();
const double x_min = Units::deg2rad(m_phi_axis.min().dVal());
const double x_max = Units::deg2rad(m_phi_axis.max().dVal());
const int n_y = m_alpha_axis.nbins();
const double y_min = Units::deg2rad(m_alpha_axis.min().dVal());
const double y_max = Units::deg2rad(m_alpha_axis.max().dVal());
return std::make_unique<OffspecDetector>(n_x, x_min, x_max, n_y, y_min, y_max);
}
|