#4987 Add feature to replace grid case.

This commit is contained in:
Kristian Bendiksen 2019-11-07 12:59:30 +01:00
parent 544c160510
commit b09103e596
6 changed files with 170 additions and 4 deletions

View File

@ -66,6 +66,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCommandFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicReloadCaseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicReplaceCaseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCaseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCasesFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicReplaceSummaryCaseFeature.h
@ -150,6 +151,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicDeleteSummaryCaseCollectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicReloadCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicReplaceCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicReplaceSummaryCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicFlyToObjectFeature.cpp

View File

@ -170,14 +170,14 @@ QStringList RicImportGeneralDataFeature::getEclipseFileNamesWithDialog( RiaDefin
.arg( eclipseInputFilePattern )
.arg( eclipseSummaryFilePattern );
}
if ( fileTypes & ECLIPSE_GRID_FILE )
{
filePatternTexts += QString( "Eclipse Grid Files (%1)" ).arg( eclipseGridFilePattern );
}
if ( fileTypes & ECLIPSE_EGRID_FILE )
{
filePatternTexts += QString( "Eclipse EGrid Files (%1)" ).arg( eclipseEGridFilePattern );
}
if ( fileTypes & ECLIPSE_GRID_FILE )
{
filePatternTexts += QString( "Eclipse Grid Files (%1)" ).arg( eclipseGridFilePattern );
}
if ( fileTypes & ECLIPSE_INPUT_FILE )
{
filePatternTexts += QString( "Eclipse Input Files and Input Properties (%1)" ).arg( eclipseInputFilePattern );

View File

@ -0,0 +1,131 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicReplaceCaseFeature.h"
#include "RiaGuiApplication.h"
#include "RiaSummaryTools.h"
#include "RicImportGeneralDataFeature.h"
#include "RimEclipseCase.h"
#include "RimEclipseResultCase.h"
#include "RimGridSummaryCase.h"
#include "RimReloadCaseTools.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RimTimeStepFilter.h"
#include "Riu3dSelectionManager.h"
#include "cafPdmObject.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFileInfo>
CAF_CMD_SOURCE_INIT( RicReplaceCaseFeature, "RicReplaceCaseFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicReplaceCaseFeature::isCommandEnabled()
{
std::vector<caf::PdmObject*> selectedFormationNamesCollObjs;
caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs );
for ( caf::PdmObject* pdmObject : selectedFormationNamesCollObjs )
{
if ( dynamic_cast<RimEclipseResultCase*>( pdmObject ) )
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReplaceCaseFeature::onActionTriggered( bool isChecked )
{
std::vector<RimEclipseResultCase*> selectedEclipseCases;
caf::SelectionManager::instance()->objectsByType( &selectedEclipseCases );
RiaGuiApplication::clearAllSelections();
const QStringList fileNames = RicImportGeneralDataFeature::getEclipseFileNamesWithDialog(
RiaDefines::ECLIPSE_RESULT_GRID );
if ( fileNames.isEmpty() ) return;
const QString fileName = fileNames[0];
for ( RimEclipseResultCase* selectedCase : selectedEclipseCases )
{
selectedCase->setGridFileName( fileName );
selectedCase->reloadEclipseGridFile();
std::vector<RimTimeStepFilter*> timeStepFilter;
selectedCase->descendantsIncludingThisOfType( timeStepFilter );
if ( timeStepFilter.size() == 1 )
{
timeStepFilter[0]->clearFilteredTimeSteps();
}
RimReloadCaseTools::reloadAllEclipseData( selectedCase );
selectedCase->updateConnectedEditors();
// Use the file base name as case user description
QFileInfo fi( fileName );
selectedCase->caseUserDescription = fi.baseName();
// Find and update attached grid summary cases.
RimSummaryCaseMainCollection* sumCaseColl = RiaSummaryTools::summaryCaseMainCollection();
if ( sumCaseColl )
{
RimGridSummaryCase* gridSummaryCase = dynamic_cast<RimGridSummaryCase*>(
sumCaseColl->findSummaryCaseFromEclipseResultCase( selectedCase ) );
if ( gridSummaryCase )
{
gridSummaryCase->setAssociatedEclipseCase( selectedCase );
gridSummaryCase->resetAutoShortName();
gridSummaryCase->createSummaryReaderInterface();
gridSummaryCase->createRftReaderInterface();
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
for ( RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots )
{
summaryPlot->loadDataAndUpdate();
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReplaceCaseFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Replace" );
// TODO: icon?
// actionToSetup->setIcon( QIcon( ":/Refresh-32.png" ) );
}

View File

@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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"
class RicReplaceCaseFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -889,6 +889,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicAddEclipseInputPropertyFeature";
menuBuilder << "RicReloadCaseFeature";
menuBuilder << "RicReplaceCaseFeature";
createExecuteScriptForCasesFeatureMenu( menuBuilder );
menuBuilder << "RicCloseSourSimDataFeature";
}

View File

@ -117,6 +117,7 @@ void RimReloadCaseTools::updateAll3dViews( RimEclipseCase* eclipseCase )
for ( RimEclipseView* reservoirView : eclipseCase->reservoirViews() )
{
CVF_ASSERT( reservoirView );
reservoirView->setEclipseCase( eclipseCase );
reservoirView->loadDataAndUpdate();
reservoirView->updateGridBoxData();
reservoirView->updateAnnotationItems();