Create a separate menu entry for importing "Grouped Well Paths"

This commit is contained in:
Gaute Lindkvist
2020-10-19 13:16:00 +02:00
parent 7650d0bde8
commit 395398587a
15 changed files with 150 additions and 23 deletions

View File

@@ -889,6 +889,7 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
/// Add a list of well path file paths (JSON files) to the well path collection
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RiaApplication::addWellPathsToModel( QList<QString> wellPathFilePaths,
bool importGrouped,
gsl::not_null<QStringList*> errorMessages )
{
if ( m_project == nullptr || m_project->oilFields.size() < 1 ) return {};
@@ -907,7 +908,7 @@ std::vector<RimWellPath*> RiaApplication::addWellPathsToModel( QList<QString>
std::vector<RimWellPath*> wellPaths;
if ( oilField->wellPathCollection )
{
wellPaths = oilField->wellPathCollection->addWellPaths( wellPathFilePaths, errorMessages );
wellPaths = oilField->wellPathCollection->addWellPaths( wellPathFilePaths, importGrouped, errorMessages );
}
oilField->wellPathCollection->updateConnectedEditors();

View File

@@ -147,6 +147,7 @@ public:
bool openOdbCaseFromFile( const QString& fileName, bool applyTimeStepFilter = false );
std::vector<RimWellPath*> addWellPathsToModel( QList<QString> wellPathFilePaths,
bool importGrouped,
gsl::not_null<QStringList*> errorMessages );
void addWellPathFormationsToModel( QList<QString> wellPathFilePaths );
std::vector<RimWellLogFile*> addWellLogsToModel( const QList<QString>& wellLogFilePaths,

View File

@@ -75,7 +75,7 @@ RimFractureModel* RicNewFractureModelFeature::addFractureModel( RimWellPath*
fractureModel->setThicknessDirectionWellPath( thicknessDirectionWellPath );
std::vector<RimWellPath*> wellPaths = {thicknessDirectionWellPath};
wellPathCollection->addWellPaths( wellPaths );
wellPathCollection->addWellPaths( wellPaths, false );
if ( project )
{

View File

@@ -118,7 +118,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked )
if ( wellPaths.size() > 0 )
{
QStringList errorMessages;
app->addWellPathsToModel( wellPaths, &errorMessages );
app->addWellPathsToModel( wellPaths, false, &errorMessages );
app->project()->scheduleCreateDisplayModelAndRedrawAllViews();
}

View File

@@ -1,6 +1,7 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportWellPaths.h
${CMAKE_CURRENT_LIST_DIR}/RicImportGroupedWellPaths.h
${CMAKE_CURRENT_LIST_DIR}/RicNewEditableWellPathFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicShowWellPlanFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.h
@@ -28,6 +29,7 @@ ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportWellPaths.cpp
${CMAKE_CURRENT_LIST_DIR}/RicImportGroupedWellPaths.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewEditableWellPathFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicShowWellPlanFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.cpp

View File

@@ -0,0 +1,69 @@
#include "RicImportGroupedWellPaths.h"
#include "RiaApplication.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RimFileWellPath.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "Riu3DMainWindowTools.h"
#include "RiuFileDialogTools.h"
#include "cafPdmFieldScriptingCapability.h"
#include <QAction>
#include <QDir>
RICF_SOURCE_INIT( RicImportGroupedWellPaths, "RicImportGroupedWellPathsFeature", "importGroupedWellPaths" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicImportGroupedWellPaths::RicImportGroupedWellPaths()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportGroupedWellPaths::onActionTriggered( bool isChecked )
{
// Open dialog box to select well path files
RiaApplication* app = RiaApplication::instance();
QString lastUsedGridFolder = app->lastUsedDialogDirectory( "BINARY_GRID" );
QString defaultDir = app->lastUsedDialogDirectoryWithFallback( "WELLPATH_DIR", lastUsedGridFolder );
QString nameList = QString( "Well Paths (%1);;All Files (*.*)" ).arg( wellPathNameFilters().join( " " ) );
QStringList wellPathFilePaths = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
"Import Well Paths",
defaultDir,
nameList );
if ( wellPathFilePaths.size() >= 1 )
{
m_importGrouped = true;
m_wellPathFiles.v() = std::vector<QString>( wellPathFilePaths.begin(), wellPathFilePaths.end() );
caf::PdmScriptResponse response = execute();
QStringList messages = response.messages();
if ( !messages.empty() )
{
QString displayMessage = QString( "Problem loading well path files:\n%2" ).arg( messages.join( "\n" ) );
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "Well Path Loading", displayMessage );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportGroupedWellPaths::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Import &Grouped Well Paths from File" );
actionToSetup->setIcon( QIcon( ":/Well.png" ) );
}

View File

@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor ASA
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicImportWellPaths.h"
class RimWellPath;
//==================================================================================================
///
//==================================================================================================
class RicImportGroupedWellPaths : public RicImportWellPaths
{
RICF_HEADER_INIT;
public:
RicImportGroupedWellPaths();
protected:
// Overrides
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -66,6 +66,7 @@ RicImportWellPaths::RicImportWellPaths()
{
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPathFolder, "wellPathFolder", "", "", "", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPathFiles, "wellPathFiles", "", "", "", "" );
CAF_PDM_InitScriptableField( &m_importGrouped, "importGrouped", false, "", "", "", "" );
}
caf::PdmScriptResponse RicImportWellPaths::execute()
@@ -120,7 +121,7 @@ caf::PdmScriptResponse RicImportWellPaths::execute()
caf::PdmScriptResponse response;
if ( !wellPathFiles.empty() )
{
std::vector<RimWellPath*> importedWellPaths = importWellPaths( wellPathFiles, &warningMessages );
std::vector<RimWellPath*> importedWellPaths = importWellPaths( wellPathFiles, m_importGrouped(), &warningMessages );
if ( !importedWellPaths.empty() )
{
RicImportWellPathsResult* wellPathsResult = new RicImportWellPathsResult;
@@ -154,6 +155,7 @@ caf::PdmScriptResponse RicImportWellPaths::execute()
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RicImportWellPaths::importWellPaths( const QStringList& wellPathFilePaths,
bool importGrouped,
QStringList* errorMessages )
{
RiaApplication* app = RiaApplication::instance();
@@ -161,7 +163,7 @@ std::vector<RimWellPath*> RicImportWellPaths::importWellPaths( const QStringList
// Remember the path to next time
app->setLastUsedDialogDirectory( "WELLPATH_DIR", QFileInfo( wellPathFilePaths.last() ).absolutePath() );
std::vector<RimWellPath*> wellPaths = app->addWellPathsToModel( wellPathFilePaths, errorMessages );
std::vector<RimWellPath*> wellPaths = app->addWellPathsToModel( wellPathFilePaths, importGrouped, errorMessages );
RimProject* project = app->project();

View File

@@ -43,15 +43,17 @@ public:
caf::PdmScriptResponse execute() override;
protected:
static std::vector<RimWellPath*> importWellPaths( const QStringList& wellPathFilePaths, QStringList* errorMessages );
static QStringList wellPathNameFilters();
static std::vector<RimWellPath*>
importWellPaths( const QStringList& wellPathFilePaths, bool importGrouped, QStringList* errorMessages );
static QStringList wellPathNameFilters();
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
protected:
caf::PdmField<QString> m_wellPathFolder;
caf::PdmField<std::vector<QString>> m_wellPathFiles;
caf::PdmField<bool> m_importGrouped;
};

View File

@@ -81,7 +81,7 @@ void RicNewEditableWellPathFeature::onActionTriggered( bool isChecked )
newModeledWellPath->setWellPathColor(
RiaColorTables::editableWellPathsPaletteColors().cycledColor3f( modelledWellpathCount ) );
wellPathCollection->addWellPaths( newWellPaths );
wellPathCollection->addWellPaths( newWellPaths, false );
wellPathCollection->uiCapability()->updateConnectedEditors();
newModeledWellPath->geometryDefinition()->enableTargetPointPicking( true );

View File

@@ -335,6 +335,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.addSeparator();
menuBuilder.subMenuStart( "Import" );
menuBuilder << "RicWellPathsImportFileFeature";
menuBuilder << "RicImportGroupedWellPathsFeature";
menuBuilder << "RicWellPathsImportSsihubFeature";
menuBuilder << "RicWellPathFormationsImportFileFeature";
menuBuilder << "RicWellLogsImportFileFeature";
@@ -458,6 +459,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
else if ( dynamic_cast<RimWellLogFile*>( firstUiItem ) )
{
menuBuilder << "RicWellPathsImportFileFeature";
menuBuilder << "RicImportGroupedWellPathsFeature";
menuBuilder << "RicWellLogsImportFileFeature";
menuBuilder << "Separator";
@@ -1278,6 +1280,7 @@ int RimContextCommandBuilder::appendImportMenu( caf::CmdFeatureMenuBuilder& menu
{
QStringList candidates;
candidates << "RicWellPathsImportFileFeature";
candidates << "RicImportGroupedWellPathsFeature";
candidates << "RicWellPathFormationsImportFileFeature";
candidates << "RicWellLogsImportFileFeature";
candidates << "RicReloadWellPathFormationNamesFeature";

View File

@@ -196,7 +196,8 @@ void RimWellPathCollection::loadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RimWellPathCollection::addWellPaths( QStringList filePaths, QStringList* errorMessages )
std::vector<RimWellPath*>
RimWellPathCollection::addWellPaths( QStringList filePaths, bool importGrouped, QStringList* errorMessages )
{
CAF_ASSERT( errorMessages );
@@ -252,7 +253,7 @@ std::vector<RimWellPath*> RimWellPathCollection::addWellPaths( QStringList fileP
}
}
readAndAddWellPaths( wellPathArray );
readAndAddWellPaths( wellPathArray, importGrouped );
CAF_ASSERT( wellPathArray.empty() );
scheduleRedrawAffectedViews();
@@ -264,9 +265,14 @@ std::vector<RimWellPath*> RimWellPathCollection::addWellPaths( QStringList fileP
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::addWellPath( gsl::not_null<RimWellPath*> wellPath )
void RimWellPathCollection::addWellPath( gsl::not_null<RimWellPath*> wellPath, bool importGrouped )
{
auto mainWellPath = findSuitableParentWellPath( wellPath );
RimWellPath* mainWellPath = nullptr;
if ( importGrouped )
{
mainWellPath = findSuitableParentWellPath( wellPath );
}
if ( mainWellPath )
{
mainWellPath->addChildWellPath( wellPath );
@@ -300,7 +306,7 @@ std::vector<RimWellPath*> RimWellPathCollection::allWellPaths() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>& wellPathArray )
void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>& wellPathArray, bool importGrouped )
{
caf::ProgressInfo progress( wellPathArray.size(), "Reading well paths from file" );
@@ -329,7 +335,7 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>&
{
wellPath->setWellPathColor( RiaColorTables::wellPathsPaletteColors().cycledColor3f( m_wellPaths.size() ) );
wellPath->setUnitSystem( findUnitSystemForWellPath( wellPath ) );
addWellPath( wellPath );
addWellPath( wellPath, importGrouped );
}
progress.incrementProgress();
@@ -341,11 +347,11 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::addWellPaths( const std::vector<RimWellPath*> incomingWellPaths )
void RimWellPathCollection::addWellPaths( const std::vector<RimWellPath*> incomingWellPaths, bool importGrouped )
{
for ( const auto& wellPath : incomingWellPaths )
{
addWellPath( wellPath );
addWellPath( wellPath, importGrouped );
}
this->sortWellsByName();
@@ -375,7 +381,7 @@ std::vector<RimWellLogFile*> RimWellPathCollection::addWellLogs( const QStringLi
if ( !wellPath )
{
wellPath = new RimWellPath();
addWellPath( wellPath );
addWellPath( wellPath, false );
}
wellPath->addWellLogFile( logFileInfo );
@@ -414,7 +420,7 @@ void RimWellPathCollection::addWellPathFormations( const QStringList& filePaths
{
wellPath = new RimWellPath();
wellPath->setName( it->first );
addWellPath( wellPath );
addWellPath( wellPath, false );
RiaLogging::info( QString( "Created new well: %1" ).arg( wellPath->name() ) );
}
wellPath->setFormationsGeometry( it->second );

View File

@@ -92,7 +92,7 @@ public:
caf::PdmField<int> wellPathClipZDistance;
void loadDataAndUpdate();
std::vector<RimWellPath*> addWellPaths( QStringList filePaths, QStringList* errorMessages );
std::vector<RimWellPath*> addWellPaths( QStringList filePaths, bool importGrouped, QStringList* errorMessages );
std::vector<RimWellPath*> topLevelWellPaths() const;
std::vector<RimWellPath*> allWellPaths() const;
void removeWellPath( RimWellPath* wellPath );
@@ -105,8 +105,8 @@ public:
RimWellPath* wellPathByName( const QString& wellPathName ) const;
RimWellPath* tryFindMatchingWellPath( const QString& wellName ) const;
void addWellPaths( const std::vector<RimWellPath*> incomingWellPaths );
void addWellPath( gsl::not_null<RimWellPath*> wellPath );
void addWellPaths( const std::vector<RimWellPath*> incomingWellPaths, bool importGrouped );
void addWellPath( gsl::not_null<RimWellPath*> wellPath, bool importGrouped );
std::vector<RimWellLogFile*> addWellLogs( const QStringList& filePaths, QStringList* errorMessages );
void addWellPathFormations( const QStringList& filePaths );
@@ -132,7 +132,7 @@ private:
caf::PdmFieldHandle* objectToggleField() override;
void readAndAddWellPaths( std::vector<RimFileWellPath*>& wellPathArray );
void readAndAddWellPaths( std::vector<RimFileWellPath*>& wellPathArray, bool importGrouped );
void sortWellsByName();
void createWellPathBranchFromExistingWellPath( RimWellPath* wellPath );

View File

@@ -453,6 +453,7 @@ void RiuMainWindow::createMenus()
importMenu->addSeparator();
QMenu* importWellMenu = importMenu->addMenu( QIcon( ":/Well.png" ), "Well Data" );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportFileFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicImportGroupedWellPathsFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportSsihubFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellLogsImportFileFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathFormationsImportFileFeature" ) );

View File

@@ -267,6 +267,7 @@ void RiuPlotMainWindow::createMenus()
importMenu->addSeparator();
QMenu* importWellMenu = importMenu->addMenu( QIcon( ":/Well.png" ), "Well Data" );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportFileFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportFileFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportSsihubFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellLogsImportFileFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathFormationsImportFileFeature" ) );