Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 4.L
  • 5.L
  • a.addPatchVersion
  • develop
  • louis.filon1
  • m.dialog_csv_2d
  • r19-statistics
  • r20.3
  • r21
  • r22
  • 0.1
  • 0.1.1
  • 0.1.2
  • 0.1.3
  • 0.2
  • 0.2.1
  • 0.3
  • 0.4
  • 0.5
  • 0.6
  • 0.7
  • 0.8.1
  • 0.9.1
  • 0.9.2.p1
  • 0.9.3
  • 0.9.4
  • 0.9.5
  • 0.9.6
  • 0.9.7
  • 0.9.8
  • 0.9.9
  • 1.0.0
  • 1.1.0
  • 1.2.0
  • 1.3.0
  • 1.4.0
  • 1.5.0
  • 1.5.1
  • 1.6.0
  • FullPython3Support6_9_AllTestsPassed
  • release-0.9.2.p2
  • repair_transmission
  • tag-sprint1
  • tag-sprint2
  • v0.0.1
  • v0.0.2
  • v0.1
  • v0.1.1
  • v0.1.2
  • v0.1.3
  • v0.2
  • v0.2.1
  • v0.3
  • v0.4
  • v0.5
  • v0.6
  • v0.7
  • v0.8.1
  • v0.9.1
  • v0.9.2.1
  • v0.9.2.2
  • v0.9.2p1
  • v0.9.3
  • v0.9.4
  • v0.9.5
  • v0.9.6
  • v0.9.7
  • v0.9.8
  • v0.9.9
  • v1.0.0
  • v1.1.0
  • v1.10.0
  • v1.11.0
  • v1.11.1
  • v1.12.0
  • v1.12.1
  • v1.13.0
  • v1.14.0
  • v1.15.0
  • v1.16.0
  • v1.17.0
  • v1.18.0
  • v1.19.0
  • v1.19.77
  • v1.19.78
  • v1.19.79
  • v1.2.0
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v1.5.1
  • v1.6.0
  • v1.6.1
  • v1.6.2
  • v1.7.0
  • v1.7.1
  • v1.8.0
  • v1.8.1
  • v1.9.0
  • v20.0
  • v20.1
  • v20.2
  • v21.0
  • v21.1
  • v21.2
  • v22.0
  • v22.1
107 results

Target

Select target project
  • c.trageser/bornagain
  • mlz/bornagain
2 results
Select Git revision
  • 4.L
  • 5.L
  • a.addPatchVersion
  • develop
  • louis.filon1
  • m.dialog_csv_2d
  • r19-statistics
  • r20.3
  • r21
  • r22
  • 0.1
  • 0.1.1
  • 0.1.2
  • 0.1.3
  • 0.2
  • 0.2.1
  • 0.3
  • 0.4
  • 0.5
  • 0.6
  • 0.7
  • 0.8.1
  • 0.9.1
  • 0.9.2.p1
  • 0.9.3
  • 0.9.4
  • 0.9.5
  • 0.9.6
  • 0.9.7
  • 0.9.8
  • 0.9.9
  • 1.0.0
  • 1.1.0
  • 1.2.0
  • 1.3.0
  • 1.4.0
  • 1.5.0
  • 1.5.1
  • 1.6.0
  • FullPython3Support6_9_AllTestsPassed
  • release-0.9.2.p2
  • repair_transmission
  • tag-sprint1
  • tag-sprint2
  • v0.0.1
  • v0.0.2
  • v0.1
  • v0.1.1
  • v0.1.2
  • v0.1.3
  • v0.2
  • v0.2.1
  • v0.3
  • v0.4
  • v0.5
  • v0.6
  • v0.7
  • v0.8.1
  • v0.9.1
  • v0.9.2.1
  • v0.9.2.2
  • v0.9.2p1
  • v0.9.3
  • v0.9.4
  • v0.9.5
  • v0.9.6
  • v0.9.7
  • v0.9.8
  • v0.9.9
  • v1.0.0
  • v1.1.0
  • v1.10.0
  • v1.11.0
  • v1.11.1
  • v1.12.0
  • v1.12.1
  • v1.13.0
  • v1.14.0
  • v1.15.0
  • v1.16.0
  • v1.17.0
  • v1.18.0
  • v1.19.0
  • v1.19.77
  • v1.19.78
  • v1.19.79
  • v1.2.0
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v1.5.1
  • v1.6.0
  • v1.6.1
  • v1.6.2
  • v1.7.0
  • v1.7.1
  • v1.8.0
  • v1.8.1
  • v1.9.0
  • v20.0
  • v20.1
  • v20.2
  • v21.0
  • v21.1
  • v21.2
  • v22.0
  • v22.1
107 results
Show changes
Commits on Source (19)
Showing
with 149 additions and 46 deletions
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
// ************************************************************************************************ // ************************************************************************************************
#include "Base/Axis/Scale.h" #include "Base/Axis/Scale.h"
#include "Base/Const/Units.h"
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "Base/Util/StringUtil.h" #include "Base/Util/StringUtil.h"
#include <iomanip> #include <iomanip>
...@@ -63,6 +64,11 @@ std::string Scale::axisLabel() const ...@@ -63,6 +64,11 @@ std::string Scale::axisLabel() const
return m_coord->label(); return m_coord->label();
} }
std::string Scale::coordName() const
{
return Coordinate(axisLabel()).name();
}
std::string Scale::unit() const std::string Scale::unit() const
{ {
return Coordinate(axisLabel()).unit(); return Coordinate(axisLabel()).unit();
...@@ -222,8 +228,7 @@ Scale Scale::plottableScale() const ...@@ -222,8 +228,7 @@ Scale Scale::plottableScale() const
{ {
ASSERT(m_coord); ASSERT(m_coord);
if (m_coord->unit() == "rad") if (m_coord->unit() == "rad")
return transformedScale(Coordinate(m_coord->name(), "deg").label(), return transformedScale(Coordinate(m_coord->name(), "deg").label(), Units::rad2deg);
[](double x) { return x * 180 / pi; });
return {m_coord->label(), m_bins}; return {m_coord->label(), m_bins};
} }
......
...@@ -80,6 +80,7 @@ public: ...@@ -80,6 +80,7 @@ public:
friend std::ostream& operator<<(std::ostream& ostr, const Scale& ax); friend std::ostream& operator<<(std::ostream& ostr, const Scale& ax);
std::string coordName() const;
std::string unit() const; std::string unit() const;
Scale plottableScale() const; Scale plottableScale() const;
......
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Base/Util/ConversionUtil.cpp
//! @brief Implements namespace Conversion.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2023
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Base/Util/ConversionUtil.h"
#include <cmath>
#include <numbers>
using std::numbers::pi;
double Convert::Refl::qz2alpha(double lambda, double qz)
{
return std::asin(qz * lambda / 4 / pi);
}
double Convert::Refl::qz2lambda(double alpha, double qz)
{
return 4 * pi * std::sin(alpha) / qz;
}
double Convert::Refl::qz(double alpha, double lambda)
{
return qz2lambda(alpha, lambda);
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Base/Util/ConversionUtil.h
//! @brief Implements namespace Conversion.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2023
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_BASE_UTIL_CONVERSIONUTIL_H
#define BORNAGAIN_BASE_UTIL_CONVERSIONUTIL_H
namespace Convert::Refl {
double qz2alpha(double lambda, double qz);
double qz2lambda(double alpha, double qz);
double qz(double alpha, double lambda);
} // namespace Convert::Refl
#endif // BORNAGAIN_BASE_UTIL_CONVERSIONUTIL_H
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "Base/Axis/Frame.h" #include "Base/Axis/Frame.h"
#include "Base/Axis/MakeScale.h" #include "Base/Axis/MakeScale.h"
#include "Base/Axis/Scale.h" #include "Base/Axis/Scale.h"
#include "Base/Const/Units.h"
#include "Device/Data/Datafield.h" #include "Device/Data/Datafield.h"
#include "Device/IO/ReadWriteINT.h" #include "Device/IO/ReadWriteINT.h"
#include "GUI/Support/XML/UtilXML.h" #include "GUI/Support/XML/UtilXML.h"
...@@ -39,10 +40,10 @@ PointwiseAxisItem::PointwiseAxisItem(QObject* parent) ...@@ -39,10 +40,10 @@ PointwiseAxisItem::PointwiseAxisItem(QObject* parent)
PointwiseAxisItem::~PointwiseAxisItem() = default; PointwiseAxisItem::~PointwiseAxisItem() = default;
void PointwiseAxisItem::setAxisAndUnit(const Scale& axis, const QString& units_label) void PointwiseAxisItem::setAxis(const Scale& axis)
{ {
m_axis = std::unique_ptr<Scale>(axis.clone()); m_axis = std::unique_ptr<Scale>(axis.clone());
m_nativeAxisUnits = units_label; m_nativeAxisUnits = QString::fromStdString(axis.unit());
} }
const Scale* PointwiseAxisItem::axis() const const Scale* PointwiseAxisItem::axis() const
...@@ -134,7 +135,12 @@ void PointwiseAxisItem::updateAxIndicators(const Frame& cs) ...@@ -134,7 +135,12 @@ void PointwiseAxisItem::updateAxIndicators(const Frame& cs)
if (!m_axis || nativeAxisUnits() == "bin") if (!m_axis || nativeAxisUnits() == "bin")
return; return;
setMin(cs.axis(0).min()); if (cs.axis(0).unit() == "rad") {
setMax(cs.axis(0).max()); setMin(Units::rad2deg(cs.axis(0).min()));
setMax(Units::rad2deg(cs.axis(0).max()));
} else {
setMin(cs.axis(0).min());
setMax(cs.axis(0).max());
}
resize(static_cast<int>(m_axis->size())); resize(static_cast<int>(m_axis->size()));
} }
...@@ -27,9 +27,9 @@ public: ...@@ -27,9 +27,9 @@ public:
~PointwiseAxisItem() override; ~PointwiseAxisItem() override;
// setters, getters // setters, getters
void setAxisAndUnit(const Scale& axis, const QString& units_label); void setAxis(const Scale& axis);
const Scale* axis() const; const Scale* axis() const;
QString nativeAxisUnits() const; QString nativeAxisUnits() const;
void updateAxIndicators(const Frame& cs); void updateAxIndicators(const Frame& cs);
......
...@@ -184,13 +184,18 @@ void GrazingScanItem::initUniformAxis(const Scale& axis) ...@@ -184,13 +184,18 @@ void GrazingScanItem::initUniformAxis(const Scale& axis)
m_uniformAlphaAxis->resize(static_cast<int>(axis.size())); m_uniformAlphaAxis->resize(static_cast<int>(axis.size()));
} }
void GrazingScanItem::initListScan(const Scale& axis, QString units, const Frame& frame) void GrazingScanItem::initListScan(const Scale& axis)
{ {
if (!m_pointwiseAlphaAxis) { if (!m_pointwiseAlphaAxis) {
m_pointwiseAlphaAxis.reset(new PointwiseAxisItem()); m_pointwiseAlphaAxis.reset(new PointwiseAxisItem());
setAxisPresentationDefaults(m_pointwiseAlphaAxis.get()); setAxisPresentationDefaults(m_pointwiseAlphaAxis.get());
} }
m_pointwiseAlphaAxis->setAxis(axis);
}
m_pointwiseAlphaAxis->setAxisAndUnit(axis, units); void GrazingScanItem::updateAxIndicators(const Frame& frame)
{
if (!m_pointwiseAlphaAxis)
return;
m_pointwiseAlphaAxis->updateAxIndicators(frame); m_pointwiseAlphaAxis->updateAxIndicators(frame);
} }
...@@ -59,7 +59,8 @@ public: ...@@ -59,7 +59,8 @@ public:
void selectListScan(); void selectListScan();
void initUniformAxis(const Scale& axis); void initUniformAxis(const Scale& axis);
void initListScan(const Scale& axis, QString units, const Frame& frame); void initListScan(const Scale& axis);
void updateAxIndicators(const Frame& frame);
private: private:
std::unique_ptr<BasicAxisItem> m_uniformAlphaAxis; std::unique_ptr<BasicAxisItem> m_uniformAlphaAxis;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "Base/Axis/Scale.h" #include "Base/Axis/Scale.h"
#include "Base/Const/Units.h" #include "Base/Const/Units.h"
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "Base/Util/ConversionUtil.h"
#include "Device/Beam/Beam.h" #include "Device/Beam/Beam.h"
#include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintGauss.h"
#include "Device/Beam/FootprintSquare.h" #include "Device/Beam/FootprintSquare.h"
...@@ -359,13 +360,13 @@ BasicAxisItem* ScanItem::inclinationAxisItem() const ...@@ -359,13 +360,13 @@ BasicAxisItem* ScanItem::inclinationAxisItem() const
return grazingScanItem()->alphaAxisItem(); return grazingScanItem()->alphaAxisItem();
} }
void ScanItem::updateToData(const Scale& axis, QString units, const Frame& frame) void ScanItem::updateToData(const Scale& axis)
{ {
if (units == "bin") { if (axis.unit() == "bin") {
grazingScanItem()->initUniformAxis(axis); grazingScanItem()->initUniformAxis(axis);
grazingScanItem()->selectUniformAxis(); grazingScanItem()->selectUniformAxis();
} else { } else {
grazingScanItem()->initListScan(axis, units, frame); grazingScanItem()->initListScan(axis);
grazingScanItem()->selectListScan(); grazingScanItem()->selectListScan();
} }
} }
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
GrazingScanItem* grazingScanItem() const; GrazingScanItem* grazingScanItem() const;
BasicAxisItem* inclinationAxisItem() const; BasicAxisItem* inclinationAxisItem() const;
void updateToData(const Scale& axis, QString units, const Frame& frame); void updateToData(const Scale& axis);
private: private:
std::unique_ptr<GrazingScanItem> m_grazingScanItem; std::unique_ptr<GrazingScanItem> m_grazingScanItem;
......
...@@ -47,14 +47,19 @@ DataItem::DataItem(const QString& modelType) ...@@ -47,14 +47,19 @@ DataItem::DataItem(const QString& modelType)
DataItem::~DataItem() = default; DataItem::~DataItem() = default;
void DataItem::setDatafield(const Datafield& data) void DataItem::setOriginalDatafield(const Datafield& data)
{ {
std::unique_lock<std::mutex> lock(m_update_data_mutex); std::unique_lock<std::mutex> lock(m_update_data_mutex);
m_datafield = std::make_unique<Datafield>(data.plottableField()); m_datafield = std::make_unique<Datafield>(data);
setLastModified(QDateTime::currentDateTime()); setLastModified(QDateTime::currentDateTime());
emit datafieldChanged(); emit datafieldChanged();
} }
void DataItem::setDatafield(const Datafield& data)
{
setOriginalDatafield(data.plottableField());
}
void DataItem::setRawDataVector(const std::vector<double>& data) void DataItem::setRawDataVector(const std::vector<double>& data)
{ {
ASSERT(m_datafield->size() == data.size()); ASSERT(m_datafield->size() == data.size());
......
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
Datafield* p_field() { return m_datafield.get(); } Datafield* p_field() { return m_datafield.get(); }
const Datafield* c_field() const { return m_datafield.get(); } const Datafield* c_field() const { return m_datafield.get(); }
void setOriginalDatafield(const Datafield& data);
virtual void setDatafield(const Datafield& data); virtual void setDatafield(const Datafield& data);
//! Sets the raw data vector from external source. //! Sets the raw data vector from external source.
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
// ************************************************************************************************ // ************************************************************************************************
#include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/DatafileItem.h"
#include "Base/Axis/Frame.h"
#include "Base/Axis/Scale.h" #include "Base/Axis/Scale.h"
#include "Device/Data/DataUtil.h" #include "Device/Data/DataUtil.h"
#include "Device/Data/Datafield.h" #include "Device/Data/Datafield.h"
...@@ -132,14 +133,14 @@ DataItem* DatafileItem::initNativeData() ...@@ -132,14 +133,14 @@ DataItem* DatafileItem::initNativeData()
return m_nativeDataItem.get(); return m_nativeDataItem.get();
} }
QString DatafileItem::nativeDataUnits() const
{
return m_nativeDataUnits;
}
bool DatafileItem::holdsDimensionalData() const bool DatafileItem::holdsDimensionalData() const
{ {
return nativeDataUnits() != "bin"; const Frame& frame = dataItem()->c_field()->frame();
for (size_t k = 0; k < frame.rank(); k++)
if (frame.axis(k).unit() != "bin")
return true;
return false;
} }
const Datafield* DatafileItem::nativeDatafield() const const Datafield* DatafileItem::nativeDatafield() const
...@@ -397,5 +398,4 @@ void DatafileItem::updateToInstrument(const InstrumentItem* instrument) ...@@ -397,5 +398,4 @@ void DatafileItem::updateToInstrument(const InstrumentItem* instrument)
auto* data_source = native_data_item ? native_data_item : data_item; auto* data_source = native_data_item ? native_data_item : data_item;
std::unique_ptr<Datafield> native_data(data_source->c_field()->clone()); std::unique_ptr<Datafield> native_data(data_source->c_field()->clone());
const QString units_label = nativeDataUnits();
} }
...@@ -58,7 +58,6 @@ public: ...@@ -58,7 +58,6 @@ public:
DataItem* initNativeData(); DataItem* initNativeData();
QString nativeDataUnits() const;
bool holdsDimensionalData() const; bool holdsDimensionalData() const;
const Datafield* nativeDatafield() const; const Datafield* nativeDatafield() const;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "Base/Axis/Scale.h" #include "Base/Axis/Scale.h"
#include "Base/Const/Units.h" #include "Base/Const/Units.h"
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "Base/Util/ConversionUtil.h"
#include "Device/Beam/Beam.h" #include "Device/Beam/Beam.h"
#include "Device/Beam/IFootprint.h" #include "Device/Beam/IFootprint.h"
#include "Device/Data/Datafield.h" #include "Device/Data/Datafield.h"
...@@ -371,14 +372,14 @@ void SpecularInstrumentItem::updateToRealData(const DatafileItem* item) ...@@ -371,14 +372,14 @@ void SpecularInstrumentItem::updateToRealData(const DatafileItem* item)
if (shape().size() != item->shape().size()) if (shape().size() != item->shape().size())
throw std::runtime_error("Specular instrument type is incompatible with passed data shape"); throw std::runtime_error("Specular instrument type is incompatible with passed data shape");
const auto& data = item->nativeDatafield()->axis(0); const auto& dataAxis = item->nativeDatafield()->axis(0);
scanItem()->updateToData(data, item->nativeDataUnits(), makeFrame()); scanItem()->updateToData(dataAxis);
scanItem()->grazingScanItem()->updateAxIndicators(makeFrame());
} }
bool SpecularInstrumentItem::alignedWith(const DatafileItem* item) const bool SpecularInstrumentItem::alignedWith(const DatafileItem* item) const
{ {
const QString native_units = item->nativeDataUnits(); if (!item->holdsDimensionalData())
if (native_units == "bin")
return scanItem()->grazingScanItem()->uniformAlphaAxisSelected() return scanItem()->grazingScanItem()->uniformAlphaAxisSelected()
&& shape() == item->shape(); && shape() == item->shape();
...@@ -389,9 +390,6 @@ bool SpecularInstrumentItem::alignedWith(const DatafileItem* item) const ...@@ -389,9 +390,6 @@ bool SpecularInstrumentItem::alignedWith(const DatafileItem* item) const
dynamic_cast<const PointwiseAxisItem*>(scanItem()->grazingScanItem()->alphaAxisItem()); dynamic_cast<const PointwiseAxisItem*>(scanItem()->grazingScanItem()->alphaAxisItem());
ASSERT(axisItem); ASSERT(axisItem);
if (axisItem->nativeAxisUnits() != native_units)
return false;
const auto* instrumentAxis = axisItem->axis(); const auto* instrumentAxis = axisItem->axis();
if (!instrumentAxis) if (!instrumentAxis)
return false; return false;
...@@ -410,15 +408,23 @@ Frame SpecularInstrumentItem::makeFrame() const ...@@ -410,15 +408,23 @@ Frame SpecularInstrumentItem::makeFrame() const
auto* axis_item = scanItem()->inclinationAxisItem(); auto* axis_item = scanItem()->inclinationAxisItem();
if (auto* pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) { if (auto* pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) {
if (!pointwise_axis->axis()) // workaround for loading project const Scale* pAxis = pointwise_axis->axis();
if (!pAxis) // workaround for loading project
return Frame({}); return Frame({});
Scale* ax0 = pointwise_axis->axis()->clone();
if (pAxis->unit() == "1/nm") {
double l = scanItem()->wavelength();
Scale ax = pAxis->transformedScale(Coordinate("alpha_i", "rad").label(), [l](double x) {
return Convert::Refl::qz2alpha(l, x);
});
return Frame(std::move(ax.clone()));
}
Scale* ax0 = pAxis->clone();
std::vector<const Scale*> f{ax0}; std::vector<const Scale*> f{ax0};
return Frame(f); return Frame(f);
} }
Scale axis = axis_item->makeScale("alpha_i (rad)"); Scale axis = axis_item->makeScale("alpha_i (rad)");
std::vector<const Scale*> f{axis.clone()}; std::vector<const Scale*> f{axis.clone()};
return Frame(f); return Frame(f);
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "GUI/Model/Job/JobItem.h" #include "GUI/Model/Job/JobItem.h"
#include "Base/Axis/Frame.h" #include "Base/Axis/Frame.h"
#include "Base/Axis/Scale.h"
#include "Device/Data/Datafield.h" #include "Device/Data/Datafield.h"
#include "Device/Detector/IDetector.h" #include "Device/Detector/IDetector.h"
#include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h"
...@@ -329,12 +330,15 @@ void JobItem::copyDatafileItemIntoJob(const DatafileItem* srcDatafileItem) ...@@ -329,12 +330,15 @@ void JobItem::copyDatafileItemIntoJob(const DatafileItem* srcDatafileItem)
createDatafileItem(); createDatafileItem();
srcDatafileItem->copyTo(realItem()); srcDatafileItem->copyTo(realItem());
// override axes units of simulated data if (rank() == 1) {
ASSERT(m_simulatedDataItem);
// m_simulatedDataItem->setCurrentCoord(m_realItem->dataItem()->currentCoord());
if (rank() == 1)
m_realItem->data1DItem()->setRealPlotStyle(); m_realItem->data1DItem()->setRealPlotStyle();
// coords of loaded data --> instrumental --> representation coords
const Datafield* old = m_realItem->data1DItem()->c_field();
Frame frame = instrumentItem()->makeFrame();
m_realItem->data1DItem()->setDatafield(
{frame.clone(), old->flatVector(), old->errorSigmas()});
}
} }
DatafileItem* JobItem::realItem() DatafileItem* JobItem::realItem()
......
...@@ -65,6 +65,13 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) ...@@ -65,6 +65,13 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document)
// Initial state // Initial state
createWidgetsForCurrentInstrument(); createWidgetsForCurrentInstrument();
subscribeOnExternalUpdates();
}
void InstrumentView::subscribeOnExternalUpdates()
{
connect(m_document->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this,
&InstrumentView::onInstrumentChangedFromExternal, Qt::UniqueConnection);
} }
void InstrumentView::showEvent(QShowEvent*) void InstrumentView::showEvent(QShowEvent*)
...@@ -80,8 +87,7 @@ void InstrumentView::hideEvent(QHideEvent*) ...@@ -80,8 +87,7 @@ void InstrumentView::hideEvent(QHideEvent*)
{ {
// when the instrument view gets hidden (meaning another view is shown), it's necessary to // when the instrument view gets hidden (meaning another view is shown), it's necessary to
// listen to changes (e.g. performed by the LinkInstrumentManager). // listen to changes (e.g. performed by the LinkInstrumentManager).
connect(m_document->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, subscribeOnExternalUpdates();
&InstrumentView::onInstrumentChangedFromExternal);
} }
void InstrumentView::createWidgetsForCurrentInstrument() void InstrumentView::createWidgetsForCurrentInstrument()
......
...@@ -34,6 +34,7 @@ private: ...@@ -34,6 +34,7 @@ private:
void showEvent(QShowEvent*) override; void showEvent(QShowEvent*) override;
void hideEvent(QHideEvent*) override; void hideEvent(QHideEvent*) override;
void subscribeOnExternalUpdates();
void createWidgetsForCurrentInstrument(); void createWidgetsForCurrentInstrument();
void onInstrumentNameEdited(const QString& newName); void onInstrumentNameEdited(const QString& newName);
void onInstrumentdescriptionEdited(const QString& t); void onInstrumentdescriptionEdited(const QString& t);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "Base/Axis/MakeScale.h" #include "Base/Axis/MakeScale.h"
#include "Base/Axis/Scale.h" #include "Base/Axis/Scale.h"
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "Base/Util/ConversionUtil.h"
#include "Device/Pol/PolFilter.h" #include "Device/Pol/PolFilter.h"
#include "Param/Distrib/Distributions.h" #include "Param/Distrib/Distributions.h"
#include "Param/Distrib/ParameterSample.h" #include "Param/Distrib/ParameterSample.h"
...@@ -141,9 +142,7 @@ void QzScan::createBeams() ...@@ -141,9 +142,7 @@ void QzScan::createBeams()
m_beams.clear(); m_beams.clear();
for (size_t i = 0; i < nScan(); i++) { for (size_t i = 0; i < nScan(); i++) {
// Qz scan is internally understood as wavelength scan // Qz scan is internally understood as wavelength scan
// TODO use some shared function "qz2lambda" double lambda = Convert::Refl::qz2lambda(defaultInclination, m_axis->binCenter(i));
double lambda =
4.0 * std::numbers::pi * std::sin(defaultInclination) / m_axis->binCenter(i);
Beam* beam = new Beam(defaultIntensity, lambda, defaultInclination); Beam* beam = new Beam(defaultIntensity, lambda, defaultInclination);
// Since the grazing geometry is not clear in q-space, the footprint should not be used // Since the grazing geometry is not clear in q-space, the footprint should not be used
beam->setFootprint(nullptr); beam->setFootprint(nullptr);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "Base/Axis/MakeScale.h" #include "Base/Axis/MakeScale.h"
#include "Base/Axis/Scale.h" #include "Base/Axis/Scale.h"
#include "Base/Const/Units.h" #include "Base/Const/Units.h"
#include "Base/Util/ConversionUtil.h"
#include "Device/Beam/Beam.h" #include "Device/Beam/Beam.h"
#include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintGauss.h"
#include "Device/Beam/FootprintSquare.h" #include "Device/Beam/FootprintSquare.h"
...@@ -288,7 +289,7 @@ BeamScan* test::makeSimulation::BasicSpecularScan(bool vsQ) ...@@ -288,7 +289,7 @@ BeamScan* test::makeSimulation::BasicSpecularScan(bool vsQ)
auto angles = angle_axis.binCenters(); auto angles = angle_axis.binCenters();
std::vector<double> qs(angle_axis.size(), 0.0); std::vector<double> qs(angle_axis.size(), 0.0);
for (size_t i = 0, size = qs.size(); i < size; ++i) for (size_t i = 0, size = qs.size(); i < size; ++i)
qs[i] = 4.0 * pi * std::sin(angles[i]) / wavelength; qs[i] = Convert::Refl::qz(angles[i], wavelength);
return new QzScan(qs); return new QzScan(qs);
} }
auto* result = new AlphaScan(EquiScan("alpha_i (rad)", n, max_angle / n, max_angle)); auto* result = new AlphaScan(EquiScan("alpha_i (rad)", n, max_angle / n, max_angle));
......