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

ditto for getter

parent 4421e87b
No related branches found
No related tags found
1 merge request!1438unify GUI code for scanning instruments
......@@ -80,7 +80,6 @@ void SourceItem::writeTo(QXmlStreamWriter* w) const
void SourceItem::readFrom(QXmlStreamReader* r)
{
ASSERT(m_wavelengthItem);
ASSERT(m_inclinationAngleItem);
const uint version = XML::readUIntAttribute(r, XML::Attrib::version);
Q_UNUSED(version)
......@@ -131,12 +130,6 @@ BeamWavelengthItem* SourceItem::wavelengthItem() const
return m_wavelengthItem.get();
}
BeamDistributionItem* SourceItem::beamDistributionItem() const
{
ASSERT(m_inclinationAngleItem);
return m_inclinationAngleItem.get();
}
double SourceItem::azimuthalAngle() const
{
ASSERT(m_azimuthalAngleItem);
......@@ -155,18 +148,6 @@ BeamAzimuthalAngleItem* SourceItem::azimuthalAngleItem() const
return m_azimuthalAngleItem.get();
}
std::shared_ptr<Beam> SourceItem::createBeam() const
{
double lambda = wavelength();
double inclination_angle = Units::deg2rad(getInclinationAngle());
double azimuthal_angle = Units::deg2rad(azimuthalAngle());
auto result =
std::make_shared<Beam>(InBeam(intensity(), lambda, inclination_angle, azimuthal_angle));
return result;
}
// ************************************************************************************************
// BeamItem
// ************************************************************************************************
......@@ -197,6 +178,7 @@ void BeamItem::readFrom(QXmlStreamReader* r)
{
const uint version = XML::readUIntAttribute(r, XML::Attrib::version);
Q_UNUSED(version)
ASSERT(m_inclinationAngleItem);
while (r->readNextStartElement()) {
QString tag = r->name().toString();
......@@ -222,11 +204,29 @@ void BeamItem::setInclinationAngle(double value)
m_inclinationAngleItem->resetToValue(value);
}
BeamDistributionItem* BeamItem::beamDistributionItem() const
{
ASSERT(m_inclinationAngleItem);
return m_inclinationAngleItem.get();
}
double BeamItem::getInclinationAngle() const
{
return dynamic_cast<BeamInclinationAngleItem*>(beamDistributionItem())->inclinationAngle();
}
std::shared_ptr<Beam> BeamItem::createBeam() const
{
double lambda = wavelength();
double inclination_angle = Units::deg2rad(getInclinationAngle());
double azimuthal_angle = Units::deg2rad(azimuthalAngle());
auto result =
std::make_shared<Beam>(InBeam(intensity(), lambda, inclination_angle, azimuthal_angle));
return result;
}
// ************************************************************************************************
// ScanItem
// ************************************************************************************************
......@@ -262,6 +262,7 @@ void ScanItem::readFrom(QXmlStreamReader* r)
{
const uint version = XML::readUIntAttribute(r, XML::Attrib::version);
Q_UNUSED(version)
ASSERT(m_inclinationAngleItem);
while (r->readNextStartElement()) {
QString tag = r->name().toString();
......@@ -323,6 +324,18 @@ void ScanItem::updateToData(const IAxis& axis, QString units)
}
}
std::shared_ptr<Beam> ScanItem::createBeam() const
{
double lambda = wavelength();
double inclination_angle = Units::deg2rad(getInclinationAngle());
double azimuthal_angle = Units::deg2rad(azimuthalAngle());
auto result =
std::make_shared<Beam>(InBeam(intensity(), lambda, inclination_angle, azimuthal_angle));
return result;
}
/*
std::shared_ptr<AlphaScan> ScanItem::createAlphaScan() const
{
......
......@@ -42,16 +42,10 @@ public:
void setWavelength(double value);
BeamWavelengthItem* wavelengthItem() const;
virtual double getInclinationAngle() const = 0;
BeamDistributionItem* beamDistributionItem() const;
double azimuthalAngle() const;
void setAzimuthalAngle(double value);
BeamAzimuthalAngleItem* azimuthalAngleItem() const;
std::shared_ptr<Beam> createBeam() const;
bool isExpandBeamParameters() const { return m_expandBeamParameters; }
void setExpandBeamParameters(bool b) { m_expandBeamParameters = b; }
......@@ -62,7 +56,6 @@ protected:
std::unique_ptr<BeamWavelengthItem> m_wavelengthItem;
std::unique_ptr<BeamAzimuthalAngleItem> m_azimuthalAngleItem;
std::unique_ptr<BeamDistributionItem> m_inclinationAngleItem;
DoubleProperty m_intensity;
bool m_expandBeamParameters = true;
......@@ -75,8 +68,14 @@ public:
void writeTo(QXmlStreamWriter* w) const;
void readFrom(QXmlStreamReader* r);
BeamDistributionItem* beamDistributionItem() const;
void setInclinationAngle(double value);
double getInclinationAngle() const override;
double getInclinationAngle() const;
std::shared_ptr<Beam> createBeam() const;
private:
std::unique_ptr<BeamDistributionItem> m_inclinationAngleItem;
};
class ScanItem : public SourceItem {
......@@ -86,7 +85,7 @@ public:
void writeTo(QXmlStreamWriter* w) const;
void readFrom(QXmlStreamReader* r);
double getInclinationAngle() const override;
double getInclinationAngle() const;
GrazingScanItem* grazingScanItem() const;
BasicAxisItem* inclinationAxisItem() const;
......@@ -101,9 +100,12 @@ public:
bool isExpandFootprint() const { return m_expandFootprint; }
void setExpandFootprint(bool b) { m_expandFootprint = b; }
std::shared_ptr<Beam> createBeam() const;
private:
SelectionProperty<FootprintItemCatalog> m_footprint;
bool m_expandFootprint = true;
std::unique_ptr<BeamDistributionItem> m_inclinationAngleItem;
};
#endif // BORNAGAIN_GUI_MODEL_DEVICE_BEAMITEMS_H
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