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

@@ -128,6 +128,7 @@ RimSummaryPlot::RimSummaryPlot()
, m_isValid( true )
, axisChangedReloadRequired( this )
, autoTitleChanged( this )
, m_legendPosition( RiuPlotWidget::Legend::BOTTOM )
{
CAF_PDM_InitScriptableObject( "Summary Plot", ":/SummaryPlotLight16x16.png", "", "A Summary Plot" );
@@ -690,7 +691,14 @@ void RimSummaryPlot::updateLegend()
{
if ( plotWidget() )
{
plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
if ( m_showPlotLegends && !isSubPlot() )
{
plotWidget()->insertLegend( m_legendPosition );
}
else
{
plotWidget()->clearLegend();
}
for ( auto c : summaryCurves() )
{
@@ -705,6 +713,14 @@ void RimSummaryPlot::updateLegend()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::setLegendPosition( RiuPlotWidget::Legend position )
{
m_legendPosition = position;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1941,7 +1957,14 @@ void RimSummaryPlot::onLoadDataAndUpdate()
if ( plotWidget() )
{
plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
if ( m_showPlotLegends && !isSubPlot() )
{
plotWidget()->insertLegend( m_legendPosition );
}
else
{
plotWidget()->clearLegend();
}
plotWidget()->setLegendFontSize( legendFontSize() );
plotWidget()->updateLegend();
}