From db2de8e31bd404a2248c98f88931c37bd5195890 2020-01-10 17:58:04 From: Alexis Jeandet Date: 2020-01-10 17:58:04 Subject: [PATCH] Added shortcut 'l' to toggle Y axis log scale (broken for spectro) Signed-off-by: Alexis Jeandet --- diff --git a/gui/include/Visualization/VisualizationGraphWidget.h b/gui/include/Visualization/VisualizationGraphWidget.h index c935e8e..49f5503 100644 --- a/gui/include/Visualization/VisualizationGraphWidget.h +++ b/gui/include/Visualization/VisualizationGraphWidget.h @@ -96,6 +96,8 @@ public: void move(double dx, double dy, bool forward = true); void transform(const DateTimeRangeTransformation& tranformation, bool forward = true); + void toggle_y_log_scale(); + // IVisualizationWidget interface void accept(IVisualizationWidgetVisitor* visitor) override; bool canDrop(Variable2& variable) const override; diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index a68f8fd..748037e 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -417,6 +417,21 @@ struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate setRange(axis->range()); m_plot->replot(QCustomPlot::rpQueuedReplot); } + void toggle_y_log_scale() + { + if(m_plot->yAxis->scaleType()==QCPAxis::stLinear) + { + m_plot->yAxis->setScaleType(QCPAxis::stLogarithmic); + QSharedPointer logTicker(new QCPAxisTickerLog); + m_plot->yAxis->setTicker(logTicker); + } + else + { + m_plot->yAxis->setScaleType(QCPAxis::stLinear); + QSharedPointer ticker(new QCPAxisTicker); + m_plot->yAxis->setTicker(ticker); + } + } }; VisualizationGraphWidget::VisualizationGraphWidget(const QString& name, QWidget* parent) @@ -679,6 +694,11 @@ void VisualizationGraphWidget::transform( emit this->setrange_sig(this->graphRange(), true, false); } +void VisualizationGraphWidget::toggle_y_log_scale() +{ + impl->toggle_y_log_scale(); +} + void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor* visitor) { if (visitor) @@ -1140,6 +1160,9 @@ void VisualizationGraphWidget::keyPressEvent(QKeyEvent* event) zoom(2, this->height() / 2, Qt::Vertical); } break; + case Qt::Key_L: + toggle_y_log_scale(); + break; default: QWidget::keyPressEvent(event); break;