Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rel perm plot legend adjustments #11996

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void RiuRelativePermeabilityPlotPanel::clearPlot()
m_caseName.clear();
m_cellReferenceText.clear();

plotCurvesInQwt( m_unitSystem, m_allCurvesArr, m_swat, m_sgas, m_cellReferenceText, false, true, true, m_qwtPlot, &m_myPlotMarkers, false );
plotCurvesInQwt( m_unitSystem, m_allCurvesArr, m_swat, m_sgas, m_cellReferenceText, false, true, true, m_qwtPlot, &m_myPlotMarkers, false, false );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -265,10 +265,9 @@ void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves()
{
std::vector<RigFlowDiagSolverInterface::RelPermCurve> selectedCurves = gatherUiSelectedCurves();

const bool useLogScale = m_logarithmicScaleKrAxisCheckBox->isChecked();
const bool fixedXAxis = m_fixedXAxisCheckBox->isChecked();
const bool fixedYAxis = m_fixedLeftYAxisCheckBox->isChecked();
const bool skipUnscaledLegend = m_showUnscaledCheckBox->isChecked() && m_showScaledCheckBox->isChecked();
const bool useLogScale = m_logarithmicScaleKrAxisCheckBox->isChecked();
const bool fixedXAxis = m_fixedXAxisCheckBox->isChecked();
const bool fixedYAxis = m_fixedLeftYAxisCheckBox->isChecked();
plotCurvesInQwt( m_unitSystem,
selectedCurves,
m_swat,
Expand All @@ -279,7 +278,8 @@ void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves()
fixedYAxis,
m_qwtPlot,
&m_myPlotMarkers,
skipUnscaledLegend );
m_showScaledCheckBox->isChecked(),
m_showUnscaledCheckBox->isChecked() );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -342,8 +342,11 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS
bool fixedLeftYAxis,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers,
bool skipUnscaledLegends )
bool showScaled,
bool showUnscaled )
{
bool skipUnscaledLegends = showScaled && showUnscaled;

plot->detachItems( QwtPlotItem::Rtti_PlotCurve );

// Workaround for detaching only plot markers that we have added
Expand Down Expand Up @@ -421,7 +424,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS
qwtCurve->setSymbol( curveSymbol );

qwtCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
qwtCurve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
qwtCurve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, false );
qwtCurve->setLegendAttribute( QwtPlotCurve::LegendShowBrush, true );

const bool showLegend = !( unscaledCurve && skipUnscaledLegends );
Expand Down Expand Up @@ -524,6 +527,18 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS
plot->setAxisAutoScale( QwtAxis::YLeft, true );
}

if ( showScaled )
{
QwtPlotCurve* curve = getLegendCurve( "Scaled", true /*scaled*/ );
curve->attach( plot );
}

if ( showUnscaled )
{
QwtPlotCurve* curve = getLegendCurve( "Unscaled", false /*scaled*/ );
curve->attach( plot );
}

QString titleStr = "Relative Permeability";
if ( !cellReferenceText.isEmpty() )
{
Expand All @@ -537,6 +552,30 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS
plot->replot();
}

QwtPlotCurve* RiuRelativePermeabilityPlotPanel::getLegendCurve( QString title, bool scaled )
{
QwtPlotCurve* curve = new QwtPlotCurve( title );

curve->setTitle( title );

curve->setStyle( QwtPlotCurve::Lines );

const QPen curvePen( QBrush(), 1, Qt::SolidLine );
curve->setPen( curvePen );

auto* curveSymbol = scaled ? new RiuQwtSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ) : new RiuQwtSymbol( RiuPlotCurveSymbol::SYMBOL_CROSS );
curveSymbol->setSize( 6, 6 );
curveSymbol->setBrush( QBrush() );
curve->setSymbol( curveSymbol );

curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
curve->setLegendAttribute( QwtPlotCurve::LegendShowBrush, false );
curve->setItemAttribute( QwtPlotItem::Legend, true );

return curve;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class QButtonGroup;
class QCheckBox;
class QwtPlot;
class QwtPlotMarker;
class QwtPlotCurve;
class QPointF;
class QGroupBox;

Expand Down Expand Up @@ -88,7 +89,10 @@ class RiuRelativePermeabilityPlotPanel : public QWidget
bool fixedLeftYAxis,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers,
bool skipUnscaledLegends );
bool showScaled,
bool showUnscaled );

static QwtPlotCurve* getLegendCurve( QString title, bool scaled );

static QString determineXAxisTitleFromCurveCollection( const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr );

Expand Down
Loading