From e6fa8fffdde8a5fc0b629b83682415c710a4b4e4 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Sat, 11 May 2024 15:49:11 +0200 Subject: [PATCH 1/6] give an option for a toggle button on graphs to change y-axis min/max #822 --- Project/QtCreator/qctools-gui/qctools-gui.pro | 9 +- Source/GUI/Plot.cpp | 87 +++++++++- Source/GUI/Plot.h | 19 +++ Source/GUI/Plots.cpp | 23 +++ Source/GUI/Plots.h | 4 + Source/GUI/yminmaxselector.cpp | 118 +++++++++++++ Source/GUI/yminmaxselector.h | 36 ++++ Source/GUI/yminmaxselector.ui | 155 ++++++++++++++++++ 8 files changed, 439 insertions(+), 12 deletions(-) create mode 100644 Source/GUI/yminmaxselector.cpp create mode 100644 Source/GUI/yminmaxselector.h create mode 100644 Source/GUI/yminmaxselector.ui diff --git a/Project/QtCreator/qctools-gui/qctools-gui.pro b/Project/QtCreator/qctools-gui/qctools-gui.pro index 2c7112ec7..320ab5611 100644 --- a/Project/QtCreator/qctools-gui/qctools-gui.pro +++ b/Project/QtCreator/qctools-gui/qctools-gui.pro @@ -75,7 +75,8 @@ HEADERS += \ $$SOURCES_PATH/GUI/filterselector.h \ $$SOURCES_PATH/GUI/playercontrol.h \ $$SOURCES_PATH/GUI/panelsview.h \ - $$SOURCES_PATH/GUI/plotschooser.h + $$SOURCES_PATH/GUI/plotschooser.h \ + $$SOURCES_PATH/GUI/yminmaxselector.h SOURCES += \ $$SOURCES_PATH/GUI/FilesList.cpp \ @@ -108,7 +109,8 @@ SOURCES += \ $$SOURCES_PATH/GUI/filterselector.cpp \ $$SOURCES_PATH/GUI/playercontrol.cpp \ $$SOURCES_PATH/GUI/panelsview.cpp \ - $$SOURCES_PATH/GUI/plotschooser.cpp + $$SOURCES_PATH/GUI/plotschooser.cpp \ + $$SOURCES_PATH/GUI/yminmaxselector.cpp include(../zlib.pri) @@ -121,7 +123,8 @@ FORMS += \ $$SOURCES_PATH/GUI/barchartconditioninput.ui \ $$SOURCES_PATH/GUI/managebarchartconditions.ui \ $$SOURCES_PATH/GUI/playercontrol.ui \ - $$SOURCES_PATH/GUI/plotschooser.ui + $$SOURCES_PATH/GUI/plotschooser.ui \ + $$SOURCES_PATH/GUI/yminmaxselector.ui \ RESOURCES += \ $$SOURCES_PATH/Resource/Resources.qrc diff --git a/Source/GUI/Plot.cpp b/Source/GUI/Plot.cpp index fdc1b0740..b78222b55 100644 --- a/Source/GUI/Plot.cpp +++ b/Source/GUI/Plot.cpp @@ -27,6 +27,8 @@ #include #include "Core/FileInformation.h" +#include +#include #include #include @@ -438,31 +440,35 @@ void Plot::initYAxis() } else { + auto yMin = 0.0; + auto yMax = 0.0; const size_t plotType = type(); const size_t plotGroup = group(); CommonStats* stat = stats( streamPos() ); const struct per_group& group = PerStreamType[plotType].PerGroup[plotGroup]; - auto yMin = 0.0; - if(m_minValue.isNull() || m_minValue.isError() || m_minValue.isUndefined()) { - yMin = stat->y_Min[plotGroup]; // auto-select min - } else { + if(m_yminMaxMode == Formula) + { if(m_minValue.isNumber()) yMin = m_minValue.toNumber(); else if(m_minValue.isCallable()) yMin = m_minValue.call().toNumber(); - } - auto yMax = 0.0; - if(m_maxValue.isNull() || m_maxValue.isError() || m_maxValue.isUndefined()) { - yMax = stat->y_Max[plotGroup]; // auto-select min - } else { if(m_maxValue.isNumber()) yMax = m_maxValue.toNumber(); else if(m_maxValue.isCallable()) yMax = m_maxValue.call().toNumber(); } + else if(m_yminMaxMode == MinMaxOfThePlot) + { + yMin = stat->y_Min[plotGroup]; // auto-select min + yMax = stat->y_Max[plotGroup]; // auto-select max + } else if(m_yminMaxMode == Custom) + { + yMin = m_customYMin; + yMax = m_customYMax; + } setYAxis( yMin, yMax, group.StepsCount ); } @@ -520,6 +526,47 @@ bool Plot::isBarchart() const return m_barchart; } +void Plot::setYAxisMinMaxMode(YMinMaxMode mode) +{ + m_yminMaxMode = mode; + initYAxis(); +} + +Plot::YMinMaxMode Plot::yAxisMinMaxMode() const +{ + return m_yminMaxMode; +} + +void Plot::setYAxisCustomMinMax(double min, double max) +{ + m_customYMin = min; + m_customYMax = max; +} + +void Plot::getYAxisCustomMinMax(double &min, double &max) +{ + min = m_customYMin; + max = m_customYMax; +} + +bool Plot::hasMinMaxFormula() const +{ + if(m_minValue.isNull() || m_minValue.isError() || m_minValue.isUndefined()) { + return false; + } + + if(m_maxValue.isNull() || m_maxValue.isError() || m_maxValue.isUndefined()) { + return false; + } + + return true; +} + +const CommonStats *Plot::getStats() const +{ + return stats( streamPos() ); +} + void Plot::setBarchart(bool value) { if(m_barchart != value) @@ -751,6 +798,28 @@ Plot::Plot( size_t streamPos, size_t Type, size_t Group, const FileInformation* #else panner->setMouseButton( Qt::MiddleButton ); #endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + + QSettings settings; + settings.beginGroup("yminmax"); + + QMetaEnum metaEnum = QMetaEnum::fromType(); + QString value = settings.value(QString::number(m_group)).toString(); + if(!value.isEmpty()) { + 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); + } + + settings.endGroup(); + } //--------------------------------------------------------------------------- diff --git a/Source/GUI/Plot.h b/Source/GUI/Plot.h index 12138aa3a..3afcbc9ea 100644 --- a/Source/GUI/Plot.h +++ b/Source/GUI/Plot.h @@ -437,6 +437,13 @@ class Plot : public QwtPlot Q_OBJECT public: + enum YMinMaxMode { + MinMaxOfThePlot, + Formula, + Custom + }; + Q_ENUM(YMinMaxMode); + explicit Plot( size_t streamPos, size_t Type, size_t Group, const FileInformation* fileInformation, QWidget *parent ); virtual ~Plot(); @@ -472,6 +479,15 @@ class Plot : public QwtPlot void updateSymbols(); bool isBarchart() const; + void setYAxisMinMaxMode(YMinMaxMode mode); + YMinMaxMode yAxisMinMaxMode() const; + + void setYAxisCustomMinMax(double min, double max); + void getYAxisCustomMinMax(double& min, double& max); + + bool hasMinMaxFormula() const; + + const CommonStats* getStats() const; Q_SIGNALS: void cursorMoved(const QPointF& point, int index); void visibilityChanged(bool visible); @@ -488,6 +504,9 @@ private Q_SLOTS: const QwtPlotCurve* curve( int index ) const; QColor curveColor( int index ) const; + YMinMaxMode m_yminMaxMode { MinMaxOfThePlot }; + double m_customYMin { 0.0 }; + double m_customYMax { 0.0 }; QJSValue m_maxValue; QJSValue m_minValue; QJSEngine m_engine; diff --git a/Source/GUI/Plots.cpp b/Source/GUI/Plots.cpp index 8473e1e48..f3e42d650 100755 --- a/Source/GUI/Plots.cpp +++ b/Source/GUI/Plots.cpp @@ -17,6 +17,7 @@ #include "Core/Core.h" #include #include "playercontrol.h" +#include "yminmaxselector.h" #include #include #include @@ -123,6 +124,18 @@ void Plots::showEditBarchartProfileDialog(const size_t plotGroup, Plot* plot, co } } +void Plots::showYMinMaxConfigDialog(const size_t plotGroup, Plot *plot, const stream_info &streamInfo, QToolButton* button) +{ + auto globalButtonPos = button->mapToGlobal(QPoint(0, 0)); + auto geometry = m_yMinMaxSelector->geometry(); + + m_yMinMaxSelector->setPlot(plot); + m_yMinMaxSelector->enableFormulaMinMax(plot->hasMinMaxFormula()); + m_yMinMaxSelector->move(QPoint(globalButtonPos.x() - geometry.width(), globalButtonPos.y())); + if(!m_yMinMaxSelector->isVisible()) + m_yMinMaxSelector->show(); +} + Plots::Plots( QWidget *parent, FileInformation* fileInformation ) : QWidget( parent ), m_zoomFactor ( 0 ), @@ -282,11 +295,18 @@ Plots::Plots( QWidget *parent, FileInformation* fileInformation ) : barchartPlotSwitch->setIcon(switchToBarcharts ? QIcon(":/icon/chart_chart.png") : QIcon(":/icon/bar_chart.png")); }); + QToolButton* yMinMaxConfigButton = new QToolButton(); + connect(plot, SIGNAL(visibilityChanged(bool)), yMinMaxConfigButton, SLOT(setVisible(bool))); + connect(yMinMaxConfigButton, &QToolButton::clicked, [=]() { + showYMinMaxConfigDialog(plotGroup, plot, streamInfo, yMinMaxConfigButton); + }); + QHBoxLayout* barchartAndConfigurationLayout = new QHBoxLayout(); barchartAndConfigurationLayout->setAlignment(Qt::AlignLeft); barchartAndConfigurationLayout->setSpacing(5); barchartAndConfigurationLayout->addWidget(barchartPlotSwitch); barchartAndConfigurationLayout->addWidget(barchartConfigButton); + barchartAndConfigurationLayout->addWidget(yMinMaxConfigButton); legendLayout->addItem(barchartAndConfigurationLayout); legendLayout->addWidget(plot->plotLegend()); @@ -496,6 +516,9 @@ Plots::Plots( QWidget *parent, FileInformation* fileInformation ) : m_scaleWidget->setScale( m_timeInterval.from, m_timeInterval.to); setCursorPos( framePos() ); + + m_yMinMaxSelector = new YMinMaxSelector(this); + m_yMinMaxSelector->setWindowFlag(Qt::Popup); } //--------------------------------------------------------------------------- diff --git a/Source/GUI/Plots.h b/Source/GUI/Plots.h index 65f9a303c..c0586e4c8 100755 --- a/Source/GUI/Plots.h +++ b/Source/GUI/Plots.h @@ -22,6 +22,8 @@ class QwtPlot; class Plot; class PlotScaleWidget; class PlayerControl; +class YMinMaxSelector; +class QToolButton; void showEditFrameCommentsDialog(QWidget* parentWidget, FileInformation* info, CommonStats* stats, size_t frameIndex); @@ -116,6 +118,7 @@ class Plots : public QWidget void loadBarchartsProfile(const QJsonObject& profile); void showEditBarchartProfileDialog(const size_t plotGroup, Plot* plot, const stream_info& streamInfo); + void showYMinMaxConfigDialog(const size_t plotGroup, Plot* plot, const stream_info& streamInfo, QToolButton* button); Q_SIGNALS: void visibleFramesChanged(int from, int to); @@ -146,6 +149,7 @@ private Q_SLOTS: void setFramePos( size_t framePos, size_t statsPos = (size_t)-1 ) const { m_fileInfoData->Frames_Pos_Set(framePos, statsPos); } private: + YMinMaxSelector* m_yMinMaxSelector; PlotScaleWidget* m_scaleWidget; CommentsPlot* m_commentsPlot; std::vector m_PanelsViews; diff --git a/Source/GUI/yminmaxselector.cpp b/Source/GUI/yminmaxselector.cpp new file mode 100644 index 000000000..1dd4cc7a7 --- /dev/null +++ b/Source/GUI/yminmaxselector.cpp @@ -0,0 +1,118 @@ +#include "yminmaxselector.h" +#include "ui_yminmaxselector.h" +#include "Plot.h" + +#include +#include + +YMinMaxSelector::YMinMaxSelector(QWidget *parent) + : QWidget(parent) + , ui(new Ui::YMinMaxSelector) +{ + ui->setupUi(this); + + connect(ui->customMinMax_radioButton, &QRadioButton::toggled, this, &YMinMaxSelector::enableCustomMinMax); +} + +YMinMaxSelector::~YMinMaxSelector() +{ + delete ui; +} + +bool YMinMaxSelector::isMinMaxFromThePlot() const +{ + return ui->minMaxOfThePlot_radioButton->isChecked(); +} + +bool YMinMaxSelector::isFormula() const +{ + return ui->minMaxSystemProvided_radioButton->isChecked(); +} + +bool YMinMaxSelector::isCustom() const +{ + return ui->customMinMax_radioButton->isChecked(); +} + +void YMinMaxSelector::enableCustomMinMax(bool value) +{ + ui->min_label->setEnabled(value); + ui->min_doubleSpinBox->setEnabled(value); + ui->max_label->setEnabled(value); + ui->max_doubleSpinBox->setEnabled(value); +} + +void YMinMaxSelector::enableFormulaMinMax(bool value) +{ + ui->minMaxSystemProvided_radioButton->setEnabled(value); +} + +void YMinMaxSelector::setPlot(Plot *plot) +{ + m_plot = plot; + + if(plot->yAxisMinMaxMode() == Plot::MinMaxOfThePlot) { + ui->minMaxOfThePlot_radioButton->setChecked(true); + } else if(plot->yAxisMinMaxMode() == Plot::Formula) { + ui->minMaxSystemProvided_radioButton->setChecked(true); + } else if(plot->yAxisMinMaxMode() == Plot::Custom) { + ui->customMinMax_radioButton->setChecked(true); + } + + double min, max; + m_plot->getYAxisCustomMinMax(min, max); + + ui->min_doubleSpinBox->setValue(min); + ui->max_doubleSpinBox->setValue(max); + + if(qFuzzyCompare(ui->min_doubleSpinBox->value(), 0) && qFuzzyCompare(ui->max_doubleSpinBox->value(), 0)) { + auto stat = m_plot->getStats(); + auto plotGroup = m_plot->group(); + + auto yMin = stat->y_Min[plotGroup]; // auto-select min + auto yMax = stat->y_Max[plotGroup]; // auto-select max + + ui->min_doubleSpinBox->setValue(yMin); + ui->max_doubleSpinBox->setValue(yMax); + } +} + +Plot *YMinMaxSelector::getPlot() const +{ + return m_plot; +} + +void YMinMaxSelector::on_apply_pushButton_clicked() +{ + if(isFormula()) + { + m_plot->setYAxisMinMaxMode(Plot::Formula); + } + else if(isMinMaxFromThePlot()) + { + m_plot->setYAxisMinMaxMode(Plot::MinMaxOfThePlot); + } + else if(isCustom()) + { + m_plot->setYAxisCustomMinMax(ui->min_doubleSpinBox->value(), ui->max_doubleSpinBox->value()); + m_plot->setYAxisMinMaxMode(Plot::Custom); + } + + QSettings settings; + settings.beginGroup("yminmax"); + + QMetaEnum metaEnum = QMetaEnum::fromType(); + QString stringValue = metaEnum.valueToKey(m_plot->yAxisMinMaxMode()); + if(m_plot->yAxisMinMaxMode() == Plot::Custom) { + stringValue.append(";"); + stringValue.append(QString::number(ui->min_doubleSpinBox->value())); + stringValue.append(";"); + stringValue.append(QString::number(ui->max_doubleSpinBox->value())); + } + + settings.setValue(QString::number(m_plot->group()), stringValue); + settings.endGroup(); + + m_plot->replot(); +} + diff --git a/Source/GUI/yminmaxselector.h b/Source/GUI/yminmaxselector.h new file mode 100644 index 000000000..2ede67eec --- /dev/null +++ b/Source/GUI/yminmaxselector.h @@ -0,0 +1,36 @@ +#ifndef YMINMAXSELECTOR_H +#define YMINMAXSELECTOR_H + +#include + +namespace Ui { +class YMinMaxSelector; +} + +class Plot; +class YMinMaxSelector : public QWidget +{ + Q_OBJECT + +public: + explicit YMinMaxSelector(QWidget *parent = nullptr); + ~YMinMaxSelector(); + + bool isMinMaxFromThePlot() const; + bool isFormula() const; + bool isCustom() const; + + void enableFormulaMinMax(bool value); + void setPlot(Plot* plot); + Plot* getPlot() const; + +private Q_SLOTS: + void enableCustomMinMax(bool value); + void on_apply_pushButton_clicked(); + +private: + Plot* m_plot { nullptr }; + Ui::YMinMaxSelector *ui; +}; + +#endif // YMINMAXSELECTOR_H diff --git a/Source/GUI/yminmaxselector.ui b/Source/GUI/yminmaxselector.ui new file mode 100644 index 000000000..0fcd65009 --- /dev/null +++ b/Source/GUI/yminmaxselector.ui @@ -0,0 +1,155 @@ + + + YMinMaxSelector + + + + 0 + 0 + 400 + 192 + + + + Form + + + true + + + + + + Select y-axis min/max + + + + + + min/max value of the plot + + + true + + + + + + + system provided min/max + + + false + + + + + + + + + custom + + + + + + + false + + + min: + + + + + + + false + + + + 0 + 0 + + + + -100000000000000004384584304507619735463404765184.000000000000000 + + + 100000000000000004384584304507619735463404765184.000000000000000 + + + + + + + false + + + max: + + + + + + + false + + + + 0 + 0 + + + + -100000000000000004384584304507619735463404765184.000000000000000 + + + 100000000000000004384584304507619735463404765184.000000000000000 + + + + + + + + + + + + Qt::Horizontal + + + + 133 + 20 + + + + + + + + Apply + + + + + + + Qt::Horizontal + + + + 132 + 20 + + + + + + + + + From b7db3b8104216a816b577f34af9f6d72ea4f6f3e Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Sun, 23 Jun 2024 17:44:48 +0200 Subject: [PATCH 2/6] use signalserver_upload.png for y min/max selector --- Source/GUI/Plots.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/GUI/Plots.cpp b/Source/GUI/Plots.cpp index f3e42d650..37f90d0c2 100755 --- a/Source/GUI/Plots.cpp +++ b/Source/GUI/Plots.cpp @@ -296,6 +296,7 @@ Plots::Plots( QWidget *parent, FileInformation* fileInformation ) : }); QToolButton* yMinMaxConfigButton = new QToolButton(); + yMinMaxConfigButton->setIcon(QIcon(":/icon/signalserver_upload.png")); connect(plot, SIGNAL(visibilityChanged(bool)), yMinMaxConfigButton, SLOT(setVisible(bool))); connect(yMinMaxConfigButton, &QToolButton::clicked, [=]() { showYMinMaxConfigDialog(plotGroup, plot, streamInfo, yMinMaxConfigButton); From 34d96556a6522333f0cde26405ad47fe1de0597b Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Sun, 23 Jun 2024 17:45:41 +0200 Subject: [PATCH 3/6] if min>max then disable the Apply and highlight in red --- Source/GUI/yminmaxselector.cpp | 77 ++++++++++++++++++++++++++++++++++ Source/GUI/yminmaxselector.h | 10 +++++ 2 files changed, 87 insertions(+) diff --git a/Source/GUI/yminmaxselector.cpp b/Source/GUI/yminmaxselector.cpp index 1dd4cc7a7..a65fb6c96 100644 --- a/Source/GUI/yminmaxselector.cpp +++ b/Source/GUI/yminmaxselector.cpp @@ -4,6 +4,7 @@ #include #include +#include YMinMaxSelector::YMinMaxSelector(QWidget *parent) : QWidget(parent) @@ -12,6 +13,10 @@ YMinMaxSelector::YMinMaxSelector(QWidget *parent) ui->setupUi(this); connect(ui->customMinMax_radioButton, &QRadioButton::toggled, this, &YMinMaxSelector::enableCustomMinMax); + + m_palette = ui->min_doubleSpinBox->palette(); + m_redPalette = ui->min_doubleSpinBox->palette(); + m_redPalette.setColor(QPalette::Base, QColor("red")); } YMinMaxSelector::~YMinMaxSelector() @@ -75,6 +80,9 @@ void YMinMaxSelector::setPlot(Plot *plot) ui->min_doubleSpinBox->setValue(yMin); ui->max_doubleSpinBox->setValue(yMax); } + + updateApplyButton(); + updateMinMaxStyling(); } Plot *YMinMaxSelector::getPlot() const @@ -114,5 +122,74 @@ void YMinMaxSelector::on_apply_pushButton_clicked() settings.endGroup(); m_plot->replot(); + hide(); +} + + +void YMinMaxSelector::on_min_doubleSpinBox_valueChanged(double arg1) +{ + Q_UNUSED(arg1) + updateApplyButton(); + updateMinMaxStyling(); +} + + +void YMinMaxSelector::on_max_doubleSpinBox_valueChanged(double arg1) +{ + Q_UNUSED(arg1) + updateApplyButton(); + updateMinMaxStyling(); +} + +void YMinMaxSelector::updateApplyButton() +{ + bool minBiggerThanMax = ui->min_doubleSpinBox->value() > ui->max_doubleSpinBox->value(); + bool customSelected = ui->customMinMax_radioButton->isChecked(); + + if(customSelected) + ui->apply_pushButton->setEnabled(!minBiggerThanMax); + else + ui->apply_pushButton->setEnabled(true); +} + +void YMinMaxSelector::updateMinMaxStyling() +{ + bool minBiggerThanMax = ui->min_doubleSpinBox->value() > ui->max_doubleSpinBox->value(); + bool customSelected = ui->customMinMax_radioButton->isChecked(); + + auto minControl = ui->min_doubleSpinBox; + auto maxControl = ui->max_doubleSpinBox; + + QPalette palette = m_palette; + if(customSelected) + { + if(minBiggerThanMax) { + palette = m_redPalette; + } + } + + minControl->setPalette(palette); + maxControl->setPalette(palette); +} + + +void YMinMaxSelector::on_minMaxOfThePlot_radioButton_clicked() +{ + updateApplyButton(); + updateMinMaxStyling(); +} + + +void YMinMaxSelector::on_minMaxSystemProvided_radioButton_clicked() +{ + updateApplyButton(); + updateMinMaxStyling(); +} + + +void YMinMaxSelector::on_customMinMax_radioButton_clicked() +{ + updateApplyButton(); + updateMinMaxStyling(); } diff --git a/Source/GUI/yminmaxselector.h b/Source/GUI/yminmaxselector.h index 2ede67eec..8f79e5f70 100644 --- a/Source/GUI/yminmaxselector.h +++ b/Source/GUI/yminmaxselector.h @@ -27,9 +27,19 @@ class YMinMaxSelector : public QWidget private Q_SLOTS: void enableCustomMinMax(bool value); void on_apply_pushButton_clicked(); + void on_min_doubleSpinBox_valueChanged(double arg1); + void on_max_doubleSpinBox_valueChanged(double arg1); + void on_minMaxOfThePlot_radioButton_clicked(); + void on_minMaxSystemProvided_radioButton_clicked(); + void on_customMinMax_radioButton_clicked(); private: + void updateApplyButton(); + void updateMinMaxStyling(); + Plot* m_plot { nullptr }; + QPalette m_palette; + QPalette m_redPalette; Ui::YMinMaxSelector *ui; }; From cdc197141367eb05909784b9d7a324d63bf1f640 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Sun, 23 Jun 2024 17:47:38 +0200 Subject: [PATCH 4/6] adjust messages based on Dave's feedback --- Source/GUI/yminmaxselector.ui | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/GUI/yminmaxselector.ui b/Source/GUI/yminmaxselector.ui index 0fcd65009..c501cb29c 100644 --- a/Source/GUI/yminmaxselector.ui +++ b/Source/GUI/yminmaxselector.ui @@ -6,7 +6,7 @@ 0 0 - 400 + 550 192 @@ -20,13 +20,13 @@ - Select y-axis min/max + Set the y-axis range - min/max value of the plot + Fit to the plotted data true @@ -36,7 +36,7 @@ - system provided min/max + Full Range false @@ -48,7 +48,7 @@ - custom + Custom From 5f20089e6cbf09ec0f95f7772b8086de6ce95c67 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Sun, 23 Jun 2024 18:18:43 +0200 Subject: [PATCH 5/6] adjust y axis colors based on axis mode selected --- Source/GUI/Plot.cpp | 23 ++++++++++++ Source/GUI/Plot.h | 1 + Source/GUI/yminmaxselector.ui | 66 ++++++++++++++++++++++++++++++----- 3 files changed, 81 insertions(+), 9 deletions(-) diff --git a/Source/GUI/Plot.cpp b/Source/GUI/Plot.cpp index b78222b55..d770fb486 100644 --- a/Source/GUI/Plot.cpp +++ b/Source/GUI/Plot.cpp @@ -529,6 +529,20 @@ bool Plot::isBarchart() const void Plot::setYAxisMinMaxMode(YMinMaxMode mode) { m_yminMaxMode = mode; + QColor color; + switch(m_yminMaxMode) { + case MinMaxOfThePlot: + color = "darkblue"; + break; + case Formula: + color = "black"; + break; + case Custom: + color = QColor(85, 0, 127); + break; + } + + setYAxisColor(color); initYAxis(); } @@ -860,6 +874,15 @@ QSize Plot::minimumSizeHint() const return QSize( hint.width(), -1 ); } +void Plot::setYAxisColor(QColor color) +{ + auto yAxis = axisWidget(QwtPlot::yLeft); + QPalette palette = yAxis->palette(); + palette.setColor(QPalette::WindowText, color); // for ticks + palette.setColor(QPalette::Text, color); // for ticks' labels + yAxis->setPalette(palette); +} + const QwtPlotCurve* Plot::curve( int index ) const { const QwtPlotItemList curves = itemList( QwtPlotItem::Rtti_PlotCurve ); diff --git a/Source/GUI/Plot.h b/Source/GUI/Plot.h index 3afcbc9ea..0a06d8987 100644 --- a/Source/GUI/Plot.h +++ b/Source/GUI/Plot.h @@ -453,6 +453,7 @@ class Plot : public QwtPlot virtual QSize sizeHint() const; virtual QSize minimumSizeHint() const; + void setYAxisColor(QColor color); void setYAxis( double min, double max, int numSteps ); void setCursorPos( double x ); diff --git a/Source/GUI/yminmaxselector.ui b/Source/GUI/yminmaxselector.ui index c501cb29c..ab399218d 100644 --- a/Source/GUI/yminmaxselector.ui +++ b/Source/GUI/yminmaxselector.ui @@ -23,27 +23,27 @@ Set the y-axis range - - + + - Fit to the plotted data + Full Range - true + false - - + + - Full Range + Fit to the plotted data - false + true - + @@ -112,6 +112,54 @@ + + + + + 20 + 0 + + + + false + + + background-color: "black"; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + background-color: "dark blue"; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + background-color: rgb(85, 0, 127) + + + QFrame::StyledPanel + + + QFrame::Raised + + + From a9de8f934281da3145d5ec635e0e30c008c9dca8 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Mon, 8 Jul 2024 14:53:48 +0200 Subject: [PATCH 6/6] introduce default YAxisMinMaxMode --- Source/Core/Core.h | 1 + Source/Core/VideoCore.cpp | 3 +++ Source/GUI/Plot.cpp | 23 +++++++++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core.h b/Source/Core/Core.h index 972d0c426..a6b112605 100755 --- a/Source/Core/Core.h +++ b/Source/Core/Core.h @@ -50,6 +50,7 @@ struct per_group const bool CheckedByDefault; const char* Description; activefilter ActiveFilterGroup; + const char* YAxisMinMaxMode; }; struct per_item diff --git a/Source/Core/VideoCore.cpp b/Source/Core/VideoCore.cpp index 8f74696a9..d042d6ddd 100644 --- a/Source/Core/VideoCore.cpp +++ b/Source/Core/VideoCore.cpp @@ -17,6 +17,7 @@ struct per_group VideoPerGroup [Group_VideoMax]= "LOW (10th percentile), and HIGH (90th percentile) values for each frame.\n" "The Y plane provides information about video brightness or luminance.", ActiveFilter_Video_signalstats, + "MinMaxOfThePlot", }, //U { @@ -25,6 +26,7 @@ struct per_group VideoPerGroup [Group_VideoMax]= "LOW (10th percentile), and HIGH (90th percentile) values for each frame.\n" "The U plane (along with V) provides information about video color.", ActiveFilter_Video_signalstats, + "Formula", }, //V { @@ -33,6 +35,7 @@ struct per_group VideoPerGroup [Group_VideoMax]= "LOW (10th percentile), and HIGH (90th percentile) values for each frame.\n" "The V plane (along with U) provides information about video color.", ActiveFilter_Video_signalstats, + "Custom;0;55" }, //YDiff { diff --git a/Source/GUI/Plot.cpp b/Source/GUI/Plot.cpp index d770fb486..74bbe4c34 100644 --- a/Source/GUI/Plot.cpp +++ b/Source/GUI/Plot.cpp @@ -813,12 +813,8 @@ 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) - QSettings settings; - settings.beginGroup("yminmax"); - - QMetaEnum metaEnum = QMetaEnum::fromType(); - QString value = settings.value(QString::number(m_group)).toString(); - if(!value.isEmpty()) { + auto applyYMinMaxMode = [&](QString value) { + QMetaEnum metaEnum = QMetaEnum::fromType(); auto splitted = value.split(";"); auto yMinMaxMode = (Plot::YMinMaxMode) metaEnum.keyToValue(splitted[0].toLatin1().constData()); @@ -830,6 +826,21 @@ Plot::Plot( size_t streamPos, size_t Type, size_t Group, const FileInformation* } 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();