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

@@ -145,6 +145,7 @@ void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterfac
m_annotationTool->attachAnnotationLine( qwtPlot(),
annotation->color(),
annotation->name(),
annotation->penStyle(),
annotation->value(),
RiaDefines::Orientation::HORIZONTAL );
}

View File

@@ -906,37 +906,6 @@ void RiuGuiTheme::storeQwtStyleSheetProperty( const QString& plotName,
s_qwtPlotItemPropertiesMap[plotName][itemType][itemName].insert( propertyName, value );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Qt::PenStyle RiuGuiTheme::getPenStyleFromString( const QString& style )
{
if ( style == "solid" )
{
return Qt::PenStyle::SolidLine;
}
else if ( style == "dash" )
{
return Qt::PenStyle::DashLine;
}
else if ( style == "dot" )
{
return Qt::PenStyle::DotLine;
}
else if ( style == "dash-dot" )
{
return Qt::PenStyle::DashDotLine;
}
else if ( style == "dash-dot-dot" )
{
return Qt::PenStyle::DashDotDotLine;
}
else
{
return Qt::PenStyle::NoPen;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -61,17 +61,16 @@ public:
static void styleQwtItem( QwtPicker* item );
private:
static void preparseStyleSheet( RiaDefines::ThemeEnum theme, QString& styleSheet );
static QString getStyleSheetPath( RiaDefines::ThemeEnum theme );
static void storeQwtStyleSheetProperty( const QString& plotName,
const QString& itemType,
const QString& itemName,
const QString& propertyName,
const QString& value );
static Qt::PenStyle getPenStyleFromString( const QString& style );
static QwtSymbol* cloneMarkerSymbol( QwtPlotMarker* marker );
static QwtSymbol* cloneCurveSymbol( QwtPlotCurve* curve );
static void formatStyleSheetForWriting( QString& styleSheet );
static void preparseStyleSheet( RiaDefines::ThemeEnum theme, QString& styleSheet );
static QString getStyleSheetPath( RiaDefines::ThemeEnum theme );
static void storeQwtStyleSheetProperty( const QString& plotName,
const QString& itemType,
const QString& itemName,
const QString& propertyName,
const QString& value );
static QwtSymbol* cloneMarkerSymbol( QwtPlotMarker* marker );
static QwtSymbol* cloneCurveSymbol( QwtPlotCurve* curve );
static void formatStyleSheetForWriting( QString& styleSheet );
private:
static RiaDefines::ThemeEnum s_currentTheme;

View File

@@ -18,6 +18,7 @@
#include "RiuPlotAnnotationTool.h"
#include "RimPlotAxisAnnotation.h"
#include "RiuGuiTheme.h"
#include "cafCategoryMapper.h"
@@ -191,6 +192,7 @@ void RiuPlotAnnotationTool::attachWellPicks( QwtPlot* plot,
void RiuPlotAnnotationTool::attachAnnotationLine( QwtPlot* plot,
const QColor& color,
const QString& annotationText,
Qt::PenStyle penStyle,
const double position,
RiaDefines::Orientation orientation )
{
@@ -204,11 +206,29 @@ void RiuPlotAnnotationTool::attachAnnotationLine( QwtPlot* plot,
textColor = RiuGuiTheme::getColorByVariableName( "textColor" );
}
RiuPlotAnnotationTool::setLineProperties( line, annotationText, orientation, position, Qt::SolidLine, color, textColor );
RiuPlotAnnotationTool::setLineProperties( line, annotationText, orientation, position, penStyle, color, textColor );
m_plotItems.push_back( line );
line->attach( m_plot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::attachAnnotation( QwtPlot* plot,
RimPlotAxisAnnotation* annotation,
RiaDefines::Orientation orientation )
{
if ( annotation->annotationType() == RimPlotAxisAnnotation::AnnotationType::LINE )
{
attachAnnotationLine( plot,
annotation->color(),
annotation->name(),
annotation->penStyle(),
annotation->value(),
orientation );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -32,6 +32,7 @@
class QString;
class QwtPlot;
class RimPlotAxisAnnotation;
class RiuPlotAnnotationTool
{
@@ -55,9 +56,12 @@ public:
void attachAnnotationLine( QwtPlot* plot,
const QColor& color,
const QString& annotationText,
Qt::PenStyle penStyle,
const double position,
RiaDefines::Orientation orientation );
void attachAnnotation( QwtPlot* plot, RimPlotAxisAnnotation* annotation, RiaDefines::Orientation orientation );
void attachAnnotationRange( QwtPlot* plot,
const QColor& color,
const QString& annotationText,

View File

@@ -606,6 +606,8 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
return true;
}
}
onMouseMoveEvent( mouseEvent );
}
return false;
}
@@ -1386,6 +1388,13 @@ RiuPlotAxis RiuQwtPlotWidget::findPlotAxisForQwtAxis( const QwtAxisId& qwtAxisId
return RiuPlotAxis::defaultLeft();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::onMouseMoveEvent( QMouseEvent* event )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -207,6 +207,8 @@ protected:
RiuPlotAxis findPlotAxisForQwtAxis( const QwtAxisId& qwtAxisId ) const;
virtual void onMouseMoveEvent( QMouseEvent* event );
private:
void selectClosestPlotItem( const QPoint& pos, bool toggleItemInSelection = false );
static int defaultMinimumWidth();

View File

@@ -162,6 +162,7 @@ void RiuSummaryQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterface*
m_annotationTool->attachAnnotationLine( m_plotWidget->qwtPlot(),
annotation->color(),
annotation->name(),
annotation->penStyle(),
annotation->value(),
orientation );
}

View File

@@ -91,7 +91,7 @@ void RiuWellLogPlot::renderTo( QPaintDevice* paintDevice )
RiuMultiPlotPage::renderTo( paintDevice );
if ( depthTrackPlot() && depthTrackPlot()->depthOrientation() == RimDepthTrackPlot::DepthOrientation::HORIZONTAL )
if ( depthTrackPlot() && depthTrackPlot()->depthOrientation() == RiaDefines::Orientation::HORIZONTAL )
m_horizontalTrackScrollBar->setVisible( true );
else
m_verticalTrackScrollBar->setVisible( true );
@@ -104,7 +104,7 @@ bool RiuWellLogPlot::showYAxis( int row, int column ) const
{
if ( depthTrackPlot() )
{
if ( depthTrackPlot()->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
if ( depthTrackPlot()->depthOrientation() == RiaDefines::Orientation::VERTICAL )
{
return column == 0;
}
@@ -132,7 +132,7 @@ void RiuWellLogPlot::reinsertScrollbar()
int colCount = this->m_gridLayout->columnCount();
int rowCount = this->m_gridLayout->rowCount();
if ( depthTrackPlot() && depthTrackPlot()->depthOrientation() == RimDepthTrackPlot::DepthOrientation::HORIZONTAL )
if ( depthTrackPlot() && depthTrackPlot()->depthOrientation() == RiaDefines::Orientation::HORIZONTAL )
{
m_gridLayout->addLayout( m_horizontalTrackScrollBarLayout, rowCount, 0, 1, colCount );
m_horizontalTrackScrollBar->setVisible( !plotWidgets.empty() );

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();
}
}

View File

@@ -23,7 +23,10 @@
#include "qwt_plot.h"
class RimWellLogTrack;
class RiuPlotAnnotationTool;
class RimPlotAxisAnnotation;
class QWheelEvent;
class QMouseEvent;
//==================================================================================================
//
@@ -39,4 +42,12 @@ public:
~RiuWellLogTrack() override;
void setAxisEnabled( QwtAxis::Position axis, bool enabled );
void createAnnotationsInPlot( const std::vector<RimPlotAxisAnnotation*>& annotations );
private:
void onMouseMoveEvent( QMouseEvent* event ) override;
private:
std::unique_ptr<RiuPlotAnnotationTool> m_annotationTool;
};

View File

@@ -54,7 +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_depthOrientation( RiaDefines::Orientation::VERTICAL )
, m_maxColumnOffset( 0.0 )
, m_showLabel( false )
{
@@ -186,7 +186,7 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot )
addColumnFeature( -posMax, -posMin, startDepth, endDepth, componentColor() );
addColumnFeature( posMin, posMax, startDepth, endDepth, componentColor() );
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::VERTICAL )
if ( m_depthOrientation == RiaDefines::Orientation::VERTICAL )
{
addMarker( -posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_LEFT_ANGLED_TRIANGLE, componentColor() );
addMarker( posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor() );
@@ -227,7 +227,7 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot )
auto plotSymbol1 = RiuPlotCurveSymbol::SYMBOL_LEFT_ALIGNED_TRIANGLE;
auto plotSymbol2 = RiuPlotCurveSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE;
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::HORIZONTAL )
if ( m_depthOrientation == RiaDefines::Orientation::HORIZONTAL )
{
plotSymbol1 = RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
plotSymbol2 = RiuPlotCurveSymbol::SYMBOL_UP_TRIANGLE;
@@ -456,7 +456,7 @@ QwtPlotItem*
marker->setSymbol( symbol );
marker->setSpacing( 6 );
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::HORIZONTAL )
if ( m_depthOrientation == RiaDefines::Orientation::HORIZONTAL )
{
marker->setXValue( depth );
marker->setYValue( position );
@@ -483,7 +483,7 @@ QwtPlotItem*
if ( drawLine )
{
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::HORIZONTAL )
if ( m_depthOrientation == RiaDefines::Orientation::HORIZONTAL )
{
marker->setLineStyle( QwtPlotMarker::HLine );
}
@@ -512,7 +512,7 @@ void RiuWellPathComponentPlotItem::addColumnFeature( double startPositio
double startY = startDepth;
double endY = endDepth;
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::HORIZONTAL )
if ( m_depthOrientation == RiaDefines::Orientation::HORIZONTAL )
{
startX = startDepth;
endX = endDepth;
@@ -612,7 +612,7 @@ void RiuWellPathComponentPlotItem::setDepthType( RimWellLogPlot::DepthTypeEnum d
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellPathComponentPlotItem::setDepthOrientation( RimWellLogPlot::DepthOrientation depthOrientation )
void RiuWellPathComponentPlotItem::setDepthOrientation( RiaDefines::Orientation depthOrientation )
{
m_depthOrientation = depthOrientation;
}
@@ -658,7 +658,7 @@ void RiuWellPathComponentPlotItem::attachToQwt()
auto riuAxis = RimDepthTrackPlot::annotationAxis( m_depthOrientation );
auto qwtAxis = RiuQwtPlotTools::toQwtPlotAxisEnum( riuAxis.axis() );
if ( m_depthOrientation == RimWellLogPlot::DepthOrientation::VERTICAL )
if ( m_depthOrientation == RiaDefines::Orientation::VERTICAL )
{
m_combinedComponentGroup.setXAxis( qwtAxis );
}

View File

@@ -65,7 +65,7 @@ public:
void setShowLabel( bool showLabel );
void setDepthType( RimWellLogPlot::DepthTypeEnum depthType );
void setDepthOrientation( RimWellLogPlot::DepthOrientation depthOrientation );
void setDepthOrientation( RiaDefines::Orientation depthOrientation );
void setContributeToLegend( bool contributeToLegend );
void setParentPlotNoReplot( QwtPlot* plot );
@@ -124,10 +124,10 @@ private:
double m_columnOffset;
double m_maxColumnOffset;
RimWellLogPlot::DepthTypeEnum m_depthType;
RimWellLogPlot::DepthOrientation m_depthOrientation;
QPointer<QwtPlot> m_parentQwtPlot;
RiuQwtPlotItemGroup m_combinedComponentGroup;
RimWellLogPlot::DepthTypeEnum m_depthType;
RiaDefines::Orientation m_depthOrientation;
QPointer<QwtPlot> m_parentQwtPlot;
RiuQwtPlotItemGroup m_combinedComponentGroup;
bool m_showLabel;
};