2017-10-09 07:30:27 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-09 07:30:27 -05: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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-09 07:30:27 -05: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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-10-09 07:30:27 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicWellLogTools.h"
|
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "Rim3dView.h"
|
2017-10-09 07:30:27 -05:00
|
|
|
#include "RimCase.h"
|
|
|
|
#include "RimEclipseResultCase.h"
|
|
|
|
#include "RimProject.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimSimWellInView.h"
|
2017-10-09 07:30:27 -05:00
|
|
|
#include "RimWellLogExtractionCurve.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimWellLogFile.h"
|
2017-10-09 07:30:27 -05:00
|
|
|
#include "RimWellLogFileChannel.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimWellLogFileCurve.h"
|
2017-10-09 07:30:27 -05:00
|
|
|
#include "RimWellLogRftCurve.h"
|
|
|
|
#include "RimWellLogTrack.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
|
|
|
|
#include "RifReaderEclipseRft.h"
|
|
|
|
|
2018-11-30 05:53:46 -06:00
|
|
|
#include "Riu3dSelectionManager.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2017-10-09 08:33:01 -05:00
|
|
|
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
|
2017-10-09 07:30:27 -05:00
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RimSimWellInView* RicWellLogTools::selectedSimulationWell( int* branchIndex )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuSelectionItem* selItem = Riu3dSelectionManager::instance()->selectedItem( Riu3dSelectionManager::RUI_TEMPORARY );
|
|
|
|
RiuSimWellSelectionItem* simWellSelItem = dynamic_cast<RiuSimWellSelectionItem*>( selItem );
|
|
|
|
if ( simWellSelItem )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
( *branchIndex ) = static_cast<int>( simWellSelItem->m_branchIndex );
|
2017-10-09 07:30:27 -05:00
|
|
|
return simWellSelItem->m_simWell;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-13 02:29:42 -05:00
|
|
|
std::vector<RimSimWellInView*> selection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &selection );
|
|
|
|
( *branchIndex ) = 0;
|
2017-10-09 07:30:27 -05:00
|
|
|
return selection.size() > 0 ? selection[0] : nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RicWellLogTools::wellHasRftData( const QString& wellName )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
|
|
|
RimEclipseResultCase* resultCase;
|
|
|
|
std::vector<RimCase*> cases;
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaApplication::instance()->project()->allCases( cases );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimCase* rimCase : cases )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( resultCase = dynamic_cast<RimEclipseResultCase*>( rimCase ) )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( resultCase->rftReader() )
|
2017-10-16 09:00:53 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return resultCase->rftReader()->wellHasRftData( wellName );
|
2017-10-16 09:00:53 -05:00
|
|
|
}
|
2017-10-09 07:30:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-30 04:09:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-30 04:09:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicWellLogTools::isWellPathOrSimWellSelectedInView()
|
|
|
|
{
|
2018-11-30 05:53:46 -06:00
|
|
|
Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance();
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuSelectionItem* selItem = riuSelManager->selectedItem( Riu3dSelectionManager::RUI_TEMPORARY );
|
2017-11-30 04:09:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuSimWellSelectionItem* simWellSelectionItem = dynamic_cast<RiuSimWellSelectionItem*>( selItem );
|
|
|
|
if ( simWellSelectionItem ) return true;
|
2017-11-30 04:09:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuWellPathSelectionItem* wellPathSelectionItem = dynamic_cast<RiuWellPathSelectionItem*>( selItem );
|
|
|
|
if ( wellPathSelectionItem ) return true;
|
2017-11-30 04:09:43 -06:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicWellLogTools::addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack,
|
|
|
|
const std::vector<RimWellLogFileChannel*>& wellLogFileChannels )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t cIdx = 0; cIdx < wellLogFileChannels.size(); cIdx++ )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimWellLogFileCurve* plotCurve = RicWellLogTools::addFileCurve( plotTrack );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RimWellPath* wellPath;
|
2017-12-13 05:38:44 -06:00
|
|
|
RimWellLogFile* wellLogFile;
|
2019-09-06 03:40:57 -05:00
|
|
|
wellLogFileChannels[cIdx]->firstAncestorOrThisOfType( wellPath );
|
|
|
|
wellLogFileChannels[cIdx]->firstAncestorOrThisOfType( wellLogFile );
|
2017-12-13 05:38:44 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( wellPath )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( wellLogFile ) plotCurve->setWellLogFile( wellLogFile );
|
2017-12-13 05:38:44 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
plotCurve->setWellPath( wellPath );
|
|
|
|
plotCurve->setWellLogChannelName( wellLogFileChannels[cIdx]->name() );
|
|
|
|
plotCurve->loadDataAndUpdate( true );
|
2017-10-09 07:30:27 -05:00
|
|
|
plotCurve->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPath* RicWellLogTools::selectedWellPathWithLogFile()
|
|
|
|
{
|
|
|
|
std::vector<RimWellPath*> selection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &selection );
|
|
|
|
if ( selection.size() > 0 )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
|
|
|
RimWellPath* wellPath = selection[0];
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( wellPath->wellLogFiles().size() > 0 )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
|
|
|
return wellPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-04-19 04:26:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-04-19 04:26:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPath* RicWellLogTools::findWellPathWithLogFileFromSelection()
|
|
|
|
{
|
2018-08-22 05:04:42 -05:00
|
|
|
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( wellPath->wellLogFiles().size() > 0 )
|
2018-04-19 04:26:03 -05:00
|
|
|
{
|
|
|
|
return wellPath;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve( RimWellLogTrack* plotTrack,
|
|
|
|
Rim3dView* view,
|
|
|
|
RimWellPath* wellPath,
|
|
|
|
const RimSimWellInView* simWell,
|
|
|
|
int branchIndex,
|
|
|
|
bool useBranchDetection,
|
|
|
|
bool showPlotWindow )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( plotTrack );
|
2017-10-09 07:30:27 -05:00
|
|
|
RimWellLogExtractionCurve* curve = new RimWellLogExtractionCurve();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() );
|
|
|
|
curve->setColor( curveColor );
|
|
|
|
if ( wellPath )
|
2017-11-28 04:00:36 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
curve->setWellPath( wellPath );
|
|
|
|
plotTrack->setFormationWellPath( wellPath );
|
|
|
|
plotTrack->setFormationTrajectoryType( RimWellLogTrack::WELL_PATH );
|
2017-11-28 04:00:36 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( simWell )
|
2017-11-28 04:00:36 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
curve->setFromSimulationWellName( simWell->name(), branchIndex, useBranchDetection );
|
|
|
|
plotTrack->setFormationSimWellName( simWell->name() );
|
|
|
|
plotTrack->setFormationBranchIndex( branchIndex );
|
|
|
|
plotTrack->setFormationTrajectoryType( RimWellLogTrack::SIMULATION_WELL );
|
2017-11-28 04:00:36 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( view )
|
2017-11-28 04:00:36 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
plotTrack->setFormationCase( view->ownerCase() );
|
2017-11-28 04:00:36 -06:00
|
|
|
}
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
curve->setPropertiesFromView( view );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
plotTrack->addCurve( curve );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
|
|
|
plotTrack->updateConnectedEditors();
|
|
|
|
|
|
|
|
RiaApplication::instance()->project()->updateConnectedEditors();
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( curve );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( showPlotWindow )
|
2018-06-29 04:36:50 -05:00
|
|
|
{
|
|
|
|
// Make sure the summary plot window is visible
|
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
|
|
|
}
|
|
|
|
|
2017-10-09 07:30:27 -05:00
|
|
|
return curve;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RimWellLogRftCurve*
|
|
|
|
RicWellLogTools::addRftCurve( RimWellLogTrack* plotTrack, const RimSimWellInView* simWell, bool showPlotWindow )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( plotTrack );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
|
|
|
RimWellLogRftCurve* curve = new RimWellLogRftCurve();
|
|
|
|
|
2017-11-28 04:00:36 -06:00
|
|
|
RimEclipseResultCase* resultCase = nullptr;
|
2017-10-09 07:30:27 -05:00
|
|
|
|
|
|
|
std::vector<RimCase*> cases;
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaApplication::instance()->project()->allCases( cases );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimCase* rimCase : cases )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( resultCase = dynamic_cast<RimEclipseResultCase*>( rimCase ) )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( simWell && resultCase )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
curve->setEclipseResultCase( resultCase );
|
|
|
|
curve->setDefaultAddress( simWell->name() );
|
2017-11-28 04:00:36 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
plotTrack->setFormationCase( resultCase );
|
|
|
|
plotTrack->setFormationSimWellName( simWell->name() );
|
2017-10-09 07:30:27 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() );
|
|
|
|
curve->setColor( curveColor );
|
2017-11-28 04:00:36 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
plotTrack->addCurve( curve );
|
|
|
|
plotTrack->setFormationTrajectoryType( RimWellLogTrack::SIMULATION_WELL );
|
2017-10-09 07:30:27 -05:00
|
|
|
plotTrack->updateConnectedEditors();
|
|
|
|
|
|
|
|
RiaApplication::instance()->project()->updateConnectedEditors();
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( curve );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( showPlotWindow )
|
2018-06-29 04:36:50 -05:00
|
|
|
{
|
|
|
|
// Make sure the summary plot window is visible
|
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
|
|
|
}
|
|
|
|
|
2017-10-09 07:30:27 -05:00
|
|
|
return curve;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-09 07:30:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RimWellLogFileCurve* RicWellLogTools::addFileCurve( RimWellLogTrack* plotTrack, bool showPlotWindow )
|
2017-10-09 07:30:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( plotTrack );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
|
|
|
RimWellLogFileCurve* curve = new RimWellLogFileCurve();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() );
|
|
|
|
curve->setColor( curveColor );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
plotTrack->addCurve( curve );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
|
|
|
plotTrack->updateConnectedEditors();
|
|
|
|
|
2018-06-29 04:36:50 -05:00
|
|
|
RiaApplication::instance()->project()->updateConnectedEditors();
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( curve );
|
2017-10-09 07:30:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( showPlotWindow )
|
2018-06-29 04:36:50 -05:00
|
|
|
{
|
|
|
|
// Make sure the summary plot window is visible
|
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
|
|
|
}
|
|
|
|
|
2017-10-09 07:30:27 -05:00
|
|
|
return curve;
|
|
|
|
}
|