From fe1acc93a6ddd645b475693dfd9868789a0e7569 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 31 May 2022 10:22:18 +0200 Subject: [PATCH] #8938 Sub Plot : Fix visibility of legend Make sure legends are set visible if any items are present in the legend --- ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp | 6 +++++- ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp index 162cde5bf4..b0ee3ef131 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp @@ -600,7 +600,11 @@ void RiuMultiPlotPage::onLegendUpdated() //-------------------------------------------------------------------------------------------------- void RiuMultiPlotPage::refreshLegends() { - // TODO - might need to do something here, but at the moment it looks like alignCanvasTops() is sufficient + QList> legends = this->legendsForVisiblePlots(); + for ( const auto& l : legends ) + { + l->setVisible( !l->isEmpty() ); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp index 438e8a81e4..c98fd6caf9 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp @@ -108,7 +108,6 @@ QSize RiuQwtPlotLegend::sizeHint() const void RiuQwtPlotLegend::updateLegend( const QVariant& variant, const QList& legendItems ) { QwtLegend::updateLegend( variant, legendItems ); - setVisible( !legendItems.empty() ); emit legendUpdated(); }