Files
ResInsight/ApplicationLibCode/ProjectDataModel/Completions/RimImportedFishboneLateralsCollection.cpp
Magne Sjaastad 8bab748fa6 Improve MSW export including multi lateral wells
Based on branch https://github.com/OPM/ResInsight/tree/system-msw-refactor

- Move completion settings to property of well path
- Rename to RimFishbones
- Export implicit COMPSEGS for fishbones main bore
- Add valve for each branch
- Increase version number to be able to handle import of legacy project files
2021-02-26 14:59:57 +01:00

150 lines
6.2 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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.
//
// 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>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimImportedFishboneLateralsCollection.h"
#include "Rim3dView.h"
#include "RimFishbonesCollection.h"
#include "RimImportedFishboneLaterals.h"
#include "RimProject.h"
#include "RigWellPath.h"
#include "RifWellPathImporter.h"
#include "Riu3DMainWindowTools.h"
// The more general term WellPathCompletionCollection was unfortunately used in this more specific case of fishbones
// In order to preserve compatibility, the old keyword is kept as an alias, but could be removed in the future.
CAF_PDM_SOURCE_INIT( RimImportedFishboneLateralsCollection, "FishboneWellPathCollection", "WellPathCompletionCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimImportedFishboneLateralsCollection::RimImportedFishboneLateralsCollection()
{
CAF_PDM_InitObject( "WellPathCompletions", ":/FishBoneGroupFromFile16x16.png", "", "" );
nameField()->uiCapability()->setUiHidden( true );
this->setName( "Imported Laterals" );
CAF_PDM_InitFieldNoDefault( &m_wellPaths, "WellPaths", "Imported Laterals", "", "", "" );
m_wellPaths.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_pipeProperties, "PipeProperties", "Pipe Properties", "", "", "" );
m_pipeProperties.uiCapability()->setUiHidden( true );
m_pipeProperties.uiCapability()->setUiTreeHidden( true );
m_pipeProperties.uiCapability()->setUiTreeChildrenHidden( true );
m_pipeProperties = new RimFishbonesPipeProperties;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimImportedFishboneLateralsCollection::importCompletionsFromFile( const QStringList& filePaths )
{
RifWellPathImporter wellPathImporter;
for ( const QString& filePath : filePaths )
{
size_t wellDataCount = wellPathImporter.wellDataCount( filePath );
for ( size_t i = 0; i < wellDataCount; ++i )
{
RifWellPathImporter::WellData wellData = wellPathImporter.readWellData( filePath, i );
RimImportedFishboneLaterals* wellCompletion = new RimImportedFishboneLaterals();
wellCompletion->setName( wellData.m_name );
wellCompletion->setCoordinates( wellData.m_wellPathGeometry->uniqueWellPathPoints() );
wellCompletion->setMeasuredDepths( wellData.m_wellPathGeometry->uniqueMeasuredDepths() );
appendCompletion( wellCompletion );
}
}
RimFishbonesCollection* fishbonesCollection;
firstAncestorOrThisOfType( fishbonesCollection );
if ( fishbonesCollection != nullptr )
{
fishbonesCollection->recalculateStartMD();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimImportedFishboneLateralsCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<const RimImportedFishboneLaterals*> RimImportedFishboneLateralsCollection::wellPaths() const
{
std::vector<const RimImportedFishboneLaterals*> paths;
for ( const RimImportedFishboneLaterals* path : m_wellPaths )
{
paths.push_back( path );
}
return paths;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimImportedFishboneLateralsCollection::setUnitSystemSpecificDefaults()
{
m_pipeProperties->setUnitSystemSpecificDefaults();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimImportedFishboneLateralsCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
caf::PdmUiGroup* wellPropertiesGroup = uiOrdering.addNewGroup( "Well Properties" );
m_pipeProperties->uiOrdering( uiConfigName, *wellPropertiesGroup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimImportedFishboneLateralsCollection::appendCompletion( RimImportedFishboneLaterals* completion )
{
m_wellPaths.push_back( completion );
updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( completion );
uiCapability()->setUiHidden( !m_wellPaths.empty() );
RimProject* project = nullptr;
firstAncestorOrThisOfTypeAsserted( project );
if ( project )
{
project->reloadCompletionTypeResultsInAllViews();
}
}