2023-01-23 05:46:54 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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 "RicCreateDepthAdjustedLasFilesUi.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
|
|
|
#include "RimCase.h"
|
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimTools.h"
|
|
|
|
#include "RimWellLogFile.h"
|
|
|
|
#include "RimWellLogFileChannel.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
|
|
|
|
|
|
|
#include "cafPdmUiCheckBoxEditor.h"
|
|
|
|
#include "cafPdmUiFilePathEditor.h"
|
|
|
|
#include "cafPdmUiOrdering.h"
|
|
|
|
#include "cafPdmUiTreeSelectionEditor.h"
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT( RicCreateDepthAdjustedLasFilesUi, "RicCreateDepthAdjustedLasFilesUi" );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicCreateDepthAdjustedLasFilesUi::RicCreateDepthAdjustedLasFilesUi()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitField( &exportFolder, "ExportFolder", QString(), "Export Folder" );
|
|
|
|
exportFolder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &selectedCase, "SelectedCase", "Select Case" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &sourceWell, "SourceWell", "Source Well" );
|
2023-02-07 10:51:35 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &wellLogFile, "WellLogFile", "Well Log File" );
|
2023-01-23 05:46:54 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &selectedResultProperties, "SelectedResultProperties", "Selected Result Properties" );
|
|
|
|
selectedResultProperties.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &destinationWells, "DestinationWells", "Destination Wells" );
|
|
|
|
destinationWells.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicCreateDepthAdjustedLasFilesUi::~RicCreateDepthAdjustedLasFilesUi()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
QList<caf::PdmOptionItemInfo> RicCreateDepthAdjustedLasFilesUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
2023-01-23 05:46:54 -06:00
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
|
|
|
if ( fieldNeedingOptions == &selectedCase )
|
|
|
|
{
|
|
|
|
RimTools::caseOptionItems( &options );
|
|
|
|
}
|
|
|
|
if ( fieldNeedingOptions == &sourceWell )
|
|
|
|
{
|
|
|
|
RimProject* proj = RimProject::current();
|
|
|
|
if ( proj )
|
|
|
|
{
|
|
|
|
std::vector<RimWellPath*> allWellPaths = proj->activeOilField()->wellPathCollection->allWellPaths();
|
|
|
|
for ( auto* wellPath : allWellPaths )
|
|
|
|
{
|
|
|
|
if ( !wellPath->wellLogFiles().empty() )
|
|
|
|
{
|
|
|
|
options.push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-07 10:51:35 -06:00
|
|
|
if ( fieldNeedingOptions == &wellLogFile )
|
|
|
|
{
|
|
|
|
if ( sourceWell )
|
|
|
|
{
|
|
|
|
for ( auto* file : sourceWell->wellLogFiles() )
|
|
|
|
{
|
|
|
|
options.push_back( caf::PdmOptionItemInfo( file->name(), file ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-23 05:46:54 -06:00
|
|
|
if ( fieldNeedingOptions == &selectedResultProperties )
|
|
|
|
{
|
2023-02-07 10:51:35 -06:00
|
|
|
if ( sourceWell && wellLogFile != nullptr )
|
2023-01-23 05:46:54 -06:00
|
|
|
{
|
2023-02-07 10:51:35 -06:00
|
|
|
for ( auto* channel : wellLogFile->wellLogChannels() )
|
2023-01-23 05:46:54 -06:00
|
|
|
{
|
2023-02-07 10:51:35 -06:00
|
|
|
if ( !m_depthProperties.contains( channel->name() ) )
|
2023-01-23 05:46:54 -06:00
|
|
|
{
|
2023-02-07 10:51:35 -06:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( channel->name(), channel->name() ) );
|
2023-01-23 05:46:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( fieldNeedingOptions == &destinationWells )
|
|
|
|
{
|
|
|
|
RimProject* proj = RimProject::current();
|
|
|
|
if ( proj )
|
|
|
|
{
|
|
|
|
std::vector<RimWellPath*> allWellPaths = proj->activeOilField()->wellPathCollection->allWellPaths();
|
|
|
|
for ( auto* wellPath : allWellPaths )
|
|
|
|
{
|
|
|
|
if ( wellPath != sourceWell )
|
|
|
|
{
|
|
|
|
options.push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RicCreateDepthAdjustedLasFilesUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
2023-01-23 05:46:54 -06:00
|
|
|
{
|
|
|
|
if ( changedField == &sourceWell )
|
|
|
|
{
|
|
|
|
selectedResultProperties.v().clear();
|
|
|
|
destinationWells.clearWithoutDelete();
|
2023-02-07 10:51:35 -06:00
|
|
|
wellLogFile = nullptr;
|
|
|
|
if ( sourceWell != nullptr && !sourceWell->wellLogFiles().empty() )
|
|
|
|
{
|
|
|
|
wellLogFile = sourceWell->wellLogFiles()[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( changedField == &wellLogFile )
|
|
|
|
{
|
|
|
|
selectedResultProperties.v().clear();
|
2023-01-23 05:46:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicCreateDepthAdjustedLasFilesUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute )
|
|
|
|
{
|
|
|
|
if ( field == &exportFolder )
|
|
|
|
{
|
|
|
|
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
|
|
|
|
if ( myAttr )
|
|
|
|
{
|
|
|
|
myAttr->m_selectDirectory = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicCreateDepthAdjustedLasFilesUi::setDefaultValues()
|
|
|
|
{
|
|
|
|
// Default folder directory
|
2023-02-26 03:48:40 -06:00
|
|
|
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "WELL_LOGS_DIR" );
|
|
|
|
exportFolder = defaultDir;
|
2023-01-23 05:46:54 -06:00
|
|
|
|
|
|
|
// Default selected case and source well
|
|
|
|
RimProject* proj = RimProject::current();
|
|
|
|
if ( proj )
|
|
|
|
{
|
|
|
|
std::vector<RimCase*> allCases;
|
|
|
|
proj->allCases( allCases );
|
|
|
|
if ( !allCases.empty() ) selectedCase = allCases[0];
|
|
|
|
|
|
|
|
std::vector<RimWellPath*> allWellPaths = proj->activeOilField()->wellPathCollection->allWellPaths();
|
|
|
|
for ( auto* wellPath : allWellPaths )
|
|
|
|
{
|
|
|
|
if ( !wellPath->wellLogFiles().empty() )
|
|
|
|
{
|
2023-02-07 10:51:35 -06:00
|
|
|
sourceWell = wellPath;
|
|
|
|
wellLogFile = wellPath->wellLogFiles()[0];
|
2023-01-23 05:46:54 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicCreateDepthAdjustedLasFilesUi::hasValidSelections() const
|
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
return !exportFolder().isEmpty() && sourceWell() != nullptr && selectedCase() != nullptr && wellLogFile != nullptr &&
|
|
|
|
!selectedResultProperties().empty() && !destinationWells.empty();
|
2023-01-23 05:46:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RicCreateDepthAdjustedLasFilesUi::invalidSelectionsLogString() const
|
|
|
|
{
|
|
|
|
if ( hasValidSelections() )
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString logStr;
|
|
|
|
if ( exportFolder().isEmpty() )
|
|
|
|
{
|
|
|
|
logStr += "Selected Export folder is empty!\n";
|
|
|
|
}
|
|
|
|
if ( selectedCase() == nullptr )
|
|
|
|
{
|
|
|
|
logStr += "Selected case is not defined!\n";
|
|
|
|
}
|
|
|
|
if ( sourceWell() == nullptr )
|
|
|
|
{
|
|
|
|
logStr += "Source well is not defined!\n";
|
|
|
|
}
|
2023-02-07 10:51:35 -06:00
|
|
|
if ( wellLogFile() == nullptr )
|
|
|
|
{
|
|
|
|
logStr += "Well log file for source well is not defined!\n";
|
|
|
|
}
|
2023-01-23 05:46:54 -06:00
|
|
|
if ( selectedResultProperties().empty() )
|
|
|
|
{
|
|
|
|
logStr += "No result properties are selected!\n";
|
|
|
|
}
|
|
|
|
if ( destinationWells.empty() )
|
|
|
|
{
|
|
|
|
logStr += "No destination wells are selected!\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return logStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicCreateDepthAdjustedLasFilesUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
|
|
{
|
|
|
|
uiOrdering.add( &exportFolder );
|
|
|
|
uiOrdering.add( &selectedCase );
|
|
|
|
uiOrdering.add( &sourceWell );
|
2023-02-07 10:51:35 -06:00
|
|
|
uiOrdering.add( &wellLogFile );
|
2023-01-23 05:46:54 -06:00
|
|
|
uiOrdering.add( &selectedResultProperties );
|
|
|
|
uiOrdering.add( &destinationWells );
|
|
|
|
|
|
|
|
uiOrdering.skipRemainingFields( true );
|
|
|
|
}
|