Show well completion annotations in horizontal plots (#9193)

This commit is contained in:
Magne Sjaastad 2022-08-15 16:55:17 +02:00 committed by GitHub
parent c16264497d
commit 016216bdb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 227 additions and 77 deletions

View File

@ -77,6 +77,28 @@ bool RiaDefines::isVertical( RiaDefines::PlotAxis axis )
return ( axis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || axis == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaDefines::PlotAxis RiaDefines::opposite( PlotAxis axis )
{
switch ( axis )
{
case RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM:
return RiaDefines::PlotAxis::PLOT_AXIS_TOP;
case RiaDefines::PlotAxis::PLOT_AXIS_TOP:
return RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM;
case RiaDefines::PlotAxis::PLOT_AXIS_LEFT:
return RiaDefines::PlotAxis::PLOT_AXIS_RIGHT;
case RiaDefines::PlotAxis::PLOT_AXIS_RIGHT:
return RiaDefines::PlotAxis::PLOT_AXIS_LEFT;
}
// Should never come here
CVF_ASSERT( false );
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -63,8 +63,9 @@ double minimumDefaultValuePlot();
double minimumDefaultLogValuePlot();
double maximumDefaultValuePlot();
bool isHorizontal( PlotAxis axis );
bool isVertical( PlotAxis axis );
bool isHorizontal( PlotAxis axis );
bool isVertical( PlotAxis axis );
PlotAxis opposite( PlotAxis axis );
double scalingFactor( QPaintDevice* paintDevice );

View File

@ -1222,10 +1222,17 @@ RimDepthTrackPlot::DepthOrientation RimDepthTrackPlot::depthOrientation() const
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimDepthTrackPlot::depthAxis() const
{
if ( m_depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
return RiuPlotAxis::defaultLeft();
else
return RiuPlotAxis::defaultBottom();
return depthAxis( m_depthOrientation() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimDepthTrackPlot::depthAxis( DepthOrientation depthOrientation )
{
if ( depthOrientation == RimDepthTrackPlot::DepthOrientation::VERTICAL ) return RiuPlotAxis::defaultLeft();
return RiuPlotAxis::defaultBottom();
}
//--------------------------------------------------------------------------------------------------
@ -1233,10 +1240,37 @@ RiuPlotAxis RimDepthTrackPlot::depthAxis() const
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimDepthTrackPlot::valueAxis() const
{
if ( m_depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
return RiuPlotAxis::defaultTop();
else
return RiuPlotAxis::defaultLeft();
return valueAxis( m_depthOrientation() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimDepthTrackPlot::valueAxis( DepthOrientation depthOrientation )
{
if ( depthOrientation == RimDepthTrackPlot::DepthOrientation::VERTICAL ) return RiuPlotAxis::defaultTop();
return RiuPlotAxis::defaultLeft();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimDepthTrackPlot::annotationAxis() const
{
return annotationAxis( m_depthOrientation() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimDepthTrackPlot::annotationAxis( DepthOrientation depthOrientation )
{
auto riuAxis = valueAxis( depthOrientation );
auto oppositeAxis = RiaDefines::opposite( riuAxis.axis() );
return RiuPlotAxis( oppositeAxis );
}
//--------------------------------------------------------------------------------------------------

View File

@ -107,6 +107,7 @@ public:
RimDepthTrackPlot::DepthOrientation depthOrientation() const;
RiuPlotAxis depthAxis() const;
RiuPlotAxis valueAxis() const;
RiuPlotAxis annotationAxis() const;
void setAutoScalePropertyValuesEnabled( bool enabled );
void setAutoScaleDepthValuesEnabled( bool enabled );
@ -149,6 +150,10 @@ public:
bool isFirstVisibleTrack( RimWellLogTrack* track );
bool isLastVisibleTrack( RimWellLogTrack* track );
static RiuPlotAxis depthAxis( DepthOrientation depthOrientation );
static RiuPlotAxis valueAxis( DepthOrientation depthOrientation );
static RiuPlotAxis annotationAxis( DepthOrientation depthOrientation );
protected:
QImage snapshotWindowContent() override;

View File

@ -452,7 +452,7 @@ void RimWellLogTrack::calculateDepthZoomRange()
{
double minObjectDepth = HUGE_VAL;
double maxObjectDepth = -HUGE_VAL;
if ( plotObject->yValueRange( &minObjectDepth, &maxObjectDepth ) )
if ( plotObject->depthValueRange( &minObjectDepth, &maxObjectDepth ) )
{
if ( minObjectDepth < minDepth )
{
@ -522,7 +522,7 @@ void RimWellLogTrack::updatePropertyValueZoom()
{
m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), componentRangeMin, componentRangeMax );
}
else if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
else
{
m_plotWidget->setAxisRange( RiuPlotAxis::defaultRight(), componentRangeMin, componentRangeMax );
}
@ -3258,11 +3258,13 @@ void RimWellLogTrack::updateWellPathAttributesOnPlot()
RimDepthTrackPlot* wellLogPlot;
this->firstAncestorOrThisOfTypeAsserted( wellLogPlot );
RimWellLogPlot::DepthTypeEnum depthType = wellLogPlot->depthType();
RimWellLogPlot::DepthTypeEnum depthType = wellLogPlot->depthType();
auto depthOrientation = wellLogPlot->depthOrientation();
for ( auto& attributePlotObject : m_wellPathAttributePlotObjects )
{
attributePlotObject->setDepthType( depthType );
attributePlotObject->setDepthOrientation( depthOrientation );
attributePlotObject->setShowLabel( m_showWellPathComponentLabels() );
attributePlotObject->loadDataAndUpdate( false );
attributePlotObject->setParentPlotNoReplot( m_plotWidget->qwtPlot() );

View File

@ -60,7 +60,8 @@ public:
SYMBOL_STAR2,
SYMBOL_HEXAGON,
SYMBOL_LEFT_TRIANGLE,
SYMBOL_RIGHT_TRIANGLE
SYMBOL_RIGHT_TRIANGLE,
SYMBOL_DOWN_ALIGNED_TRIANGLE
};
RiuPlotCurveSymbol( PointSymbolEnum riuStyle,

View File

@ -61,6 +61,18 @@ RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, Labe
case SYMBOL_DOWN_TRIANGLE:
style = QwtSymbol::DTriangle;
break;
case SYMBOL_DOWN_ALIGNED_TRIANGLE:
style = QwtSymbol::Path;
{
QPainterPath path;
path.moveTo( 0, 0 );
path.lineTo( 0, -10 );
path.lineTo( -10, -10 );
path.lineTo( 0, 0 );
setPath( path );
setPinPoint( QPointF( 0, -10 ) );
}
break;
case SYMBOL_LEFT_ALIGNED_TRIANGLE:
style = QwtSymbol::Path;
{

View File

@ -20,7 +20,9 @@
#include "RiaColorTables.h"
#include "RiaColorTools.h"
#include "RiaPlotDefines.h"
#include "RimDepthTrackPlot.h"
#include "RimFishbones.h"
#include "RimFracture.h"
#include "RimFractureTemplate.h"
@ -33,6 +35,7 @@
#include "RimWellPathValve.h"
#include "RigWellPath.h"
#include "RiuPlotAxis.h"
#include "RiuQwtPlotTools.h"
#include "qwt_plot.h"
@ -51,6 +54,7 @@ RiuWellPathComponentPlotItem::RiuWellPathComponentPlotItem( const RimWellPath* w
, m_componentType( RiaDefines::WellPathComponentType::WELL_PATH )
, m_columnOffset( 0.0 )
, m_depthType( RiaDefines::DepthTypeEnum::MEASURED_DEPTH )
, m_depthOrientation( RimWellLogPlot::DepthOrientation::VERTICAL )
, m_maxColumnOffset( 0.0 )
, m_showLabel( false )
{
@ -181,8 +185,18 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot )
double posMax = 0.75 + m_columnOffset;
addColumnFeature( -posMax, -posMin, startDepth, endDepth, componentColor() );
addColumnFeature( posMin, posMax, startDepth, endDepth, componentColor() );
addMarker( -posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_LEFT_ANGLED_TRIANGLE, componentColor() );
addMarker( posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor() );
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::VERTICAL )
{
addMarker( -posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_LEFT_ANGLED_TRIANGLE, componentColor() );
addMarker( posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor() );
}
else
{
addMarker( -posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_DOWN_ALIGNED_TRIANGLE, componentColor() );
addMarker( posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_LEFT_ANGLED_TRIANGLE, componentColor() );
}
addMarker( casingTrackEnd,
endDepth,
12,
@ -209,18 +223,20 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot )
const double markerSpacing = 30;
const int markerSize = 6;
double markerDepth = startDepth;
auto plotSymbol1 = RiuPlotCurveSymbol::SYMBOL_LEFT_ALIGNED_TRIANGLE;
auto plotSymbol2 = RiuPlotCurveSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE;
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::HORIZONTAL )
{
plotSymbol1 = RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
plotSymbol2 = RiuPlotCurveSymbol::SYMBOL_UP_TRIANGLE;
}
while ( markerDepth < endDepth - 5 )
{
addMarker( -casingTrackEnd,
markerDepth,
markerSize,
RiuPlotCurveSymbol::SYMBOL_LEFT_ALIGNED_TRIANGLE,
componentColor() );
addMarker( casingTrackEnd,
markerDepth,
markerSize,
RiuPlotCurveSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE,
componentColor() );
addMarker( -casingTrackEnd, markerDepth, markerSize, plotSymbol1, componentColor() );
addMarker( casingTrackEnd, markerDepth, markerSize, plotSymbol2, componentColor() );
markerDepth += markerSpacing;
}
@ -396,35 +412,36 @@ std::pair<double, double> RiuWellPathComponentPlotItem::depthsOfDepthType() cons
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellPathComponentPlotItem::addMarker( double posX,
void RiuWellPathComponentPlotItem::addMarker( double position,
double depth,
int size,
RiuPlotCurveSymbol::PointSymbolEnum symbolType,
cvf::Color4f baseColor,
const QString& label /*= QString("")*/,
Qt::Alignment labelAlignment /*= Qt::AlignTop*/,
Qt::Orientation labelOrientation /*= Qt::Vertical*/,
bool drawLine /*= false*/,
bool contrastTextColor /*= true*/ )
const QString& label /*= QString( "" )*/,
Qt::Alignment labelAlignment /*= Qt::AlignVCenter | Qt::AlignRight*/,
Qt::Orientation labelOrientation /*= Qt::Horizontal*/,
bool drawLine /*= false*/,
bool contrastTextColor /*= false */ )
{
QwtPlotItem* marker =
createMarker( posX, depth, size, symbolType, baseColor, label, labelAlignment, labelOrientation, drawLine, contrastTextColor );
createMarker( position, depth, size, symbolType, baseColor, label, labelAlignment, labelOrientation, drawLine, contrastTextColor );
m_combinedComponentGroup.addPlotItem( marker );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtPlotItem* RiuWellPathComponentPlotItem::createMarker( double posX,
double depth,
int size,
RiuPlotCurveSymbol::PointSymbolEnum symbolType,
cvf::Color4f baseColor,
const QString& label /*= QString("")*/,
Qt::Alignment labelAlignment /*= Qt::AlignTop*/,
Qt::Orientation labelOrientation /*= Qt::Vertical*/,
bool drawLine /*= false*/,
bool contrastTextColor /*= true*/ )
QwtPlotItem*
RiuWellPathComponentPlotItem::createMarker( double position,
double depth,
int size,
RiuPlotCurveSymbol::PointSymbolEnum symbolType,
cvf::Color4f baseColor,
const QString& label /*= QString( "" )*/,
Qt::Alignment labelAlignment /*= Qt::AlignVCenter | Qt::AlignRight*/,
Qt::Orientation labelOrientation /*= Qt::Horizontal*/,
bool drawLine /*= false*/,
bool contrastTextColor /*= false */ )
{
QColor bgColor = RiaColorTools::toQColor( baseColor );
QColor textColor = RiaColorTools::toQColor( baseColor.toColor3f(), 1.0 );
@ -438,8 +455,19 @@ QwtPlotItem* RiuWellPathComponentPlotItem::createMarker( double
symbol->setColor( bgColor );
marker->setSymbol( symbol );
marker->setSpacing( 6 );
marker->setXValue( posX );
marker->setYValue( depth );
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::HORIZONTAL )
{
marker->setXValue( depth );
marker->setYValue( position );
labelOrientation = Qt::Vertical;
labelAlignment = Qt::AlignTop;
}
else
{
marker->setXValue( position );
marker->setYValue( depth );
}
if ( m_showLabel )
{
@ -455,7 +483,15 @@ QwtPlotItem* RiuWellPathComponentPlotItem::createMarker( double
if ( drawLine )
{
marker->setLineStyle( QwtPlotMarker::HLine );
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::HORIZONTAL )
{
marker->setLineStyle( QwtPlotMarker::HLine );
}
else
{
marker->setLineStyle( QwtPlotMarker::VLine );
}
marker->setLinePen( bgColor, 2.0, Qt::SolidLine );
}
return marker;
@ -464,13 +500,26 @@ QwtPlotItem* RiuWellPathComponentPlotItem::createMarker( double
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellPathComponentPlotItem::addColumnFeature( double startX,
double endX,
void RiuWellPathComponentPlotItem::addColumnFeature( double startPosition,
double endPosition,
double startDepth,
double endDepth,
cvf::Color4f baseColor,
Qt::BrushStyle brushStyle /*= Qt::SolidPattern*/ )
Qt::BrushStyle brushStyle /*= Qt::SolidPattern */ )
{
double startX = startPosition;
double endX = endPosition;
double startY = startDepth;
double endY = endDepth;
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::HORIZONTAL )
{
startX = startDepth;
endX = endDepth;
startY = startPosition;
endY = endPosition;
}
QColor baseQColor = RiaColorTools::toQColor( baseColor );
if ( brushStyle != Qt::SolidPattern )
{
@ -478,11 +527,11 @@ void RiuWellPathComponentPlotItem::addColumnFeature( double startX,
QColor semiTransparentWhite( Qt::white );
semiTransparentWhite.setAlphaF( 0.9f );
QwtPlotItem* backgroundShape =
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startDepth, endDepth, semiTransparentWhite, Qt::SolidPattern );
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startY, endY, semiTransparentWhite, Qt::SolidPattern );
m_combinedComponentGroup.addPlotItem( backgroundShape );
QwtPlotItem* patternShape =
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startDepth, endDepth, baseQColor, brushStyle );
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startY, endY, baseQColor, brushStyle );
m_combinedComponentGroup.addPlotItem( patternShape );
if ( endX >= 0.0 )
{
@ -498,7 +547,7 @@ void RiuWellPathComponentPlotItem::addColumnFeature( double startX,
else
{
QwtPlotItem* backgroundShape =
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startDepth, endDepth, baseQColor, Qt::SolidPattern );
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startY, endY, baseQColor, Qt::SolidPattern );
m_combinedComponentGroup.addPlotItem( backgroundShape );
if ( endX >= 0.0 )
@ -521,7 +570,7 @@ cvf::Color4f RiuWellPathComponentPlotItem::componentColor( float alpha /*= 1.0*/
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellPathComponentPlotItem::xValueRange( double* minimumValue, double* maximumValue ) const
bool RiuWellPathComponentPlotItem::propertyValueRange( double* minimumValue, double* maximumValue ) const
{
CVF_ASSERT( minimumValue && maximumValue );
*maximumValue = 1.0;
@ -532,7 +581,7 @@ bool RiuWellPathComponentPlotItem::xValueRange( double* minimumValue, double* ma
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellPathComponentPlotItem::yValueRange( double* minimumValue, double* maximumValue ) const
bool RiuWellPathComponentPlotItem::depthValueRange( double* minimumValue, double* maximumValue ) const
{
CVF_ASSERT( minimumValue && maximumValue );
@ -560,6 +609,14 @@ void RiuWellPathComponentPlotItem::setDepthType( RimWellLogPlot::DepthTypeEnum d
m_depthType = depthType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellPathComponentPlotItem::setDepthOrientation( RimWellLogPlot::DepthOrientation depthOrientation )
{
m_depthOrientation = depthOrientation;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -597,6 +654,18 @@ void RiuWellPathComponentPlotItem::attachToQwt()
if ( m_parentQwtPlot )
{
m_combinedComponentGroup.attach( m_parentQwtPlot );
auto riuAxis = RimDepthTrackPlot::annotationAxis( m_depthOrientation );
auto qwtAxis = RiuQwtPlotTools::toQwtPlotAxisEnum( riuAxis.axis() );
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::VERTICAL )
{
m_combinedComponentGroup.setXAxis( qwtAxis );
}
else
{
m_combinedComponentGroup.setYAxis( qwtAxis );
}
}
}

View File

@ -60,37 +60,39 @@ public:
RiaDefines::WellPathComponentType componentType() const;
bool xValueRange( double* minimumValue, double* maximumValue ) const;
bool yValueRange( double* minimumValue, double* maximumValue ) const;
bool propertyValueRange( double* minimumValue, double* maximumValue ) const;
bool depthValueRange( double* minimumValue, double* maximumValue ) const;
void setShowLabel( bool showLabel );
void setDepthType( RimWellLogPlot::DepthTypeEnum depthType );
void setDepthOrientation( RimWellLogPlot::DepthOrientation depthOrientation );
void setContributeToLegend( bool contributeToLegend );
void setParentQwtPlotAndReplot( QwtPlot* plot );
void setParentPlotNoReplot( QwtPlot* plot );
void attachToQwt();
void detachFromQwt();
void reattachToQwt();
private:
void setParentQwtPlotAndReplot( QwtPlot* plot );
void calculateColumnOffsets( const RimWellPathComponentInterface* component );
void onLoadDataAndUpdate( bool updateParentPlot );
std::pair<double, double> depthsOfDepthType() const;
void addMarker( double posX,
double depth,
int size,
RiuPlotCurveSymbol::PointSymbolEnum symbolType,
cvf::Color4f baseColor,
const QString& label = QString( "" ),
Qt::Alignment labelAlignment = Qt::AlignVCenter | Qt::AlignRight,
Qt::Orientation labelOrientation = Qt::Horizontal,
bool drawLine = false,
bool contrastTextColor = false );
QwtPlotItem* createMarker( double posX,
void addMarker( double position,
double depth,
int size,
RiuPlotCurveSymbol::PointSymbolEnum symbolType,
cvf::Color4f baseColor,
const QString& label = QString( "" ),
Qt::Alignment labelAlignment = Qt::AlignVCenter | Qt::AlignRight,
Qt::Orientation labelOrientation = Qt::Horizontal,
bool drawLine = false,
bool contrastTextColor = false );
QwtPlotItem* createMarker( double position,
double depth,
int size,
RiuPlotCurveSymbol::PointSymbolEnum symbolType,
@ -100,12 +102,13 @@ private:
Qt::Orientation labelOrientation = Qt::Horizontal,
bool drawLine = false,
bool contrastTextColor = false );
void addColumnFeature( double startX,
double endX,
double startDepth,
double endDepth,
cvf::Color4f baseColor,
Qt::BrushStyle brushStyle = Qt::SolidPattern );
void addColumnFeature( double startPosition,
double endPosition,
double startDepth,
double endDepth,
cvf::Color4f baseColor,
Qt::BrushStyle brushStyle = Qt::SolidPattern );
cvf::Color4f componentColor( float alpha = 1.0 ) const;
@ -121,9 +124,10 @@ private:
double m_columnOffset;
double m_maxColumnOffset;
RimWellLogPlot::DepthTypeEnum m_depthType;
QPointer<QwtPlot> m_parentQwtPlot;
RiuQwtPlotItemGroup m_combinedComponentGroup;
RimWellLogPlot::DepthTypeEnum m_depthType;
RimWellLogPlot::DepthOrientation m_depthOrientation;
QPointer<QwtPlot> m_parentQwtPlot;
RiuQwtPlotItemGroup m_combinedComponentGroup;
bool m_showLabel;
};