2016-09-19 04:17:36 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2016- Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2016-09-19 04:17:36 -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
|
|
|
//
|
2016-09-19 04:17:36 -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>
|
2016-09-19 04:17:36 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicExportToLasFileResampleUi.h"
|
2016-10-26 00:53:59 -05:00
|
|
|
|
|
|
|
#include "cafPdmUiCheckBoxEditor.h"
|
2016-09-19 04:17:36 -05:00
|
|
|
#include "cafPdmUiFilePathEditor.h"
|
2016-10-14 06:30:04 -05:00
|
|
|
#include "cafPdmUiOrdering.h"
|
2016-10-26 00:53:59 -05:00
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicExportToLasFileObj, "RicExportToLasFileObj" );
|
2016-10-14 06:30:04 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-14 06:30:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RicExportToLasFileObj::RicExportToLasFileObj( void )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitObject( "RicExportToLasFileObj", "", "", "" );
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitField( &tvdrkbOffset, "tvdrkbOffset", QString( "" ), "TVDRKB offset (RKB - MSL) [m]", "", "", "" );
|
2016-10-14 06:30:04 -05:00
|
|
|
}
|
2016-09-19 04:17:36 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicExportToLasFileResampleUi, "RicExportToLasFileResampleUi" );
|
2016-09-19 04:17:36 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-09-19 04:17:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RicExportToLasFileResampleUi::RicExportToLasFileResampleUi( void )
|
2016-09-19 04:17:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitObject( "Resample LAS curves for export", "", "", "" );
|
2016-09-19 04:17:36 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitField( &exportFolder, "ExportFolder", QString(), "Export Folder", "", "", "" );
|
|
|
|
exportFolder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
2016-09-19 04:17:36 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitField( &activateResample, "ActivateResample", false, "Resample Curve Data", "", "", "" );
|
|
|
|
activateResample.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitField( &resampleInterval, "ResampleInterval", 1.0, "Resample Interval [m]", "", "", "" );
|
2016-09-19 04:17:36 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitField( &exportTvdrkb, "ExportTvdrkb", false, "Export TVDRKB", "", "", "" );
|
|
|
|
exportTvdrkb.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_tvdrkbOffsets, "tvdrkbOffsets", "", "", "", "" );
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2016-09-19 04:17:36 -05:00
|
|
|
updateFieldVisibility();
|
|
|
|
}
|
|
|
|
|
2016-10-14 06:30:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-14 06:30:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicExportToLasFileResampleUi::~RicExportToLasFileResampleUi()
|
|
|
|
{
|
|
|
|
m_tvdrkbOffsets.deleteAllChildObjects();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-14 06:30:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicExportToLasFileResampleUi::tvdrkbDiffForWellPaths( std::vector<double>* rkbDiffs )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t i = 0; i < m_tvdrkbOffsets.size(); i++ )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2016-10-26 00:31:43 -05:00
|
|
|
double value = HUGE_VAL;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_tvdrkbOffsets()[i]->tvdrkbOffset().isEmpty() )
|
2016-10-26 00:31:43 -05:00
|
|
|
{
|
|
|
|
value = m_tvdrkbOffsets()[i]->tvdrkbOffset().toDouble();
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
rkbDiffs->push_back( value );
|
2016-10-14 06:30:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-14 06:30:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicExportToLasFileResampleUi::setRkbDiffs( const std::vector<QString>& wellNames,
|
|
|
|
const std::vector<double>& rkbDiffs )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t i = 0; i < wellNames.size(); i++ )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
|
|
|
RicExportToLasFileObj* obj = new RicExportToLasFileObj;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( rkbDiffs[i] != HUGE_VAL )
|
2016-10-26 00:31:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
obj->tvdrkbOffset = QString::number( rkbDiffs[i] );
|
2016-10-26 00:31:43 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
obj->tvdrkbOffset.uiCapability()->setUiName( wellNames[i] );
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_tvdrkbOffsets.push_back( obj );
|
2016-10-14 06:30:04 -05:00
|
|
|
}
|
2016-10-26 00:31:43 -05:00
|
|
|
|
|
|
|
updateFieldVisibility();
|
2016-10-14 06:30:04 -05:00
|
|
|
}
|
|
|
|
|
2016-09-19 04:17:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-09-19 04:17:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicExportToLasFileResampleUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
2016-09-19 04:17:36 -05:00
|
|
|
{
|
|
|
|
updateFieldVisibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-09-19 04:17:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicExportToLasFileResampleUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute )
|
2016-09-19 04:17:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( field == &exportFolder )
|
2016-09-19 04:17:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
|
|
|
|
if ( myAttr )
|
2016-09-19 04:17:36 -05:00
|
|
|
{
|
|
|
|
myAttr->m_selectDirectory = true;
|
|
|
|
}
|
|
|
|
}
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( field == &exportTvdrkb || field == &activateResample )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
|
|
|
|
if ( myAttr )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
|
|
|
myAttr->m_useNativeCheckBoxLabel = true;
|
|
|
|
}
|
|
|
|
}
|
2016-09-19 04:17:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-09-19 04:17:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicExportToLasFileResampleUi::updateFieldVisibility()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( activateResample )
|
2016-09-19 04:17:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
resampleInterval.uiCapability()->setUiReadOnly( false );
|
2016-09-19 04:17:36 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
resampleInterval.uiCapability()->setUiReadOnly( true );
|
2016-09-19 04:17:36 -05:00
|
|
|
}
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RicExportToLasFileObj* obj : m_tvdrkbOffsets )
|
2016-10-26 00:31:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
obj->tvdrkbOffset.uiCapability()->setUiReadOnly( !exportTvdrkb );
|
2016-10-26 00:31:43 -05:00
|
|
|
}
|
2016-09-19 04:17:36 -05:00
|
|
|
}
|
2016-10-14 06:30:04 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-14 06:30:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicExportToLasFileResampleUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
uiOrdering.add( &exportFolder );
|
|
|
|
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Resampling" );
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
group->add( &activateResample );
|
|
|
|
group->add( &resampleInterval );
|
2016-10-14 06:30:04 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiGroup* tvdrkbGroup = uiOrdering.addNewGroup( "TVDRKB" );
|
|
|
|
tvdrkbGroup->add( &exportTvdrkb );
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiGroup* group = tvdrkbGroup->addNewGroup(
|
|
|
|
"Difference between TVDRKB and TVDMSL, clear diff for no export" );
|
|
|
|
for ( auto& obj : m_tvdrkbOffsets )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
group->add( &obj->tvdrkbOffset );
|
2016-10-14 06:30:04 -05:00
|
|
|
}
|
|
|
|
}
|