Support horizontally stacked curves (#8553)

* #8548 Horizontal track : Improve stacked curves
* Add horizontal track bar
* Show relevant scroll bar for horizontal and vertical plots
* Show max property value at top for horizontal plots
This commit is contained in:
Magne Sjaastad 2022-02-21 07:15:56 +01:00 committed by GitHub
parent 5c72d31cc9
commit 4ed5250d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 115 additions and 35 deletions

View File

@ -182,6 +182,12 @@ void RimWellLogCurve::updateCurveAppearance()
{
RimPlotCurve::updateCurveAppearance();
RimDepthTrackPlot::DepthOrientation orientation = RimDepthTrackPlot::DepthOrientation::VERTICAL;
RimDepthTrackPlot* wellLogPlot = nullptr;
firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot ) orientation = wellLogPlot->depthOrientation();
if ( m_plotCurve )
{
m_plotCurve->setXAxis( RiuPlotAxis::defaultTop() );
@ -193,9 +199,16 @@ void RimWellLogCurve::updateCurveAppearance()
RiuQwtPlotCurve* qwtPlotCurve = dynamic_cast<RiuQwtPlotCurve*>( m_plotCurve );
if ( qwtPlotCurve )
{
qwtPlotCurve->setOrientation( Qt::Horizontal );
qwtPlotCurve->setBaseline( -std::numeric_limits<double>::infinity() );
qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true );
if ( orientation == RimDepthTrackPlot::DepthOrientation::VERTICAL )
{
qwtPlotCurve->setOrientation( Qt::Horizontal );
qwtPlotCurve->setBaseline( -std::numeric_limits<double>::infinity() );
}
else
{
qwtPlotCurve->setOrientation( Qt::Vertical );
qwtPlotCurve->setBaseline( 0.0 );
}
}
}
}
@ -221,13 +234,21 @@ QString RimWellLogCurve::wellLogCurveIconName()
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::setOverrideCurveData( const std::vector<double>& propertyValues,
const std::vector<double>& depthValues,
const RiaCurveDataTools::CurveIntervals& curveIntervals )
const RiaCurveDataTools::CurveIntervals& curveIntervals,
bool isVerticalPlot )
{
auto minmax_it = std::minmax_element( propertyValues.begin(), propertyValues.end() );
this->setOverrideCurveDataPropertyValueRange( *( minmax_it.first ), *( minmax_it.second ) );
if ( m_plotCurve )
{
m_plotCurve->setSamplesValues( propertyValues, depthValues );
if ( isVerticalPlot )
{
m_plotCurve->setSamplesValues( propertyValues, depthValues );
}
else
{
m_plotCurve->setSamplesValues( depthValues, propertyValues );
}
m_plotCurve->setLineSegmentStartStopIndices( curveIntervals );
}
}

View File

@ -85,7 +85,8 @@ public:
void setOverrideCurveData( const std::vector<double>& propertyValues,
const std::vector<double>& depthValues,
const RiaCurveDataTools::CurveIntervals& curveIntervals );
const RiaCurveDataTools::CurveIntervals& curveIntervals,
bool isVerticalPlot );
virtual RiaDefines::PhaseType resultPhase() const;

View File

@ -1508,7 +1508,6 @@ RiuPlotWidget* RimWellLogTrack::doCreatePlotViewWidget( QWidget* mainWindowParen
if ( m_plotWidget == nullptr )
{
m_plotWidget = new RiuWellLogTrack( this, mainWindowParent );
m_plotWidget->setAxisInverted( getDepthAxis(), true );
updateAxisScaleEngine();
for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx )
@ -1975,6 +1974,20 @@ void RimWellLogTrack::updateAxisScaleEngine()
{
if ( !m_plotWidget ) return;
RimDepthTrackPlot* wellLogPlot = nullptr;
this->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
{
m_plotWidget->setAxisInverted( RiuPlotAxis::defaultLeft(), true );
}
else
{
m_plotWidget->setAxisInverted( RiuPlotAxis::defaultLeft(), false );
}
}
if ( m_isLogarithmicScaleEnabled )
{
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtPlot::xTop, new QwtLogScaleEngine );
@ -2488,6 +2501,14 @@ void RimWellLogTrack::updateStackedCurveData()
if ( allDepthValues.empty() ) continue;
bool isVerticalTrack = true;
RimDepthTrackPlot* wellLogPlot;
this->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
isVerticalTrack = ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL );
}
size_t stackIndex = 0u;
std::vector<double> allStackedValues( allDepthValues.size(), 0.0 );
for ( auto curve : stackedCurvesInGroup )
@ -2511,10 +2532,10 @@ void RimWellLogTrack::updateStackedCurveData()
false,
m_isLogarithmicScaleEnabled );
auto plotDepthValues = tempCurveData.depthValuesByIntervals( depthType, displayUnit );
auto plotDepthValues = tempCurveData.depths( depthType );
auto polyLineStartStopIndices = tempCurveData.polylineStartStopIndices();
curve->setOverrideCurveData( allStackedValues, plotDepthValues, polyLineStartStopIndices );
curve->setOverrideCurveData( allStackedValues, plotDepthValues, polyLineStartStopIndices, isVerticalTrack );
curve->setZOrder( zPos );
if ( !dynamic_cast<RimWellFlowRateCurve*>( curve ) )

View File

@ -17,22 +17,31 @@
RiuWellLogPlot::RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* parent )
: RiuMultiPlotPage( plotDefinition, parent )
{
m_trackScrollBar = new QScrollBar( nullptr );
m_trackScrollBar->setOrientation( Qt::Vertical );
m_trackScrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
m_verticalTrackScrollBar = new QScrollBar( nullptr );
m_verticalTrackScrollBar->setOrientation( Qt::Vertical );
m_verticalTrackScrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
m_trackScrollBarLayout = new QVBoxLayout;
m_trackScrollBarLayout->addWidget( m_trackScrollBar, 0 );
m_verticalTrackScrollBarLayout = new QVBoxLayout;
m_verticalTrackScrollBarLayout->addWidget( m_verticalTrackScrollBar, 0 );
connect( m_trackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
connect( m_verticalTrackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
m_horizontalTrackScrollBar = new QScrollBar( nullptr );
m_horizontalTrackScrollBar->setOrientation( Qt::Horizontal );
m_horizontalTrackScrollBar->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
m_horizontalTrackScrollBarLayout = new QHBoxLayout;
m_horizontalTrackScrollBarLayout->addWidget( m_horizontalTrackScrollBar, 0 );
connect( m_horizontalTrackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimDepthTrackPlot* RiuWellLogPlot::wellLogPlotDefinition()
RimDepthTrackPlot* RiuWellLogPlot::depthTrackPlot()
{
RimDepthTrackPlot* wellLogPlot = dynamic_cast<RimDepthTrackPlot*>( m_plotDefinition.p() );
auto* wellLogPlot = dynamic_cast<RimDepthTrackPlot*>( m_plotDefinition.p() );
CAF_ASSERT( wellLogPlot );
return wellLogPlot;
}
@ -54,13 +63,21 @@ void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisib
double visibleRange = maxVisible - minVisible;
m_trackScrollBar->blockSignals( true );
m_verticalTrackScrollBar->blockSignals( true );
{
m_trackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) );
m_trackScrollBar->setPageStep( (int)visibleRange );
m_trackScrollBar->setValue( (int)minVisible );
m_verticalTrackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) );
m_verticalTrackScrollBar->setPageStep( (int)visibleRange );
m_verticalTrackScrollBar->setValue( (int)minVisible );
}
m_trackScrollBar->blockSignals( false );
m_verticalTrackScrollBar->blockSignals( false );
m_horizontalTrackScrollBar->blockSignals( true );
{
m_horizontalTrackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) );
m_horizontalTrackScrollBar->setPageStep( (int)visibleRange );
m_horizontalTrackScrollBar->setValue( (int)minVisible );
}
m_horizontalTrackScrollBar->blockSignals( false );
}
//--------------------------------------------------------------------------------------------------
@ -68,9 +85,15 @@ void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisib
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::renderTo( QPaintDevice* paintDevice )
{
m_trackScrollBar->setVisible( false );
m_verticalTrackScrollBar->setVisible( false );
m_horizontalTrackScrollBar->setVisible( false );
RiuMultiPlotPage::renderTo( paintDevice );
m_trackScrollBar->setVisible( true );
if ( depthTrackPlot() && depthTrackPlot()->depthOrientation() == RimDepthTrackPlot::DepthOrientation::HORIZONTAL )
m_horizontalTrackScrollBar->setVisible( true );
else
m_verticalTrackScrollBar->setVisible( true );
}
//--------------------------------------------------------------------------------------------------
@ -88,10 +111,19 @@ void RiuWellLogPlot::reinsertScrollbar()
{
QList<QPointer<RiuPlotWidget>> plotWidgets = this->visiblePlotWidgets();
int colCount = this->m_gridLayout->columnCount();
int rowCount = this->m_gridLayout->rowCount();
m_gridLayout->addLayout( m_trackScrollBarLayout, 2, colCount, 1, 1 );
m_trackScrollBar->setVisible( !plotWidgets.empty() );
m_gridLayout->setColumnStretch( colCount, 0 );
if ( depthTrackPlot() && depthTrackPlot()->depthOrientation() == RimDepthTrackPlot::DepthOrientation::HORIZONTAL )
{
m_gridLayout->addLayout( m_horizontalTrackScrollBarLayout, rowCount, 0, 1, colCount );
m_horizontalTrackScrollBar->setVisible( !plotWidgets.empty() );
}
else
{
m_gridLayout->addLayout( m_verticalTrackScrollBarLayout, 2, colCount, 1, 1 );
m_verticalTrackScrollBar->setVisible( !plotWidgets.empty() );
m_gridLayout->setColumnStretch( colCount, 0 );
}
}
//--------------------------------------------------------------------------------------------------
@ -99,7 +131,7 @@ void RiuWellLogPlot::reinsertScrollbar()
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::alignScrollbar( int offset )
{
m_trackScrollBarLayout->setContentsMargins( 0, offset, 0, 0 );
m_verticalTrackScrollBarLayout->setContentsMargins( 0, offset, 0, 0 );
}
//--------------------------------------------------------------------------------------------------
@ -109,11 +141,11 @@ void RiuWellLogPlot::slotSetMinDepth( int value )
{
double minimumDepth;
double maximumDepth;
wellLogPlotDefinition()->visibleDepthRange( &minimumDepth, &maximumDepth );
depthTrackPlot()->visibleDepthRange( &minimumDepth, &maximumDepth );
double delta = value - minimumDepth;
wellLogPlotDefinition()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta );
wellLogPlotDefinition()->setAutoScaleDepthEnabled( false );
depthTrackPlot()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta );
depthTrackPlot()->setAutoScaleDepthEnabled( false );
}
//--------------------------------------------------------------------------------------------------
@ -121,7 +153,9 @@ void RiuWellLogPlot::slotSetMinDepth( int value )
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::performUpdate()
{
m_trackScrollBar->setVisible( false );
m_horizontalTrackScrollBar->setVisible( false );
m_verticalTrackScrollBar->setVisible( false );
reinsertPlotWidgets();
reinsertScrollbar();
int axisShift = alignCanvasTops();

View File

@ -41,13 +41,16 @@ protected:
void alignScrollbar( int offset );
private:
RimDepthTrackPlot* wellLogPlotDefinition();
RimDepthTrackPlot* depthTrackPlot();
private slots:
void slotSetMinDepth( int value );
void performUpdate() override;
private:
QPointer<QVBoxLayout> m_trackScrollBarLayout;
QScrollBar* m_trackScrollBar;
QPointer<QVBoxLayout> m_verticalTrackScrollBarLayout;
QScrollBar* m_verticalTrackScrollBar;
QPointer<QHBoxLayout> m_horizontalTrackScrollBarLayout;
QScrollBar* m_horizontalTrackScrollBar;
};