#8522 Summary Plot: Prune unused axes after move or delete

This commit is contained in:
Kristian Bendiksen
2022-02-21 11:32:26 +01:00
parent 1a1acfa006
commit 10cb2d7d0b
9 changed files with 62 additions and 11 deletions

View File

@@ -860,7 +860,7 @@ void RiuQtChartsPlotWidget::setYAxis( RiuPlotAxis axis, QtCharts::QAbstractSerie
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQtChartsPlotWidget::ensureAxis( RiuPlotAxis axis )
void RiuQtChartsPlotWidget::ensureAxisIsCreated( RiuPlotAxis axis )
{
if ( m_axes.find( axis ) == m_axes.end() )
{
@@ -874,7 +874,7 @@ void RiuQtChartsPlotWidget::ensureAxis( RiuPlotAxis axis )
void RiuQtChartsPlotWidget::setAxis( RiuPlotAxis axis, QtCharts::QAbstractSeries* series )
{
// Make sure the axis we are about to set exists.
ensureAxis( axis );
ensureAxisIsCreated( axis );
if ( qtChart()->series().contains( series ) && !series->attachedAxes().contains( plotAxis( axis ) ) )
{
@@ -1111,3 +1111,20 @@ Qt::Alignment RiuQtChartsPlotWidget::mapPlotAxisToQtAlignment( RiaDefines::PlotA
if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) return Qt::AlignLeft;
return Qt::AlignRight;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQtChartsPlotWidget::pruneAxes( const std::set<RiuPlotAxis>& usedAxes )
{
for ( auto [plotAxis, qtAxis] : m_axes )
{
if ( usedAxes.count( plotAxis ) == 0 )
{
// This axis is now unused, and can be disabled
qtAxis->setVisible( false );
m_axesEnabled[plotAxis] = false;
m_axesAutoScale[plotAxis] = false;
}
}
}