#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

@@ -107,8 +107,9 @@ public:
virtual void setAxisTitleText( RiuPlotAxis axis, const QString& title ) = 0;
virtual void setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) = 0;
virtual bool isMultiAxisSupported() const = 0;
virtual RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) = 0;
virtual bool isMultiAxisSupported() const = 0;
virtual RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) = 0;
virtual void pruneAxes( const std::set<RiuPlotAxis>& usedAxes ) = 0;
virtual void setPlotTitle( const QString& plotTitle ) = 0;
const QString& plotTitle() const;
@@ -153,7 +154,7 @@ public:
virtual int axisExtent( RiuPlotAxis axis ) const = 0;
virtual void ensureAxis( RiuPlotAxis axis ) = 0;
virtual void ensureAxisIsCreated( RiuPlotAxis axis ) = 0;
QPoint dragStartPosition() const;

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;
}
}
}

View File

@@ -92,6 +92,7 @@ public:
void setAxisFormat( RiuPlotAxis axis, const QString& format );
void pruneAxes( const std::set<RiuPlotAxis>& usedAxis ) override;
RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) override;
bool isMultiAxisSupported() const override;
@@ -134,7 +135,7 @@ public:
int axisExtent( RiuPlotAxis axis ) const override;
void ensureAxis( RiuPlotAxis axis ) override;
void ensureAxisIsCreated( RiuPlotAxis axis ) override;
QPoint dragStartPosition() const;

View File

@@ -1051,7 +1051,7 @@ QwtPlot* RiuQwtPlotWidget::qwtPlot() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::ensureAxis( RiuPlotAxis axis )
void RiuQwtPlotWidget::ensureAxisIsCreated( RiuPlotAxis axis )
{
}
@@ -1190,3 +1190,11 @@ bool RiuQwtPlotWidget::isMultiAxisSupported() const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::pruneAxes( const std::set<RiuPlotAxis>& usedAxes )
{
// Currently not supported.
}

View File

@@ -91,6 +91,7 @@ public:
void setAxisTitleText( RiuPlotAxis axis, const QString& title ) override;
void setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) override;
void pruneAxes( const std::set<RiuPlotAxis>& usedAxes ) override;
RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) override;
bool isMultiAxisSupported() const override;
@@ -131,7 +132,7 @@ public:
int axisExtent( RiuPlotAxis axis ) const override;
void ensureAxis( RiuPlotAxis axis ) override;
void ensureAxisIsCreated( RiuPlotAxis axis ) override;
QPoint dragStartPosition() const;