#4666 Support color fill for formations in Well Log Tracks

This commit is contained in:
Gaute Lindkvist 2019-09-10 13:23:29 +02:00
parent 69793cd691
commit 06cea12447
4 changed files with 126 additions and 47 deletions

View File

@ -127,6 +127,18 @@ void AppEnum<RimWellLogTrack::WidthScaleFactor>::setUp()
addItem( RimWellLogTrack::EXTRA_WIDE_TRACK, "EXTRA_WIDE_TRACK", "Extra wide" );
setDefault( RimWellLogTrack::NORMAL_TRACK );
}
template <>
void AppEnum<RiuPlotAnnotationTool::FormationDisplay>::setUp()
{
addItem( RiuPlotAnnotationTool::NONE, "NONE", "None" );
addItem( RiuPlotAnnotationTool::DARK_LINES, "DARK_LINES", "Dark Lines" );
addItem( RiuPlotAnnotationTool::COLORED_LINES, "COLORED_LINES", "Colored Lines" );
addItem( RiuPlotAnnotationTool::COLOR_SHADING, "COLOR_SHADING", "Color Shading" );
addItem( RiuPlotAnnotationTool::COLOR_SHADING_AND_LINES, "SHADING_AND_LINES", "Color Shading and Lines" );
setDefault( RiuPlotAnnotationTool::NONE );
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
@ -161,7 +173,9 @@ RimWellLogTrack::RimWellLogTrack()
m_majorTickInterval.uiCapability()->setUiHidden( true );
m_minorTickInterval.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_showFormations, "ShowFormations", false, "Show Lines", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_formationDisplay, "FormationDisplay", "Show Formations", "", "", "" );
CAF_PDM_InitField( &m_showFormations_OBSOLETE, "ShowFormations", false, "Show Lines", "", "", "" );
m_showFormations_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_showFormationLabels, "ShowFormationLabels", true, "Show Labels", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_formationSource, "FormationSource", "Source", "", "", "" );
@ -354,7 +368,7 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
m_wellLogTrackPlotWidget->replot();
}
else if ( changedField == &m_showFormations || changedField == &m_formationSource )
else if ( changedField == &m_formationDisplay || changedField == &m_formationSource )
{
if ( changedField == &m_formationSource && m_formationSource == WELL_PICK_FILTER )
{
@ -785,13 +799,13 @@ void RimWellLogTrack::loadDataAndUpdate( bool updateParentPlotAndToolbars )
curves[cIdx]->loadDataAndUpdate( false );
}
if ( m_showFormations )
if ( m_formationDisplay == RiuPlotAnnotationTool::NONE )
{
setFormationFieldsUiReadOnly( false );
setFormationFieldsUiReadOnly( true );
}
else
{
setFormationFieldsUiReadOnly( true );
setFormationFieldsUiReadOnly( false );
}
if ( m_wellLogTrackPlotWidget )
@ -836,7 +850,7 @@ void RimWellLogTrack::setAndUpdateWellPathFormationNamesData( RimCase* rimCase,
updateConnectedEditors();
if ( m_showFormations )
if ( m_formationDisplay != RiuPlotAnnotationTool::NONE )
{
updateFormationNamesOnPlot();
}
@ -868,7 +882,7 @@ void RimWellLogTrack::setAndUpdateSimWellFormationNamesData( RimCase* rimCase, c
updateConnectedEditors();
if ( m_showFormations )
if ( m_formationDisplay != RiuPlotAnnotationTool::NONE )
{
updateFormationNamesOnPlot();
}
@ -1205,7 +1219,7 @@ void RimWellLogTrack::setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setShowFormations( bool on )
{
m_showFormations = on;
m_showFormations_OBSOLETE = on;
}
//--------------------------------------------------------------------------------------------------
@ -1213,7 +1227,7 @@ void RimWellLogTrack::setShowFormations( bool on )
//--------------------------------------------------------------------------------------------------
bool RimWellLogTrack::showFormations() const
{
return m_showFormations;
return m_showFormations_OBSOLETE;
}
//--------------------------------------------------------------------------------------------------
@ -1281,7 +1295,7 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
uiOrdering.add( &m_userName );
caf::PdmUiGroup* formationGroup = uiOrdering.addNewGroup( "Zonation/Formation Names" );
formationGroup->add( &m_showFormations );
formationGroup->add( &m_formationDisplay );
formationGroup->add( &m_showFormationLabels );
if ( !m_formationsForCaseWithSimWellOnly )
@ -1345,6 +1359,17 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::initAfterRead()
{
if ( m_showFormations_OBSOLETE() && m_formationDisplay() == RiuPlotAnnotationTool::NONE )
{
m_formationDisplay = RiuPlotAnnotationTool::COLORED_LINES;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1509,7 +1534,7 @@ void RimWellLogTrack::uiOrderingForRftPltFormations( caf::PdmUiOrdering& uiOrder
{
caf::PdmUiGroup* formationGroup = uiOrdering.addNewGroup( "Zonation/Formation Names" );
formationGroup->setCollapsedByDefault( true );
formationGroup->add( &m_showFormations );
formationGroup->add( &m_formationDisplay );
formationGroup->add( &m_formationSource );
if ( m_formationSource == CASE )
{
@ -1728,7 +1753,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
{
removeFormationNames();
if ( m_showFormations == false ) return;
if ( m_formationDisplay == RiuPlotAnnotationTool::NONE ) return;
if ( m_annotationTool == nullptr )
{
@ -1807,7 +1832,14 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
&formationNamesToPlot,
&yValues );
m_annotationTool->attachFormationNames( this->viewer(), formationNamesToPlot, yValues, m_showFormationLabels() );
std::pair<double, double> xRange = std::make_pair( m_visibleXRangeMin(), m_visibleXRangeMax() );
m_annotationTool->attachFormationNames( this->viewer(),
formationNamesToPlot,
xRange,
yValues,
m_formationDisplay(),
m_showFormationLabels() );
}
else if ( m_formationSource() == WELL_PICK_FILTER )
{

View File

@ -22,6 +22,7 @@
#include "RimWellLogPlot.h"
#include "RigWellPathFormations.h"
#include "RiuPlotAnnotationTool.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
@ -40,7 +41,6 @@ class RimWellPathAttributeCollection;
class RimWellFlowRateCurve;
class RimWellLogCurve;
class RimWellPath;
class RiuPlotAnnotationTool;
class RiuWellPathComponentPlotItem;
class RiuWellLogTrack;
class RigEclipseWellLogExtractor;
@ -177,6 +177,7 @@ private:
caf::PdmFieldHandle* objectToggleField() override;
caf::PdmFieldHandle* userDescriptionField() override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void initAfterRead() override;
void computeAndSetXRangeMinForLogarithmicScale();
@ -228,27 +229,29 @@ private:
caf::PdmField<double> m_majorTickInterval;
caf::PdmField<double> m_minorTickInterval;
caf::PdmField<bool> m_showFormations;
caf::PdmField<bool> m_showFormationLabels;
caf::PdmField<caf::AppEnum<FormationSource>> m_formationSource;
caf::PdmPtrField<RimCase*> m_formationCase;
caf::PdmField<caf::AppEnum<TrajectoryType>> m_formationTrajectoryType;
caf::PdmPtrField<RimWellPath*> m_formationWellPathForSourceCase;
caf::PdmPtrField<RimWellPath*> m_formationWellPathForSourceWellPath;
caf::PdmField<QString> m_formationSimWellName;
caf::PdmField<int> m_formationBranchIndex;
caf::PdmField<caf::AppEnum<RigWellPathFormations::FormationLevel>> m_formationLevel;
caf::PdmField<bool> m_showformationFluids;
caf::PdmField<caf::AppEnum<WidthScaleFactor>> m_widthScaleFactor;
caf::PdmField<bool> m_formationBranchDetection;
caf::PdmField<bool> m_showWellPathAttributes;
caf::PdmField<bool> m_showWellPathCompletions;
caf::PdmField<bool> m_showWellPathComponentsBothSides;
caf::PdmField<bool> m_showWellPathComponentLabels;
caf::PdmField<bool> m_wellPathAttributesInLegend;
caf::PdmField<bool> m_wellPathCompletionsInLegend;
caf::PdmPtrField<RimWellPath*> m_wellPathComponentSource;
caf::PdmPtrField<RimWellPathAttributeCollection*> m_wellPathAttributeCollection;
caf::PdmField<caf::AppEnum<RiuPlotAnnotationTool::FormationDisplay>> m_formationDisplay;
caf::PdmField<bool> m_showFormationLabels;
caf::PdmField<caf::AppEnum<FormationSource>> m_formationSource;
caf::PdmPtrField<RimCase*> m_formationCase;
caf::PdmField<caf::AppEnum<TrajectoryType>> m_formationTrajectoryType;
caf::PdmPtrField<RimWellPath*> m_formationWellPathForSourceCase;
caf::PdmPtrField<RimWellPath*> m_formationWellPathForSourceWellPath;
caf::PdmField<QString> m_formationSimWellName;
caf::PdmField<int> m_formationBranchIndex;
caf::PdmField<caf::AppEnum<RigWellPathFormations::FormationLevel>> m_formationLevel;
caf::PdmField<bool> m_showformationFluids;
caf::PdmField<caf::AppEnum<WidthScaleFactor>> m_widthScaleFactor;
caf::PdmField<bool> m_formationBranchDetection;
caf::PdmField<bool> m_showWellPathAttributes;
caf::PdmField<bool> m_showWellPathCompletions;
caf::PdmField<bool> m_showWellPathComponentsBothSides;
caf::PdmField<bool> m_showWellPathComponentLabels;
caf::PdmField<bool> m_wellPathAttributesInLegend;
caf::PdmField<bool> m_wellPathCompletionsInLegend;
caf::PdmPtrField<RimWellPath*> m_wellPathComponentSource;
caf::PdmPtrField<RimWellPathAttributeCollection*> m_wellPathAttributeCollection;
caf::PdmField<bool> m_showFormations_OBSOLETE;
std::vector<std::unique_ptr<RiuWellPathComponentPlotItem>> m_wellPathAttributePlotObjects;

View File

@ -18,10 +18,13 @@
#include "RiuPlotAnnotationTool.h"
#include "RiaColorTables.h"
#include <QString>
#include "cvfMath.h"
#include "qwt_plot.h"
#include "qwt_plot_shapeitem.h"
//--------------------------------------------------------------------------------------------------
///
@ -36,7 +39,9 @@ RiuPlotAnnotationTool::~RiuPlotAnnotationTool()
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::attachFormationNames( QwtPlot* plot,
const std::vector<QString>& names,
const std::pair<double, double> xRange,
const std::vector<std::pair<double, double>> yPositions,
FormationDisplay formationDisplay,
bool showNames )
{
detachAllAnnotations();
@ -46,6 +51,8 @@ void RiuPlotAnnotationTool::attachFormationNames( QwtPlot*
double delta = 0.5;
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
for ( size_t i = 0; i < names.size(); i++ )
{
QwtPlotMarker* line( new QwtPlotMarker() );
@ -59,9 +66,34 @@ void RiuPlotAnnotationTool::attachFormationNames( QwtPlot*
name += " Top";
}
}
if ( formationDisplay & COLOR_SHADING )
{
QColor shadingColor = colors.cycledQColor( i );
shadingColor.setAlpha( 150 );
QwtPlotShapeItem* shading = new QwtPlotShapeItem( name );
RiuPlotAnnotationTool::horizontalDashedLine( line, name, yPositions[i].first );
QwtInterval axisInterval = m_plot->axisInterval( QwtPlot::xBottom );
QRectF shadingRect( axisInterval.minValue(),
yPositions[i].first,
axisInterval.width(),
yPositions[i].second - yPositions[i].first );
shading->setRect( shadingRect );
shading->setPen( shadingColor );
shading->setBrush( QBrush( shadingColor ) );
shading->attach( m_plot );
shading->setZ( -100.0 );
shading->setXAxis( QwtPlot::xBottom );
m_markers.push_back( std::move( shading ) );
}
QColor lineColor( 0, 0, 0, 0 );
if ( formationDisplay & DARK_LINES || formationDisplay & COLORED_LINES )
{
lineColor = formationDisplay & DARK_LINES ? QColor( 0, 0, 100 ) : colors.cycledQColor( i );
}
RiuPlotAnnotationTool::horizontalDashedLineWithColor( line, lineColor, QColor( 0, 0, 0 ), name, yPositions[i].first );
line->attach( m_plot );
m_markers.push_back( std::move( line ) );
@ -108,7 +140,7 @@ void RiuPlotAnnotationTool::attachAnnotationLine( QwtPlot* plot,
m_plot = plot;
QwtPlotMarker* line( new QwtPlotMarker() );
RiuPlotAnnotationTool::horizontalDashedLineWithColor( line, color, annotationText, yPosition );
RiuPlotAnnotationTool::horizontalDashedLineWithColor( line, color, color, annotationText, yPosition );
line->attach( m_plot );
m_markers.push_back( std::move( line ) );
}
@ -134,16 +166,14 @@ void RiuPlotAnnotationTool::detachAllAnnotations()
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::horizontalDashedLine( QwtPlotMarker* line, const QString& name, double yValue )
{
horizontalDashedLineWithColor( line, QColor( 0, 0, 100 ), name, yValue );
horizontalDashedLineWithColor( line, QColor( 0, 0, 100 ), QColor( 0, 0, 100 ), name, yValue );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::horizontalDashedLineWithColor( QwtPlotMarker* line,
const QColor& color,
const QString& name,
double yValue )
void RiuPlotAnnotationTool::horizontalDashedLineWithColor(
QwtPlotMarker* line, const QColor& color, const QColor& textColor, const QString& name, double yValue )
{
QPen curvePen;
curvePen.setStyle( Qt::DashLine );
@ -153,6 +183,8 @@ void RiuPlotAnnotationTool::horizontalDashedLineWithColor( QwtPlotMarker* line,
line->setLineStyle( QwtPlotMarker::HLine );
line->setLinePen( curvePen );
line->setYValue( yValue );
line->setLabel( name );
QwtText label( name );
label.setColor( textColor );
line->setLabel( label );
line->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
}

View File

@ -30,13 +30,25 @@ class QwtPlot;
class RiuPlotAnnotationTool
{
public:
enum FormationDisplay
{
NONE = 0x00,
DARK_LINES = 0x01,
COLORED_LINES = 0x02,
COLOR_SHADING = 0x04,
COLOR_SHADING_AND_LINES = 0x05
};
public:
RiuPlotAnnotationTool(){};
~RiuPlotAnnotationTool();
void attachFormationNames( QwtPlot* plot,
const std::vector<QString>& names,
const std::pair<double, double> xRange,
const std::vector<std::pair<double, double>> yPositions,
FormationDisplay formationDisplay,
bool showNames = true );
void attachWellPicks( QwtPlot* plot, const std::vector<QString>& names, const std::vector<double> yPositions );
@ -46,10 +58,10 @@ public:
private:
static void horizontalDashedLine( QwtPlotMarker* line, const QString& name, double yValue );
static void
horizontalDashedLineWithColor( QwtPlotMarker* line, const QColor& color, const QString& name, double yValue );
static void horizontalDashedLineWithColor(
QwtPlotMarker* line, const QColor& color, const QColor& textColor, const QString& name, double yValue );
private:
QPointer<QwtPlot> m_plot;
std::vector<QwtPlotMarker*> m_markers;
QPointer<QwtPlot> m_plot;
std::vector<QwtPlotItem*> m_markers;
};