From ecc8cc562d667be5e63f14829fa76d21f7a7f5ba Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Tue, 9 Jul 2024 17:25:25 +0200 Subject: [PATCH 1/3] add Reset button by Apply in the yaxis strategy selector #832 --- Source/GUI/Plot.cpp | 70 +++++++++++++++++++++------------------ Source/GUI/Plot.h | 1 + Source/GUI/Plots.cpp | 17 ++++++++++ Source/GUI/Plots.h | 2 ++ Source/GUI/mainwindow.cpp | 7 ++++ Source/GUI/mainwindow.h | 2 ++ Source/GUI/mainwindow.ui | 6 ++++ 7 files changed, 73 insertions(+), 32 deletions(-) diff --git a/Source/GUI/Plot.cpp b/Source/GUI/Plot.cpp index 74bbe4c34..23b9e61e2 100644 --- a/Source/GUI/Plot.cpp +++ b/Source/GUI/Plot.cpp @@ -526,6 +526,43 @@ bool Plot::isBarchart() const return m_barchart; } +void Plot::loadYAxisMinMaxMode() +{ + const struct per_group& group = PerStreamType[m_type].PerGroup[m_group]; + + auto applyYMinMaxMode = [&](QString value) { + QMetaEnum metaEnum = QMetaEnum::fromType(); + auto splitted = value.split(";"); + auto yMinMaxMode = (Plot::YMinMaxMode) metaEnum.keyToValue(splitted[0].toLatin1().constData()); + + if(yMinMaxMode == Plot::Custom) { + auto min = splitted[1].toDouble(); + auto max = splitted[2].toDouble(); + + setYAxisCustomMinMax(min, max); + } + + setYAxisMinMaxMode(yMinMaxMode); + }; + + if(group.YAxisMinMaxMode) { + QString yMinMaxModeStringValue = group.YAxisMinMaxMode; + qDebug() << "applying default yMinMaxMode: " << yMinMaxModeStringValue; + applyYMinMaxMode(yMinMaxModeStringValue); + } + + QSettings settings; + settings.beginGroup("yminmax"); + + QString value = settings.value(QString::number(m_group)).toString(); + if(!value.isEmpty()) { + qDebug() << "applying yMinMaxMode from settings: " << value; + applyYMinMaxMode(value); + } + + settings.endGroup(); +} + void Plot::setYAxisMinMaxMode(YMinMaxMode mode) { m_yminMaxMode = mode; @@ -813,38 +850,7 @@ Plot::Plot( size_t streamPos, size_t Type, size_t Group, const FileInformation* panner->setMouseButton( Qt::MiddleButton ); #endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - auto applyYMinMaxMode = [&](QString value) { - QMetaEnum metaEnum = QMetaEnum::fromType(); - auto splitted = value.split(";"); - auto yMinMaxMode = (Plot::YMinMaxMode) metaEnum.keyToValue(splitted[0].toLatin1().constData()); - - if(yMinMaxMode == Plot::Custom) { - auto min = splitted[1].toDouble(); - auto max = splitted[2].toDouble(); - - setYAxisCustomMinMax(min, max); - } - - setYAxisMinMaxMode(yMinMaxMode); - }; - - if(group.YAxisMinMaxMode) { - QString yMinMaxModeStringValue = group.YAxisMinMaxMode; - qDebug() << "applying default yMinMaxMode: " << yMinMaxModeStringValue; - applyYMinMaxMode(yMinMaxModeStringValue); - } - - QSettings settings; - settings.beginGroup("yminmax"); - - QString value = settings.value(QString::number(m_group)).toString(); - if(!value.isEmpty()) { - qDebug() << "applying yMinMaxMode from settings: " << value; - applyYMinMaxMode(value); - } - - settings.endGroup(); - + loadYAxisMinMaxMode(); } //--------------------------------------------------------------------------- diff --git a/Source/GUI/Plot.h b/Source/GUI/Plot.h index 0a06d8987..f2bccda3b 100644 --- a/Source/GUI/Plot.h +++ b/Source/GUI/Plot.h @@ -496,6 +496,7 @@ class Plot : public QwtPlot public Q_SLOTS: void initYAxis(); void setBarchart(bool value); + void loadYAxisMinMaxMode(); // default or from settings private Q_SLOTS: void onPickerMoved( const QPointF& ); diff --git a/Source/GUI/Plots.cpp b/Source/GUI/Plots.cpp index 37f90d0c2..dd21264f0 100755 --- a/Source/GUI/Plots.cpp +++ b/Source/GUI/Plots.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include //--------------------------------------------------------------------------- @@ -177,6 +179,8 @@ Plots::Plots( QWidget *parent, FileInformation* fileInformation ) : qDebug() << "Plot::visibilityChanged for " << plot << "visible: " << visible; }); + connect(this, &Plots::reloadYAxisMinMaxMode, plot, &Plot::loadYAxisMinMaxMode); + const size_t plotType = plot->type(); const size_t plotGroup = plot->group(); const CommonStats* stat = stats( plot->streamPos() ); @@ -1348,6 +1352,19 @@ void Plots::updatePlotsVisibility(const QMap> & visiblePlots); + void updatePlotsYAxisMinMaxMode(); const QwtPlot* plot( size_t streamPos, size_t group ) const; CommentsPlot* commentsPlot() const { return m_commentsPlot; } @@ -123,6 +124,7 @@ class Plots : public QWidget Q_SIGNALS: void visibleFramesChanged(int from, int to); void barchartProfileChanged(); + void reloadYAxisMinMaxMode(); public Q_SLOTS: void onCurrentFrameChanged(); diff --git a/Source/GUI/mainwindow.cpp b/Source/GUI/mainwindow.cpp index 3d417729b..8f18a0b77 100755 --- a/Source/GUI/mainwindow.cpp +++ b/Source/GUI/mainwindow.cpp @@ -1060,3 +1060,10 @@ void MainWindow::on_setupFilters_pushButton_clicked() m_plotsChooser->setGeometry(newGeometry); } } + +void MainWindow::on_actionReset_all_y_axis_ranges_to_default_triggered() +{ + if(PlotsArea) + PlotsArea->updatePlotsYAxisMinMaxMode(); +} + diff --git a/Source/GUI/mainwindow.h b/Source/GUI/mainwindow.h index 35f0e1479..1e21aa612 100755 --- a/Source/GUI/mainwindow.h +++ b/Source/GUI/mainwindow.h @@ -251,6 +251,8 @@ private Q_SLOTS: void on_setupFilters_pushButton_clicked(); + void on_actionReset_all_y_axis_ranges_to_default_triggered(); + protected: void closeEvent(QCloseEvent* event); void resizeEvent(QResizeEvent* event); diff --git a/Source/GUI/mainwindow.ui b/Source/GUI/mainwindow.ui index 3a2c4113c..39b4efaa9 100755 --- a/Source/GUI/mainwindow.ui +++ b/Source/GUI/mainwindow.ui @@ -167,6 +167,7 @@ + @@ -709,6 +710,11 @@ Show / hide filters panel + + + Reset all y-axis ranges to default + + From bc23c7badc744f2fd0e46b7133762fb5d2b236c3 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Thu, 11 Jul 2024 20:38:36 +0200 Subject: [PATCH 2/3] 'All Y-axis' to make it more explicit --- Source/GUI/Plots.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/GUI/Plots.cpp b/Source/GUI/Plots.cpp index dd21264f0..a3a9597d1 100755 --- a/Source/GUI/Plots.cpp +++ b/Source/GUI/Plots.cpp @@ -1354,7 +1354,7 @@ void Plots::updatePlotsVisibility(const QMap Date: Thu, 11 Jul 2024 20:49:07 +0200 Subject: [PATCH 3/3] allowe resetting individual y-axis for selected plot --- Source/GUI/yminmaxselector.cpp | 14 ++++++++++++ Source/GUI/yminmaxselector.h | 2 ++ Source/GUI/yminmaxselector.ui | 41 ++++++++++++++++++++-------------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/Source/GUI/yminmaxselector.cpp b/Source/GUI/yminmaxselector.cpp index a65fb6c96..262de64ff 100644 --- a/Source/GUI/yminmaxselector.cpp +++ b/Source/GUI/yminmaxselector.cpp @@ -193,3 +193,17 @@ void YMinMaxSelector::on_customMinMax_radioButton_clicked() updateMinMaxStyling(); } + +void YMinMaxSelector::on_reset_pushButton_clicked() +{ + QSettings settings; + settings.beginGroup("yminmax"); + settings.remove(QString::number(m_plot->group())); + settings.endGroup(); + + m_plot->setYAxisCustomMinMax(0, 0); + m_plot->loadYAxisMinMaxMode(); + m_plot->replot(); + hide(); +} + diff --git a/Source/GUI/yminmaxselector.h b/Source/GUI/yminmaxselector.h index 8f79e5f70..9f14e5d77 100644 --- a/Source/GUI/yminmaxselector.h +++ b/Source/GUI/yminmaxselector.h @@ -33,6 +33,8 @@ private Q_SLOTS: void on_minMaxSystemProvided_radioButton_clicked(); void on_customMinMax_radioButton_clicked(); + void on_reset_pushButton_clicked(); + private: void updateApplyButton(); void updateMinMaxStyling(); diff --git a/Source/GUI/yminmaxselector.ui b/Source/GUI/yminmaxselector.ui index ab399218d..51922a506 100644 --- a/Source/GUI/yminmaxselector.ui +++ b/Source/GUI/yminmaxselector.ui @@ -6,7 +6,7 @@ 0 0 - 550 + 579 192 @@ -17,7 +17,27 @@ true - + + + + Apply + + + + + + + Qt::Horizontal + + + + 132 + 20 + + + + + Set the y-axis range @@ -177,25 +197,12 @@ - + - Apply + Reset - - - - Qt::Horizontal - - - - 132 - 20 - - - -