From 74cfc14143712b83b01757cbabf88b010e1111e6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 14 Sep 2024 17:05:53 +0200 Subject: [PATCH] #11696 Make sure PC axis is visible when required Use QwtPlotCurve directly to make it possible to see the Y Axis --- .../RiuRelativePermeabilityPlotPanel.cpp | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp index 0b8e5b6c2d..f6a5924f8a 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp @@ -27,14 +27,12 @@ #include "RiuDockedQwtPlot.h" #include "RiuGuiTheme.h" #include "RiuPlotCurveSymbol.h" -#include "RiuQwtPlotCurve.h" #include "RiuQwtPlotTools.h" #include "RiuQwtSymbol.h" #include "RiuRelativePermeabilityPlotUpdater.h" #include "RiuTextDialog.h" #include "cvfAssert.h" -#include "cvfTrace.h" #include "qwt_legend.h" #include "qwt_plot.h" @@ -89,6 +87,14 @@ RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel( QWidget* par , m_swat( HUGE_VAL ) , m_sgas( HUGE_VAL ) , m_plotUpdater( new RiuRelativePermeabilityPlotUpdater( this ) ) + , m_qwtPlot( nullptr ) + , m_selectedCurvesButtonGroup( nullptr ) + , m_groupBox( nullptr ) + , m_logarithmicScaleKrAxisCheckBox( nullptr ) + , m_showUnscaledCheckBox( nullptr ) + , m_fixedXAxisCheckBox( nullptr ) + , m_fixedLeftYAxisCheckBox( nullptr ) + { m_qwtPlot = new RelPermQwtPlot( this ); m_qwtPlot->setProperty( "qss-class", "RelPermPlot" ); @@ -161,7 +167,6 @@ RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel( QWidget* par RiuRelativePermeabilityPlotPanel::~RiuRelativePermeabilityPlotPanel() { } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -352,11 +357,10 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS plotOnWhichYAxis = RIGHT_YAXIS; } - RiuQwtPlotCurve* qwtCurve = new RiuQwtPlotCurve( nullptr, curve.name.c_str() ); + QwtPlotCurve* qwtCurve = new QwtPlotCurve( curve.name.c_str() ); CVF_ASSERT( curve.saturationVals.size() == curve.yVals.size() ); - const bool includePositiveValuesOnly = ( logScaleLeftAxis && plotOnWhichYAxis == LEFT_YAXIS ); - qwtCurve->setSamplesFromXValuesAndYValues( curve.saturationVals, curve.yVals, includePositiveValuesOnly ); + qwtCurve->setSamples( curve.saturationVals.data(), curve.yVals.data(), static_cast( curve.saturationVals.size() ) ); qwtCurve->setTitle( curve.name.c_str() ); @@ -390,7 +394,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS const QPen curvePen( QBrush(), 1, penStyle ); qwtCurve->setPen( curvePen ); - RiuQwtSymbol* curveSymbol = new RiuQwtSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ); + auto* curveSymbol = new RiuQwtSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ); curveSymbol->setSize( 6, 6 ); curveSymbol->setBrush( Qt::NoBrush ); qwtCurve->setSymbol( curveSymbol ); @@ -403,7 +407,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS if ( plotOnWhichYAxis == RIGHT_YAXIS ) { - qwtCurve->setYAxis( RiuPlotAxis::defaultRight() ); + qwtCurve->setYAxis( { QwtAxis::YRight, 0 } ); shouldEnableRightYAxis = true; } @@ -432,9 +436,15 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS } if ( shouldEnableRightYAxis ) + { plot->setAxesCount( QwtAxis::YRight, 1 ); + plot->setAxisVisible( QwtAxis::YRight, true ); + } else + { plot->setAxesCount( QwtAxis::YRight, 0 ); + plot->setAxisVisible( QwtAxis::YRight, false ); + } addTransparentCurve( plot, points, axes, logScaleLeftAxis );