Depth Axis : Improve visibility logic

This commit is contained in:
Magne Sjaastad 2022-08-23 23:55:40 -07:00 committed by GitHub
parent 8c835b5568
commit 4d244bc848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 findFirstVisibleTrack = [this]() {
auto plots = visiblePlots();
if ( !plots.empty() ) return plots.front();
return static_cast<RimWellLogTrack*>( nullptr );
};
auto plots = visiblePlots();
auto firstVisibleTrack = findFirstVisibleTrack();
return firstVisibleTrack && firstVisibleTrack == track;
}
for ( auto p : plots )
{
auto plotWidget = p->plotWidget();
if ( !plotWidget ) continue;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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 );
};
bool isFirstTrack = ( p == plots.front() );
bool isLastTrack = ( p == plots.back() );
auto lastVisibleTrack = findLastVisibleTrack();
return lastVisibleTrack && lastVisibleTrack == track;
p->updateAxesVisibility( depthOrientation(), isFirstTrack, isLastTrack );
}
}
//--------------------------------------------------------------------------------------------------
@ -1066,6 +1053,8 @@ void RimDepthTrackPlot::updatePlots()
{
if ( m_showWindow )
{
updateDepthAxisVisibility();
for ( RimPlot* plot : plots() )
{
plot->loadDataAndUpdate();

View File

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

View File

@ -574,6 +574,10 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
updateParentLayout();
RimDepthTrackPlot* depthTrackPlot;
this->firstAncestorOrThisOfTypeAsserted( depthTrackPlot );
depthTrackPlot->updateDepthAxisVisibility();
}
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() ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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( 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 )

View File

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