mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-07 14:43:10 -06:00
Axis assignment : Use axis with same unit by default
This commit is contained in:
parent
d5b108d2ef
commit
47a44a79df
@ -2413,18 +2413,65 @@ std::vector<RimPlotAxisPropertiesInterface*> RimSummaryPlot::plotAxes() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::assignPlotAxis( RimSummaryCurve* curve )
|
||||
void RimSummaryPlot::assignPlotAxis( RimSummaryCurve* destinationCurve )
|
||||
{
|
||||
enum class AxisAssignmentStrategy
|
||||
{
|
||||
ALL_TO_LEFT,
|
||||
ALL_TO_RIGHT,
|
||||
ALTERNATING
|
||||
ALTERNATING,
|
||||
USE_MATCHING_UNIT
|
||||
};
|
||||
|
||||
RiaDefines::PlotAxis plotAxis = RiaDefines::PlotAxis::PLOT_AXIS_LEFT;
|
||||
|
||||
auto strategy = AxisAssignmentStrategy::ALTERNATING;
|
||||
auto strategy = AxisAssignmentStrategy::USE_MATCHING_UNIT;
|
||||
if ( strategy == AxisAssignmentStrategy::USE_MATCHING_UNIT )
|
||||
{
|
||||
auto destinationUnit = destinationCurve->unitNameY();
|
||||
|
||||
bool isLeftUsed = false;
|
||||
bool isRightUsed = false;
|
||||
|
||||
for ( auto c : summaryCurves() )
|
||||
{
|
||||
if ( c == destinationCurve ) continue;
|
||||
|
||||
if ( c->axisY() == RiuPlotAxis::defaultLeft() ) isLeftUsed = true;
|
||||
if ( c->axisY() == RiuPlotAxis::defaultRight() ) isRightUsed = true;
|
||||
|
||||
auto currentUnit = c->unitNameY();
|
||||
|
||||
if ( currentUnit == destinationUnit )
|
||||
{
|
||||
for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties )
|
||||
{
|
||||
if ( axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ||
|
||||
axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT )
|
||||
{
|
||||
destinationCurve->setLeftOrRightAxisY( c->axisY() );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isLeftUsed )
|
||||
{
|
||||
destinationCurve->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isRightUsed )
|
||||
{
|
||||
destinationCurve->setLeftOrRightAxisY( RiuPlotAxis::defaultRight() );
|
||||
return;
|
||||
}
|
||||
|
||||
strategy = AxisAssignmentStrategy::ALTERNATING;
|
||||
}
|
||||
|
||||
if ( strategy == AxisAssignmentStrategy::ALTERNATING )
|
||||
{
|
||||
size_t axisCountLeft = 0;
|
||||
@ -2452,14 +2499,14 @@ void RimSummaryPlot::assignPlotAxis( RimSummaryCurve* curve )
|
||||
if ( plotWidget() && plotWidget()->isMultiAxisSupported() )
|
||||
{
|
||||
QString axisObjectName = "New Axis";
|
||||
if ( !curve->summaryAddressY().uiText().empty() )
|
||||
axisObjectName = QString::fromStdString( curve->summaryAddressY().uiText() );
|
||||
if ( !destinationCurve->summaryAddressY().uiText().empty() )
|
||||
axisObjectName = QString::fromStdString( destinationCurve->summaryAddressY().uiText() );
|
||||
|
||||
newPlotAxis = plotWidget()->createNextPlotAxis( plotAxis );
|
||||
addNewAxisProperties( newPlotAxis, axisObjectName );
|
||||
}
|
||||
|
||||
curve->setLeftOrRightAxisY( newPlotAxis );
|
||||
destinationCurve->setLeftOrRightAxisY( newPlotAxis );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user