2017-08-29 07:29:45 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-08-29 07:29:45 -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
|
|
|
//
|
2017-08-29 07:29:45 -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>
|
2017-08-29 07:29:45 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicSaveEclipseInputVisibleCellsUi.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2023-02-20 01:18:08 -06:00
|
|
|
#include "RiaPreferences.h"
|
2017-08-29 07:29:45 -05:00
|
|
|
|
|
|
|
#include "cafPdmUiFilePathEditor.h"
|
|
|
|
#include "cafPdmUiOrdering.h"
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
void RicSaveEclipseInputVisibleCellsUi::ExportKeywordEnum::setUp()
|
|
|
|
{
|
|
|
|
addItem( RicSaveEclipseInputVisibleCellsUi::FLUXNUM, "FLUXNUM", "FLUXNUM" );
|
|
|
|
addItem( RicSaveEclipseInputVisibleCellsUi::MULTNUM, "MULTNUM", "MULTNUM" );
|
2021-04-23 01:25:51 -05:00
|
|
|
addItem( RicSaveEclipseInputVisibleCellsUi::ACTNUM, "ACTNUM", "ACTNUM" );
|
2019-09-06 03:40:57 -05:00
|
|
|
setDefault( RicSaveEclipseInputVisibleCellsUi::FLUXNUM );
|
2017-08-29 07:29:45 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
} // namespace caf
|
2017-08-29 07:29:45 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicSaveEclipseInputVisibleCellsUi, "RicSaveEclipseInputVisibleCellsUi" );
|
2017-08-29 07:29:45 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-29 07:29:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-04-23 01:25:51 -05:00
|
|
|
RicSaveEclipseInputVisibleCellsUi::RicSaveEclipseInputVisibleCellsUi()
|
2019-09-06 03:40:57 -05:00
|
|
|
: exportFilenameManuallyChanged( false )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitObject( "Export Visible Cells FLUXNUM/MULTNUM/ACTNUM" );
|
2017-08-29 07:29:45 -05:00
|
|
|
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitField( &exportFilename, "ExportFilename", QString(), "Export Filename" );
|
2019-09-06 03:40:57 -05:00
|
|
|
exportFilename.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &exportKeyword, "ExportKeyword", "Export Keyword" );
|
|
|
|
CAF_PDM_InitField( &visibleActiveCellsValue, "VisibleActiveCellsValue", 1, "Visible Active Cells Value" );
|
|
|
|
CAF_PDM_InitField( &hiddenActiveCellsValue, "HiddenActiveCellsValue", 0, "Hidden Active Cells Value" );
|
|
|
|
CAF_PDM_InitField( &inactiveCellsValue, "InactiveCellsValue", 0, "Inactive Cells Value" );
|
2017-08-29 07:29:45 -05:00
|
|
|
|
2023-02-20 01:18:08 -06:00
|
|
|
CAF_PDM_InitField( &writeEchoInGrdeclFiles,
|
|
|
|
"WriteEchoInGrdeclFiles",
|
|
|
|
RiaPreferences::current()->writeEchoInGrdeclFiles(),
|
|
|
|
"Write NOECHO and ECHO" );
|
|
|
|
|
2017-08-29 07:29:45 -05:00
|
|
|
exportFilename = getDefaultExportPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-29 07:29:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RicSaveEclipseInputVisibleCellsUi::~RicSaveEclipseInputVisibleCellsUi()
|
|
|
|
{
|
|
|
|
}
|
2017-08-29 07:29:45 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-29 07:29:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicSaveEclipseInputVisibleCellsUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( field == &exportFilename )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
2021-10-14 07:36:06 -05:00
|
|
|
auto* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( myAttr )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
2021-10-14 07:36:06 -05:00
|
|
|
myAttr->m_selectSaveFileName = true;
|
|
|
|
myAttr->m_fileSelectionFilter = "GRDECL files (*.grdecl *.GRDECL);;All files (*.*)";
|
2017-08-29 07:29:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-29 07:29:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicSaveEclipseInputVisibleCellsUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
uiOrdering.add( &exportFilename );
|
|
|
|
uiOrdering.add( &exportKeyword );
|
2023-02-20 01:18:08 -06:00
|
|
|
uiOrdering.add( &writeEchoInGrdeclFiles );
|
2019-09-06 03:40:57 -05:00
|
|
|
uiOrdering.add( &visibleActiveCellsValue );
|
|
|
|
uiOrdering.add( &hiddenActiveCellsValue );
|
|
|
|
uiOrdering.add( &inactiveCellsValue );
|
2017-08-29 07:29:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-29 07:29:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicSaveEclipseInputVisibleCellsUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( changedField == &exportFilename )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
|
|
|
exportFilenameManuallyChanged = true;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( changedField == &exportKeyword )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !exportFilenameManuallyChanged )
|
2017-08-29 07:29:45 -05:00
|
|
|
{
|
|
|
|
exportFilename = getDefaultExportPath();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-29 07:29:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RicSaveEclipseInputVisibleCellsUi::getDefaultExportPath() const
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QDir baseDir( RiaApplication::instance()->currentProjectPath() );
|
|
|
|
return baseDir.absoluteFilePath( QString( "%1.grdecl" ).arg( exportKeyword().text() ) );
|
2017-08-29 07:29:45 -05:00
|
|
|
}
|