Add support for placing legend at several positions

Show legends on top of preview plot
This commit is contained in:
Magne Sjaastad
2023-11-23 17:13:47 +01:00
parent 243b07c42f
commit 4b0f2b362e
10 changed files with 35 additions and 43 deletions

View File

@@ -117,11 +117,10 @@ public:
virtual bool plotTitleEnabled() const = 0;
virtual void setPlotTitleFontSize( int titleFontSize ) = 0;
virtual void setLegendFontSize( int fontSize ) = 0;
virtual void setInternalLegendVisible( bool visible ) = 0;
virtual void insertLegend( RiuPlotWidget::Legend ) = 0;
virtual void clearLegend() = 0;
virtual void updateLegend() = 0;
virtual void setLegendFontSize( int fontSize ) = 0;
virtual void insertLegend( RiuPlotWidget::Legend ) = 0;
virtual void clearLegend() = 0;
virtual void updateLegend() = 0;
virtual void detachItems( RiuPlotWidget::PlotItemType plotItemType ) = 0;

View File

@@ -287,21 +287,6 @@ void RiuQtChartsPlotWidget::setLegendFontSize( int fontSize )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQtChartsPlotWidget::setInternalLegendVisible( bool visible )
{
if ( visible )
{
insertLegend( RiuPlotWidget::Legend::BOTTOM );
}
else
{
clearLegend();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -112,7 +112,6 @@ public:
void setPlotTitleFontSize( int titleFontSize ) override;
void setLegendFontSize( int fontSize ) override;
void setInternalLegendVisible( bool visible ) override;
void insertLegend( RiuPlotWidget::Legend ) override;
void clearLegend() override;

View File

@@ -270,22 +270,6 @@ void RiuQwtPlotWidget::setLegendFontSize( int fontSize )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setInternalLegendVisible( bool visible )
{
if ( visible )
{
auto* legend = new QwtLegend( this );
m_plot->insertLegend( legend, QwtPlot::BottomLegend );
}
else
{
m_plot->insertLegend( nullptr );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -103,7 +103,6 @@ public:
void setPlotTitleFontSize( int titleFontSize ) override;
void setLegendFontSize( int fontSize ) override;
void setInternalLegendVisible( bool visible ) override;
void insertLegend( RiuPlotWidget::Legend ) override;
void clearLegend() override;

View File

@@ -42,7 +42,7 @@ RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* p
RiuQtChartsPlotTools::setCommonPlotBehaviour( m_plotWidget );
RiuQtChartsPlotTools::setDefaultAxes( m_plotWidget );
m_plotWidget->setInternalLegendVisible( true );
m_plotWidget->insertLegend( RiuPlotWidget::Legend::BOTTOM );
}
//--------------------------------------------------------------------------------------------------
///

View File

@@ -103,7 +103,7 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*=
// PERFORMANCE NOTE
// Do not set internal legends visible, as this will cause a performance hit.
m_plotWidget->setInternalLegendVisible( false );
m_plotWidget->clearLegend();
m_annotationTool = std::unique_ptr<RiuPlotAnnotationTool>( new RiuPlotAnnotationTool() );
}