mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4987 Add feature to replace grid case.
This commit is contained in:
parent
544c160510
commit
b09103e596
@ -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
|
||||
|
@ -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 );
|
||||
|
131
ApplicationCode/Commands/RicReplaceCaseFeature.cpp
Normal file
131
ApplicationCode/Commands/RicReplaceCaseFeature.cpp
Normal 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" ) );
|
||||
}
|
31
ApplicationCode/Commands/RicReplaceCaseFeature.h
Normal file
31
ApplicationCode/Commands/RicReplaceCaseFeature.h
Normal 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;
|
||||
};
|
@ -889,6 +889,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
menuBuilder << "RicAddEclipseInputPropertyFeature";
|
||||
menuBuilder << "RicReloadCaseFeature";
|
||||
menuBuilder << "RicReplaceCaseFeature";
|
||||
createExecuteScriptForCasesFeatureMenu( menuBuilder );
|
||||
menuBuilder << "RicCloseSourSimDataFeature";
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user