Almost right

This commit is contained in:
Gaute Lindkvist
2020-10-20 13:01:46 +02:00
parent 362dcb4dd1
commit 19a8aece0e
31 changed files with 202 additions and 108 deletions

View File

@@ -711,7 +711,7 @@ QList<caf::PdmOptionItemInfo>
{
std::set<QString> sortedWellNames = this->findSortedWellNames();
caf::IconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.svg" );
for ( const QString& wname : sortedWellNames )
{
options.push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );

View File

@@ -511,7 +511,7 @@ QList<caf::PdmOptionItemInfo>
{
if ( m_case && m_case->eclipseCaseData() )
{
caf::IconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.svg" );
const std::set<QString> sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames();
for ( const QString& name : sortedWellNameSet )
{

View File

@@ -293,7 +293,7 @@ QList<caf::PdmOptionItemInfo>
{
if ( m_case && m_case->eclipseCaseData() )
{
caf::IconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.svg" );
const std::set<QString> sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames();
for ( const QString& name : sortedWellNameSet )
{

View File

@@ -40,7 +40,7 @@ CAF_PDM_SOURCE_INIT( RimAdvancedSnapshotExportDefinition, "MultiSnapshotDefiniti
//--------------------------------------------------------------------------------------------------
RimAdvancedSnapshotExportDefinition::RimAdvancedSnapshotExportDefinition()
{
// CAF_PDM_InitObject("MultiSnapshotDefinition", ":/Well.png", "", "");
// CAF_PDM_InitObject("MultiSnapshotDefinition", ":/Well.svg", "", "");
CAF_PDM_InitObject( "MultiSnapshotDefinition", "", "", "" );
CAF_PDM_InitField( &isActive, "IsActive", true, "Active", "", "", "" );

View File

@@ -348,7 +348,7 @@ QList<caf::PdmOptionItemInfo>
{
caf::PdmChildArrayField<RimSimWellInView*>& simWells = coll->wells;
caf::IconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.svg" );
for ( RimSimWellInView* eclWell : simWells )
{
options.push_back( caf::PdmOptionItemInfo( eclWell->name(), eclWell, false, simWellIcon ) );

View File

@@ -16,7 +16,7 @@ CAF_PDM_SOURCE_INIT( RimFileWellPath, "WellPath" );
RimFileWellPath::RimFileWellPath()
{
CAF_PDM_InitScriptableObjectWithNameAndComment( "File Well Path",
":/Well.png",
":/Well.svg",
"",
"",
"FileWellPath",

View File

@@ -65,7 +65,7 @@ CAF_PDM_SOURCE_INIT( RimSimWellInView, "Well" );
RimSimWellInView::RimSimWellInView()
{
CAF_PDM_InitScriptableObjectWithNameAndComment( "Simulation Well",
":/Well.png",
":/Well.svg",
"",
"",
"SimulationWell",

View File

@@ -242,7 +242,7 @@ void RimTools::wellPathOptionItems( QList<caf::PdmOptionItemInfo>* options )
auto wellPathColl = RimTools::wellPathCollection();
if ( wellPathColl )
{
caf::IconProvider wellIcon( ":/Well.png" );
caf::IconProvider wellIcon( ":/Well.svg" );
for ( auto wellPath : wellPathColl->allWellPaths() )
{
options->push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath, false, wellIcon ) );
@@ -261,7 +261,7 @@ void RimTools::wellPathWithFormationsOptionItems( QList<caf::PdmOptionItemInfo>*
std::vector<RimWellPath*> wellPaths;
RimTools::wellPathWithFormations( &wellPaths );
caf::IconProvider wellIcon( ":/Well.png" );
caf::IconProvider wellIcon( ":/Well.svg" );
for ( auto wellPath : wellPaths )
{
options->push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath, false, wellIcon ) );

View File

@@ -845,7 +845,7 @@ QList<caf::PdmOptionItemInfo>
{
std::set<QString> sortedWellNames = eclipseCase->sortedSimWellNames();
caf::IconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.svg" );
for ( const QString& wname : sortedWellNames )
{
options.push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );

View File

@@ -676,7 +676,7 @@ QList<caf::PdmOptionItemInfo>
{
std::set<QString> sortedWellNames = this->sortedSimWellNames();
caf::IconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.svg" );
for ( const QString& wname : sortedWellNames )
{
options.push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );

View File

@@ -605,7 +605,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions( const c
std::set<QString> wellNames = reader->wellNames();
for ( const QString& name : wellNames )
{
options.push_back( caf::PdmOptionItemInfo( name, name, false, caf::IconProvider( ":/Well.png" ) ) );
options.push_back( caf::PdmOptionItemInfo( name, name, false, caf::IconProvider( ":/Well.svg" ) ) );
}
}
}

View File

@@ -321,7 +321,7 @@ void RimWellLogTrack::simWellOptionItems( QList<caf::PdmOptionItemInfo>* options
sortedWellNames = eclipseCase->eclipseCaseData()->findSortedWellNames();
}
caf::IconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.svg" );
for ( const QString& wname : sortedWellNames )
{
options->push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );

View File

@@ -72,8 +72,9 @@ const char RimWellPath::SIM_WELL_NONE_UI_TEXT[] = "None";
///
//--------------------------------------------------------------------------------------------------
RimWellPath::RimWellPath()
: nameChanged( this )
{
CAF_PDM_InitScriptableObjectWithNameAndComment( "WellPath", ":/Well.png", "", "", "WellPath", "A ResInsight Well Path" );
CAF_PDM_InitScriptableObjectWithNameAndComment( "WellPath", ":/Well.svg", "", "", "WellPath", "A ResInsight Well Path" );
CAF_PDM_InitScriptableFieldNoDefault( &m_name, "Name", "Name", "", "", "" );
m_name.registerKeywordAlias( "WellPathName" );
@@ -471,6 +472,7 @@ void RimWellPath::setNameNoUpdateOfExportName( const QString& name )
{
m_name = name;
tryAssociateWithSimulationWell();
nameChanged.send();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -69,6 +69,9 @@ class RimWellPath : public caf::PdmObject, public RimWellPathComponentInterface
static const char SIM_WELL_NONE_UI_TEXT[];
public:
caf::Signal<> nameChanged;
public:
RimWellPath();
~RimWellPath() override;

View File

@@ -134,6 +134,51 @@ void RimWellPathCollection::fieldChangedByUi( const caf::PdmFieldHandle* changed
scheduleRedrawAffectedViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RimWellPathCollection::detachWellPaths( const std::vector<RimWellPath*> wellPathsToDetach )
{
std::set<RimWellPath*> regularWellPathsToDetach;
std::set<RimWellPathGroup*> wellPathGroupsToRemove;
for ( auto wellPath : wellPathsToDetach )
{
std::vector<RimWellPath*> descendants;
wellPath->descendantsIncludingThisOfType( descendants );
for ( auto descendant : descendants )
{
auto group = dynamic_cast<RimWellPathGroup*>( descendant );
if ( group )
{
wellPathGroupsToRemove.insert( group );
}
else
{
regularWellPathsToDetach.insert( descendant );
}
}
}
std::vector<RimWellPath*> detachedWellPaths;
for ( auto wellPath : regularWellPathsToDetach )
{
removeWellPath( wellPath );
detachedWellPaths.push_back( wellPath );
}
for ( auto group : wellPathGroupsToRemove )
{
removeWellPath( group );
}
for ( auto group : wellPathGroupsToRemove )
{
delete group;
}
return detachedWellPaths;
}
//--------------------------------------------------------------------------------------------------
/// Read files containing well path data, or create geometry based on the targets
//--------------------------------------------------------------------------------------------------
@@ -199,7 +244,6 @@ void RimWellPathCollection::loadDataAndUpdate()
{
group->createWellPathGeometry();
}
this->checkAndFixBranchNames();
this->sortWellsByName();
}
@@ -277,13 +321,13 @@ std::vector<RimWellPath*>
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::addWellPath( gsl::not_null<RimWellPath*> wellPath, bool importGrouped )
{
RimWellPathGroup* wellPathGroup = nullptr;
RimWellPathGroup* parentWellPathGroup = nullptr;
if ( importGrouped )
{
wellPathGroup = findOrCreateWellPathGroup( wellPath );
parentWellPathGroup = findOrCreateWellPathGroup( wellPath );
}
if ( !wellPathGroup )
if ( !parentWellPathGroup )
{
m_wellPaths.push_back( wellPath );
}
@@ -346,24 +390,9 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>&
progress.incrementProgress();
}
wellPathArray.clear(); // This should not be used again. We may have deleted items
this->checkAndFixBranchNames();
this->sortWellsByName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::checkAndFixBranchNames()
{
for ( auto wellPath : m_wellPaths )
{
if ( auto group = dynamic_cast<RimWellPathGroup*>( wellPath.p() ); group )
{
group->fixBranchNames();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -373,7 +402,6 @@ void RimWellPathCollection::addWellPaths( const std::vector<RimWellPath*> incomi
{
addWellPath( wellPath, importGrouped );
}
this->checkAndFixBranchNames();
this->sortWellsByName();
updateAllRequiredEditors();
@@ -410,7 +438,6 @@ std::vector<RimWellLogFile*> RimWellPathCollection::addWellLogs( const QStringLi
}
}
this->checkAndFixBranchNames();
this->sortWellsByName();
updateAllRequiredEditors();
@@ -463,7 +490,6 @@ void RimWellPathCollection::addWellPathFormations( const QStringList& filePaths
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "Well Picks Import", outputMessage );
}
this->checkAndFixBranchNames();
this->sortWellsByName();
updateAllRequiredEditors();
}
@@ -600,17 +626,30 @@ void RimWellPathCollection::deleteAllWellPaths()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::groupWellPaths( const std::vector<RimWellPath*> wellPaths )
void RimWellPathCollection::groupWellPaths( const std::vector<RimWellPath*>& wellPaths )
{
// TODO: implement
auto detachedWellPaths = detachWellPaths( wellPaths );
for ( auto wellPath : detachedWellPaths )
{
addWellPath( wellPath, true );
}
this->sortWellsByName();
this->updateAllRequiredEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::ungroupWellPaths( const std::vector<RimWellPath*> wellPaths )
void RimWellPathCollection::ungroupWellPaths( const std::vector<RimWellPath*>& wellPaths )
{
// TODO: implement
auto detachedWellPaths = detachWellPaths( wellPaths );
for ( auto wellPath : detachedWellPaths )
{
addWellPath( wellPath, false );
}
this->sortWellsByName();
this->updateAllRequiredEditors();
}
//--------------------------------------------------------------------------------------------------
@@ -664,8 +703,13 @@ void RimWellPathCollection::reloadAllWellPathFormations()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::removeWellPath( RimWellPath* wellPath )
void RimWellPathCollection::removeWellPath( gsl::not_null<RimWellPath*> wellPath )
{
if ( auto group = dynamic_cast<RimWellPathGroup*>( wellPath.get() ); group )
{
group->removeAllChildWellPaths();
}
bool removed = false;
if ( m_wellPaths.count( wellPath ) != 0u )
{
@@ -687,10 +731,9 @@ void RimWellPathCollection::removeWellPath( RimWellPath* wellPath )
}
}
}
CAF_ASSERT( removed );
if ( !removed ) return;
RimFileWellPath* fileWellPath = dynamic_cast<RimFileWellPath*>( wellPath );
RimFileWellPath* fileWellPath = dynamic_cast<RimFileWellPath*>( wellPath.get() );
if ( fileWellPath )
{
bool isFilePathUsed = false;

View File

@@ -96,10 +96,11 @@ public:
std::vector<RimWellPath*> addWellPaths( QStringList filePaths, bool importGrouped, QStringList* errorMessages );
std::vector<RimWellPath*> topLevelWellPaths() const;
std::vector<RimWellPath*> allWellPaths() const;
void removeWellPath( RimWellPath* wellPath );
void deleteAllWellPaths();
void groupWellPaths( const std::vector<RimWellPath*> wellPaths );
void ungroupWellPaths( const std::vector<RimWellPath*> wellPaths );
void removeWellPath( gsl::not_null<RimWellPath*> wellPath );
void deleteAllWellPaths();
void groupWellPaths( const std::vector<RimWellPath*>& wellPaths );
void ungroupWellPaths( const std::vector<RimWellPath*>& wellPaths );
RimWellPath* mostRecentlyUpdatedWellPath();
@@ -129,13 +130,14 @@ public:
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
std::vector<RimWellPath*> detachWellPaths( const std::vector<RimWellPath*> wellPathsToDetach );
private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
caf::PdmFieldHandle* objectToggleField() override;
void checkAndFixBranchNames();
void readAndAddWellPaths( std::vector<RimFileWellPath*>& wellPathArray, bool importGrouped );
void sortWellsByName();

View File

@@ -22,6 +22,8 @@
#include "RiaTextStringTools.h"
#include "RigWellPath.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiTreeOrdering.h"
#include <QStringList>
@@ -32,9 +34,15 @@ CAF_PDM_SOURCE_INIT( RimWellPathGroup, "WellPathGroup" );
///
//--------------------------------------------------------------------------------------------------
RimWellPathGroup::RimWellPathGroup()
: wellPathAddedOrRemoved( this )
{
CAF_PDM_InitScriptableObjectWithNameAndComment( "Well Path Group", ":/Well.png", "", "", "WellPathGroup", "A Group of Well Paths" );
CAF_PDM_InitFieldNoDefault( &m_childWellPaths, "ChildWellPaths", "Child Well Paths", "", "", "" );
CAF_PDM_InitScriptableObjectWithNameAndComment( "Well Path Group",
":/WellPathGroup.svg",
"",
"",
"WellPathGroup",
"A Group of Well Paths" );
CAF_PDM_InitScriptableFieldNoDefault( &m_childWellPaths, "ChildWellPaths", "Child Well Paths", "", "", "" );
setWellPathGeometry( new RigWellPath );
}
@@ -56,6 +64,8 @@ void RimWellPathGroup::addChildWellPath( RimWellPath* wellPath )
setWellPathGeometry( geometryCopy.p() );
m_childWellPaths.push_back( wellPath );
}
wellPath->nameChanged.connect( this, &RimWellPathGroup::onChildNameChanged );
updateWellPathName();
}
@@ -115,6 +125,8 @@ void RimWellPathGroup::createWellPathGeometry()
group->createWellPathGeometry();
}
}
if ( wellPathGeometries().empty() ) return;
auto commonGeometry = RigWellPath::commonGeometry( wellPathGeometries() );
for ( auto wellPath : m_childWellPaths )
{
@@ -126,33 +138,6 @@ void RimWellPathGroup::createWellPathGeometry()
setWellPathGeometry( commonGeometry.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGroup::fixBranchNames()
{
const auto& measuredDepths = this->wellPathGeometry()->measuredDepths();
int index = 1;
for ( auto wellPath : m_childWellPaths )
{
auto group = dynamic_cast<RimWellPathGroup*>( wellPath.p() );
if ( group )
{
group->fixBranchNames();
if ( group->name() == this->name() )
{
QString groupName = QString( "%1 branch #%2" ).arg( this->name() ).arg( index++ );
if ( !measuredDepths.empty() )
{
groupName += QString( " at md=%1" ).arg( measuredDepths.back() );
}
group->setName( groupName );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -195,15 +180,41 @@ void RimWellPathGroup::updateWellPathName()
//--------------------------------------------------------------------------------------------------
QString RimWellPathGroup::createWellPathName() const
{
QStringList allNames;
for ( auto wellPath : m_childWellPaths )
QStringList allNames;
std::vector<RimWellPath*> descendantWellPaths;
this->descendantsOfType( descendantWellPaths );
for ( auto wellPath : descendantWellPaths )
{
allNames.push_back( wellPath->name() );
if ( !dynamic_cast<RimWellPathGroup*>( wellPath ) )
{
allNames.push_back( wellPath->name() );
}
}
QString commonName = RiaTextStringTools::commonRoot( allNames );
QString trimmedCommonName = RiaTextStringTools::trimNonAlphaNumericCharacters( commonName );
return trimmedCommonName;
QString commonName = RiaTextStringTools::commonRoot( allNames );
QString trimmedCommonName = RiaTextStringTools::trimNonAlphaNumericCharacters( commonName );
QStringList branchNames;
for ( auto& name : allNames )
{
name.remove( commonName );
name = RiaTextStringTools::trimNonAlphaNumericCharacters( name );
name = name.simplified();
if ( !name.isEmpty() ) branchNames.push_back( name );
}
QString fullName = trimmedCommonName;
if ( !branchNames.isEmpty() )
{
fullName += QString( "(%1)" ).arg( branchNames.join( ", " ) );
}
return fullName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGroup::onChildNameChanged( const caf::SignalEmitter* emitter )
{
updateWellPathName();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -24,6 +24,7 @@
class RimWellPathGroup : public RimWellPath
{
CAF_PDM_HEADER_INIT;
caf::Signal<> wellPathAddedOrRemoved;
public:
RimWellPathGroup();
@@ -37,7 +38,6 @@ public:
void createWellPathGeometry();
void updateWellPathName();
void fixBranchNames();
void makeMoreLevelsIfNecessary();
protected:
@@ -47,6 +47,8 @@ private:
std::vector<const RigWellPath*> wellPathGeometries() const;
QString createWellPathName() const;
void onChildNameChanged( const caf::SignalEmitter* emitter );
private:
caf::PdmChildArrayField<RimWellPath*> m_childWellPaths;
};
};