Skip to content

Commit

Permalink
#11696 Make sure PC axis is visible when required
Browse files Browse the repository at this point in the history
Use QwtPlotCurve directly to make it possible to see the Y Axis
  • Loading branch information
magnesj authored Sep 14, 2024
1 parent d8b8c86 commit 74cfc14
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" );
Expand Down Expand Up @@ -161,7 +167,6 @@ RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel( QWidget* par
RiuRelativePermeabilityPlotPanel::~RiuRelativePermeabilityPlotPanel()
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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<int>( curve.saturationVals.size() ) );

qwtCurve->setTitle( curve.name.c_str() );

Expand Down Expand Up @@ -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 );
Expand All @@ -403,7 +407,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS

if ( plotOnWhichYAxis == RIGHT_YAXIS )
{
qwtCurve->setYAxis( RiuPlotAxis::defaultRight() );
qwtCurve->setYAxis( { QwtAxis::YRight, 0 } );
shouldEnableRightYAxis = true;
}

Expand Down Expand Up @@ -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 );

Expand Down

0 comments on commit 74cfc14

Please sign in to comment.