From fd7c48efa725df952f06a4fe124d238b297e73e3 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Thu, 24 Nov 2022 15:49:43 +0100
Subject: [PATCH 1/4] AxisPropertyEditor: rm tooltips for double properties

---
 GUI/View/Instrument/AxisPropertyEditor.cpp         | 3 +--
 GUI/View/Instrument/AxisPropertyEditor.h           | 2 +-
 GUI/View/Instrument/DepthProbeInstrumentEditor.cpp | 3 +--
 GUI/View/Instrument/OffspecBeamEditor.cpp          | 2 +-
 GUI/View/Instrument/SphericalDetectorEditor.cpp    | 6 ++----
 5 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/GUI/View/Instrument/AxisPropertyEditor.cpp b/GUI/View/Instrument/AxisPropertyEditor.cpp
index 1c0c37ed60f..22c5aedcb1d 100644
--- a/GUI/View/Instrument/AxisPropertyEditor.cpp
+++ b/GUI/View/Instrument/AxisPropertyEditor.cpp
@@ -22,8 +22,7 @@
 #include <QSpinBox>
 
 AxisPropertyEditor::AxisPropertyEditor(QWidget* parent, const QString& groupTitle,
-                                       AxisProperty* axisProperty, QString nbinsTooltip,
-                                       QString /*minTooltip*/, QString /*maxTooltip*/)
+                                       AxisProperty* axisProperty, QString nbinsTooltip)
     : QGroupBox(groupTitle, parent)
     , m_axisProperty(axisProperty)
 {
diff --git a/GUI/View/Instrument/AxisPropertyEditor.h b/GUI/View/Instrument/AxisPropertyEditor.h
index ca3dbcc07e8..9fcc61e2a33 100644
--- a/GUI/View/Instrument/AxisPropertyEditor.h
+++ b/GUI/View/Instrument/AxisPropertyEditor.h
@@ -30,7 +30,7 @@ class AxisPropertyEditor : public QGroupBox {
     Q_OBJECT
 public:
     AxisPropertyEditor(QWidget* parent, const QString& groupTitle, AxisProperty* axisProperty,
-                       QString nbinsTooltip = "", QString minTooltip = "", QString maxTooltip = "");
+                       QString nbinsTooltip = "");
 
     //! Reload UI from data
     void updateData();
diff --git a/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp b/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp
index 2bc823379f2..32d82c3764e 100644
--- a/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp
+++ b/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp
@@ -47,8 +47,7 @@ DepthProbeInstrumentEditor::DepthProbeInstrumentEditor(QWidget* parent,
     vLayout->addWidget(inclinationEditor);
 
     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");
+        this, "Depth axis", &instrument->zAxis(), "Number of points in scan across sample bulk");
     vLayout->addWidget(depthAxisEditor);
 
     GroupBoxCollapser::installIntoGroupBox(parametersGroupBox);
diff --git a/GUI/View/Instrument/OffspecBeamEditor.cpp b/GUI/View/Instrument/OffspecBeamEditor.cpp
index 1a52bc3db43..7f7ef3e46f5 100644
--- a/GUI/View/Instrument/OffspecBeamEditor.cpp
+++ b/GUI/View/Instrument/OffspecBeamEditor.cpp
@@ -51,7 +51,7 @@ OffspecBeamEditor::OffspecBeamEditor(QWidget* parent, OffspecInstrumentItem* ite
 
     auto* inclinationEditor =
         new AxisPropertyEditor(this, "Inclination angle", &item->alphaAxis(),
-                               "Number of points in scan", "Starting value", "Ending value");
+                               "Number of points in scan");
     vLayout->addWidget(inclinationEditor);
 
     auto* azimuthalEditor =
diff --git a/GUI/View/Instrument/SphericalDetectorEditor.cpp b/GUI/View/Instrument/SphericalDetectorEditor.cpp
index 38d9870f9a5..14f9ef2c83a 100644
--- a/GUI/View/Instrument/SphericalDetectorEditor.cpp
+++ b/GUI/View/Instrument/SphericalDetectorEditor.cpp
@@ -28,13 +28,11 @@ SphericalDetectorEditor::SphericalDetectorEditor(QWidget* parent, SphericalDetec
     grid->setColumnStretch(2, 1);
 
     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");
+        new AxisPropertyEditor(this, u8"\u03c6 axis", &item->phiAxis(), "Number of phi-axis bins");
     grid->addWidget(phiAxisEditor, 1, 0);
 
     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");
+        this, u8"\u03b1 axis", &item->alphaAxis(), "Number of alpha-axis bins");
     grid->addWidget(alphaAxisEditor, 1, 1);
 
     auto* resolutionFunctionEditor =
-- 
GitLab


From dc7c37d77aa57225cc6d2c25671e43760cba1ba0 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Thu, 24 Nov 2022 17:39:17 +0100
Subject: [PATCH 2/4] ParticleLayoutItem: eliminate totalDensity descriptor

---
 GUI/Model/Sample/ParticleLayoutItem.cpp        | 13 -------------
 GUI/Model/Sample/ParticleLayoutItem.h          |  5 ++---
 GUI/Model/ToCore/SampleToCore.cpp              |  2 +-
 GUI/View/Realspace/RealspaceBuilder.cpp        |  2 +-
 GUI/View/SampleDesigner/ParticleLayoutForm.cpp |  5 ++++-
 5 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/GUI/Model/Sample/ParticleLayoutItem.cpp b/GUI/Model/Sample/ParticleLayoutItem.cpp
index edef14c9b14..ee630d166e8 100644
--- a/GUI/Model/Sample/ParticleLayoutItem.cpp
+++ b/GUI/Model/Sample/ParticleLayoutItem.cpp
@@ -47,19 +47,6 @@ DoubleDescriptor ParticleLayoutItem::ownDensity() const
     return m_ownDensity;
 }
 
-DoubleDescriptor ParticleLayoutItem::totalDensity() const
-{
-    // create descriptor with same value as own density, then change the getter and setter
-    DoubleDescriptor d = ownDensity();
-    d.set = [=](double d) {
-        if (!totalDensityIsDefinedByInterference())
-            const_cast<DoubleProperty*>(&m_ownDensity)->set(d);
-    };
-    d.get = [=]() { return totalDensityValue(); };
-    d.path = [=]() { return m_ownDensity.uid() + "/totalDensity"; };
-    return d;
-}
-
 double ParticleLayoutItem::totalDensityValue() const
 {
     if (!totalDensityIsDefinedByInterference())
diff --git a/GUI/Model/Sample/ParticleLayoutItem.h b/GUI/Model/Sample/ParticleLayoutItem.h
index 47bde686101..f461e2d879a 100644
--- a/GUI/Model/Sample/ParticleLayoutItem.h
+++ b/GUI/Model/Sample/ParticleLayoutItem.h
@@ -34,14 +34,13 @@ public:
     //!
     //! This is the editable value. If an interference is present, this value may not be the one to
     //! be used for building the domain layout or to be presented. For the correct value-to-use,
-    //! whether an interference is present or not, use totalDensity().
+    //! whether an interference is present or not, use totalDensityValue().
     DoubleDescriptor ownDensity() const;
 
     //! The real density.
     //!
-    //! Returns ownDensity() if the interference is not influencing the density. If the
+    //! Returns ownDensity() value if the interference is not influencing the density. If the
     //! interference is defining the density, this is the interference-calculated density.
-    DoubleDescriptor totalDensity() const;
     double totalDensityValue() const;
 
     //! The particles this layout contains.
diff --git a/GUI/Model/ToCore/SampleToCore.cpp b/GUI/Model/ToCore/SampleToCore.cpp
index e904fbee0a9..afc563838ce 100644
--- a/GUI/Model/ToCore/SampleToCore.cpp
+++ b/GUI/Model/ToCore/SampleToCore.cpp
@@ -59,7 +59,7 @@ std::unique_ptr<Layer> createLayer(const LayerItem& item)
 std::unique_ptr<ParticleLayout> createParticleLayout(const ParticleLayoutItem& item)
 {
     auto layout = std::make_unique<ParticleLayout>();
-    double total_density = item.totalDensity();
+    double total_density = item.totalDensityValue();
     layout->setTotalParticleSurfaceDensity(total_density);
     return layout;
 }
diff --git a/GUI/View/Realspace/RealspaceBuilder.cpp b/GUI/View/Realspace/RealspaceBuilder.cpp
index d7c78594145..ad7e4b6c22c 100644
--- a/GUI/View/Realspace/RealspaceBuilder.cpp
+++ b/GUI/View/Realspace/RealspaceBuilder.cpp
@@ -164,7 +164,7 @@ void RealspaceBuilder::populateLayout(Model* model, const ParticleLayoutItem& la
         return;
 
     double layer_size = sceneGeometry.layerSize;
-    double total_density = layoutItem.totalDensity();
+    double total_density = layoutItem.totalDensityValue();
 
     auto particle3DContainer_vector = particle3DContainerVector(layoutItem, origin);
     auto* interferenceItem = layoutItem.interference().currentItem();
diff --git a/GUI/View/SampleDesigner/ParticleLayoutForm.cpp b/GUI/View/SampleDesigner/ParticleLayoutForm.cpp
index 72bb61a7f39..60422ab56b3 100644
--- a/GUI/View/SampleDesigner/ParticleLayoutForm.cpp
+++ b/GUI/View/SampleDesigner/ParticleLayoutForm.cpp
@@ -36,7 +36,7 @@ ParticleLayoutForm::ParticleLayoutForm(LayerForm* parent, ParticleLayoutItem* la
 {
     FormLayouter layouter(this, ec);
     layouter.setContentsMargins(30, 6, 0, 0);
-    int rowOfTotalDensity = layouter.addValue(m_layoutItem->totalDensity());
+    int rowOfTotalDensity = layouter.addValue(m_layoutItem->ownDensity());
     m_totalDensitySpinBox =
         layouter.widgetAt<DoubleSpinBox*>(rowOfTotalDensity, QFormLayout::FieldRole);
     ASSERT(m_totalDensitySpinBox);
@@ -105,6 +105,9 @@ void ParticleLayoutForm::updateDensityEnabling()
 
 void ParticleLayoutForm::updateDensityValue()
 {
+    if(m_layoutItem->totalDensityIsDefinedByInterference())
+        m_layoutItem->ownDensity().set(m_layoutItem->totalDensityValue());
+
     m_totalDensitySpinBox->updateValue();
 }
 
-- 
GitLab


From 34cc59dfe19b8b92210c759465e0c71f8efcb9b8 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Thu, 24 Nov 2022 17:39:45 +0100
Subject: [PATCH 3/4] clang-format

---
 GUI/View/Instrument/DepthProbeInstrumentEditor.cpp | 4 ++--
 GUI/View/Instrument/OffspecBeamEditor.cpp          | 5 ++---
 GUI/View/Instrument/SphericalDetectorEditor.cpp    | 4 ++--
 GUI/View/SampleDesigner/ParticleLayoutForm.cpp     | 2 +-
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp b/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp
index 32d82c3764e..07df7fe89a8 100644
--- a/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp
+++ b/GUI/View/Instrument/DepthProbeInstrumentEditor.cpp
@@ -46,8 +46,8 @@ DepthProbeInstrumentEditor::DepthProbeInstrumentEditor(QWidget* parent,
         new InclinationAnglesEditor(this, instrument->beamItem()->inclinationAngleItem());
     vLayout->addWidget(inclinationEditor);
 
-    auto* depthAxisEditor = new AxisPropertyEditor(
-        this, "Depth axis", &instrument->zAxis(), "Number of points in scan across sample bulk");
+    auto* depthAxisEditor = new AxisPropertyEditor(this, "Depth axis", &instrument->zAxis(),
+                                                   "Number of points in scan across sample bulk");
     vLayout->addWidget(depthAxisEditor);
 
     GroupBoxCollapser::installIntoGroupBox(parametersGroupBox);
diff --git a/GUI/View/Instrument/OffspecBeamEditor.cpp b/GUI/View/Instrument/OffspecBeamEditor.cpp
index 7f7ef3e46f5..2dd49ad2486 100644
--- a/GUI/View/Instrument/OffspecBeamEditor.cpp
+++ b/GUI/View/Instrument/OffspecBeamEditor.cpp
@@ -49,9 +49,8 @@ OffspecBeamEditor::OffspecBeamEditor(QWidget* parent, OffspecInstrumentItem* ite
                                item->beamItem()->wavelengthItem());
     vLayout->addWidget(wavelengthEditor);
 
-    auto* inclinationEditor =
-        new AxisPropertyEditor(this, "Inclination angle", &item->alphaAxis(),
-                               "Number of points in scan");
+    auto* inclinationEditor = new AxisPropertyEditor(this, "Inclination angle", &item->alphaAxis(),
+                                                     "Number of points in scan");
     vLayout->addWidget(inclinationEditor);
 
     auto* azimuthalEditor =
diff --git a/GUI/View/Instrument/SphericalDetectorEditor.cpp b/GUI/View/Instrument/SphericalDetectorEditor.cpp
index 14f9ef2c83a..630665c2991 100644
--- a/GUI/View/Instrument/SphericalDetectorEditor.cpp
+++ b/GUI/View/Instrument/SphericalDetectorEditor.cpp
@@ -31,8 +31,8 @@ SphericalDetectorEditor::SphericalDetectorEditor(QWidget* parent, SphericalDetec
         new AxisPropertyEditor(this, u8"\u03c6 axis", &item->phiAxis(), "Number of phi-axis bins");
     grid->addWidget(phiAxisEditor, 1, 0);
 
-    auto* alphaAxisEditor = new AxisPropertyEditor(
-        this, u8"\u03b1 axis", &item->alphaAxis(), "Number of alpha-axis bins");
+    auto* alphaAxisEditor = new AxisPropertyEditor(this, u8"\u03b1 axis", &item->alphaAxis(),
+                                                   "Number of alpha-axis bins");
     grid->addWidget(alphaAxisEditor, 1, 1);
 
     auto* resolutionFunctionEditor =
diff --git a/GUI/View/SampleDesigner/ParticleLayoutForm.cpp b/GUI/View/SampleDesigner/ParticleLayoutForm.cpp
index 60422ab56b3..1d3b09e5f09 100644
--- a/GUI/View/SampleDesigner/ParticleLayoutForm.cpp
+++ b/GUI/View/SampleDesigner/ParticleLayoutForm.cpp
@@ -105,7 +105,7 @@ void ParticleLayoutForm::updateDensityEnabling()
 
 void ParticleLayoutForm::updateDensityValue()
 {
-    if(m_layoutItem->totalDensityIsDefinedByInterference())
+    if (m_layoutItem->totalDensityIsDefinedByInterference())
         m_layoutItem->ownDensity().set(m_layoutItem->totalDensityValue());
 
     m_totalDensitySpinBox->updateValue();
-- 
GitLab


From 4b4bb2659b2528ff37b7d36a774a5c74e919dac7 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Thu, 24 Nov 2022 18:00:18 +0100
Subject: [PATCH 4/4] SampleToCore: merge lines

---
 GUI/Model/ToCore/SampleToCore.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/GUI/Model/ToCore/SampleToCore.cpp b/GUI/Model/ToCore/SampleToCore.cpp
index afc563838ce..b9616699450 100644
--- a/GUI/Model/ToCore/SampleToCore.cpp
+++ b/GUI/Model/ToCore/SampleToCore.cpp
@@ -59,8 +59,7 @@ std::unique_ptr<Layer> createLayer(const LayerItem& item)
 std::unique_ptr<ParticleLayout> createParticleLayout(const ParticleLayoutItem& item)
 {
     auto layout = std::make_unique<ParticleLayout>();
-    double total_density = item.totalDensityValue();
-    layout->setTotalParticleSurfaceDensity(total_density);
+    layout->setTotalParticleSurfaceDensity(item.totalDensityValue());
     return layout;
 }
 
-- 
GitLab