#8787 Summary Multiplot: Fix inversion of axis with axis aggregation.

This commit is contained in:
Kristian Bendiksen 2022-05-23 15:48:20 +02:00 committed by Magne Sjaastad
parent 01e670a3d8
commit 1aa41968a5
2 changed files with 26 additions and 17 deletions

View File

@ -768,10 +768,11 @@ void RimSummaryMultiPlot::syncAxisRanges()
{ {
double minVal = axis->visibleRangeMin(); double minVal = axis->visibleRangeMin();
double maxVal = axis->visibleRangeMax(); double maxVal = axis->visibleRangeMax();
if ( axis->isAxisInverted() ) std::swap( minVal, maxVal );
if ( axisRanges.count( axis->plotAxisType() ) == 0 ) if ( axisRanges.count( axis->plotAxisType() ) == 0 )
{ {
axisRanges[axis->plotAxisType()] = std::make_pair( axis->visibleRangeMin(), axis->visibleRangeMax() ); axisRanges[axis->plotAxisType()] = std::make_pair( minVal, maxVal );
} }
else else
{ {
@ -787,7 +788,8 @@ void RimSummaryMultiPlot::syncAxisRanges()
{ {
for ( auto axis : plot->plotAxes() ) for ( auto axis : plot->plotAxes() )
{ {
const auto& [minVal, maxVal] = axisRanges[axis->plotAxisType()]; auto [minVal, maxVal] = axisRanges[axis->plotAxisType()];
if ( axis->isAxisInverted() ) std::swap( minVal, maxVal );
axis->setAutoZoom( false ); axis->setAutoZoom( false );
axis->setVisibleRangeMin( minVal ); axis->setVisibleRangeMin( minVal );
axis->setVisibleRangeMax( maxVal ); axis->setVisibleRangeMax( maxVal );
@ -955,25 +957,23 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
// set all plots to use the global min/max values for each category // set all plots to use the global min/max values for each category
for ( auto axis : plot->plotAxes() ) for ( auto axis : plot->plotAxes() )
{ {
QwtLinearScaleEngine scaleEngine; auto [minVal, maxVal] = axisRanges[axis->plotAxisType()];
if ( RiaDefines::isVertical( axis->plotAxisType().axis() ) && !std::isinf( minVal ) && !std::isinf( maxVal ) )
const auto& [minVal, maxVal] = axisRanges[axis->plotAxisType()];
if ( axis->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT && minVal <= maxVal )
{ {
axis->setAutoZoom( false ); axis->setAutoZoom( false );
auto adjustedMin = minVal; if ( axis->isAxisInverted() ) std::swap( minVal, maxVal );
auto adjustedMax = maxVal;
if ( !axis->isLogarithmicScaleEnabled() ) if ( !axis->isLogarithmicScaleEnabled() )
{ {
int maxMajorTickIntervalCount = 8; int maxMajorTickIntervalCount = 8;
double stepSize = 0.0; double stepSize = 0.0;
scaleEngine.autoScale( maxMajorTickIntervalCount, adjustedMin, adjustedMax, stepSize ); QwtLinearScaleEngine scaleEngine;
scaleEngine.autoScale( maxMajorTickIntervalCount, minVal, maxVal, stepSize );
} }
axis->setVisibleRangeMin( adjustedMin ); axis->setVisibleRangeMin( minVal );
axis->setVisibleRangeMax( adjustedMax ); axis->setVisibleRangeMax( maxVal );
} }
} }
@ -1132,7 +1132,11 @@ void RimSummaryMultiPlot::onSubPlotChanged( const caf::SignalEmitter* emitter )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryMultiPlot::onSubPlotAxisChanged( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot ) void RimSummaryMultiPlot::onSubPlotAxisChanged( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot )
{ {
if ( !m_linkSubPlotAxes() ) return; if ( !m_linkSubPlotAxes() )
{
syncAxisRanges();
return;
}
for ( auto plot : summaryPlots() ) for ( auto plot : summaryPlots() )
{ {
@ -1142,6 +1146,8 @@ void RimSummaryMultiPlot::onSubPlotAxisChanged( const caf::SignalEmitter* emitte
plot->updateAll(); plot->updateAll();
} }
} }
syncAxisRanges();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -911,9 +911,10 @@ void RimSummaryPlot::updateZoomForAxis( RiuPlotAxis plotAxis )
} }
else else
{ {
plotWidget()->setAxisScale( yAxisProps->plotAxisType(), double min = yAxisProps->visibleRangeMin();
yAxisProps->visibleRangeMin(), double max = yAxisProps->visibleRangeMax();
yAxisProps->visibleRangeMax() ); if ( yAxisProps->isAxisInverted() ) std::swap( min, max );
plotWidget()->setAxisScale( yAxisProps->plotAxisType(), min, max );
} }
plotWidget()->setAxisInverted( yAxisProps->plotAxisType(), yAxisProps->isAxisInverted() ); plotWidget()->setAxisInverted( yAxisProps->plotAxisType(), yAxisProps->isAxisInverted() );
@ -1662,6 +1663,8 @@ void RimSummaryPlot::updateZoomFromParentPlot()
for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties ) for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties )
{ {
auto [axisMin, axisMax] = plotWidget()->axisRange( axisProperties->plotAxisType() ); auto [axisMin, axisMax] = plotWidget()->axisRange( axisProperties->plotAxisType() );
if ( axisProperties->isAxisInverted() ) std::swap( axisMin, axisMax );
axisProperties->setVisibleRangeMax( axisMax ); axisProperties->setVisibleRangeMax( axisMax );
axisProperties->setVisibleRangeMin( axisMin ); axisProperties->setVisibleRangeMin( axisMin );
axisProperties->updateConnectedEditors(); axisProperties->updateConnectedEditors();