mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#8522 Summary Plot: Prune unused axes after move or delete
This commit is contained in:
parent
1a1acfa006
commit
10cb2d7d0b
@ -95,8 +95,15 @@ RimPlotAxisProperties::RimPlotAxisProperties()
|
|||||||
m_annotations.uiCapability()->setUiTreeHidden( true );
|
m_annotations.uiCapability()->setUiTreeHidden( true );
|
||||||
|
|
||||||
updateOptionSensitivity();
|
updateOptionSensitivity();
|
||||||
|
}
|
||||||
|
|
||||||
setDeletable( true );
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimPlotAxisProperties::isDeletable() const
|
||||||
|
{
|
||||||
|
// The default axes (which have index 0) are not deletable
|
||||||
|
return m_plotAxisIndex != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -77,6 +77,9 @@ public:
|
|||||||
bool isAxisInverted() const override;
|
bool isAxisInverted() const override;
|
||||||
void setAxisInverted( bool inverted );
|
void setAxisInverted( bool inverted );
|
||||||
|
|
||||||
|
bool isDeletable() const override;
|
||||||
|
|
||||||
|
|
||||||
std::vector<RimPlotAxisAnnotation*> annotations() const override;
|
std::vector<RimPlotAxisAnnotation*> annotations() const override;
|
||||||
void appendAnnotation( RimPlotAxisAnnotation* annotation ) override;
|
void appendAnnotation( RimPlotAxisAnnotation* annotation ) override;
|
||||||
void removeAllAnnotations() override;
|
void removeAllAnnotations() override;
|
||||||
|
@ -753,6 +753,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
|
|||||||
|
|
||||||
updatePlotAxis();
|
updatePlotAxis();
|
||||||
plot->updateAxes();
|
plot->updateAxes();
|
||||||
|
plot->updateAll();
|
||||||
|
|
||||||
updateTextInPlot = true;
|
updateTextInPlot = true;
|
||||||
}
|
}
|
||||||
@ -2099,6 +2100,11 @@ void RimEnsembleCurveSet::setAxisY( RiuPlotAxis plotAxis )
|
|||||||
RimSummaryPlot* plot = nullptr;
|
RimSummaryPlot* plot = nullptr;
|
||||||
firstAncestorOrThisOfTypeAsserted( plot );
|
firstAncestorOrThisOfTypeAsserted( plot );
|
||||||
m_plotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis );
|
m_plotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis );
|
||||||
|
|
||||||
|
for ( RimSummaryCurve* curve : curves() )
|
||||||
|
{
|
||||||
|
curve->setLeftOrRightAxisY( axisY() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -845,7 +845,7 @@ void RimSummaryPlot::updateZoomForAxis( RiuPlotAxis plotAxis )
|
|||||||
}
|
}
|
||||||
|
|
||||||
double min, max;
|
double min, max;
|
||||||
RimPlotAxisLogRangeCalculator calc( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, plotCurves );
|
RimPlotAxisLogRangeCalculator calc( plotAxis.axis(), plotCurves );
|
||||||
calc.computeAxisRange( &min, &max );
|
calc.computeAxisRange( &min, &max );
|
||||||
|
|
||||||
if ( yAxisProps->isAxisInverted() )
|
if ( yAxisProps->isAxisInverted() )
|
||||||
@ -2008,7 +2008,7 @@ RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent
|
|||||||
|
|
||||||
for ( auto axisProperties : m_axisProperties )
|
for ( auto axisProperties : m_axisProperties )
|
||||||
{
|
{
|
||||||
plotWidget()->ensureAxis( axisProperties->plotAxisType() );
|
plotWidget()->ensureAxisIsCreated( axisProperties->plotAxisType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
|
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
|
||||||
@ -2482,6 +2482,13 @@ void RimSummaryPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childAr
|
|||||||
|
|
||||||
if ( plotWidget() )
|
if ( plotWidget() )
|
||||||
{
|
{
|
||||||
|
std::set<RiuPlotAxis> usedPlotAxis;
|
||||||
|
for ( auto axisProperties : m_axisProperties )
|
||||||
|
{
|
||||||
|
usedPlotAxis.insert( axisProperties->plotAxisType() );
|
||||||
|
}
|
||||||
|
|
||||||
|
plotWidget()->pruneAxes( usedPlotAxis );
|
||||||
updateAxes();
|
updateAxes();
|
||||||
plotWidget()->scheduleReplot();
|
plotWidget()->scheduleReplot();
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,7 @@ public:
|
|||||||
|
|
||||||
virtual bool isMultiAxisSupported() const = 0;
|
virtual bool isMultiAxisSupported() const = 0;
|
||||||
virtual RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) = 0;
|
virtual RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) = 0;
|
||||||
|
virtual void pruneAxes( const std::set<RiuPlotAxis>& usedAxes ) = 0;
|
||||||
|
|
||||||
virtual void setPlotTitle( const QString& plotTitle ) = 0;
|
virtual void setPlotTitle( const QString& plotTitle ) = 0;
|
||||||
const QString& plotTitle() const;
|
const QString& plotTitle() const;
|
||||||
@ -153,7 +154,7 @@ public:
|
|||||||
|
|
||||||
virtual int axisExtent( RiuPlotAxis axis ) const = 0;
|
virtual int axisExtent( RiuPlotAxis axis ) const = 0;
|
||||||
|
|
||||||
virtual void ensureAxis( RiuPlotAxis axis ) = 0;
|
virtual void ensureAxisIsCreated( RiuPlotAxis axis ) = 0;
|
||||||
|
|
||||||
QPoint dragStartPosition() const;
|
QPoint dragStartPosition() const;
|
||||||
|
|
||||||
|
@ -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() )
|
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 )
|
void RiuQtChartsPlotWidget::setAxis( RiuPlotAxis axis, QtCharts::QAbstractSeries* series )
|
||||||
{
|
{
|
||||||
// Make sure the axis we are about to set exists.
|
// Make sure the axis we are about to set exists.
|
||||||
ensureAxis( axis );
|
ensureAxisIsCreated( axis );
|
||||||
|
|
||||||
if ( qtChart()->series().contains( series ) && !series->attachedAxes().contains( plotAxis( 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;
|
if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) return Qt::AlignLeft;
|
||||||
return Qt::AlignRight;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -92,6 +92,7 @@ public:
|
|||||||
|
|
||||||
void setAxisFormat( RiuPlotAxis axis, const QString& format );
|
void setAxisFormat( RiuPlotAxis axis, const QString& format );
|
||||||
|
|
||||||
|
void pruneAxes( const std::set<RiuPlotAxis>& usedAxis ) override;
|
||||||
RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) override;
|
RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) override;
|
||||||
bool isMultiAxisSupported() const override;
|
bool isMultiAxisSupported() const override;
|
||||||
|
|
||||||
@ -134,7 +135,7 @@ public:
|
|||||||
|
|
||||||
int axisExtent( RiuPlotAxis axis ) const override;
|
int axisExtent( RiuPlotAxis axis ) const override;
|
||||||
|
|
||||||
void ensureAxis( RiuPlotAxis axis ) override;
|
void ensureAxisIsCreated( RiuPlotAxis axis ) override;
|
||||||
|
|
||||||
QPoint dragStartPosition() const;
|
QPoint dragStartPosition() const;
|
||||||
|
|
||||||
|
@ -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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuQwtPlotWidget::pruneAxes( const std::set<RiuPlotAxis>& usedAxes )
|
||||||
|
{
|
||||||
|
// Currently not supported.
|
||||||
|
}
|
||||||
|
@ -91,6 +91,7 @@ public:
|
|||||||
void setAxisTitleText( RiuPlotAxis axis, const QString& title ) override;
|
void setAxisTitleText( RiuPlotAxis axis, const QString& title ) override;
|
||||||
void setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) override;
|
void setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) override;
|
||||||
|
|
||||||
|
void pruneAxes( const std::set<RiuPlotAxis>& usedAxes ) override;
|
||||||
RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) override;
|
RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) override;
|
||||||
bool isMultiAxisSupported() const override;
|
bool isMultiAxisSupported() const override;
|
||||||
|
|
||||||
@ -131,7 +132,7 @@ public:
|
|||||||
|
|
||||||
int axisExtent( RiuPlotAxis axis ) const override;
|
int axisExtent( RiuPlotAxis axis ) const override;
|
||||||
|
|
||||||
void ensureAxis( RiuPlotAxis axis ) override;
|
void ensureAxisIsCreated( RiuPlotAxis axis ) override;
|
||||||
|
|
||||||
QPoint dragStartPosition() const;
|
QPoint dragStartPosition() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user