2015-08-11 06:45:00 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-08-11 06:45:00 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-08-11 06:45:00 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-08-11 06:45:00 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-08-11 06:55:31 -05:00
|
|
|
#include "RicSaveEclipseResultAsInputPropertyExec.h"
|
2015-08-11 06:45:00 -05:00
|
|
|
|
2017-06-28 03:13:59 -05:00
|
|
|
#include "RiaApplication.h"
|
2018-02-02 02:37:34 -06:00
|
|
|
#include "RiaLogging.h"
|
2015-08-11 06:45:00 -05:00
|
|
|
|
2018-10-10 08:12:54 -05:00
|
|
|
#include "RicEclipseCellResultToFileImpl.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RicExportFeatureImpl.h"
|
2015-08-11 06:45:00 -05:00
|
|
|
|
2017-06-28 03:13:59 -05:00
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
|
|
|
|
#include "RimBinaryExportSettings.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimEclipseCellColors.h"
|
|
|
|
#include "RimEclipseView.h"
|
|
|
|
|
2018-02-27 09:37:06 -06:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2015-08-11 06:45:00 -05:00
|
|
|
|
|
|
|
#include "cafPdmUiPropertyViewDialog.h"
|
2017-06-28 03:13:59 -05:00
|
|
|
#include "cafUtils.h"
|
2015-08-11 06:45:00 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-11 06:45:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RicSaveEclipseResultAsInputPropertyExec::RicSaveEclipseResultAsInputPropertyExec( RimEclipseCellColors* cellColors )
|
|
|
|
: CmdExecuteCommand( nullptr )
|
2015-08-11 06:45:00 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( cellColors );
|
2015-08-11 06:45:00 -05:00
|
|
|
m_cellColors = cellColors;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-11 06:45:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RicSaveEclipseResultAsInputPropertyExec::~RicSaveEclipseResultAsInputPropertyExec()
|
|
|
|
{
|
|
|
|
}
|
2015-08-11 06:45:00 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-11 06:45:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-11 06:55:31 -05:00
|
|
|
QString RicSaveEclipseResultAsInputPropertyExec::name()
|
2015-08-11 06:45:00 -05:00
|
|
|
{
|
2017-03-15 05:49:32 -05:00
|
|
|
return "Export Property To File";
|
2015-08-11 06:45:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-11 06:45:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-11 06:55:31 -05:00
|
|
|
void RicSaveEclipseResultAsInputPropertyExec::redo()
|
2015-08-11 06:45:00 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( m_cellColors );
|
2015-08-11 06:45:00 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_cellColors->reservoirView() ) return;
|
|
|
|
if ( !m_cellColors->reservoirView()->eclipseCase() ) return;
|
|
|
|
if ( !m_cellColors->reservoirView()->eclipseCase()->eclipseCaseData() ) return;
|
2015-08-11 06:45:00 -05:00
|
|
|
|
|
|
|
RimBinaryExportSettings exportSettings;
|
|
|
|
exportSettings.eclipseKeyword = m_cellColors->resultVariable();
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaApplication* app = RiaApplication::instance();
|
|
|
|
QString projectFolder = app->currentProjectPath();
|
|
|
|
if ( projectFolder.isEmpty() )
|
2015-08-11 06:45:00 -05:00
|
|
|
{
|
|
|
|
projectFolder = m_cellColors->reservoirView()->eclipseCase()->locationOnDisc();
|
|
|
|
}
|
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
QString outputFileName = projectFolder + "/" + caf::Utils::makeValidFileBasename( m_cellColors->resultVariableUiShortName() ) +
|
2021-10-14 07:36:06 -05:00
|
|
|
".GRDECL";
|
2015-08-11 06:45:00 -05:00
|
|
|
|
|
|
|
exportSettings.fileName = outputFileName;
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiPropertyViewDialog propertyDialog( Riu3DMainWindowTools::mainWindowWidget(),
|
|
|
|
&exportSettings,
|
|
|
|
"Export Binary Eclipse Data to Text File",
|
|
|
|
"" );
|
|
|
|
RicExportFeatureImpl::configureForExport( propertyDialog.dialogButtonBox() );
|
2017-01-04 06:13:06 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( propertyDialog.exec() == QDialog::Accepted )
|
2015-08-11 06:45:00 -05:00
|
|
|
{
|
|
|
|
size_t timeStep = m_cellColors->reservoirView()->currentTimeStep();
|
|
|
|
|
2019-05-23 06:59:19 -05:00
|
|
|
QString errMsg;
|
2023-02-26 03:48:40 -06:00
|
|
|
bool isOk =
|
|
|
|
RicEclipseCellResultToFileImpl::writeBinaryResultToTextFile( exportSettings.fileName,
|
|
|
|
m_cellColors->reservoirView()->eclipseCase()->eclipseCaseData(),
|
|
|
|
timeStep,
|
|
|
|
m_cellColors,
|
|
|
|
exportSettings.eclipseKeyword,
|
|
|
|
exportSettings.undefinedValue,
|
|
|
|
"saveEclipseResultAsInputPropertyExec",
|
|
|
|
exportSettings.writeEchoInGrdeclFiles,
|
|
|
|
&errMsg );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !isOk )
|
2015-08-11 06:45:00 -05:00
|
|
|
{
|
2020-02-12 04:43:15 -06:00
|
|
|
QString fullError =
|
|
|
|
QString( "Failed to exported current result to %1. Error was: %2" ).arg( exportSettings.fileName ).arg( errMsg );
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaLogging::error( fullError );
|
2015-08-11 06:45:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-11 06:45:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-11 06:55:31 -05:00
|
|
|
void RicSaveEclipseResultAsInputPropertyExec::undo()
|
2015-08-11 06:45:00 -05:00
|
|
|
{
|
|
|
|
// TODO
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( 0 );
|
2015-08-11 06:45:00 -05:00
|
|
|
}
|