mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4499 Add feature to replace summary case.
This commit is contained in:
parent
aa11e3601b
commit
544c160510
@ -68,6 +68,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicCommandFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadCaseFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCaseFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCasesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReplaceSummaryCaseFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicFlyToObjectFeature.h
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.h
|
||||
@ -150,6 +151,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadCaseFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCaseFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReplaceSummaryCaseFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicFlyToObjectFeature.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.cpp
|
||||
|
@ -154,7 +154,7 @@ void RicImportGeneralDataFeature::setupActionLook( QAction* actionToSetup )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportGeneralDataFeature::openFileDialog( ImportFileType fileTypes )
|
||||
QStringList RicImportGeneralDataFeature::getEclipseFileNamesWithDialog( RiaDefines::ImportFileType fileTypes )
|
||||
{
|
||||
QString eclipseGridFilePattern( "*.GRID" );
|
||||
QString eclipseEGridFilePattern( "*.EGRID" );
|
||||
@ -195,7 +195,15 @@ void RicImportGeneralDataFeature::openFileDialog( ImportFileType fileTypes )
|
||||
"Import Data File",
|
||||
defaultDir,
|
||||
fullPattern );
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportGeneralDataFeature::openFileDialog( ImportFileType fileTypes )
|
||||
{
|
||||
QStringList fileNames = getEclipseFileNamesWithDialog( fileTypes );
|
||||
if ( fileNames.empty() ) return;
|
||||
|
||||
if ( fileTypes == ANY_ECLIPSE_FILE )
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
|
||||
static OpenCaseResults openEclipseFilesFromFileNames( const QStringList& fileNames, bool doCreateDefaultPlot );
|
||||
static QStringList fileNamesFromCaseNames( const QStringList& caseNames );
|
||||
static QStringList getEclipseFileNamesWithDialog( RiaDefines::ImportFileType fileTypes );
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
|
83
ApplicationCode/Commands/RicReplaceSummaryCaseFeature.cpp
Normal file
83
ApplicationCode/Commands/RicReplaceSummaryCaseFeature.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicReplaceSummaryCaseFeature.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RicImportGeneralDataFeature.h"
|
||||
|
||||
#include "RimFileSummaryCase.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicReplaceSummaryCaseFeature, "RicReplaceSummaryCaseFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicReplaceSummaryCaseFeature::isCommandEnabled()
|
||||
{
|
||||
RimSummaryCase* rimSummaryCase = caf::SelectionManager::instance()->selectedItemOfType<RimFileSummaryCase>();
|
||||
return rimSummaryCase != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicReplaceSummaryCaseFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimFileSummaryCase* summaryCase = caf::SelectionManager::instance()->selectedItemOfType<RimFileSummaryCase>();
|
||||
if ( !summaryCase ) return;
|
||||
|
||||
const QStringList fileNames = RicImportGeneralDataFeature::getEclipseFileNamesWithDialog(
|
||||
RiaDefines::ECLIPSE_SUMMARY_FILE );
|
||||
if ( fileNames.isEmpty() ) return;
|
||||
|
||||
QString oldSummaryHeaderFilename = summaryCase->summaryHeaderFilename();
|
||||
summaryCase->setSummaryHeaderFileName( fileNames[0] );
|
||||
summaryCase->resetAutoShortName();
|
||||
summaryCase->createSummaryReaderInterface();
|
||||
summaryCase->createRftReaderInterface();
|
||||
RiaLogging::info( QString( "Replaced summary data for %1" ).arg( oldSummaryHeaderFilename ) );
|
||||
|
||||
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
|
||||
for ( RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots )
|
||||
{
|
||||
summaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicReplaceSummaryCaseFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Replace" );
|
||||
// TODO: get an icon?
|
||||
// actionToSetup->setIcon( QIcon( ":/Refresh-32.png" ) );
|
||||
}
|
31
ApplicationCode/Commands/RicReplaceSummaryCaseFeature.h
Normal file
31
ApplicationCode/Commands/RicReplaceSummaryCaseFeature.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 RicReplaceSummaryCaseFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
@ -847,6 +847,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicImportObservedDataFeature";
|
||||
menuBuilder << "RicImportObservedFmuDataFeature";
|
||||
menuBuilder << "RicReloadSummaryCaseFeature";
|
||||
menuBuilder << "RicReplaceSummaryCaseFeature";
|
||||
menuBuilder << "RicCreateSummaryCaseCollectionFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicCutReferencesToClipboardFeature";
|
||||
|
@ -34,6 +34,8 @@
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT( RimSummaryCase, "SummaryCase" );
|
||||
|
||||
const QString RimSummaryCase::DEFAULT_DISPLAY_NAME = "Display Name";
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -41,7 +43,7 @@ RimSummaryCase::RimSummaryCase()
|
||||
{
|
||||
CAF_PDM_InitObject( "Summary Case", ":/SummaryCase16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_shortName, "ShortName", QString( "Display Name" ), "Display Name", "", "", "" );
|
||||
CAF_PDM_InitField( &m_shortName, "ShortName", QString( "Display Name" ), DEFAULT_DISPLAY_NAME, "", "", "" );
|
||||
CAF_PDM_InitField( &m_useAutoShortName, "AutoShortyName", false, "Use Auto Display Name", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryHeaderFilename, "SummaryHeaderFilename", "Summary Header File", "", "", "" );
|
||||
@ -231,10 +233,19 @@ void RimSummaryCase::updateAutoShortName()
|
||||
|
||||
m_shortName = oilField->uniqueShortNameForCase( this );
|
||||
}
|
||||
else if ( m_shortName() == QString( "Display Name" ) )
|
||||
else if ( m_shortName() == DEFAULT_DISPLAY_NAME )
|
||||
{
|
||||
m_shortName = caseName();
|
||||
}
|
||||
|
||||
updateTreeItemName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCase::resetAutoShortName()
|
||||
{
|
||||
m_shortName = DEFAULT_DISPLAY_NAME;
|
||||
updateAutoShortName();
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
RiaEclipseUnitTools::UnitSystemType unitsSystem();
|
||||
|
||||
void updateAutoShortName();
|
||||
void resetAutoShortName();
|
||||
void updateOptionSensitivity();
|
||||
|
||||
virtual void createSummaryReaderInterface() = 0;
|
||||
@ -87,6 +88,8 @@ protected:
|
||||
|
||||
std::shared_ptr<RigCaseRealizationParameters> m_crlParameters;
|
||||
|
||||
static const QString DEFAULT_DISPLAY_NAME;
|
||||
|
||||
private:
|
||||
void initAfterRead() override;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user