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

[j.0] restore axes panel ()

Merging branch 'j.0'  into 'main'.

See merge request !2449
parents 95efa119 257e03c8
No related branches found
No related tags found
1 merge request!2449restore axes panel
Pipeline #134176 passed
......@@ -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,17 +179,32 @@ 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;
Data2DItem* AxesPanel::dataItem()
{
return m_data_source->currentData2DItem();
}
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()
{
ASSERT(dataItem());
for (const auto& updater : m_updaters)
updater();
}
......@@ -17,6 +17,7 @@
#include <QWidget>
class Data2DItem;
class DataSource;
//! Widget to edit properties of a Data2DItem.
......@@ -27,6 +28,8 @@ public:
~AxesPanel();
private:
Data2DItem* dataItem();
void updatePanel();
void updateUIValues();
QVector<std::function<void()>> m_updaters;
......
......@@ -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 (m_data_source->currentData1DItem())
for (const auto& updater : m_updaters)
updater();
ASSERT(dataItem());
for (const auto& updater : m_updaters)
updater();
}
......@@ -28,10 +28,9 @@ public:
AxisPanel(DataSource*);
~AxisPanel();
private:
Data1DItem* dataItem();
void updatePanel();
private:
void updateItemCoords(DataItem* item);
void updateUIValues();
......
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