ResInsight/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp

1938 lines
76 KiB
C++
Raw Normal View History

2017-02-13 01:37:31 -06:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
2017-02-13 01:37:31 -06:00
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
2017-02-13 01:37:31 -06:00
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
2017-02-13 01:37:31 -06:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellLogTrack.h"
2017-10-25 07:41:54 -05:00
#include "RiaApplication.h"
#include "RiaColorTables.h"
2018-06-28 01:23:16 -05:00
#include "RiaExtractionTools.h"
#include "RiaSimWellBranchTools.h"
2017-10-25 07:41:54 -05:00
#include "RigEclipseCaseData.h"
2019-02-11 13:19:19 -06:00
#include "RigEclipseResultAddress.h"
2017-10-25 07:41:54 -05:00
#include "RigEclipseWellLogExtractor.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemResultAddress.h"
#include "RigFormationNames.h"
#include "RigGeoMechCaseData.h"
#include "RigGeoMechWellLogExtractor.h"
#include "RigResultAccessorFactory.h"
#include "RigSimWellData.h"
#include "RigSimulationWellCenterLineCalculator.h"
#include "RigSimulationWellCoordsAndMD.h"
2017-02-13 01:37:31 -06:00
#include "RigStatisticsCalculator.h"
#include "RigWellLogCurveData.h"
2017-10-25 07:41:54 -05:00
#include "RigWellPath.h"
2017-11-27 08:23:26 -06:00
#include "RigWellPathFormations.h"
2017-10-25 07:41:54 -05:00
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimGeoMechCase.h"
#include "RimMainPlotCollection.h"
#include "RimPerforationCollection.h"
#include "RimPerforationInterval.h"
2017-10-25 07:41:54 -05:00
#include "RimProject.h"
#include "RimTools.h"
#include "RimWellFlowRateCurve.h"
2017-02-13 01:37:31 -06:00
#include "RimWellLogCurve.h"
2017-10-25 07:41:54 -05:00
#include "RimWellLogPlotCollection.h"
#include "RimWellPath.h"
#include "RimWellPathAttribute.h"
#include "RimWellPathAttributeCollection.h"
#include "RimWellPathCompletions.h"
#include "RimWellPathFracture.h"
#include "RimWellPathFractureCollection.h"
#include "RimWellPltPlot.h"
#include "RimWellRftPlot.h"
2017-02-13 01:37:31 -06:00
#include "RiuMainWindow.h"
2017-10-25 07:41:54 -05:00
#include "RiuPlotAnnotationTool.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuWellLogPlot.h"
#include "RiuWellLogTrack.h"
#include "RiuWellPathComponentPlotItem.h"
2017-02-13 01:37:31 -06:00
2018-06-28 01:23:16 -05:00
#include "RiuQwtLinearScaleEngine.h"
2017-02-13 01:37:31 -06:00
#include "cvfAssert.h"
#define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0
#define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0
#define RI_LOGPLOTTRACK_MINOR_TICK_DEFAULT
2017-02-13 01:37:31 -06:00
CAF_PDM_SOURCE_INIT( RimWellLogTrack, "WellLogPlotTrack" );
2017-02-13 01:37:31 -06:00
2017-10-25 07:41:54 -05:00
namespace caf
{
template <>
void AppEnum<RimWellLogTrack::TrajectoryType>::setUp()
{
addItem( RimWellLogTrack::WELL_PATH, "WELL_PATH", "Well Path" );
addItem( RimWellLogTrack::SIMULATION_WELL, "SIMULATION_WELL", "Simulation Well" );
setDefault( RimWellLogTrack::WELL_PATH );
}
template <>
void AppEnum<RimWellLogTrack::FormationSource>::setUp()
{
addItem( RimWellLogTrack::CASE, "CASE", "Case" );
addItem( RimWellLogTrack::WELL_PICK_FILTER, "WELL_PICK_FILTER", "Well Picks for Well Path" );
setDefault( RimWellLogTrack::CASE );
}
template <>
void AppEnum<RigWellPathFormations::FormationLevel>::setUp()
{
addItem( RigWellPathFormations::NONE, "NONE", "None" );
addItem( RigWellPathFormations::ALL, "ALL", "All" );
addItem( RigWellPathFormations::GROUP, "GROUP", "Formation Group" );
addItem( RigWellPathFormations::LEVEL0, "LEVEL0", "Formation" );
addItem( RigWellPathFormations::LEVEL1, "LEVEL1", "Formation 1" );
addItem( RigWellPathFormations::LEVEL2, "LEVEL2", "Formation 2" );
addItem( RigWellPathFormations::LEVEL3, "LEVEL3", "Formation 3" );
addItem( RigWellPathFormations::LEVEL4, "LEVEL4", "Formation 4" );
addItem( RigWellPathFormations::LEVEL5, "LEVEL5", "Formation 5" );
addItem( RigWellPathFormations::LEVEL6, "LEVEL6", "Formation 6" );
addItem( RigWellPathFormations::LEVEL7, "LEVEL7", "Formation 7" );
addItem( RigWellPathFormations::LEVEL8, "LEVEL8", "Formation 8" );
addItem( RigWellPathFormations::LEVEL9, "LEVEL9", "Formation 9" );
addItem( RigWellPathFormations::LEVEL10, "LEVEL10", "Formation 10" );
setDefault( RigWellPathFormations::ALL );
2017-10-25 07:41:54 -05:00
}
template <>
void AppEnum<RimWellLogTrack::WidthScaleFactor>::setUp()
{
addItem( RimWellLogTrack::EXTRA_NARROW_TRACK, "EXTRA_NARROW_TRACK", "Extra Narrow" );
addItem( RimWellLogTrack::NARROW_TRACK, "NARROW_TRACK", "Narrow" );
addItem( RimWellLogTrack::NORMAL_TRACK, "NORMAL_TRACK", "Normal" );
addItem( RimWellLogTrack::WIDE_TRACK, "WIDE_TRACK", "Wide" );
addItem( RimWellLogTrack::EXTRA_WIDE_TRACK, "EXTRA_WIDE_TRACK", "Extra wide" );
setDefault( RimWellLogTrack::NORMAL_TRACK );
}
} // namespace caf
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
RimWellLogTrack::RimWellLogTrack()
{
CAF_PDM_InitObject( "Track", ":/WellLogTrack16x16.png", "", "" );
2017-02-13 01:37:31 -06:00
CAF_PDM_InitFieldNoDefault( &m_userName, "TrackDescription", "Name", "", "", "" );
m_userName.uiCapability()->setUiReadOnly( true );
2017-02-13 01:37:31 -06:00
CAF_PDM_InitField( &m_show, "Show", true, "Show Track", "", "", "" );
m_show.uiCapability()->setUiHidden( true );
2017-02-13 01:37:31 -06:00
CAF_PDM_InitFieldNoDefault( &curves, "Curves", "", "", "", "" );
curves.uiCapability()->setUiHidden( true );
2017-02-13 01:37:31 -06:00
CAF_PDM_InitField( &m_visibleXRangeMin, "VisibleXRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "" );
CAF_PDM_InitField( &m_visibleXRangeMax, "VisibleXRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" );
2017-02-13 01:37:31 -06:00
CAF_PDM_InitField( &m_isAutoScaleXEnabled, "AutoScaleX", true, "Auto Scale", "", "", "" );
m_isAutoScaleXEnabled.uiCapability()->setUiHidden( true );
2017-02-13 01:37:31 -06:00
CAF_PDM_InitField( &m_isLogarithmicScaleEnabled, "LogarithmicScaleX", false, "Logarithmic Scale", "", "", "" );
2017-10-25 07:41:54 -05:00
CAF_PDM_InitFieldNoDefault( &m_xAxisGridVisibility, "ShowXGridLines", "Show Grid Lines", "", "", "" );
CAF_PDM_InitField( &m_explicitTickIntervals, "ExplicitTickIntervals", false, "Manually Set Tick Intervals", "", "", "" );
CAF_PDM_InitField( &m_majorTickInterval, "MajorTickIntervals", 0.0, "Major Tick Interval", "", "", "" );
CAF_PDM_InitField( &m_minorTickInterval, "MinorTickIntervals", 0.0, "Minor Tick Interval", "", "", "" );
m_majorTickInterval.uiCapability()->setUiHidden( true );
m_minorTickInterval.uiCapability()->setUiHidden( true );
2018-06-28 01:23:16 -05:00
CAF_PDM_InitField( &m_showFormations, "ShowFormations", false, "Show Lines", "", "", "" );
CAF_PDM_InitField( &m_showFormationLabels, "ShowFormationLabels", true, "Show Labels", "", "", "" );
2017-10-25 07:41:54 -05:00
CAF_PDM_InitFieldNoDefault( &m_formationSource, "FormationSource", "Source", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_formationTrajectoryType, "FormationTrajectoryType", "Trajectory", "", "", "" );
2017-10-25 07:41:54 -05:00
CAF_PDM_InitFieldNoDefault( &m_formationWellPathForSourceCase, "FormationWellPath", "Well Path", "", "", "" );
m_formationWellPathForSourceCase.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_formationWellPathForSourceWellPath,
"FormationWellPathForSourceWellPath",
"Well Path",
"",
"",
"" );
m_formationWellPathForSourceWellPath.uiCapability()->setUiTreeChildrenHidden( true );
2017-10-25 07:41:54 -05:00
CAF_PDM_InitField( &m_formationSimWellName,
"FormationSimulationWellName",
QString( "None" ),
"Simulation Well",
"",
"",
"" );
CAF_PDM_InitField( &m_formationBranchIndex, "FormationBranchIndex", 0, " ", "", "", "" );
CAF_PDM_InitField( &m_formationBranchDetection,
"FormationBranchDetection",
true,
"Branch Detection",
"",
"Compute branches based on how simulation well cells are organized",
"" );
2017-10-25 07:41:54 -05:00
CAF_PDM_InitFieldNoDefault( &m_formationCase, "FormationCase", "Formation Case", "", "", "" );
m_formationCase.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_formationLevel, "FormationLevel", "Well Pick Filter", "", "", "" );
CAF_PDM_InitField( &m_showformationFluids, "ShowFormationFluids", false, "Show Fluids", "", "", "" );
CAF_PDM_InitField( &m_showWellPathAttributes, "ShowWellPathAttributes", false, "Show Well Attributes", "", "", "" );
CAF_PDM_InitField( &m_wellPathAttributesInLegend, "WellPathAttributesInLegend", false, "Attributes in Legend", "", "", "" );
CAF_PDM_InitField( &m_showWellPathCompletions, "ShowWellPathCompletions", true, "Show Well Completions", "", "", "" );
CAF_PDM_InitField( &m_wellPathCompletionsInLegend,
"WellPathCompletionsInLegend",
false,
"Completions in Legend",
"",
"",
"" );
CAF_PDM_InitField( &m_showWellPathComponentsBothSides, "ShowWellPathAttrBothSides", true, "Show Both Sides", "", "", "" );
CAF_PDM_InitField( &m_showWellPathComponentLabels, "ShowWellPathAttrLabels", false, "Show Labels", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wellPathComponentSource, "AttributesWellPathSource", "Well Path", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wellPathAttributeCollection, "AttributesCollection", "Well Attributes", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_widthScaleFactor, "Width", "Track Width", "", "Set width of track. ", "" );
m_formationsForCaseWithSimWellOnly = false;
2017-02-13 01:37:31 -06:00
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
RimWellLogTrack::~RimWellLogTrack()
{
curves.deleteAllChildObjects();
if ( m_wellLogTrackPlotWidget )
2017-02-13 01:37:31 -06:00
{
m_wellLogTrackPlotWidget->deleteLater();
m_wellLogTrackPlotWidget = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setDescription( const QString& description )
2017-02-13 01:37:31 -06:00
{
m_userName = description;
}
2017-10-26 03:01:56 -05:00
//--------------------------------------------------------------------------------------------------
///
2017-10-26 03:01:56 -05:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::simWellOptionItems( QList<caf::PdmOptionItemInfo>* options, RimCase* rimCase )
2017-10-26 03:01:56 -05:00
{
CVF_ASSERT( options );
if ( !options ) return;
2017-10-26 03:01:56 -05:00
std::set<QString> sortedWellNames;
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( rimCase );
2017-10-26 03:01:56 -05:00
if ( eclipseCase && eclipseCase->eclipseCaseData() )
2017-10-26 03:01:56 -05:00
{
sortedWellNames = eclipseCase->eclipseCaseData()->findSortedWellNames();
}
caf::QIconProvider simWellIcon( ":/Well.png" );
for ( const QString& wname : sortedWellNames )
2017-10-26 03:01:56 -05:00
{
options->push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );
2017-10-26 03:01:56 -05:00
}
if ( options->size() == 0 )
2017-10-26 03:01:56 -05:00
{
options->push_front( caf::PdmOptionItemInfo( "None", "None" ) );
2017-10-26 03:01:56 -05:00
}
}
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
2017-02-13 01:37:31 -06:00
{
if ( changedField == &m_show )
2017-02-13 01:37:31 -06:00
{
if ( m_wellLogTrackPlotWidget )
2017-02-13 01:37:31 -06:00
{
m_wellLogTrackPlotWidget->setVisible( m_show() );
2017-02-13 01:37:31 -06:00
}
updateParentPlotLayout();
}
else if ( changedField == &m_widthScaleFactor )
{
updateParentPlotLayout();
updateAxisAndGridTickIntervals();
applyXZoomFromVisibleRange();
2017-02-13 01:37:31 -06:00
}
else if ( changedField == &m_explicitTickIntervals )
2018-06-28 01:23:16 -05:00
{
if ( m_wellLogTrackPlotWidget )
2018-06-28 01:23:16 -05:00
{
m_majorTickInterval = m_wellLogTrackPlotWidget->getCurrentMajorTickInterval();
m_minorTickInterval = m_wellLogTrackPlotWidget->getCurrentMinorTickInterval();
}
m_majorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() );
m_minorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() );
if ( !m_explicitTickIntervals() )
2018-06-28 01:23:16 -05:00
{
updateAxisAndGridTickIntervals();
}
}
else if ( changedField == &m_xAxisGridVisibility || changedField == &m_majorTickInterval ||
changedField == &m_minorTickInterval )
{
updateAxisAndGridTickIntervals();
}
else if ( changedField == &m_visibleXRangeMin || changedField == &m_visibleXRangeMax )
2017-02-13 01:37:31 -06:00
{
m_wellLogTrackPlotWidget->setXRange( m_visibleXRangeMin, m_visibleXRangeMax );
m_wellLogTrackPlotWidget->replot();
2017-02-13 01:37:31 -06:00
m_isAutoScaleXEnabled = false;
bool emptyRange = std::abs( m_visibleXRangeMax() - m_visibleXRangeMin ) <
1.0e-6 * std::max( 1.0, std::max( m_visibleXRangeMax(), m_visibleXRangeMin() ) );
m_explicitTickIntervals.uiCapability()->setUiReadOnly( emptyRange );
m_xAxisGridVisibility.uiCapability()->setUiReadOnly( emptyRange );
updateEditors();
2018-06-28 01:23:16 -05:00
updateParentPlotLayout();
updateAxisAndGridTickIntervals();
2017-02-13 01:37:31 -06:00
}
else if ( changedField == &m_isAutoScaleXEnabled )
2017-02-13 01:37:31 -06:00
{
if ( m_isAutoScaleXEnabled() )
{
this->calculateXZoomRangeAndUpdateQwt();
2017-02-13 01:37:31 -06:00
computeAndSetXRangeMinForLogarithmicScale();
if ( m_wellLogTrackPlotWidget ) m_wellLogTrackPlotWidget->replot();
}
2017-02-13 01:37:31 -06:00
}
else if ( changedField == &m_isLogarithmicScaleEnabled )
2017-02-13 01:37:31 -06:00
{
updateAxisScaleEngine();
if ( m_isLogarithmicScaleEnabled() )
2018-06-28 01:23:16 -05:00
{
m_explicitTickIntervals = false;
}
m_explicitTickIntervals.uiCapability()->setUiHidden( m_isLogarithmicScaleEnabled() );
2017-02-13 01:37:31 -06:00
this->calculateXZoomRangeAndUpdateQwt();
2017-02-13 01:37:31 -06:00
computeAndSetXRangeMinForLogarithmicScale();
m_wellLogTrackPlotWidget->setXRange( m_visibleXRangeMin, m_visibleXRangeMax );
2017-02-13 01:37:31 -06:00
m_wellLogTrackPlotWidget->replot();
}
else if ( changedField == &m_showFormations || changedField == &m_formationSource )
2017-10-25 07:41:54 -05:00
{
if ( changedField == &m_formationSource && m_formationSource == WELL_PICK_FILTER )
{
std::vector<RimWellPath*> wellPaths;
RimTools::wellPathWithFormations( &wellPaths );
for ( RimWellPath* wellPath : wellPaths )
{
if ( wellPath == m_formationWellPathForSourceCase )
{
m_formationWellPathForSourceWellPath = m_formationWellPathForSourceCase();
break;
}
}
}
loadDataAndUpdate( true );
RimWellRftPlot* rftPlot( nullptr );
2017-11-07 03:02:43 -06:00
firstAncestorOrThisOfType( rftPlot );
if ( rftPlot )
2017-11-07 03:02:43 -06:00
{
rftPlot->updateConnectedEditors();
}
else
{
RimWellPltPlot* pltPlot( nullptr );
firstAncestorOrThisOfType( pltPlot );
if ( pltPlot )
2017-11-07 03:02:43 -06:00
{
pltPlot->updateConnectedEditors();
}
}
2017-10-25 07:41:54 -05:00
}
else if ( changedField == &m_showFormationLabels )
{
loadDataAndUpdate();
}
else if ( changedField == &m_formationCase )
2017-10-25 07:41:54 -05:00
{
2017-10-26 03:01:56 -05:00
QList<caf::PdmOptionItemInfo> options;
RimWellLogTrack::simWellOptionItems( &options, m_formationCase );
2017-10-25 07:41:54 -05:00
if ( options.isEmpty() || m_formationCase == nullptr )
2017-10-25 07:41:54 -05:00
{
m_formationSimWellName = QString( "None" );
2017-10-25 07:41:54 -05:00
}
loadDataAndUpdate( true );
2017-10-25 07:41:54 -05:00
}
else if ( changedField == &m_formationWellPathForSourceCase )
2017-10-25 07:41:54 -05:00
{
loadDataAndUpdate( true );
2017-10-25 07:41:54 -05:00
}
else if ( changedField == &m_formationSimWellName )
2017-10-25 07:41:54 -05:00
{
loadDataAndUpdate( true );
2017-10-25 07:41:54 -05:00
}
else if ( changedField == &m_formationTrajectoryType )
2017-10-25 07:41:54 -05:00
{
if ( m_formationTrajectoryType == WELL_PATH )
{
RimProject* proj = RiaApplication::instance()->project();
m_formationWellPathForSourceCase = proj->wellPathFromSimWellName( m_formationSimWellName );
}
else
{
if ( m_formationWellPathForSourceCase )
{
m_formationSimWellName = m_formationWellPathForSourceCase->associatedSimulationWellName();
}
}
loadDataAndUpdate( true );
2017-10-25 07:41:54 -05:00
}
else if ( changedField == &m_formationBranchIndex || changedField == &m_formationBranchDetection )
2017-10-25 07:41:54 -05:00
{
m_formationBranchIndex = RiaSimWellBranchTools::clampBranchIndex( m_formationSimWellName,
m_formationBranchIndex,
m_formationBranchDetection );
loadDataAndUpdate( true );
2017-11-07 03:02:43 -06:00
}
else if ( changedField == &m_formationWellPathForSourceWellPath )
{
loadDataAndUpdate( true );
}
else if ( changedField == &m_formationLevel )
{
loadDataAndUpdate();
}
else if ( changedField == &m_showformationFluids )
{
loadDataAndUpdate();
}
else if ( changedField == &m_showWellPathAttributes || changedField == &m_showWellPathCompletions ||
changedField == &m_showWellPathComponentsBothSides || changedField == &m_showWellPathComponentLabels ||
changedField == &m_wellPathAttributesInLegend || changedField == &m_wellPathCompletionsInLegend )
{
updateWellPathAttributesOnPlot();
updateParentPlotLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
else if ( changedField == &m_wellPathComponentSource )
{
updateWellPathAttributesCollection();
updateWellPathAttributesOnPlot();
updateParentPlotLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
2017-11-07 03:02:43 -06:00
}
2017-10-25 07:41:54 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateParentPlotLayout()
{
RimWellLogPlot* wellLogPlot;
this->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
RiuWellLogPlot* wellLogPlotViewer = dynamic_cast<RiuWellLogPlot*>( wellLogPlot->viewWidget() );
if ( wellLogPlotViewer )
{
wellLogPlotViewer->updateChildrenLayout();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateAxisAndGridTickIntervals()
{
if ( !m_wellLogTrackPlotWidget ) return;
if ( m_explicitTickIntervals )
{
m_wellLogTrackPlotWidget->setMajorAndMinorTickIntervals( m_majorTickInterval(), m_minorTickInterval() );
}
2018-06-28 01:23:16 -05:00
else
{
int xMajorTickIntervals = 3;
int xMinorTickIntervals = 0;
switch ( m_widthScaleFactor() )
2018-06-28 01:23:16 -05:00
{
case EXTRA_NARROW_TRACK:
xMajorTickIntervals = 3;
xMinorTickIntervals = 2;
break;
case NARROW_TRACK:
xMajorTickIntervals = 3;
xMinorTickIntervals = 5;
break;
case NORMAL_TRACK:
xMajorTickIntervals = 5;
xMinorTickIntervals = 5;
break;
case WIDE_TRACK:
xMajorTickIntervals = 5;
xMinorTickIntervals = 10;
break;
case EXTRA_WIDE_TRACK:
xMajorTickIntervals = 10;
xMinorTickIntervals = 10;
break;
2018-06-28 01:23:16 -05:00
}
m_wellLogTrackPlotWidget->setAutoTickIntervalCounts( xMajorTickIntervals, xMinorTickIntervals );
2018-06-28 01:23:16 -05:00
}
switch ( m_xAxisGridVisibility() )
{
case RimWellLogPlot::AXIS_GRID_NONE:
m_wellLogTrackPlotWidget->enableXGridLines( false, false );
break;
case RimWellLogPlot::AXIS_GRID_MAJOR:
m_wellLogTrackPlotWidget->enableXGridLines( true, false );
break;
case RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR:
m_wellLogTrackPlotWidget->enableXGridLines( true, true );
break;
}
RimWellLogPlot* plot = nullptr;
this->firstAncestorOrThisOfTypeAsserted( plot );
switch ( plot->depthGridLinesVisibility() )
{
case RimWellLogPlot::AXIS_GRID_NONE:
m_wellLogTrackPlotWidget->enableDepthGridLines( false, false );
break;
case RimWellLogPlot::AXIS_GRID_MAJOR:
m_wellLogTrackPlotWidget->enableDepthGridLines( true, false );
break;
case RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR:
m_wellLogTrackPlotWidget->enableDepthGridLines( true, true );
break;
}
m_wellLogTrackPlotWidget->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateAllLegendItems()
{
reattachAllCurves();
if ( m_wellLogTrackPlotWidget )
2018-09-07 08:18:41 -05:00
{
m_wellLogTrackPlotWidget->updateLegend();
}
}
2017-10-25 07:41:54 -05:00
//--------------------------------------------------------------------------------------------------
///
2017-10-25 07:41:54 -05:00
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellLogTrack::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
2017-10-25 07:41:54 -05:00
{
QList<caf::PdmOptionItemInfo> options;
if ( options.size() > 0 ) return options;
2017-10-25 07:41:54 -05:00
if ( fieldNeedingOptions == &m_formationWellPathForSourceCase )
2017-10-25 07:41:54 -05:00
{
RimTools::wellPathOptionItems( &options );
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
2017-10-25 07:41:54 -05:00
}
else if ( fieldNeedingOptions == &m_formationWellPathForSourceWellPath )
{
RimTools::wellPathWithFormationsOptionItems( &options );
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
else if ( fieldNeedingOptions == &m_formationCase )
2017-10-25 07:41:54 -05:00
{
RimTools::caseOptionItems( &options );
2017-10-25 07:41:54 -05:00
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
2017-10-25 07:41:54 -05:00
}
else if ( fieldNeedingOptions == &m_formationSimWellName )
2017-10-25 07:41:54 -05:00
{
RimWellLogTrack::simWellOptionItems( &options, m_formationCase );
2017-10-25 07:41:54 -05:00
}
else if ( fieldNeedingOptions == &m_formationBranchIndex )
2017-10-25 07:41:54 -05:00
{
auto simulationWellBranches = RiaSimWellBranchTools::simulationWellBranches( m_formationSimWellName(),
m_formationBranchDetection );
options = RiaSimWellBranchTools::valueOptionsForBranchIndexField( simulationWellBranches );
2017-10-25 07:41:54 -05:00
}
else if ( fieldNeedingOptions == &m_formationLevel )
{
if ( m_formationWellPathForSourceWellPath )
{
const RigWellPathFormations* formations = m_formationWellPathForSourceWellPath->formationsGeometry();
if ( formations )
{
using FormationLevelEnum = caf::AppEnum<RigWellPathFormations::FormationLevel>;
options.push_back( caf::PdmOptionItemInfo( FormationLevelEnum::uiText( RigWellPathFormations::NONE ),
RigWellPathFormations::NONE ) );
options.push_back( caf::PdmOptionItemInfo( FormationLevelEnum::uiText( RigWellPathFormations::ALL ),
RigWellPathFormations::ALL ) );
for ( const RigWellPathFormations::FormationLevel& level : formations->formationsLevelsPresent() )
{
size_t index = FormationLevelEnum::index( level );
if ( index >= FormationLevelEnum::size() ) continue;
options.push_back( caf::PdmOptionItemInfo( FormationLevelEnum::uiTextFromIndex( index ),
FormationLevelEnum::fromIndex( index ) ) );
}
}
}
}
else if ( fieldNeedingOptions == &m_wellPathComponentSource )
{
RimTools::wellPathOptionItems( &options );
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
2017-10-25 07:41:54 -05:00
return options;
2017-02-13 01:37:31 -06:00
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellLogTrack::objectToggleField()
{
return &m_show;
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellLogTrack::userDescriptionField()
{
return &m_userName;
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::addCurve( RimWellLogCurve* curve )
2017-02-13 01:37:31 -06:00
{
curves.push_back( curve );
2017-02-13 01:37:31 -06:00
if ( m_wellLogTrackPlotWidget )
2017-02-13 01:37:31 -06:00
{
curve->setParentQwtPlotAndReplot( m_wellLogTrackPlotWidget );
2017-02-13 01:37:31 -06:00
}
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::insertCurve( RimWellLogCurve* curve, size_t index )
2017-02-13 01:37:31 -06:00
{
curves.insert( index, curve );
2017-02-13 01:37:31 -06:00
// Todo: Mark curve data to use either TVD or MD
if ( m_wellLogTrackPlotWidget )
2017-02-13 01:37:31 -06:00
{
curve->setParentQwtPlotAndReplot( m_wellLogTrackPlotWidget );
2017-02-13 01:37:31 -06:00
}
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::takeOutCurve( RimWellLogCurve* curve )
2017-02-13 01:37:31 -06:00
{
size_t index = curves.index( curve );
if ( index < curves.size() )
2017-02-13 01:37:31 -06:00
{
curves[index]->detachQwtCurve();
curves.removeChildObject( curve );
2017-02-13 01:37:31 -06:00
}
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::deleteAllCurves()
{
curves.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-02-13 01:37:31 -06:00
RiuWellLogTrack* RimWellLogTrack::viewer()
{
return m_wellLogTrackPlotWidget;
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximumDepth )
2017-02-13 01:37:31 -06:00
{
double minDepth = HUGE_VAL;
double maxDepth = -HUGE_VAL;
for ( RimPlotCurve* curve : curves )
2017-02-13 01:37:31 -06:00
{
double minCurveDepth = HUGE_VAL;
double maxCurveDepth = -HUGE_VAL;
if ( curve->isCurveVisible() && curve->yValueRange( &minCurveDepth, &maxCurveDepth ) )
2017-02-13 01:37:31 -06:00
{
if ( minCurveDepth < minDepth )
2017-02-13 01:37:31 -06:00
{
minDepth = minCurveDepth;
}
if ( maxCurveDepth > maxDepth )
2017-02-13 01:37:31 -06:00
{
maxDepth = maxCurveDepth;
}
}
}
if ( m_showWellPathAttributes || m_showWellPathCompletions )
{
for ( const std::unique_ptr<RiuWellPathComponentPlotItem>& plotObject : m_wellPathAttributePlotObjects )
{
double minObjectDepth = HUGE_VAL;
double maxObjectDepth = -HUGE_VAL;
if ( plotObject->yValueRange( &minObjectDepth, &maxObjectDepth ) )
{
if ( minObjectDepth < minDepth )
{
minDepth = minObjectDepth;
}
if ( maxObjectDepth > maxDepth )
{
maxDepth = maxObjectDepth;
}
}
}
}
2017-02-13 01:37:31 -06:00
*minimumDepth = minDepth;
*maximumDepth = maxDepth;
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::loadDataAndUpdate( bool updateParentPlotAndToolbars )
2017-02-13 01:37:31 -06:00
{
RimWellLogPlot* wellLogPlot = nullptr;
firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot && m_wellLogTrackPlotWidget )
2017-02-13 01:37:31 -06:00
{
if ( isFirstVisibleTrackInPlot() )
2018-07-06 02:17:16 -05:00
{
m_wellLogTrackPlotWidget->setDepthTitle( wellLogPlot->depthPlotTitle() );
2018-07-06 02:17:16 -05:00
}
m_wellLogTrackPlotWidget->setXTitle( m_xAxisTitle );
2017-02-13 01:37:31 -06:00
}
for ( size_t cIdx = 0; cIdx < curves.size(); ++cIdx )
2017-02-13 01:37:31 -06:00
{
curves[cIdx]->loadDataAndUpdate( false );
2017-02-13 01:37:31 -06:00
}
2017-10-25 07:41:54 -05:00
if ( m_showFormations )
{
setFormationFieldsUiReadOnly( false );
}
else
{
setFormationFieldsUiReadOnly( true );
}
if ( m_wellLogTrackPlotWidget )
{
this->updateWellPathAttributesCollection();
this->updateWellPathAttributesOnPlot();
m_wellLogTrackPlotWidget->updateLegend();
this->updateAxisScaleEngine();
this->updateFormationNamesOnPlot();
this->applyXZoomFromVisibleRange();
}
2018-06-28 01:23:16 -05:00
this->updateAxisAndGridTickIntervals();
m_majorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() );
m_minorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() );
bool emptyRange = std::abs( m_visibleXRangeMax() - m_visibleXRangeMin ) <
1.0e-6 * std::max( 1.0, std::max( m_visibleXRangeMax(), m_visibleXRangeMin() ) );
m_explicitTickIntervals.uiCapability()->setUiReadOnly( emptyRange );
m_xAxisGridVisibility.uiCapability()->setUiReadOnly( emptyRange );
updateAllLegendItems();
if ( updateParentPlotAndToolbars )
{
updateParentPlotLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
2017-02-13 01:37:31 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAndUpdateWellPathFormationNamesData( RimCase* rimCase, RimWellPath* wellPath )
{
m_formationCase = rimCase;
m_formationTrajectoryType = RimWellLogTrack::WELL_PATH;
m_formationWellPathForSourceCase = wellPath;
m_formationSimWellName = "";
m_formationBranchIndex = -1;
updateConnectedEditors();
if ( m_showFormations )
{
updateFormationNamesOnPlot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAndUpdateSimWellFormationNamesAndBranchData( RimCase* rimCase,
const QString& simWellName,
int branchIndex,
bool useBranchDetection )
{
m_formationBranchIndex = branchIndex;
m_formationBranchDetection = useBranchDetection;
setAndUpdateSimWellFormationNamesData( rimCase, simWellName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAndUpdateSimWellFormationNamesData( RimCase* rimCase, const QString& simWellName )
{
m_formationCase = rimCase;
m_formationTrajectoryType = RimWellLogTrack::SIMULATION_WELL;
m_formationWellPathForSourceCase = nullptr;
m_formationSimWellName = simWellName;
updateConnectedEditors();
if ( m_showFormations )
{
updateFormationNamesOnPlot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAutoScaleXEnabled( bool enabled )
{
m_isAutoScaleXEnabled = enabled;
}
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setXAxisTitle( const QString& text )
2017-02-13 01:37:31 -06:00
{
m_xAxisTitle = text;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogTrack::depthPlotTitle() const
{
RimWellLogPlot* parent;
this->firstAncestorOrThisOfTypeAsserted( parent );
return parent->depthPlotTitle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellLogTrack::widthScaleFactor() const
{
return static_cast<int>( m_widthScaleFactor() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setWidthScaleFactor( WidthScaleFactor scaleFactor )
{
m_widthScaleFactor = scaleFactor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setFormationWellPath( RimWellPath* wellPath )
{
m_formationWellPathForSourceCase = wellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimWellLogTrack::formationWellPath() const
{
return m_formationWellPathForSourceCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setFormationSimWellName( const QString& simWellName )
{
m_formationSimWellName = simWellName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setFormationBranchIndex( int branchIndex )
{
m_formationBranchIndex = branchIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setFormationCase( RimCase* rimCase )
{
m_formationCase = rimCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setFormationTrajectoryType( TrajectoryType trajectoryType )
{
m_formationTrajectoryType = trajectoryType;
}
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RimWellLogTrack::formationNamesCase() const
{
return m_formationCase();
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::recreateViewer()
{
if ( m_wellLogTrackPlotWidget == nullptr )
2017-02-13 01:37:31 -06:00
{
m_wellLogTrackPlotWidget = new RiuWellLogTrack( this );
2017-02-13 01:37:31 -06:00
updateAxisScaleEngine();
for ( size_t cIdx = 0; cIdx < curves.size(); ++cIdx )
2017-02-13 01:37:31 -06:00
{
curves[cIdx]->setParentQwtPlotNoReplot( this->m_wellLogTrackPlotWidget );
2017-02-13 01:37:31 -06:00
}
this->m_wellLogTrackPlotWidget->replot();
2017-02-13 01:37:31 -06:00
}
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::detachAllCurves()
{
for ( RimPlotCurve* curve : curves )
{
curve->detachQwtCurve();
}
for ( auto& plotObjects : m_wellPathAttributePlotObjects )
{
plotObjects->detachFromQwt();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::reattachAllCurves()
{
for ( RimPlotCurve* curve : curves )
{
curve->reattachQwtCurve();
}
for ( auto& plotObjects : m_wellPathAttributePlotObjects )
2017-02-13 01:37:31 -06:00
{
plotObjects->reattachToQwt();
2017-02-13 01:37:31 -06:00
}
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateParentPlotZoom()
2017-02-13 01:37:31 -06:00
{
if ( m_wellLogTrackPlotWidget )
2017-02-13 01:37:31 -06:00
{
RimWellLogPlot* wellLogPlot;
firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
2017-02-13 01:37:31 -06:00
{
wellLogPlot->updateDepthZoom();
2017-02-13 01:37:31 -06:00
}
}
}
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::calculateXZoomRangeAndUpdateQwt()
{
this->calculateXZoomRange();
this->applyXZoomFromVisibleRange();
}
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::applyXZoomFromVisibleRange()
{
if ( !m_wellLogTrackPlotWidget ) return;
2018-06-26 06:14:29 -05:00
m_wellLogTrackPlotWidget->setXRange( m_visibleXRangeMin, m_visibleXRangeMax );
// Attribute range. Fixed range where well components are positioned [-1, 1].
// Set an extended range here to allow for some label space.
double componentRangeMax = 1.5 * ( 10.0 / ( m_widthScaleFactor() ) );
double componentRangeMin = -0.25;
if ( m_showWellPathComponentsBothSides )
{
componentRangeMin = -1.5;
}
m_wellLogTrackPlotWidget->setXRange( componentRangeMin, componentRangeMax, QwtPlot::xBottom );
m_wellLogTrackPlotWidget->replot();
2017-02-13 01:37:31 -06:00
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::calculateXZoomRange()
2017-02-13 01:37:31 -06:00
{
std::map<int, std::vector<RimWellFlowRateCurve*>> stackCurveGroups = visibleStackedCurves();
for ( const std::pair<int, std::vector<RimWellFlowRateCurve*>>& curveGroup : stackCurveGroups )
{
for ( RimWellFlowRateCurve* stCurve : curveGroup.second )
stCurve->updateStackedPlotData();
}
2017-02-13 01:37:31 -06:00
if ( !m_isAutoScaleXEnabled() )
2017-02-13 01:37:31 -06:00
{
return;
}
double minValue = HUGE_VAL;
double maxValue = -HUGE_VAL;
size_t visibleCurves = 0u;
for ( auto curve : curves )
2017-02-13 01:37:31 -06:00
{
double minCurveValue = HUGE_VAL;
double maxCurveValue = -HUGE_VAL;
if ( curve->isCurveVisible() )
2017-02-13 01:37:31 -06:00
{
visibleCurves++;
if ( curve->xValueRange( &minCurveValue, &maxCurveValue ) )
2017-02-13 01:37:31 -06:00
{
if ( minCurveValue < minValue )
{
minValue = minCurveValue;
}
2017-02-13 01:37:31 -06:00
if ( maxCurveValue > maxValue )
{
maxValue = maxCurveValue;
}
2017-02-13 01:37:31 -06:00
}
}
}
if ( minValue == HUGE_VAL )
2017-02-13 01:37:31 -06:00
{
if ( visibleCurves )
{
minValue = RI_LOGPLOTTRACK_MINX_DEFAULT;
maxValue = RI_LOGPLOTTRACK_MAXX_DEFAULT;
}
else
{
// Empty axis when there are no curves
minValue = 0;
maxValue = 0;
}
2017-02-13 01:37:31 -06:00
}
if ( m_minorTickInterval() != 0.0 )
{
std::tie( minValue, maxValue ) = adjustXRange( minValue, maxValue, m_minorTickInterval() );
}
2017-02-13 01:37:31 -06:00
m_visibleXRangeMin = minValue;
m_visibleXRangeMax = maxValue;
computeAndSetXRangeMinForLogarithmicScale();
updateEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateEditors()
{
this->updateConnectedEditors();
2017-02-13 01:37:31 -06:00
RimWellLogPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
plot->updateConnectedEditors();
2017-02-13 01:37:31 -06:00
RimWellRftPlot* rftPlot( nullptr );
firstAncestorOrThisOfType( rftPlot );
if ( rftPlot )
{
rftPlot->updateConnectedEditors();
}
else
{
RimWellPltPlot* pltPlot( nullptr );
firstAncestorOrThisOfType( pltPlot );
if ( pltPlot )
{
pltPlot->updateConnectedEditors();
}
}
2017-02-13 01:37:31 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setVisibleXRange( double minValue, double maxValue )
{
this->setAutoScaleXEnabled( false );
m_visibleXRangeMin = minValue;
m_visibleXRangeMax = maxValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setTickIntervals( double majorTickInterval, double minorTickInterval )
{
m_explicitTickIntervals = true;
m_majorTickInterval = majorTickInterval;
m_minorTickInterval = minorTickInterval;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility gridLines )
{
m_xAxisGridVisibility = gridLines;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setShowFormations( bool on )
{
m_showFormations = on;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogTrack::showFormations() const
{
return m_showFormations;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setShowFormationLabels( bool on )
{
m_showFormationLabels = on;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogTrack::showWellPathAttributes() const
{
return m_showWellPathAttributes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setShowWellPathAttributes( bool on )
{
m_showWellPathAttributes = on;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setWellPathAttributesSource( RimWellPath* wellPath )
{
m_wellPathComponentSource = wellPath;
updateWellPathAttributesCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimWellLogTrack::wellPathAttributeSource() const
{
return m_wellPathComponentSource;
}
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
RimWellLogCurve* RimWellLogTrack::curveDefinitionFromCurve( const QwtPlotCurve* curve ) const
2017-02-13 01:37:31 -06:00
{
for ( size_t idx = 0; idx < curves.size(); idx++ )
2017-02-13 01:37:31 -06:00
{
if ( curves[idx]->qwtPlotCurve() == curve )
2017-02-13 01:37:31 -06:00
{
return curves[idx];
}
}
2017-10-25 07:41:54 -05:00
return nullptr;
}
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
2017-02-13 01:37:31 -06:00
{
uiOrdering.add( &m_userName );
caf::PdmUiGroup* formationGroup = uiOrdering.addNewGroup( "Zonation/Formation Names" );
2017-10-25 07:41:54 -05:00
formationGroup->add( &m_showFormations );
formationGroup->add( &m_showFormationLabels );
if ( !m_formationsForCaseWithSimWellOnly )
{
formationGroup->add( &m_formationSource );
}
else
{
m_formationSource = CASE;
}
2017-10-25 07:41:54 -05:00
if ( m_formationSource() == CASE )
2017-10-25 07:41:54 -05:00
{
formationGroup->add( &m_formationCase );
2017-10-25 07:41:54 -05:00
if ( !m_formationsForCaseWithSimWellOnly )
2017-10-25 07:41:54 -05:00
{
formationGroup->add( &m_formationTrajectoryType );
if ( m_formationTrajectoryType() == WELL_PATH )
{
formationGroup->add( &m_formationWellPathForSourceCase );
}
2017-10-25 07:41:54 -05:00
}
if ( m_formationsForCaseWithSimWellOnly || m_formationTrajectoryType() == SIMULATION_WELL )
{
formationGroup->add( &m_formationSimWellName );
RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName( formationGroup,
m_formationSimWellName,
m_formationBranchDetection,
m_formationBranchIndex );
}
}
else if ( m_formationSource() == WELL_PICK_FILTER )
{
formationGroup->add( &m_formationWellPathForSourceWellPath );
if ( m_formationWellPathForSourceWellPath() )
{
formationGroup->add( &m_formationLevel );
formationGroup->add( &m_showformationFluids );
}
}
2017-10-25 07:41:54 -05:00
caf::PdmUiGroup* componentGroup = uiOrdering.addNewGroup( "Well Path Components" );
componentGroup->add( &m_showWellPathAttributes );
componentGroup->add( &m_showWellPathCompletions );
componentGroup->add( &m_wellPathAttributesInLegend );
componentGroup->add( &m_wellPathCompletionsInLegend );
componentGroup->add( &m_showWellPathComponentsBothSides );
componentGroup->add( &m_showWellPathComponentLabels );
componentGroup->add( &m_wellPathComponentSource );
uiOrderingForXAxisSettings( uiOrdering );
2017-10-25 07:41:54 -05:00
caf::PdmUiGroup* trackSettingsGroup = uiOrdering.addNewGroup( "Track Settings" );
trackSettingsGroup->add( &m_widthScaleFactor );
uiOrdering.skipRemainingFields( true );
2017-02-13 01:37:31 -06:00
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
size_t RimWellLogTrack::curveIndex( RimWellLogCurve* curve )
2017-02-13 01:37:31 -06:00
{
return curves.index( curve );
2017-02-13 01:37:31 -06:00
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
bool RimWellLogTrack::isVisible()
{
return m_show;
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateAxisScaleEngine()
{
if ( m_isLogarithmicScaleEnabled )
2017-02-13 01:37:31 -06:00
{
m_wellLogTrackPlotWidget->setAxisScaleEngine( QwtPlot::xTop, new QwtLogScaleEngine );
2017-02-13 01:37:31 -06:00
// NB! Must assign scale engine to bottom in order to make QwtPlotGrid work
m_wellLogTrackPlotWidget->setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine );
2017-02-13 01:37:31 -06:00
}
else
{
m_wellLogTrackPlotWidget->setAxisScaleEngine( QwtPlot::xTop, new RiuQwtLinearScaleEngine );
2017-02-13 01:37:31 -06:00
// NB! Must assign scale engine to bottom in order to make QwtPlotGrid work
m_wellLogTrackPlotWidget->setAxisScaleEngine( QwtPlot::xBottom, new RiuQwtLinearScaleEngine );
2017-02-13 01:37:31 -06:00
}
}
2018-07-06 02:17:16 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogTrack::isFirstVisibleTrackInPlot() const
{
RimWellLogPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
size_t ownIndex = plot->trackIndex( this );
2018-07-06 02:17:16 -05:00
return plot->firstVisibleTrackIndex() == ownIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<double, double> RimWellLogTrack::adjustXRange( double minValue, double maxValue, double tickInterval )
{
double minRemainder = std::fmod( minValue, tickInterval );
double maxRemainder = std::fmod( maxValue, tickInterval );
double adjustedMin = minValue - minRemainder;
double adjustedMax = maxValue + ( tickInterval - maxRemainder );
return std::make_pair( adjustedMin, adjustedMax );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateWellPathAttributesCollection()
{
m_wellPathAttributeCollection = nullptr;
if ( m_wellPathComponentSource )
{
std::vector<RimWellPathAttributeCollection*> attributeCollection;
m_wellPathComponentSource->descendantsIncludingThisOfType( attributeCollection );
if ( !attributeCollection.empty() )
{
m_wellPathAttributeCollection = attributeCollection.front();
}
}
}
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::computeAndSetXRangeMinForLogarithmicScale()
{
if ( m_isAutoScaleXEnabled && m_isLogarithmicScaleEnabled )
2017-02-13 01:37:31 -06:00
{
double pos = HUGE_VAL;
double neg = -HUGE_VAL;
for ( size_t cIdx = 0; cIdx < curves.size(); cIdx++ )
2017-02-13 01:37:31 -06:00
{
if ( curves[cIdx]->isCurveVisible() && curves[cIdx]->curveData() )
2017-02-13 01:37:31 -06:00
{
RigStatisticsCalculator::posNegClosestToZero( curves[cIdx]->curveData()->xPlotValues(), pos, neg );
2017-02-13 01:37:31 -06:00
}
}
if ( pos != HUGE_VAL )
2017-02-13 01:37:31 -06:00
{
m_visibleXRangeMin = pos;
}
}
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setLogarithmicScale( bool enable )
2017-02-13 01:37:31 -06:00
{
m_isLogarithmicScaleEnabled = enable;
updateAxisScaleEngine();
computeAndSetXRangeMinForLogarithmicScale();
}
//--------------------------------------------------------------------------------------------------
///
2017-02-13 01:37:31 -06:00
//--------------------------------------------------------------------------------------------------
std::map<int, std::vector<RimWellFlowRateCurve*>> RimWellLogTrack::visibleStackedCurves()
2017-02-13 01:37:31 -06:00
{
std::map<int, std::vector<RimWellFlowRateCurve*>> stackedCurves;
for ( RimWellLogCurve* curve : curves )
2017-02-13 01:37:31 -06:00
{
if ( curve && curve->isCurveVisible() )
2017-02-13 01:37:31 -06:00
{
RimWellFlowRateCurve* wfrCurve = dynamic_cast<RimWellFlowRateCurve*>( curve );
if ( wfrCurve != nullptr )
{
stackedCurves[wfrCurve->groupId()].push_back( wfrCurve );
}
2017-02-13 01:37:31 -06:00
}
}
return stackedCurves;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogTrack::description()
{
return m_userName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellLogCurve*> RimWellLogTrack::curvesVector()
{
std::vector<RimWellLogCurve*> curvesVector;
for ( RimWellLogCurve* curve : curves )
{
curvesVector.push_back( curve );
}
return curvesVector;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::uiOrderingForRftPltFormations( caf::PdmUiOrdering& uiOrdering )
{
caf::PdmUiGroup* formationGroup = uiOrdering.addNewGroup( "Zonation/Formation Names" );
formationGroup->setCollapsedByDefault( true );
formationGroup->add( &m_showFormations );
formationGroup->add( &m_formationSource );
if ( m_formationSource == CASE )
{
formationGroup->add( &m_formationCase );
}
if ( m_formationSource == WELL_PICK_FILTER )
{
if ( m_formationWellPathForSourceWellPath() && m_formationWellPathForSourceWellPath()->hasFormations() )
{
formationGroup->add( &m_formationLevel );
formationGroup->add( &m_showformationFluids );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::uiOrderingForXAxisSettings( caf::PdmUiOrdering& uiOrdering )
{
caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "X Axis Settings" );
gridGroup->add( &m_isLogarithmicScaleEnabled );
gridGroup->add( &m_visibleXRangeMin );
gridGroup->add( &m_visibleXRangeMax );
gridGroup->add( &m_xAxisGridVisibility );
// TODO Revisit if these settings are required
// See issue https://github.com/OPM/ResInsight/issues/4367
// gridGroup->add(&m_explicitTickIntervals);
// gridGroup->add(&m_majorTickInterval);
// gridGroup->add(&m_minorTickInterval);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setFormationsForCaseWithSimWellOnly( bool caseWithSimWellOnly )
{
m_formationsForCaseWithSimWellOnly = caseWithSimWellOnly;
}
2017-10-25 07:41:54 -05:00
//--------------------------------------------------------------------------------------------------
///
2017-10-25 07:41:54 -05:00
//--------------------------------------------------------------------------------------------------
RigEclipseWellLogExtractor* RimWellLogTrack::createSimWellExtractor( RimWellLogPlotCollection* wellLogCollection,
RimCase* rimCase,
const QString& simWellName,
int branchIndex,
bool useBranchDetection )
2017-10-25 07:41:54 -05:00
{
if ( !wellLogCollection ) return nullptr;
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( rimCase );
if ( !eclipseCase ) return nullptr;
std::vector<const RigWellPath*> wellPaths = RiaSimWellBranchTools::simulationWellBranches( simWellName,
useBranchDetection );
if ( wellPaths.size() == 0 ) return nullptr;
2017-10-25 07:41:54 -05:00
CVF_ASSERT( branchIndex < static_cast<int>( wellPaths.size() ) );
return ( wellLogCollection->findOrCreateSimWellExtractor( simWellName,
QString( "Find or create sim well extractor" ),
wellPaths[branchIndex],
eclipseCase->eclipseCaseData() ) );
2017-10-27 04:41:19 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2017-10-27 04:41:19 -05:00
//--------------------------------------------------------------------------------------------------
CurveSamplingPointData RimWellLogTrack::curveSamplingPointData( RigEclipseWellLogExtractor* extractor,
RigResultAccessor* resultAccessor )
2017-10-27 04:41:19 -05:00
{
CurveSamplingPointData curveData;
curveData.md = extractor->cellIntersectionMDs();
curveData.tvd = extractor->cellIntersectionTVDs();
extractor->curveData( resultAccessor, &curveData.data );
2017-10-27 04:41:19 -05:00
return curveData;
}
//--------------------------------------------------------------------------------------------------
///
2017-10-27 04:41:19 -05:00
//--------------------------------------------------------------------------------------------------
CurveSamplingPointData RimWellLogTrack::curveSamplingPointData( RigGeoMechWellLogExtractor* extractor,
const RigFemResultAddress& resultAddress )
2017-10-27 04:41:19 -05:00
{
CurveSamplingPointData curveData;
curveData.md = extractor->cellIntersectionMDs();
curveData.tvd = extractor->cellIntersectionTVDs();
2017-10-25 07:41:54 -05:00
extractor->curveData( resultAddress, 0, &curveData.data );
2017-10-27 04:41:19 -05:00
return curveData;
}
//--------------------------------------------------------------------------------------------------
///
2017-10-27 04:41:19 -05:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::findFormationNamesToPlot( const CurveSamplingPointData& curveData,
const std::vector<QString>& formationNamesVector,
RimWellLogPlot::DepthTypeEnum depthType,
std::vector<QString>* formationNamesToPlot,
std::vector<std::pair<double, double>>* yValues )
2017-10-27 04:41:19 -05:00
{
if ( formationNamesVector.empty() ) return;
2017-10-27 04:41:19 -05:00
std::vector<size_t> formationNameIndicesFromCurve;
for ( double nameIdx : curveData.data )
2017-10-25 07:41:54 -05:00
{
if ( nameIdx != std::numeric_limits<double>::infinity() )
{
formationNameIndicesFromCurve.push_back( static_cast<size_t>( round( nameIdx ) ) );
}
else
{
formationNameIndicesFromCurve.push_back( std::numeric_limits<size_t>::max() );
}
2017-10-25 07:41:54 -05:00
}
if ( formationNameIndicesFromCurve.empty() ) return;
2017-10-25 07:41:54 -05:00
2017-10-27 04:41:19 -05:00
std::vector<double> depthVector;
2017-10-25 07:41:54 -05:00
if ( depthType == RimWellLogPlot::MEASURED_DEPTH || depthType == RimWellLogPlot::PSEUDO_LENGTH )
2017-10-27 04:41:19 -05:00
{
depthVector = curveData.md;
}
else if ( depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH )
2017-10-27 04:41:19 -05:00
{
depthVector = curveData.tvd;
}
2017-10-25 07:41:54 -05:00
if ( depthVector.empty() ) return;
2017-10-25 07:41:54 -05:00
2017-10-27 04:41:19 -05:00
double currentYStart = depthVector[0];
size_t prevNameIndex = formationNameIndicesFromCurve[0];
size_t currentNameIndex;
2017-10-25 07:41:54 -05:00
for ( size_t i = 1; i < formationNameIndicesFromCurve.size(); i++ )
2017-10-25 07:41:54 -05:00
{
2017-10-27 04:41:19 -05:00
currentNameIndex = formationNameIndicesFromCurve[i];
if ( currentNameIndex != std::numeric_limits<size_t>::max() && currentNameIndex != prevNameIndex )
2017-10-25 07:41:54 -05:00
{
if ( prevNameIndex < formationNamesVector.size() )
2017-10-27 04:41:19 -05:00
{
formationNamesToPlot->push_back( formationNamesVector[prevNameIndex] );
yValues->push_back( std::make_pair( currentYStart, depthVector[i - 1] ) );
2017-10-27 04:41:19 -05:00
}
currentYStart = depthVector[i];
prevNameIndex = currentNameIndex;
2017-10-25 07:41:54 -05:00
}
2017-10-27 04:41:19 -05:00
}
size_t lastFormationIdx = formationNameIndicesFromCurve.back();
if ( lastFormationIdx < formationNamesVector.size() )
{
formationNamesToPlot->push_back( formationNamesVector[lastFormationIdx] );
yValues->push_back( std::make_pair( currentYStart, depthVector.back() ) );
}
2017-10-27 04:41:19 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2017-10-27 04:41:19 -05:00
//--------------------------------------------------------------------------------------------------
std::vector<QString> RimWellLogTrack::formationNamesVector( RimCase* rimCase )
2017-10-27 04:41:19 -05:00
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( rimCase );
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>( rimCase );
2017-10-27 04:41:19 -05:00
if ( eclipseCase )
2017-10-27 04:41:19 -05:00
{
if ( eclipseCase->eclipseCaseData()->activeFormationNames() )
{
return eclipseCase->eclipseCaseData()->activeFormationNames()->formationNames();
}
2017-10-27 04:41:19 -05:00
}
else if ( geoMechCase )
2017-10-27 04:41:19 -05:00
{
if ( geoMechCase->geoMechData()->femPartResults()->activeFormationNames() )
{
return geoMechCase->geoMechData()->femPartResults()->activeFormationNames()->formationNames();
}
2017-10-27 04:41:19 -05:00
}
return std::vector<QString>();
2017-10-27 04:41:19 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setFormationFieldsUiReadOnly( bool readOnly /*= true*/ )
{
m_showFormationLabels.uiCapability()->setUiReadOnly( readOnly );
m_formationSource.uiCapability()->setUiReadOnly( readOnly );
m_formationTrajectoryType.uiCapability()->setUiReadOnly( readOnly );
m_formationSimWellName.uiCapability()->setUiReadOnly( readOnly );
m_formationCase.uiCapability()->setUiReadOnly( readOnly );
m_formationWellPathForSourceCase.uiCapability()->setUiReadOnly( readOnly );
m_formationWellPathForSourceWellPath.uiCapability()->setUiReadOnly( readOnly );
m_formationBranchDetection.uiCapability()->setUiReadOnly( readOnly );
m_formationBranchIndex.uiCapability()->setUiReadOnly( readOnly );
m_formationLevel.uiCapability()->setUiReadOnly( readOnly );
m_showformationFluids.uiCapability()->setUiReadOnly( readOnly );
}
2017-11-27 08:23:26 -06:00
//--------------------------------------------------------------------------------------------------
///
2017-11-27 08:23:26 -06:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateFormationNamesOnPlot()
{
removeFormationNames();
if ( m_showFormations == false ) return;
2017-10-27 04:41:19 -05:00
if ( m_annotationTool == nullptr )
2017-10-27 04:41:19 -05:00
{
m_annotationTool = std::unique_ptr<RiuPlotAnnotationTool>( new RiuPlotAnnotationTool() );
2017-10-27 04:41:19 -05:00
}
2017-11-27 08:23:26 -06:00
std::vector<QString> formationNamesToPlot;
2017-10-25 07:41:54 -05:00
RimWellLogPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
if ( m_formationSource == CASE )
2017-11-27 08:23:26 -06:00
{
if ( ( m_formationSimWellName == QString( "None" ) && m_formationWellPathForSourceCase == nullptr ) ||
m_formationCase == nullptr )
return;
2017-11-27 08:23:26 -06:00
RimMainPlotCollection* mainPlotCollection;
this->firstAncestorOrThisOfTypeAsserted( mainPlotCollection );
2017-10-27 04:41:19 -05:00
2017-11-27 08:23:26 -06:00
RimWellLogPlotCollection* wellLogCollection = mainPlotCollection->wellLogPlotCollection();
2017-10-27 04:41:19 -05:00
2017-11-27 08:23:26 -06:00
CurveSamplingPointData curveData;
2017-10-25 07:41:54 -05:00
RigEclipseWellLogExtractor* eclWellLogExtractor = nullptr;
RigGeoMechWellLogExtractor* geoMechWellLogExtractor = nullptr;
2017-10-25 07:41:54 -05:00
if ( m_formationTrajectoryType == SIMULATION_WELL )
2017-11-27 08:23:26 -06:00
{
eclWellLogExtractor = RimWellLogTrack::createSimWellExtractor( wellLogCollection,
m_formationCase,
m_formationSimWellName,
m_formationBranchIndex,
m_formationBranchDetection );
2017-11-27 08:23:26 -06:00
}
else
{
eclWellLogExtractor = RiaExtractionTools::wellLogExtractorEclipseCase( m_formationWellPathForSourceCase,
dynamic_cast<RimEclipseCase*>(
m_formationCase() ) );
2017-11-27 08:23:26 -06:00
}
2017-10-25 07:41:54 -05:00
if ( eclWellLogExtractor )
2017-11-27 08:23:26 -06:00
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_formationCase() );
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::
createFromResultAddress( eclipseCase->eclipseCaseData(),
0,
RiaDefines::PorosityModelType::MATRIX_MODEL,
0,
RigEclipseResultAddress( RiaDefines::FORMATION_NAMES,
RiaDefines::activeFormationNamesResultName() ) );
curveData = RimWellLogTrack::curveSamplingPointData( eclWellLogExtractor, resultAccessor.p() );
2017-11-27 08:23:26 -06:00
}
else
{
geoMechWellLogExtractor = RiaExtractionTools::wellLogExtractorGeoMechCase( m_formationWellPathForSourceCase,
dynamic_cast<RimGeoMechCase*>(
m_formationCase() ) );
if ( !geoMechWellLogExtractor ) return;
2017-10-25 07:41:54 -05:00
2017-11-27 08:23:26 -06:00
std::string activeFormationNamesResultName = RiaDefines::activeFormationNamesResultName().toStdString();
curveData = RimWellLogTrack::curveSamplingPointData( geoMechWellLogExtractor,
RigFemResultAddress( RIG_FORMATION_NAMES,
activeFormationNamesResultName,
"" ) );
2017-11-27 08:23:26 -06:00
}
2017-10-25 07:41:54 -05:00
2018-09-27 03:01:45 -05:00
std::vector<std::pair<double, double>> yValues;
std::vector<QString> formationNamesVector = RimWellLogTrack::formationNamesVector( m_formationCase );
RimWellLogTrack::findFormationNamesToPlot( curveData,
formationNamesVector,
plot->depthType(),
&formationNamesToPlot,
&yValues );
m_annotationTool->attachFormationNames( this->viewer(), formationNamesToPlot, yValues, m_showFormationLabels() );
}
else if ( m_formationSource() == WELL_PICK_FILTER )
{
if ( m_formationWellPathForSourceWellPath == nullptr ) return;
if ( !( plot->depthType() == RimWellLogPlot::MEASURED_DEPTH ||
plot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) )
{
return;
}
std::vector<double> yValues;
const RigWellPathFormations* formations = m_formationWellPathForSourceWellPath->formationsGeometry();
if ( !formations ) return;
formations->depthAndFormationNamesUpToLevel( m_formationLevel(),
&formationNamesToPlot,
&yValues,
m_showformationFluids(),
plot->depthType() );
m_annotationTool->attachWellPicks( this->viewer(), formationNamesToPlot, yValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateWellPathAttributesOnPlot()
{
m_wellPathAttributePlotObjects.clear();
if ( wellPathAttributeSource() )
{
std::vector<const RimWellPathComponentInterface*> allWellPathComponents;
if ( m_showWellPathAttributes || m_showWellPathCompletions )
{
m_wellPathAttributePlotObjects.push_back( std::unique_ptr<RiuWellPathComponentPlotItem>(
new RiuWellPathComponentPlotItem( wellPathAttributeSource() ) ) );
}
if ( m_showWellPathAttributes )
{
if ( m_wellPathAttributeCollection )
{
std::vector<RimWellPathAttribute*> attributes = m_wellPathAttributeCollection->attributes();
for ( const RimWellPathAttribute* attribute : attributes )
{
if ( attribute->isEnabled() )
{
allWellPathComponents.push_back( attribute );
}
}
}
}
if ( m_showWellPathCompletions )
{
const RimWellPathCompletions* completionsCollection = wellPathAttributeSource()->completions();
std::vector<const RimWellPathComponentInterface*> allCompletions = completionsCollection->allCompletions();
for ( const RimWellPathComponentInterface* completion : allCompletions )
{
if ( completion->isEnabled() )
{
allWellPathComponents.push_back( completion );
}
}
}
const std::map<RiaDefines::WellPathComponentType, int> sortIndices = {{RiaDefines::WELL_PATH, 0},
{RiaDefines::CASING, 1},
{RiaDefines::LINER, 2},
{RiaDefines::PERFORATION_INTERVAL, 3},
{RiaDefines::FISHBONES, 4},
{RiaDefines::FRACTURE, 5},
{RiaDefines::PACKER, 6},
{RiaDefines::ICD, 7},
{RiaDefines::AICD, 8},
{RiaDefines::ICV, 9}};
std::stable_sort( allWellPathComponents.begin(),
allWellPathComponents.end(),
[&sortIndices]( const RimWellPathComponentInterface* lhs,
const RimWellPathComponentInterface* rhs ) {
return sortIndices.at( lhs->componentType() ) < sortIndices.at( rhs->componentType() );
} );
std::set<QString> completionsAssignedToLegend;
for ( const RimWellPathComponentInterface* component : allWellPathComponents )
{
std::unique_ptr<RiuWellPathComponentPlotItem> plotItem(
new RiuWellPathComponentPlotItem( wellPathAttributeSource(), component ) );
QString legendTitle = plotItem->legendTitle();
bool contributeToLegend = m_wellPathCompletionsInLegend() &&
!completionsAssignedToLegend.count( legendTitle );
plotItem->setContributeToLegend( contributeToLegend );
m_wellPathAttributePlotObjects.push_back( std::move( plotItem ) );
completionsAssignedToLegend.insert( legendTitle );
}
RimWellLogPlot* wellLogPlot;
this->firstAncestorOrThisOfTypeAsserted( wellLogPlot );
RimWellLogPlot::DepthTypeEnum depthType = wellLogPlot->depthType();
for ( auto& attributePlotObject : m_wellPathAttributePlotObjects )
{
attributePlotObject->setDepthType( depthType );
attributePlotObject->setShowLabel( m_showWellPathComponentLabels() );
attributePlotObject->loadDataAndUpdate( false );
attributePlotObject->setParentQwtPlotNoReplot( m_wellLogTrackPlotWidget );
}
}
applyXZoomFromVisibleRange();
}
2017-10-25 07:41:54 -05:00
//--------------------------------------------------------------------------------------------------
///
2017-10-25 07:41:54 -05:00
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::removeFormationNames()
{
if ( m_annotationTool )
2017-10-25 07:41:54 -05:00
{
m_annotationTool->detachAllAnnotations();
}
}