mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9773 Import data from Reveal and StimPlan as summary case.
This commit is contained in:
@@ -46,6 +46,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveInfoTextProvider.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressModifier.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimRftCase.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimCsvSummaryCase.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -96,6 +97,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveInfoTextProvider.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressModifier.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimRftCase.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimCsvSummaryCase.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023- 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 "RimCsvSummaryCase.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RifRevealCsvSummaryReader.h"
|
||||
#include "RifStimPlanCsvSummaryReader.h"
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimCsvSummaryCase, "CsvSummaryCase" );
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template <>
|
||||
void caf::AppEnum<RimCsvSummaryCase::FileType>::setUp()
|
||||
{
|
||||
addItem( RimCsvSummaryCase::FileType::REVEAL, "REVEAL", "Reveal" );
|
||||
addItem( RimCsvSummaryCase::FileType::STIMPLAN, "STIMPLAN", "StimPlan" );
|
||||
|
||||
setDefault( RimCsvSummaryCase::FileType::REVEAL );
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCsvSummaryCase::RimCsvSummaryCase()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault( &m_fileType, "FileType", "File Type" );
|
||||
CAF_PDM_InitField( &m_startDate, "StartDate", QDateTime::currentDateTime(), "Start Date" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCsvSummaryCase::caseName() const
|
||||
{
|
||||
QFileInfo caseFileName( this->summaryHeaderFilename() );
|
||||
return caseFileName.completeBaseName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCsvSummaryCase::createSummaryReaderInterface()
|
||||
{
|
||||
m_summaryReader = nullptr;
|
||||
|
||||
if ( caf::Utils::fileExists( this->summaryHeaderFilename() ) )
|
||||
{
|
||||
if ( m_fileType == FileType::REVEAL )
|
||||
{
|
||||
auto reader = new RifRevealCsvSummaryReader;
|
||||
QString errorMessage;
|
||||
if ( auto [ok, caseName] = reader->parse( summaryHeaderFilename(), &errorMessage ); ok )
|
||||
{
|
||||
m_summaryReader = reader;
|
||||
m_displayName = caseName;
|
||||
}
|
||||
else
|
||||
{
|
||||
RiaLogging::error( "Failed to read Reveal summary file" );
|
||||
RiaLogging::error( errorMessage );
|
||||
}
|
||||
}
|
||||
else if ( m_fileType == FileType::STIMPLAN )
|
||||
{
|
||||
auto reader = new RifStimPlanCsvSummaryReader;
|
||||
QString errorMessage;
|
||||
if ( auto [ok, caseName] = reader->parse( summaryHeaderFilename(), m_startDate, &errorMessage ); ok )
|
||||
{
|
||||
m_summaryReader = reader;
|
||||
m_displayName = caseName;
|
||||
}
|
||||
else
|
||||
{
|
||||
RiaLogging::error( "Failed to read StimPlan summary file" );
|
||||
RiaLogging::error( errorMessage );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifSummaryReaderInterface* RimCsvSummaryCase::summaryReader()
|
||||
{
|
||||
if ( m_summaryReader.isNull() )
|
||||
{
|
||||
createSummaryReaderInterface();
|
||||
}
|
||||
return m_summaryReader.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCsvSummaryCase::setFileType( FileType fileType )
|
||||
{
|
||||
m_fileType = fileType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCsvSummaryCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
RimSummaryCase::defineUiOrdering( uiConfigName, uiOrdering );
|
||||
|
||||
if ( m_fileType == FileType::STIMPLAN ) uiOrdering.add( &m_startDate );
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023- 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 "RimSummaryCase.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimCsvSummaryCase : public RimSummaryCase
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum class FileType
|
||||
{
|
||||
REVEAL,
|
||||
STIMPLAN
|
||||
};
|
||||
|
||||
RimCsvSummaryCase();
|
||||
|
||||
QString caseName() const override;
|
||||
|
||||
void setFileType( FileType fileType );
|
||||
|
||||
void createSummaryReaderInterface() override;
|
||||
RifSummaryReaderInterface* summaryReader() override;
|
||||
|
||||
protected:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
private:
|
||||
cvf::ref<RifSummaryReaderInterface> m_summaryReader;
|
||||
caf::PdmField<caf::AppEnum<FileType>> m_fileType;
|
||||
caf::PdmField<QDateTime> m_startDate;
|
||||
};
|
||||
Reference in New Issue
Block a user