diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp index 16b37542f2..0fde3bcf15 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp @@ -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 ); } //-------------------------------------------------------------------------------------------------- @@ -265,10 +265,9 @@ void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves() { std::vector 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, @@ -279,7 +278,8 @@ void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves() fixedYAxis, m_qwtPlot, &m_myPlotMarkers, - skipUnscaledLegend ); + m_showScaledCheckBox->isChecked(), + m_showUnscaledCheckBox->isChecked() ); } //-------------------------------------------------------------------------------------------------- @@ -342,8 +342,11 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS bool fixedLeftYAxis, QwtPlot* plot, std::vector* 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 @@ -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 ); @@ -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() ) { @@ -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; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.h b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.h index 1c947085fd..5a7194ec2b 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.h +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.h @@ -32,6 +32,7 @@ class QButtonGroup; class QCheckBox; class QwtPlot; class QwtPlotMarker; +class QwtPlotCurve; class QPointF; class QGroupBox; @@ -88,7 +89,10 @@ class RiuRelativePermeabilityPlotPanel : public QWidget bool fixedLeftYAxis, QwtPlot* plot, std::vector* myPlotMarkers, - bool skipUnscaledLegends ); + bool showScaled, + bool showUnscaled ); + + static QwtPlotCurve* getLegendCurve( QString title, bool scaled ); static QString determineXAxisTitleFromCurveCollection( const std::vector& curveArr );