From 257e03c856f1e8ef0fc98b8bcad18e295d7846d2 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Wed, 13 Mar 2024 08:46:16 +0100 Subject: [PATCH] AxesPanel::updatePanel complete --- GUI/View/Setup/AxesPanel.cpp | 34 +++++++++++++++++----------------- GUI/View/Setup/AxisPanel.cpp | 7 ++++--- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/GUI/View/Setup/AxesPanel.cpp b/GUI/View/Setup/AxesPanel.cpp index d50f36d2399..d77087d0879 100644 --- a/GUI/View/Setup/AxesPanel.cpp +++ b/GUI/View/Setup/AxesPanel.cpp @@ -17,6 +17,7 @@ #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h" #include "GUI/Model/Data/Data2DItem.h" +#include "GUI/Model/Files/DatafilesSet.h" #include "GUI/Model/Job/DataSource.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Support/Data/ComboProperty.h" @@ -39,14 +40,6 @@ AxesPanel::AxesPanel(DataSource* ds) layout->setContentsMargins(8, 20, 8, 8); layout->setSpacing(5); - if (m_data_source->allData2DItems().empty()) - return; - - for (auto* item : m_data_source->allData2DItems()) - disconnect(item, nullptr, this, nullptr); - - m_updaters.clear(); - layout->addRow("Color scheme:", GUI::Util::createComboBox([this] { return *gApp->color_gradient_combo; }, [this](const QString& s) { @@ -186,11 +179,8 @@ AxesPanel::AxesPanel(DataSource* ds) layout->addRow(zGroup); - updateUIValues(); - - // react on external changes (e.g. zooming in customplot shall update the axis values) - connect(m_data_source->currentData2DItem(), &DataItem::itemAxesRangeChanged, this, - &AxesPanel::updateUIValues, Qt::UniqueConnection); + connect(gDoc->datafiles(), &DatafilesSet::setChanged, this, &AxesPanel::updatePanel); + updatePanel(); } AxesPanel::~AxesPanel() = default; @@ -200,11 +190,21 @@ Data2DItem* AxesPanel::dataItem() return m_data_source->currentData2DItem(); } -void AxesPanel::updatePanel() {} +void AxesPanel::updatePanel() +{ + if (dataItem()) { + // react on external changes (e.g. zooming in customplot shall update the axis values) + connect(m_data_source->currentData2DItem(), &DataItem::itemAxesRangeChanged, this, + &AxesPanel::updateUIValues, Qt::UniqueConnection); + updateUIValues(); + show(); + } else + hide(); +} void AxesPanel::updateUIValues() { - if (m_data_source->currentData2DItem()) - for (const auto& updater : m_updaters) - updater(); + ASSERT(dataItem()); + for (const auto& updater : m_updaters) + updater(); } diff --git a/GUI/View/Setup/AxisPanel.cpp b/GUI/View/Setup/AxisPanel.cpp index 428e9392904..19e6719dcea 100644 --- a/GUI/View/Setup/AxisPanel.cpp +++ b/GUI/View/Setup/AxisPanel.cpp @@ -145,6 +145,7 @@ void AxisPanel::updatePanel() for (auto* item : m_data_source->allData1DItems()) connect(item, &DataItem::axesUnitsChanged, this, &AxisPanel::updateItemCoords, Qt::UniqueConnection); + updateUIValues(); show(); } else hide(); @@ -161,7 +162,7 @@ void AxisPanel::updateItemCoords(DataItem* item) void AxisPanel::updateUIValues() { - if (dataItem()) - for (const auto& updater : m_updaters) - updater(); + ASSERT(dataItem()); + for (const auto& updater : m_updaters) + updater(); } -- GitLab