Depth Axis : Improve visibility logic

This commit is contained in:
Magne Sjaastad 2022-08-23 23:55:40 -07:00
parent 86b21714eb
commit 6ac6b5a795
4 changed files with 58 additions and 44 deletions

View File

@ -771,33 +771,20 @@ void RimDepthTrackPlot::onPlotsReordered( const SignalEmitter* emitter )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimDepthTrackPlot::isFirstVisibleTrack( RimWellLogTrack* track ) void RimDepthTrackPlot::updateDepthAxisVisibility()
{ {
// Find first visible track auto plots = visiblePlots();
auto findFirstVisibleTrack = [this]() {
auto plots = visiblePlots();
if ( !plots.empty() ) return plots.front();
return static_cast<RimWellLogTrack*>( nullptr );
};
auto firstVisibleTrack = findFirstVisibleTrack(); for ( auto p : plots )
return firstVisibleTrack && firstVisibleTrack == track; {
} auto plotWidget = p->plotWidget();
if ( !plotWidget ) continue;
//-------------------------------------------------------------------------------------------------- bool isFirstTrack = ( p == plots.front() );
/// bool isLastTrack = ( p == plots.back() );
//--------------------------------------------------------------------------------------------------
bool RimDepthTrackPlot::isLastVisibleTrack( RimWellLogTrack* track )
{
// Find last visible track
auto findLastVisibleTrack = [this]() {
auto plots = visiblePlots();
if ( !plots.empty() ) return plots.back();
return static_cast<RimWellLogTrack*>( nullptr );
};
auto lastVisibleTrack = findLastVisibleTrack(); p->updateAxesVisibility( depthOrientation(), isFirstTrack, isLastTrack );
return lastVisibleTrack && lastVisibleTrack == track; }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1066,6 +1053,8 @@ void RimDepthTrackPlot::updatePlots()
{ {
if ( m_showWindow ) if ( m_showWindow )
{ {
updateDepthAxisVisibility();
for ( RimPlot* plot : plots() ) for ( RimPlot* plot : plots() )
{ {
plot->loadDataAndUpdate(); plot->loadDataAndUpdate();

View File

@ -149,8 +149,7 @@ public:
RiaDefines::DepthUnitType caseDepthUnit() const; RiaDefines::DepthUnitType caseDepthUnit() const;
bool isFirstVisibleTrack( RimWellLogTrack* track ); void updateDepthAxisVisibility();
bool isLastVisibleTrack( RimWellLogTrack* track );
static RiuPlotAxis depthAxis( DepthOrientation depthOrientation ); static RiuPlotAxis depthAxis( DepthOrientation depthOrientation );
static RiuPlotAxis valueAxis( DepthOrientation depthOrientation ); static RiuPlotAxis valueAxis( DepthOrientation depthOrientation );

View File

@ -574,6 +574,10 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
} }
updateParentLayout(); updateParentLayout();
RimDepthTrackPlot* depthTrackPlot;
this->firstAncestorOrThisOfTypeAsserted( depthTrackPlot );
depthTrackPlot->updateDepthAxisVisibility();
} }
else if ( changedField == &m_description ) else if ( changedField == &m_description )
{ {
@ -1263,6 +1267,46 @@ bool RimWellLogTrack::isEmptyVisiblePropertyRange() const
1.0e-6 * std::max( 1.0, std::max( m_visiblePropertyValueRangeMax(), m_visiblePropertyValueRangeMin() ) ); 1.0e-6 * std::max( 1.0, std::max( m_visiblePropertyValueRangeMax(), m_visiblePropertyValueRangeMin() ) );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateAxesVisibility( RimDepthTrackPlot::DepthOrientation orientation, bool isFirstTrack, bool isLastTrack )
{
if ( !m_plotWidget ) return;
auto setAxisVisible = [this]( QwtAxis::Position axis, bool enable ) {
auto plot = m_plotWidget->qwtPlot();
if ( !plot ) return false;
bool isCurrentlyEnabled = plot->isAxisVisible( axis );
if ( enable == isCurrentlyEnabled ) return false;
m_plotWidget->setAxisEnabled( axis, enable );
return true;
};
bool needUpdate = false;
if ( orientation == RimDepthTrackPlot::DepthOrientation::VERTICAL )
{
// Show depth axis only for the first track (on the left side)
needUpdate |= setAxisVisible( QwtAxis::XBottom, false );
needUpdate |= setAxisVisible( QwtAxis::XTop, true );
needUpdate |= setAxisVisible( QwtAxis::YLeft, isFirstTrack );
needUpdate |= setAxisVisible( QwtAxis::YRight, false );
}
else
{
// Show depth axis only for the last track (on the bottom side)
needUpdate |= setAxisVisible( QwtAxis::XTop, false );
needUpdate |= setAxisVisible( QwtAxis::XBottom, isLastTrack );
needUpdate |= setAxisVisible( QwtAxis::YLeft, true );
needUpdate |= setAxisVisible( QwtAxis::YRight, false );
}
if ( needUpdate ) onLoadDataAndUpdate();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1287,25 +1331,6 @@ void RimWellLogTrack::onLoadDataAndUpdate()
{ {
m_plotWidget->setAxisTitleText( valueAxis(), m_propertyValueAxisTitle ); m_plotWidget->setAxisTitleText( valueAxis(), m_propertyValueAxisTitle );
m_plotWidget->setAxisTitleText( depthAxis(), wellLogPlot->depthAxisTitle() ); m_plotWidget->setAxisTitleText( depthAxis(), wellLogPlot->depthAxisTitle() );
if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
{
// Show depth axis only for the first track (on the left side)
bool isFirstTrack = wellLogPlot->isFirstVisibleTrack( this );
m_plotWidget->setAxisEnabled( QwtAxis::XTop, true );
m_plotWidget->setAxisEnabled( QwtAxis::XBottom, false );
m_plotWidget->setAxisEnabled( QwtAxis::YLeft, isFirstTrack );
m_plotWidget->setAxisEnabled( QwtAxis::YRight, false );
}
else
{
// Show depth axis only for the last track (on the bottom side)
bool isLastTrack = wellLogPlot->isLastVisibleTrack( this );
m_plotWidget->setAxisEnabled( QwtAxis::XTop, false );
m_plotWidget->setAxisEnabled( QwtAxis::XBottom, isLastTrack );
m_plotWidget->setAxisEnabled( QwtAxis::YLeft, true );
m_plotWidget->setAxisEnabled( QwtAxis::YRight, false );
}
} }
for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx ) for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx )

View File

@ -237,6 +237,7 @@ public:
void setCurvesTreeVisibility( bool isVisible ); void setCurvesTreeVisibility( bool isVisible );
void setEnsembleWellLogCurveSet( RimEnsembleWellLogCurveSet* curveSet ); void setEnsembleWellLogCurveSet( RimEnsembleWellLogCurveSet* curveSet );
void updateAxesVisibility( RimDepthTrackPlot::DepthOrientation orientation, bool isFirstTrack, bool isLastTrack );
protected: protected:
// RimViewWindow overrides // RimViewWindow overrides