Depth Track Plots: Optionally show a line in all tracks

* #9378 Depth Track Plots: Optionally show a line in all tracks
* Use RiaDefines::Orientation
This commit is contained in:
Magne Sjaastad
2022-10-24 16:24:51 +02:00
committed by GitHub
parent 286855cce0
commit a33f651bcc
25 changed files with 341 additions and 111 deletions

View File

@@ -21,6 +21,8 @@
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RimPlotAxisAnnotation.h"
#include "RimWellLogCurve.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogTrack.h"
@@ -28,6 +30,7 @@
#include "RigWellLogCurveData.h"
#include "RiuGuiTheme.h"
#include "RiuPlotAnnotationTool.h"
#include "RiuPlotCurve.h"
#include "RiuPlotCurveInfoTextProvider.h"
#include "RiuQwtCurvePointTracker.h"
@@ -37,6 +40,7 @@
#include "qwt_plot_curve.h"
#include "qwt_scale_draw.h"
#include "qwt_scale_engine.h"
#include "qwt_scale_map.h"
#include "qwt_scale_widget.h"
#include <QWheelEvent>
@@ -75,7 +79,7 @@ protected:
RimWellLogPlot* wlp = nullptr;
m_wellLogTrack->firstAncestorOfType( wlp );
if ( wlp && wlp->depthOrientation() == RimDepthTrackPlot::DepthOrientation::HORIZONTAL )
if ( wlp && wlp->depthOrientation() == RiaDefines::Orientation::HORIZONTAL )
{
str = QString( "%1\nDepth: %2" ).arg( depthAxisValueString ).arg( xAxisValueString );
}
@@ -149,8 +153,7 @@ public:
{
auto [xValue, yValue] = curve->sample( sampleIndex );
auto depth = depthTrackPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ? yValue
: xValue;
auto depth = depthTrackPlot->depthOrientation() == RiaDefines::Orientation::VERTICAL ? yValue : xValue;
auto propertyValue = annotationCurve->closestYValueForX( depth );
@@ -184,12 +187,14 @@ RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* track, QWidget* parent /*= nu
RimWellLogPlot* wlp = nullptr;
track->firstAncestorOfType( wlp );
bool isVertical = ( wlp && wlp->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL );
bool isVertical = ( wlp && wlp->depthOrientation() == RiaDefines::Orientation::VERTICAL );
setAxisEnabled( QwtAxis::YLeft, true );
setAxisEnabled( QwtAxis::YRight, false );
setAxisEnabled( QwtAxis::XTop, !isVertical );
setAxisEnabled( QwtAxis::XBottom, isVertical );
m_annotationTool = std::make_unique<RiuPlotAnnotationTool>();
new RiuWellLogCurvePointTracker( this->qwtPlot(), &wellLogCurveInfoTextProvider, track );
}
@@ -220,3 +225,62 @@ void RiuWellLogTrack::setAxisEnabled( QwtAxis::Position axis, bool enabled )
setAxisTitleEnabled( plotAxis, enabled );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::createAnnotationsInPlot( const std::vector<RimPlotAxisAnnotation*>& annotations )
{
m_annotationTool->detachAllAnnotations();
RimDepthTrackPlot* depthTrackPlot = nullptr;
m_plotDefinition->firstAncestorOfType( depthTrackPlot );
if ( !depthTrackPlot ) return;
auto orientation = depthTrackPlot->depthOrientation() == RiaDefines::Orientation::HORIZONTAL
? RiaDefines::Orientation::VERTICAL
: RiaDefines::Orientation::HORIZONTAL;
for ( auto annotation : annotations )
{
m_annotationTool->attachAnnotation( qwtPlot(), annotation, orientation );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::onMouseMoveEvent( QMouseEvent* mouseEvent )
{
if ( !m_plotDefinition ) return;
RimDepthTrackPlot* depthTrackPlot = nullptr;
m_plotDefinition->firstAncestorOfType( depthTrackPlot );
if ( !depthTrackPlot || !depthTrackPlot->isDepthMarkerLineEnabled() ) return;
auto plotwidget = dynamic_cast<RiuQwtPlotWidget*>( m_plotDefinition->plotWidget() );
if ( !plotwidget ) return;
auto plot = plotwidget->qwtPlot();
double depth = 0.0;
auto riuPlotAxis = depthTrackPlot->depthAxis();
auto qwtAxis = plotwidget->toQwtPlotAxis( riuPlotAxis );
const QwtScaleMap axisMap = plot->canvasMap( qwtAxis );
if ( depthTrackPlot->depthOrientation() == RiaDefines::Orientation::HORIZONTAL )
{
depth = axisMap.invTransform( mouseEvent->pos().x() );
}
else
{
depth = axisMap.invTransform( mouseEvent->pos().y() );
}
depthTrackPlot->setDepthMarkerPosition( depth );
for ( auto p : depthTrackPlot->plots() )
{
p->updateAxes();
}
}