diff --git a/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake index 405d7430a9..0aadafdc3e 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake @@ -11,7 +11,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCasesFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicImportInputEclipseCaseFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsCaseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicApplyPropertyFilterAsCellResultFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseTimeStepFilterFeature.cpp @@ -19,7 +19,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicEclipseHideFaultFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicEclipseShowOnlyFaultFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicRenameCaseFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseEnsemblesFromFilesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAddLinkedEclipsePropertyFilterFeature.cpp diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp index bf44072d1f..5e521cbe02 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp @@ -38,9 +38,9 @@ void RicImportEclipseCaseTimeStepFilterFeature::onActionTriggered( bool isChecke QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); QString fileName = RiuFileDialogTools::getOpenFileName( Riu3DMainWindowTools::mainWindowWidget(), - "Import Eclipse File", + "Import Grid Model", defaultDir, - "Eclipse Grid Files (*.GRID *.EGRID)" ); + "Binary Grid Models (*.GRID *.EGRID)" ); if ( !fileName.isEmpty() ) { defaultDir = QFileInfo( fileName ).absolutePath(); @@ -59,5 +59,5 @@ void RicImportEclipseCaseTimeStepFilterFeature::onActionTriggered( bool isChecke void RicImportEclipseCaseTimeStepFilterFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/Case48x48.png" ) ); - actionToSetup->setText( "Import Eclipse Case (Time Step Filtered)" ); + actionToSetup->setText( "Import Grid Model (Time Step Filtered)" ); } diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp index 5ad80a4879..f1c691167d 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -45,7 +45,7 @@ void RicImportEclipseCasesFeature::onActionTriggered( bool isChecked ) RicRecursiveFileSearchDialogResult result = RicRecursiveFileSearchDialog::runRecursiveSearchDialog( RiaGuiApplication::widgetToUseAsParent(), - "Import Eclipse Cases", + "Import Grid Models", defaultDir, m_pathFilter, m_fileNameFilter, @@ -78,5 +78,5 @@ void RicImportEclipseCasesFeature::onActionTriggered( bool isChecked ) void RicImportEclipseCasesFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/Cases16x16.png" ) ); - actionToSetup->setText( "Import Eclipse Cases Recursively" ); + actionToSetup->setText( "Import Grid Models Recursively" ); } diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportGridModelFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicImportGridModelFeature.cpp new file mode 100644 index 0000000000..0ff84c5b69 --- /dev/null +++ b/ApplicationLibCode/Commands/EclipseCommands/RicImportGridModelFeature.cpp @@ -0,0 +1,110 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportGridModelFeature.h" + +#include "RiaApplication.h" +#include "RiaDefines.h" +#include "RiaGuiApplication.h" +#include "RiaLogging.h" + +#include "RicImportEclipseCaseFeature.h" +#include "RicImportGeneralDataFeature.h" + +#include "RimEclipseView.h" +#include "RimProject.h" + +#include "RiuFileDialogTools.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicImportGridModelFeature, "RicImportGridModelFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportGridModelFeature::onActionTriggered( bool isChecked ) +{ + RiaApplication* app = RiaApplication::instance(); + + const QString binaryGridPattern = "*.GRID *.EGRID"; + const QString textGridPattern = "*.GRDECL"; + const QString roffPattern = "*.ROFF *.ROFFASC"; + const QString allGridsPattern = QString( "%1 %2 %3" ).arg( binaryGridPattern, textGridPattern, roffPattern ); + + const QString binaryGridFilter = QString( "Binary Grid Models (%1)" ).arg( binaryGridPattern ); + + const QStringList filterGroups = { QString( "Grid Models (%1)" ).arg( allGridsPattern ), + binaryGridFilter, + QString( "Text Grid Models (%1)" ).arg( textGridPattern ), + QString( "Roff Grid Models (%1)" ).arg( roffPattern ) }; + + const QString defaultDirLabel = RiaDefines::defaultDirectoryLabel( RiaDefines::ImportFileType::ANY_ECLIPSE_FILE ); + const QString defaultDir = app->lastUsedDialogDirectory( defaultDirLabel ); + + // Default to the binary grid filter (GRID/EGRID) when the dialog opens. + QString selectedFilter = binaryGridFilter; + + // Use nullptr as parent: this command can be invoked from both the 3D main window and the plot window. + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( RiaGuiApplication::widgetToUseAsParent(), + "Import Grid Models", + defaultDir, + filterGroups.join( ";;" ), + &selectedFilter ); + + if ( fileNames.isEmpty() ) return; + + app->setLastUsedDialogDirectory( defaultDirLabel, QFileInfo( fileNames.last() ).absolutePath() ); + + // Track existing views so newly imported PVD surfaces can be enabled only in new views. + RimProject* project = RimProject::current(); + const std::vector allViewsBefore = RicImportEclipseCaseFeature::allEclipseViews( project ); + + constexpr bool doCreateDefaultPlot = true; + constexpr bool createDefaultView = true; + const auto results = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( fileNames, doCreateDefaultPlot, createDefaultView ); + + if ( !results ) + { + RiaLogging::error( std::format( "Failed to open grid model files: {}", fileNames.join( ", " ).toStdString() ) ); + return; + } + + // openEclipseFilesFromFileNames already adds GRDECL/ROFF/summary files to recent files; + // the binary Eclipse grid path does not, so add those here. + for ( const QString& f : results.eclipseCaseFiles ) + { + app->addToRecentFiles( f ); + } + + // Auto-import matching PVD surface files for any imported binary grid files. + if ( !results.eclipseCaseFiles.isEmpty() ) + { + RicImportEclipseCaseFeature::importPvdSurfacesForGridFiles( results.eclipseCaseFiles, allViewsBefore ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportGridModelFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/Case.svg" ) ); + actionToSetup->setText( "Import Grid Models" ); +} diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicImportGridModelFeature.h similarity index 72% rename from ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.h rename to ApplicationLibCode/Commands/EclipseCommands/RicImportGridModelFeature.h index 6bdfe6aebd..348fa84a72 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicImportGridModelFeature.h @@ -1,7 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2015- Statoil ASA -// Copyright (C) 2015- Ceetron Solutions AS +// Copyright (C) 2026- 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 @@ -19,12 +18,15 @@ #pragma once -#include "RicImportGeneralDataFeature.h" +#include "cafCmdFeature.h" //================================================================================================== -/// +/// Umbrella feature for importing grid models of any supported type +/// (binary GRID/EGRID, text GRDECL, Roff). Presents a single file dialog with +/// filter groups for each format plus a combined group, and routes the selected +/// files to the matching importer based on extension. //================================================================================================== -class RicImportInputEclipseCaseFeature : public RicImportGeneralDataFeature +class RicImportGridModelFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp deleted file mode 100644 index f041490ca3..0000000000 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp +++ /dev/null @@ -1,41 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RicImportInputEclipseCaseFeature.h" - -#include - -CAF_CMD_SOURCE_INIT( RicImportInputEclipseCaseFeature, "RicImportInputEclipseCaseFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicImportInputEclipseCaseFeature::onActionTriggered( bool isChecked ) -{ - RicImportGeneralDataFeature::openFileDialog( RiaDefines::ImportFileType::ECLIPSE_INPUT_FILE ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicImportInputEclipseCaseFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setIcon( QIcon( ":/EclipseInput48x48.png" ) ); - actionToSetup->setText( "Import Input Eclipse Case" ); -} diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportRoffCaseFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicImportRoffCaseFeature.cpp deleted file mode 100644 index eb6593419b..0000000000 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportRoffCaseFeature.cpp +++ /dev/null @@ -1,40 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2022- 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RicImportRoffCaseFeature.h" - -#include - -CAF_CMD_SOURCE_INIT( RicImportRoffCaseFeature, "RicImportRoffCaseFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicImportRoffCaseFeature::onActionTriggered( bool isChecked ) -{ - RicImportGeneralDataFeature::openFileDialog( RiaDefines::ImportFileType::ROFF_FILE ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicImportRoffCaseFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setIcon( QIcon( ":/EclipseInput48x48.png" ) ); - actionToSetup->setText( "Import Roff Case" ); -} diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportRoffCaseFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicImportRoffCaseFeature.h deleted file mode 100644 index 304c4fd546..0000000000 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportRoffCaseFeature.h +++ /dev/null @@ -1,33 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2022- 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "RicImportGeneralDataFeature.h" - -//================================================================================================== -/// -//================================================================================================== -class RicImportRoffCaseFeature : public RicImportGeneralDataFeature -{ - CAF_CMD_HEADER_INIT; - -protected: - void onActionTriggered( bool isChecked ) override; - void setupActionLook( QAction* actionToSetup ) override; -}; diff --git a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp index 9dd2c85c1f..f9b8eabc08 100644 --- a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp @@ -188,7 +188,7 @@ void RicImportGeneralDataFeature::onActionTriggered( bool isChecked ) void RicImportGeneralDataFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/Case.svg" ) ); - actionToSetup->setText( "Import Eclipse Files" ); + actionToSetup->setText( "Import Grid Models" ); } //-------------------------------------------------------------------------------------------------- @@ -319,7 +319,7 @@ QStringList RicImportGeneralDataFeature::getEclipseFileNamesWithDialog( RiaDefin QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectory( defaultDirectoryLabel( fileType ) ); // Use nullptr as parent to this dialog, as this function is called from both plot window and main window - QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr, "Import Data File", defaultDir, fullPattern ); + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr, "Import Grid Model", defaultDir, fullPattern ); return fileNames; } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp index f279bfae03..3f3d75cebf 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp @@ -121,7 +121,7 @@ void RimEclipseCaseCollection::removeCaseFromAllGroups( RimEclipseCase* reservoi //-------------------------------------------------------------------------------------------------- void RimEclipseCaseCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { - menuBuilder << "RicImportEclipseCaseFeature"; + menuBuilder << "RicImportGridModelFeature"; menuBuilder << "RicImportGridAndSummaryEnsembleFeature"; menuBuilder << "Separator"; @@ -203,9 +203,6 @@ QStringList RimEclipseCaseCollection::importMenuFeatureNames() return { "RicImportEclipseCasesFeature", "RicImportEclipseCaseTimeStepFilterFeature", "Separator", - "RicImportInputEclipseCaseFeature", - "RicImportRoffCaseFeature", - "Separator", "RicCreateGridCaseGroupFromFilesFeature", "RicCreateGridCaseEnsemblesFromFilesFeature", "RicEclipseCaseNewGroupFeature" }; diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index bb3398653c..87262ae923 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -602,7 +602,7 @@ void RiuMainWindow::createToolBars() { QToolBar* toolbar = addToolBar( tr( "Standard" ) ); toolbar->setObjectName( toolbar->windowTitle() ); - toolbar->addAction( cmdFeatureMgr->action( "RicImportEclipseCaseFeature" ) ); + toolbar->addAction( cmdFeatureMgr->action( "RicImportGridModelFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicImportGridAndSummaryEnsembleFeature" ) ); toolbar->addSeparator(); toolbar->addAction( cmdFeatureMgr->action( "RicOpenProjectFeature" ) ); @@ -620,8 +620,7 @@ void RiuMainWindow::createToolBars() { QToolBar* toolbar = addToolBar( tr( "Import" ) ); toolbar->setObjectName( toolbar->windowTitle() ); - toolbar->addAction( cmdFeatureMgr->action( "RicImportEclipseCaseFeature" ) ); - toolbar->addAction( cmdFeatureMgr->action( "RicImportInputEclipseCaseFeature" ) ); + toolbar->addAction( cmdFeatureMgr->action( "RicImportGridModelFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicImportSummaryCaseFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicImportEnsembleFeature" ) ); toolbar->hide(); diff --git a/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp b/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp index 5013cd7750..23700c3e59 100644 --- a/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp @@ -117,7 +117,7 @@ void RiuMenuBarBuildTools::addImportMenuForMainWindow( QObject* parent, QMenu* m QMenu* importMenu = menu->addMenu( QIcon( ":/import.svg" ), "&Import" ); - importMenu->addAction( cmdFeatureMgr->action( "RicImportEclipseCaseFeature" ) ); + importMenu->addAction( cmdFeatureMgr->action( "RicImportGridModelFeature" ) ); importMenu->addAction( cmdFeatureMgr->action( "RicImportGridAndSummaryEnsembleFeature" ) ); importMenu->addSeparator(); diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp index 9da72176aa..10201123f9 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp @@ -394,7 +394,7 @@ QStringList RiuPlotMainWindow::toolbarCommandIds( const QString& toolbarName ) if ( toolbarName.isEmpty() || toolbarName == "Standard" ) { - commandIds << "RicImportEclipseCaseFeature"; + commandIds << "RicImportGridModelFeature"; commandIds << "RicImportSummaryCaseFeature"; commandIds << "RicImportGridAndSummaryEnsembleFeature"; commandIds << "RicImportEnsembleFeature";