mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add support for placing legend at several positions
Show legends on top of preview plot
This commit is contained in:
parent
243b07c42f
commit
4b0f2b362e
@ -97,6 +97,7 @@ RicSummaryPlotEditorUi::RicSummaryPlotEditorUi()
|
||||
CAF_PDM_InitFieldNoDefault( &m_regionAppearanceType, "RegionAppearanceType", "Region" );
|
||||
|
||||
m_previewPlot = std::make_unique<RimSummaryPlot>();
|
||||
m_previewPlot->setLegendPosition( RiuPlotWidget::Legend::TOP );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_applyButtonField, "ApplySelection", "" );
|
||||
m_applyButtonField = false;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -162,6 +162,7 @@ public:
|
||||
|
||||
void updateAll();
|
||||
void updateLegend() override;
|
||||
void setLegendPosition( RiuPlotWidget::Legend position );
|
||||
|
||||
void setPlotInfoLabel( const QString& label );
|
||||
void showPlotInfoLabel( bool show );
|
||||
@ -352,5 +353,6 @@ private:
|
||||
std::unique_ptr<RimSummaryPlotNameHelper> m_nameHelperAllCurves;
|
||||
caf::PdmChildField<RimSummaryPlotSourceStepping*> m_sourceStepping;
|
||||
|
||||
bool m_isValid;
|
||||
bool m_isValid;
|
||||
RiuPlotWidget::Legend m_legendPosition;
|
||||
};
|
||||
|
@ -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;
|
||||
|
||||
|
@ -287,21 +287,6 @@ void RiuQtChartsPlotWidget::setLegendFontSize( int fontSize )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQtChartsPlotWidget::setInternalLegendVisible( bool visible )
|
||||
{
|
||||
if ( visible )
|
||||
{
|
||||
insertLegend( RiuPlotWidget::Legend::BOTTOM );
|
||||
}
|
||||
else
|
||||
{
|
||||
clearLegend();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -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() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user