mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7927 Add user interface for exporting multiple surfaces.
This commit is contained in:
@@ -73,6 +73,8 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeletePressureTableItemFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCaseFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCurveFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicGenerateMultipleSurfacesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicGenerateMultipleSurfacesUi.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -149,6 +151,8 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeletePressureTableItemFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCaseFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCurveFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicGenerateMultipleSurfacesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicGenerateMultipleSurfacesUi.cpp
|
||||
)
|
||||
|
||||
if(Qt5Charts_FOUND)
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicGenerateMultipleSurfacesFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "CommandRouter/RimcExtractSurfaces.h"
|
||||
#include "RicGenerateMultipleSurfacesUi.h"
|
||||
#include "RicImportEnsembleSurfaceFeature.h"
|
||||
#include "RicRecursiveFileSearchDialog.h"
|
||||
#include "RimDialogData.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuPropertyViewTabWidget.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafPdmSettings.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafProgressInfo.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicGenerateMultipleSurfacesFeature, "RicGenerateMultipleSurfacesFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicGenerateMultipleSurfacesFeature::openDialogAndExecuteCommand()
|
||||
{
|
||||
// Get the list of egrid files
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" );
|
||||
|
||||
QString pathFilter( "*" );
|
||||
QString fileNameFilter( "*" );
|
||||
|
||||
RicRecursiveFileSearchDialogResult result =
|
||||
RicRecursiveFileSearchDialog::runRecursiveSearchDialog( nullptr,
|
||||
"Choose Eclipse Cases",
|
||||
defaultDir,
|
||||
pathFilter,
|
||||
fileNameFilter,
|
||||
QStringList( ".EGRID" ) );
|
||||
|
||||
if ( !result.ok || result.files.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Read min/max k layer from first grid case
|
||||
int minLayerK = -1;
|
||||
int maxLayerK = -1;
|
||||
if ( !RimcCommandRouter_extractSurfaces::readMinMaxLayerFromGridFile( result.files[0], minLayerK, maxLayerK ) )
|
||||
return;
|
||||
|
||||
RicGenerateMultipleSurfacesUi* ui = RimProject::current()->dialogData()->generateEnsembleSurfacesUi();
|
||||
ui->setLayersMinMax( minLayerK, maxLayerK );
|
||||
|
||||
RiuPropertyViewTabWidget propertyDialog( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
ui,
|
||||
"Export Multiple Surfaces",
|
||||
ui->tabNames() );
|
||||
|
||||
if ( propertyDialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
executeCommand( *ui, result.files.toStdList() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicGenerateMultipleSurfacesFeature::executeCommand( const RicGenerateMultipleSurfacesUi& ui,
|
||||
const std::list<QString>& fileNames )
|
||||
{
|
||||
std::vector layers = ui.layers();
|
||||
|
||||
caf::ProgressInfo progress( fileNames.size(), "Generating ensemble surfaces" );
|
||||
|
||||
QStringList allSurfaceFileNames;
|
||||
for ( auto fileName : fileNames )
|
||||
{
|
||||
auto task = progress.task( QString( "Extracting surfaces for %1" ).arg( fileName ) );
|
||||
auto [isOk, surfaceFileNames] = RimcCommandRouter_extractSurfaces::extractSurfaces( fileName, layers );
|
||||
if ( isOk ) allSurfaceFileNames << surfaceFileNames;
|
||||
}
|
||||
|
||||
if ( ui.autoCreateEnsembleSurfaces() )
|
||||
RicImportEnsembleSurfaceFeature::importEnsembleSurfaceFromFiles( allSurfaceFileNames );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicGenerateMultipleSurfacesFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicGenerateMultipleSurfacesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
openDialogAndExecuteCommand();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicGenerateMultipleSurfacesFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Generate Multiple Surfaces..." );
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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 "cafCmdFeature.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
class RicGenerateMultipleSurfacesUi;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicGenerateMultipleSurfacesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void openDialogAndExecuteCommand();
|
||||
static void executeCommand( const RicGenerateMultipleSurfacesUi& ui, const std::list<QString>& fileNames );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
141
ApplicationLibCode/Commands/RicGenerateMultipleSurfacesUi.cpp
Normal file
141
ApplicationLibCode/Commands/RicGenerateMultipleSurfacesUi.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicGenerateMultipleSurfacesUi.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RicGenerateMultipleSurfacesUi, "RicGenerateMultipleSurfacesUi" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicGenerateMultipleSurfacesUi::RicGenerateMultipleSurfacesUi()
|
||||
{
|
||||
CAF_PDM_InitObject( "Export Multiple Surfaces", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_layers, "Layers", "Layers", "", "", "" );
|
||||
CAF_PDM_InitField( &m_autoCreateEnsembleSurfaces,
|
||||
"AutoCreateEnsembleSurfaces",
|
||||
false,
|
||||
"Create Ensemble Surfaces From Exported Files",
|
||||
"",
|
||||
"",
|
||||
"" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_minLayer, "MinLayer", "MinLayer", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_maxLayer, "MaxLayer", "MaxLayer", "", "", "" );
|
||||
|
||||
m_tabNames << "Layers"
|
||||
<< "Ensemble Surfaces";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicGenerateMultipleSurfacesUi::~RicGenerateMultipleSurfacesUi()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QStringList& RicGenerateMultipleSurfacesUi::tabNames() const
|
||||
{
|
||||
return m_tabNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicGenerateMultipleSurfacesUi::setLayersMinMax( int minLayer, int maxLayer )
|
||||
{
|
||||
m_minLayer = minLayer;
|
||||
m_maxLayer = maxLayer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicGenerateMultipleSurfacesUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( field == &m_layers )
|
||||
{
|
||||
caf::PdmUiListEditorAttribute* myAttr = dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
{
|
||||
myAttr->m_heightHint = 280;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicGenerateMultipleSurfacesUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
if ( uiConfigName == m_tabNames[0] )
|
||||
{
|
||||
uiOrdering.add( &m_layers );
|
||||
}
|
||||
else if ( uiConfigName == m_tabNames[1] )
|
||||
{
|
||||
uiOrdering.add( &m_autoCreateEnsembleSurfaces );
|
||||
}
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RicGenerateMultipleSurfacesUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
if ( fieldNeedingOptions == &m_layers )
|
||||
{
|
||||
for ( int layer = m_minLayer; layer < m_maxLayer; layer++ )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( QString::number( layer ), layer ) );
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<int> RicGenerateMultipleSurfacesUi::layers() const
|
||||
{
|
||||
return m_layers();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicGenerateMultipleSurfacesUi::autoCreateEnsembleSurfaces() const
|
||||
{
|
||||
return m_autoCreateEnsembleSurfaces;
|
||||
}
|
||||
62
ApplicationLibCode/Commands/RicGenerateMultipleSurfacesUi.h
Normal file
62
ApplicationLibCode/Commands/RicGenerateMultipleSurfacesUi.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
class RigEclipseCaseData;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicGenerateMultipleSurfacesUi : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicGenerateMultipleSurfacesUi();
|
||||
~RicGenerateMultipleSurfacesUi() override;
|
||||
const QStringList& tabNames() const;
|
||||
|
||||
void setLayersMinMax( int minLayer, int maxLayer );
|
||||
|
||||
std::vector<int> layers() const;
|
||||
|
||||
bool autoCreateEnsembleSurfaces() const;
|
||||
|
||||
protected:
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
|
||||
caf::PdmField<std::vector<int>> m_layers;
|
||||
caf::PdmField<bool> m_autoCreateEnsembleSurfaces;
|
||||
caf::PdmField<int> m_minLayer;
|
||||
caf::PdmField<int> m_maxLayer;
|
||||
|
||||
QStringList m_tabNames;
|
||||
};
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RicImportEnsembleFeature.h"
|
||||
#include "RicRecursiveFileSearchDialog.h"
|
||||
|
||||
#include "RimEnsembleSurface.h"
|
||||
@@ -63,6 +64,13 @@ void RicImportEnsembleSurfaceFeature::onActionTriggered( bool isChecked )
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString pathCacheName = "ENSEMBLE_SURFACE_FILES";
|
||||
QStringList fileNames = runRecursiveFileSearchDialog( "Import Ensemble Surface", pathCacheName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportEnsembleSurfaceFeature::importEnsembleSurfaceFromFiles( const QStringList& fileNames )
|
||||
{
|
||||
if ( fileNames.isEmpty() ) return;
|
||||
|
||||
QString ensembleName = RiaEnsembleNameTools::findSuitableEnsembleName( fileNames );
|
||||
|
||||
@@ -27,10 +27,13 @@
|
||||
//==================================================================================================
|
||||
class RicImportEnsembleSurfaceFeature : public caf::CmdFeature
|
||||
{
|
||||
public:
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
RicImportEnsembleSurfaceFeature();
|
||||
|
||||
static void importEnsembleSurfaceFromFiles( const QStringList& fileNames );
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
|
||||
Reference in New Issue
Block a user