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

AxesPanel::updatePanel complete

parent 598717f7
No related branches found
No related tags found
1 merge request!2449restore axes panel
Pipeline #134175 passed
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h"
#include "GUI/Model/Axis/BasicAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h"
#include "GUI/Model/Data/Data2DItem.h" #include "GUI/Model/Data/Data2DItem.h"
#include "GUI/Model/Files/DatafilesSet.h"
#include "GUI/Model/Job/DataSource.h" #include "GUI/Model/Job/DataSource.h"
#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Project/ProjectDocument.h"
#include "GUI/Support/Data/ComboProperty.h" #include "GUI/Support/Data/ComboProperty.h"
...@@ -39,14 +40,6 @@ AxesPanel::AxesPanel(DataSource* ds) ...@@ -39,14 +40,6 @@ AxesPanel::AxesPanel(DataSource* ds)
layout->setContentsMargins(8, 20, 8, 8); layout->setContentsMargins(8, 20, 8, 8);
layout->setSpacing(5); 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:", layout->addRow("Color scheme:",
GUI::Util::createComboBox([this] { return *gApp->color_gradient_combo; }, GUI::Util::createComboBox([this] { return *gApp->color_gradient_combo; },
[this](const QString& s) { [this](const QString& s) {
...@@ -186,11 +179,8 @@ AxesPanel::AxesPanel(DataSource* ds) ...@@ -186,11 +179,8 @@ AxesPanel::AxesPanel(DataSource* ds)
layout->addRow(zGroup); layout->addRow(zGroup);
updateUIValues(); connect(gDoc->datafiles(), &DatafilesSet::setChanged, this, &AxesPanel::updatePanel);
updatePanel();
// 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);
} }
AxesPanel::~AxesPanel() = default; AxesPanel::~AxesPanel() = default;
...@@ -200,11 +190,21 @@ Data2DItem* AxesPanel::dataItem() ...@@ -200,11 +190,21 @@ Data2DItem* AxesPanel::dataItem()
return m_data_source->currentData2DItem(); 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() void AxesPanel::updateUIValues()
{ {
if (m_data_source->currentData2DItem()) ASSERT(dataItem());
for (const auto& updater : m_updaters) for (const auto& updater : m_updaters)
updater(); updater();
} }
...@@ -145,6 +145,7 @@ void AxisPanel::updatePanel() ...@@ -145,6 +145,7 @@ void AxisPanel::updatePanel()
for (auto* item : m_data_source->allData1DItems()) for (auto* item : m_data_source->allData1DItems())
connect(item, &DataItem::axesUnitsChanged, this, &AxisPanel::updateItemCoords, connect(item, &DataItem::axesUnitsChanged, this, &AxisPanel::updateItemCoords,
Qt::UniqueConnection); Qt::UniqueConnection);
updateUIValues();
show(); show();
} else } else
hide(); hide();
...@@ -161,7 +162,7 @@ void AxisPanel::updateItemCoords(DataItem* item) ...@@ -161,7 +162,7 @@ void AxisPanel::updateItemCoords(DataItem* item)
void AxisPanel::updateUIValues() void AxisPanel::updateUIValues()
{ {
if (dataItem()) ASSERT(dataItem());
for (const auto& updater : m_updaters) for (const auto& updater : m_updaters)
updater(); updater();
} }
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