mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Group only with selected paths
This commit is contained in:
parent
19a8aece0e
commit
f569d6872b
@ -163,13 +163,15 @@ std::vector<RimWellPath*> RimWellPathCollection::detachWellPaths( const std::vec
|
|||||||
std::vector<RimWellPath*> detachedWellPaths;
|
std::vector<RimWellPath*> detachedWellPaths;
|
||||||
for ( auto wellPath : regularWellPathsToDetach )
|
for ( auto wellPath : regularWellPathsToDetach )
|
||||||
{
|
{
|
||||||
removeWellPath( wellPath );
|
if ( detachWellPath( wellPath ) )
|
||||||
|
{
|
||||||
detachedWellPaths.push_back( wellPath );
|
detachedWellPaths.push_back( wellPath );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for ( auto group : wellPathGroupsToRemove )
|
for ( auto group : wellPathGroupsToRemove )
|
||||||
{
|
{
|
||||||
removeWellPath( group );
|
detachWellPath( group );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto group : wellPathGroupsToRemove )
|
for ( auto group : wellPathGroupsToRemove )
|
||||||
@ -179,6 +181,29 @@ std::vector<RimWellPath*> RimWellPathCollection::detachWellPaths( const std::vec
|
|||||||
return detachedWellPaths;
|
return detachedWellPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimWellPathCollection::detachWellPath( gsl::not_null<RimWellPath*> wellPath )
|
||||||
|
{
|
||||||
|
if ( m_wellPaths.count( wellPath ) != 0u )
|
||||||
|
{
|
||||||
|
m_wellPaths.removeChildObject( wellPath );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RimWellPathGroup* group = nullptr;
|
||||||
|
wellPath->firstAncestorOfType( group );
|
||||||
|
if ( group )
|
||||||
|
{
|
||||||
|
group->removeChildWellPath( wellPath );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Read files containing well path data, or create geometry based on the targets
|
/// Read files containing well path data, or create geometry based on the targets
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -324,7 +349,7 @@ void RimWellPathCollection::addWellPath( gsl::not_null<RimWellPath*> wellPath, b
|
|||||||
RimWellPathGroup* parentWellPathGroup = nullptr;
|
RimWellPathGroup* parentWellPathGroup = nullptr;
|
||||||
if ( importGrouped )
|
if ( importGrouped )
|
||||||
{
|
{
|
||||||
parentWellPathGroup = findOrCreateWellPathGroup( wellPath );
|
parentWellPathGroup = findOrCreateWellPathGroup( wellPath, allWellPaths() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !parentWellPathGroup )
|
if ( !parentWellPathGroup )
|
||||||
@ -629,9 +654,12 @@ void RimWellPathCollection::deleteAllWellPaths()
|
|||||||
void RimWellPathCollection::groupWellPaths( const std::vector<RimWellPath*>& wellPaths )
|
void RimWellPathCollection::groupWellPaths( const std::vector<RimWellPath*>& wellPaths )
|
||||||
{
|
{
|
||||||
auto detachedWellPaths = detachWellPaths( wellPaths );
|
auto detachedWellPaths = detachWellPaths( wellPaths );
|
||||||
|
std::vector<RimWellPath*> allWellPathsToGroupWith = detachedWellPaths;
|
||||||
|
|
||||||
for ( auto wellPath : detachedWellPaths )
|
for ( auto wellPath : detachedWellPaths )
|
||||||
{
|
{
|
||||||
addWellPath( wellPath, true );
|
auto parentWellPathGroup = findOrCreateWellPathGroup( wellPath, allWellPathsToGroupWith );
|
||||||
|
allWellPathsToGroupWith.push_back( parentWellPathGroup );
|
||||||
}
|
}
|
||||||
this->sortWellsByName();
|
this->sortWellsByName();
|
||||||
this->updateAllRequiredEditors();
|
this->updateAllRequiredEditors();
|
||||||
@ -645,7 +673,7 @@ void RimWellPathCollection::ungroupWellPaths( const std::vector<RimWellPath*>& w
|
|||||||
auto detachedWellPaths = detachWellPaths( wellPaths );
|
auto detachedWellPaths = detachWellPaths( wellPaths );
|
||||||
for ( auto wellPath : detachedWellPaths )
|
for ( auto wellPath : detachedWellPaths )
|
||||||
{
|
{
|
||||||
addWellPath( wellPath, false );
|
m_wellPaths.push_back( wellPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
this->sortWellsByName();
|
this->sortWellsByName();
|
||||||
@ -705,33 +733,7 @@ void RimWellPathCollection::reloadAllWellPathFormations()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimWellPathCollection::removeWellPath( gsl::not_null<RimWellPath*> wellPath )
|
void RimWellPathCollection::removeWellPath( gsl::not_null<RimWellPath*> wellPath )
|
||||||
{
|
{
|
||||||
if ( auto group = dynamic_cast<RimWellPathGroup*>( wellPath.get() ); group )
|
bool removed = detachWellPath( wellPath );
|
||||||
{
|
|
||||||
group->removeAllChildWellPaths();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool removed = false;
|
|
||||||
if ( m_wellPaths.count( wellPath ) != 0u )
|
|
||||||
{
|
|
||||||
m_wellPaths.removeChildObject( wellPath );
|
|
||||||
removed = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for ( auto possibleParentWellPath : allWellPaths() )
|
|
||||||
{
|
|
||||||
if ( auto wellPathGroup = dynamic_cast<RimWellPathGroup*>( possibleParentWellPath ); wellPathGroup )
|
|
||||||
{
|
|
||||||
if ( wellPathGroup->hasChildWellPath( wellPath ) )
|
|
||||||
{
|
|
||||||
wellPathGroup->removeChildWellPath( wellPath );
|
|
||||||
removed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( !removed ) return;
|
|
||||||
|
|
||||||
RimFileWellPath* fileWellPath = dynamic_cast<RimFileWellPath*>( wellPath.get() );
|
RimFileWellPath* fileWellPath = dynamic_cast<RimFileWellPath*>( wellPath.get() );
|
||||||
if ( fileWellPath )
|
if ( fileWellPath )
|
||||||
@ -797,7 +799,8 @@ std::vector<RimWellPathGroup*> RimWellPathCollection::topLevelGroups() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimWellPathGroup* RimWellPathCollection::findOrCreateWellPathGroup( gsl::not_null<RimWellPath*> wellPath )
|
RimWellPathGroup* RimWellPathCollection::findOrCreateWellPathGroup( gsl::not_null<RimWellPath*> wellPath,
|
||||||
|
const std::vector<RimWellPath*>& wellPathsToGroupWith )
|
||||||
{
|
{
|
||||||
auto wellPathGeometry = wellPath->wellPathGeometry();
|
auto wellPathGeometry = wellPath->wellPathGeometry();
|
||||||
if ( !wellPathGeometry ) return nullptr;
|
if ( !wellPathGeometry ) return nullptr;
|
||||||
@ -805,7 +808,7 @@ RimWellPathGroup* RimWellPathCollection::findOrCreateWellPathGroup( gsl::not_nul
|
|||||||
const double eps = 1.0e-4;
|
const double eps = 1.0e-4;
|
||||||
std::map<RimWellPath*, double> wellPathsWithCommonGeometry;
|
std::map<RimWellPath*, double> wellPathsWithCommonGeometry;
|
||||||
|
|
||||||
for ( auto existingWellPath : allWellPaths() )
|
for ( auto existingWellPath : wellPathsToGroupWith )
|
||||||
{
|
{
|
||||||
double identicalTubeLength = existingWellPath->wellPathGeometry()->identicalTubeLength( *wellPathGeometry );
|
double identicalTubeLength = existingWellPath->wellPathGeometry()->identicalTubeLength( *wellPathGeometry );
|
||||||
if ( identicalTubeLength > eps )
|
if ( identicalTubeLength > eps )
|
||||||
@ -829,6 +832,7 @@ RimWellPathGroup* RimWellPathCollection::findOrCreateWellPathGroup( gsl::not_nul
|
|||||||
|
|
||||||
if ( mostSimilarWellPathGroup )
|
if ( mostSimilarWellPathGroup )
|
||||||
{
|
{
|
||||||
|
detachWellPath( wellPath );
|
||||||
mostSimilarWellPathGroup->addChildWellPath( wellPath.get() );
|
mostSimilarWellPathGroup->addChildWellPath( wellPath.get() );
|
||||||
}
|
}
|
||||||
else if ( !wellPathsWithCommonGeometry.empty() )
|
else if ( !wellPathsWithCommonGeometry.empty() )
|
||||||
@ -838,10 +842,9 @@ RimWellPathGroup* RimWellPathCollection::findOrCreateWellPathGroup( gsl::not_nul
|
|||||||
|
|
||||||
for ( auto [existingWellPath, identicalTubeLength] : wellPathsWithCommonGeometry )
|
for ( auto [existingWellPath, identicalTubeLength] : wellPathsWithCommonGeometry )
|
||||||
{
|
{
|
||||||
removeWellPath( existingWellPath );
|
detachWellPath( existingWellPath );
|
||||||
group->addChildWellPath( existingWellPath );
|
group->addChildWellPath( existingWellPath );
|
||||||
}
|
}
|
||||||
group->addChildWellPath( wellPath );
|
|
||||||
|
|
||||||
mostSimilarWellPathGroup = group;
|
mostSimilarWellPathGroup = group;
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,7 @@ protected:
|
|||||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||||
|
|
||||||
std::vector<RimWellPath*> detachWellPaths( const std::vector<RimWellPath*> wellPathsToDetach );
|
std::vector<RimWellPath*> detachWellPaths( const std::vector<RimWellPath*> wellPathsToDetach );
|
||||||
|
bool detachWellPath( gsl::not_null<RimWellPath*> wellPath );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
@ -142,7 +143,8 @@ private:
|
|||||||
void sortWellsByName();
|
void sortWellsByName();
|
||||||
|
|
||||||
std::vector<RimWellPathGroup*> topLevelGroups() const;
|
std::vector<RimWellPathGroup*> topLevelGroups() const;
|
||||||
RimWellPathGroup* findOrCreateWellPathGroup( gsl::not_null<RimWellPath*> wellPath );
|
RimWellPathGroup* findOrCreateWellPathGroup( gsl::not_null<RimWellPath*> wellPath,
|
||||||
|
const std::vector<RimWellPath*>& wellPathsToGroupWith );
|
||||||
|
|
||||||
RiaEclipseUnitTools::UnitSystemType findUnitSystemForWellPath( const RimWellPath* wellPath );
|
RiaEclipseUnitTools::UnitSystemType findUnitSystemForWellPath( const RimWellPath* wellPath );
|
||||||
|
|
||||||
|
@ -99,6 +99,10 @@ bool RimWellPathGroup::hasChildWellPath( RimWellPath* wellPath )
|
|||||||
void RimWellPathGroup::removeChildWellPath( RimWellPath* wellPath )
|
void RimWellPathGroup::removeChildWellPath( RimWellPath* wellPath )
|
||||||
{
|
{
|
||||||
m_childWellPaths.removeChildObject( wellPath );
|
m_childWellPaths.removeChildObject( wellPath );
|
||||||
|
if ( auto geometry = wellPath->wellPathGeometry(); geometry )
|
||||||
|
{
|
||||||
|
geometry->setUniqueStartIndex( 0u );
|
||||||
|
}
|
||||||
createWellPathGeometry();
|
createWellPathGeometry();
|
||||||
updateWellPathName();
|
updateWellPathName();
|
||||||
}
|
}
|
||||||
@ -108,7 +112,11 @@ void RimWellPathGroup::removeChildWellPath( RimWellPath* wellPath )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimWellPathGroup::removeAllChildWellPaths()
|
void RimWellPathGroup::removeAllChildWellPaths()
|
||||||
{
|
{
|
||||||
m_childWellPaths.clear();
|
auto childWellPaths = m_childWellPaths.childObjects();
|
||||||
|
for ( auto wellPath : childWellPaths )
|
||||||
|
{
|
||||||
|
removeChildWellPath( wellPath );
|
||||||
|
}
|
||||||
setWellPathGeometry( cvf::ref<RigWellPath>( new RigWellPath ).p() );
|
setWellPathGeometry( cvf::ref<RigWellPath>( new RigWellPath ).p() );
|
||||||
updateWellPathName();
|
updateWellPathName();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user