Add automatic well path grouping

This commit is contained in:
Gaute Lindkvist
2020-10-22 08:19:00 +02:00
parent 9401a81097
commit 0fc5e033f5
7 changed files with 216 additions and 12 deletions

View File

@@ -1164,6 +1164,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicToggleWellPathGroupingFeature";
}
if ( caf::CmdFeatureManager::instance()->getCommandFeature( "RicAutomaticWellPathGroupingFeature" )->canFeatureBeExecuted() )
{
menuBuilder << "Separator";
menuBuilder << "RicAutomaticWellPathGroupingFeature";
}
if ( caf::CmdFeatureManager::instance()->getCommandFeature( "RicDeleteItemFeature" )->canFeatureBeExecuted() )
{
menuBuilder << "Separator";

View File

@@ -409,11 +409,13 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>&
{
wellPath->setWellPathColor( RiaColorTables::wellPathsPaletteColors().cycledColor3f( m_wellPaths.size() ) );
wellPath->setUnitSystem( findUnitSystemForWellPath( wellPath ) );
addWellPath( wellPath, importGrouped );
addWellPath( wellPath, false );
}
progress.incrementProgress();
}
groupWellPaths( allWellPaths(), true );
wellPathArray.clear(); // This should not be used again. We may have deleted items
this->sortWellsByName();
}
@@ -651,18 +653,39 @@ void RimWellPathCollection::deleteAllWellPaths()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::groupWellPaths( const std::vector<RimWellPath*>& wellPaths )
void RimWellPathCollection::groupWellPaths( const std::vector<RimWellPath*>& wellPaths, bool allowAddingToExistingGroups )
{
auto detachedWellPaths = detachWellPaths( wellPaths );
std::vector<RimWellPath*> allWellPathsToGroupWith = detachedWellPaths;
auto detachedWellPaths = detachWellPaths( wellPaths );
if ( allowAddingToExistingGroups )
{
for ( auto wellPath : allWellPaths() )
{
if ( dynamic_cast<RimWellPathGroup*>( wellPath ) )
{
auto existingGroupPaths = detachWellPaths( {wellPath} );
detachedWellPaths.insert( detachedWellPaths.end(), existingGroupPaths.begin(), existingGroupPaths.end() );
}
}
}
auto wellPathsToGroupWith = detachedWellPaths;
for ( auto wellPath : detachedWellPaths )
{
auto parentGroup = findOrCreateWellPathGroup( wellPath, allWellPathsToGroupWith );
if ( parentGroup && std::find( allWellPathsToGroupWith.begin(), allWellPathsToGroupWith.end(), parentGroup ) ==
allWellPathsToGroupWith.end() )
auto parentGroup = findOrCreateWellPathGroup( wellPath, wellPathsToGroupWith );
if ( parentGroup )
{
allWellPathsToGroupWith.push_back( parentGroup );
auto groupIsNew = std::find( wellPathsToGroupWith.begin(), wellPathsToGroupWith.end(), parentGroup ) ==
wellPathsToGroupWith.end();
if ( groupIsNew )
{
wellPathsToGroupWith.push_back( parentGroup );
}
}
else
{
m_wellPaths.push_back( wellPath );
}
}
this->sortWellsByName();
@@ -737,7 +760,7 @@ void RimWellPathCollection::reloadAllWellPathFormations()
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::removeWellPath( gsl::not_null<RimWellPath*> wellPath )
{
bool removed = detachWellPath( wellPath );
detachWellPath( wellPath );
RimFileWellPath* fileWellPath = dynamic_cast<RimFileWellPath*>( wellPath.get() );
if ( fileWellPath )
@@ -843,7 +866,7 @@ RimWellPathGroup* RimWellPathCollection::findOrCreateWellPathGroup( gsl::not_nul
detachWellPath( wellPath );
mostSimilarWellPathGroup->addChildWellPath( wellPath.get() );
}
else if ( !wellPathsWithCommonGeometry.empty() )
else if ( wellPathsWithCommonGeometry.size() > 1u )
{
RimWellPathGroup* group = new RimWellPathGroup;
m_wellPaths.push_back( group );

View File

@@ -99,7 +99,7 @@ public:
void removeWellPath( gsl::not_null<RimWellPath*> wellPath );
void deleteAllWellPaths();
void groupWellPaths( const std::vector<RimWellPath*>& wellPaths );
void groupWellPaths( const std::vector<RimWellPath*>& wellPaths, bool allowAddingToExistingGroups = false );
void ungroupWellPaths( const std::vector<RimWellPath*>& wellPaths );
RimWellPath* mostRecentlyUpdatedWellPath();