From 00ed4fc11dd5c0835902879a78a8abede64d7c99 Mon Sep 17 00:00:00 2001 From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de> Date: Tue, 22 Nov 2022 18:42:48 +0100 Subject: [PATCH] AxisPropertyEditor: nbins replaced --- GUI/Model/Descriptor/AxisProperty.cpp | 10 ++++++++++ GUI/Model/Descriptor/AxisProperty.h | 6 ++++++ GUI/View/Instrument/AxisPropertyEditor.cpp | 10 ++++++++-- GUI/View/Instrument/AxisPropertyEditor.h | 3 ++- GUI/View/Instrument/DepthProbeInstrumentEditor.cpp | 5 ++++- GUI/View/Instrument/OffspecBeamEditor.cpp | 5 ++++- GUI/View/Instrument/SphericalDetectorEditor.cpp | 10 ++++++++-- 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/GUI/Model/Descriptor/AxisProperty.cpp b/GUI/Model/Descriptor/AxisProperty.cpp index 78e8aa34195..594d48733b9 100644 --- a/GUI/Model/Descriptor/AxisProperty.cpp +++ b/GUI/Model/Descriptor/AxisProperty.cpp @@ -54,3 +54,13 @@ void AxisProperty::rwAxisProperty(Streamer& s, const QString& tag) Serialize::rwProperty(s, m_max); s.finish(tag); } + +uint AxisProperty::NEW_nbins() const +{ + return m_nbins_NEW; +} + +void AxisProperty::NEW_setNbins(uint value) +{ + m_nbins_NEW = value; +} diff --git a/GUI/Model/Descriptor/AxisProperty.h b/GUI/Model/Descriptor/AxisProperty.h index d683b6b2d3f..8318c963d9c 100644 --- a/GUI/Model/Descriptor/AxisProperty.h +++ b/GUI/Model/Descriptor/AxisProperty.h @@ -57,6 +57,12 @@ public: std::unique_ptr<FixedBinAxis> createAxis(double scaleFactor) const; void rwAxisProperty(Streamer& s, const QString& tag); + + uint NEW_nbins() const; + void NEW_setNbins(uint value); + +private: + uint m_nbins_NEW = 100; }; // clang-format off diff --git a/GUI/View/Instrument/AxisPropertyEditor.cpp b/GUI/View/Instrument/AxisPropertyEditor.cpp index 89fcc8d8580..f59136680e4 100644 --- a/GUI/View/Instrument/AxisPropertyEditor.cpp +++ b/GUI/View/Instrument/AxisPropertyEditor.cpp @@ -22,7 +22,8 @@ #include <QSpinBox> AxisPropertyEditor::AxisPropertyEditor(QWidget* parent, const QString& groupTitle, - AxisProperty* axisProperty) + AxisProperty* axisProperty, QString nbinsTooltip, + QString minTooltip, QString maxTooltip) : QGroupBox(groupTitle, parent) , m_axisProperty(axisProperty) { @@ -30,7 +31,12 @@ AxisPropertyEditor::AxisPropertyEditor(QWidget* parent, const QString& groupTitl auto* formLayout = new QFormLayout(this); formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); - m_nbinsSpinBox = GUI::Util::createSpinBoxRow(formLayout, axisProperty->nbins()); + m_nbinsSpinBox = GUI::Util::createIntSpinbox([=] { return axisProperty->NEW_nbins(); }, + [=](int v) { axisProperty->NEW_setNbins(static_cast<uint>(v)); }, nullptr /*updaters*/, + nbinsTooltip, RealLimits::nonnegative()); + formLayout->addRow(GUI::Util::labelWithUnit("Nbins", "nbins") + ":", m_nbinsSpinBox); + + m_minSpinBox = GUI::Util::createDoubleSpinBoxRow(formLayout, axisProperty->min()); m_maxSpinBox = GUI::Util::createDoubleSpinBoxRow(formLayout, axisProperty->max()); diff --git a/GUI/View/Instrument/AxisPropertyEditor.h b/GUI/View/Instrument/AxisPropertyEditor.h index 83c91c3902d..ca3dbcc07e8 100644 --- a/GUI/View/Instrument/AxisPropertyEditor.h +++ b/GUI/View/Instrument/AxisPropertyEditor.h @@ -29,7 +29,8 @@ class DoubleSpinBox; class AxisPropertyEditor : public QGroupBox { Q_OBJECT public: - AxisPropertyEditor(QWidget* parent, const QString& groupTitle, AxisProperty* axisProperty); + AxisPropertyEditor(QWidget* parent, const QString& groupTitle, AxisProperty* axisProperty, + QString nbinsTooltip = "", QString minTooltip = "", QString maxTooltip = ""); //! Reload UI from data void updateData(); diff --git a/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp b/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp index 0ac9b50f0b5..c5201ff15dc 100644 --- a/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp +++ b/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp @@ -46,7 +46,10 @@ DepthProbeInstrumentEditor::DepthProbeInstrumentEditor(QWidget* parent, new InclinationAnglesEditor(this, instrument->beamItem()->inclinationAngleItem()); vLayout->addWidget(inclinationEditor); - auto* depthAxisEditor = new AxisPropertyEditor(this, "Depth axis", &instrument->zAxis()); + auto* depthAxisEditor = new AxisPropertyEditor(this, "Depth axis", &instrument->zAxis(), + "Number of points in scan across sample bulk", + "Starting value below sample horizon", + "Ending value above sample horizon"); vLayout->addWidget(depthAxisEditor); GroupBoxCollapser::installIntoGroupBox(parametersGroupBox); diff --git a/GUI/View/Instrument/OffspecBeamEditor.cpp b/GUI/View/Instrument/OffspecBeamEditor.cpp index c51581854ec..dda9aec60e8 100644 --- a/GUI/View/Instrument/OffspecBeamEditor.cpp +++ b/GUI/View/Instrument/OffspecBeamEditor.cpp @@ -49,7 +49,10 @@ OffspecBeamEditor::OffspecBeamEditor(QWidget* parent, OffspecInstrumentItem* ite item->beamItem()->wavelengthItem()); vLayout->addWidget(wavelengthEditor); - auto* inclinationEditor = new AxisPropertyEditor(this, "Inclination angle", &item->alphaAxis()); + auto* inclinationEditor = new AxisPropertyEditor(this, "Inclination angle", &item->alphaAxis(), + "Number of points in scan", + "Starting value", + "Ending value"); vLayout->addWidget(inclinationEditor); auto* azimuthalEditor = diff --git a/GUI/View/Instrument/SphericalDetectorEditor.cpp b/GUI/View/Instrument/SphericalDetectorEditor.cpp index 1d8df1ab4f9..9438763c0ca 100644 --- a/GUI/View/Instrument/SphericalDetectorEditor.cpp +++ b/GUI/View/Instrument/SphericalDetectorEditor.cpp @@ -27,10 +27,16 @@ SphericalDetectorEditor::SphericalDetectorEditor(QWidget* parent, SphericalDetec grid->setColumnStretch(1, 1); grid->setColumnStretch(2, 1); - auto* phiAxisEditor = new AxisPropertyEditor(this, u8"\u03c6 axis", &item->phiAxis()); + auto* phiAxisEditor = new AxisPropertyEditor(this, u8"\u03c6 axis", &item->phiAxis(), + "Number of phi-axis bins", + "Lower edge of first phi-bin", + "Upper edge of last phi-bin"); grid->addWidget(phiAxisEditor, 1, 0); - auto* alphaAxisEditor = new AxisPropertyEditor(this, u8"\u03b1 axis", &item->alphaAxis()); + auto* alphaAxisEditor = new AxisPropertyEditor(this, u8"\u03b1 axis", &item->alphaAxis(), + "Number of alpha-axis bins", + "Lower edge of first alpha-bin", + "Upper edge of last alpha-bin"); grid->addWidget(alphaAxisEditor, 1, 1); auto* resolutionFunctionEditor = -- GitLab