2015-10-15 04:27:12 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-10-15 04:27:12 -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-10-15 04:27:12 -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-10-15 04:27:12 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicExportToLasFileFeature.h"
|
|
|
|
|
2017-06-28 03:13:59 -05:00
|
|
|
#include "RicExportFeatureImpl.h"
|
2016-09-19 04:17:36 -05:00
|
|
|
#include "RicExportToLasFileResampleUi.h"
|
2017-02-24 07:14:29 -06:00
|
|
|
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2016-09-16 05:46:25 -05:00
|
|
|
#include "RigLasFileExporter.h"
|
2017-02-24 07:14:29 -06:00
|
|
|
#include "RigWellLogCurveData.h"
|
2015-10-15 04:27:12 -05:00
|
|
|
|
2017-02-24 07:14:29 -06:00
|
|
|
#include "RimWellLogCurve.h"
|
2019-10-09 02:21:28 -05:00
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
#include "RimWellLogTrack.h"
|
2016-12-17 09:29:36 -06:00
|
|
|
|
2016-09-19 04:17:36 -05:00
|
|
|
#include "cafPdmUiPropertyViewDialog.h"
|
2015-10-15 04:27:12 -05:00
|
|
|
#include "cafSelectionManager.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2015-10-15 04:27:12 -05:00
|
|
|
#include <QAction>
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicExportToLasFileFeature, "RicExportToLasFileFeature" );
|
2016-09-16 05:46:25 -05:00
|
|
|
|
2019-10-09 02:21:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<QString> RicExportToLasFileFeature::exportToLasFiles( const QString& exportFolder,
|
|
|
|
const QString& exportPrefix,
|
2019-10-11 08:54:19 -05:00
|
|
|
const RimWellLogPlot* plotWindow,
|
2019-10-09 02:21:28 -05:00
|
|
|
bool exportTvdRkb,
|
|
|
|
bool capitalizeFileNames,
|
2020-01-08 07:52:28 -06:00
|
|
|
bool alwaysOverwrite,
|
2019-10-09 02:21:28 -05:00
|
|
|
double resampleInterval )
|
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
std::vector<RimWellLogCurve*> allCurves;
|
|
|
|
std::vector<RimPlot*> plots = plotWindow->visiblePlots();
|
2019-10-09 02:21:28 -05:00
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( RimPlot* plot : plots )
|
2019-10-09 02:21:28 -05:00
|
|
|
{
|
2019-10-11 08:54:19 -05:00
|
|
|
RimWellLogTrack* track = dynamic_cast<RimWellLogTrack*>( plot );
|
|
|
|
if ( track )
|
|
|
|
{
|
|
|
|
std::vector<RimWellLogCurve*> curves = track->visibleCurves();
|
|
|
|
allCurves.insert( allCurves.end(), curves.begin(), curves.end() );
|
|
|
|
}
|
2019-10-09 02:21:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<QString> wellNames;
|
|
|
|
std::vector<double> rkbDiffs;
|
|
|
|
{
|
|
|
|
RigLasFileExporter lasExporter( allCurves );
|
|
|
|
lasExporter.wellPathsAndRkbDiff( &wellNames, &rkbDiffs );
|
|
|
|
|
|
|
|
return exportToLasFiles( exportFolder,
|
|
|
|
exportPrefix,
|
|
|
|
allCurves,
|
|
|
|
wellNames,
|
|
|
|
rkbDiffs,
|
|
|
|
capitalizeFileNames,
|
2020-01-08 07:52:28 -06:00
|
|
|
alwaysOverwrite,
|
2019-10-09 02:21:28 -05:00
|
|
|
resampleInterval );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<QString> RicExportToLasFileFeature::exportToLasFiles( const QString& exportFolder,
|
|
|
|
const QString& filePrefix,
|
|
|
|
std::vector<RimWellLogCurve*> curves,
|
|
|
|
const std::vector<QString>& wellNames,
|
|
|
|
const std::vector<double>& rkbDiffs,
|
|
|
|
bool capitalizeFileNames,
|
2020-01-08 07:52:28 -06:00
|
|
|
bool alwaysOverwrite,
|
2019-10-09 02:21:28 -05:00
|
|
|
double resampleInterval )
|
|
|
|
{
|
|
|
|
RigLasFileExporter lasExporter( curves );
|
|
|
|
|
|
|
|
std::vector<QString> writtenFiles;
|
|
|
|
|
|
|
|
if ( resampleInterval > 0.0 )
|
|
|
|
{
|
|
|
|
lasExporter.setResamplingInterval( resampleInterval );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !rkbDiffs.empty() )
|
|
|
|
{
|
|
|
|
lasExporter.setRkbDiffs( wellNames, rkbDiffs );
|
|
|
|
}
|
|
|
|
|
2020-01-08 07:52:28 -06:00
|
|
|
writtenFiles = lasExporter.writeToFolder( exportFolder, filePrefix, capitalizeFileNames, alwaysOverwrite );
|
2019-10-09 02:21:28 -05:00
|
|
|
|
|
|
|
// Remember the path to next time
|
|
|
|
RiaApplication::instance()->setLastUsedDialogDirectory( "WELL_LOGS_DIR", exportFolder );
|
|
|
|
return writtenFiles;
|
|
|
|
}
|
|
|
|
|
2015-10-15 04:27:12 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-10-15 04:27:12 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicExportToLasFileFeature::isCommandEnabled()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return false;
|
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellRftPlot() ) return false;
|
2017-02-07 02:34:11 -06:00
|
|
|
|
2016-12-17 09:29:36 -06:00
|
|
|
return RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves().size() > 0;
|
2015-10-15 04:27:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-10-15 04:27:12 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicExportToLasFileFeature::onActionTriggered( bool isChecked )
|
2015-10-15 04:27:12 -05:00
|
|
|
{
|
2017-04-20 03:38:58 -05:00
|
|
|
this->disableModelChangeContribution();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return;
|
2017-02-07 02:34:11 -06:00
|
|
|
|
2016-12-17 09:29:36 -06:00
|
|
|
std::vector<RimWellLogCurve*> curves = RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( curves.size() == 0 ) return;
|
2015-10-15 07:39:53 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder(
|
|
|
|
"WELL_LOGS_DIR" );
|
2016-09-19 04:17:36 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RigLasFileExporter lasExporter( curves );
|
2016-09-19 04:17:36 -05:00
|
|
|
RicExportToLasFileResampleUi featureUi;
|
|
|
|
featureUi.exportFolder = defaultDir;
|
2016-10-14 06:30:04 -05:00
|
|
|
|
2019-09-30 04:59:51 -05:00
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellBoreStabilityPlot() )
|
|
|
|
{
|
|
|
|
featureUi.filePrefix = "WBS_";
|
|
|
|
featureUi.capitalizeFileName = true;
|
|
|
|
}
|
|
|
|
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
|
|
|
std::vector<QString> wellNames;
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<double> rkbDiffs;
|
|
|
|
lasExporter.wellPathsAndRkbDiff( &wellNames, &rkbDiffs );
|
|
|
|
featureUi.setRkbDiffs( wellNames, rkbDiffs );
|
2016-10-14 06:30:04 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
|
|
|
|
caf::PdmUiPropertyViewDialog propertyDialog( nullptr,
|
|
|
|
&featureUi,
|
|
|
|
"Export Curve Data to LAS file(s)",
|
|
|
|
"",
|
|
|
|
QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
|
|
|
RicExportFeatureImpl::configureForExport( propertyDialog.dialogButtonBox() );
|
|
|
|
propertyDialog.resize( QSize( 400, 330 ) );
|
|
|
|
|
|
|
|
if ( propertyDialog.exec() == QDialog::Accepted && !featureUi.exportFolder().isEmpty() )
|
2016-09-16 05:46:25 -05:00
|
|
|
{
|
2019-10-09 02:21:28 -05:00
|
|
|
double resampleInterval = 0.0;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( featureUi.activateResample )
|
2016-09-19 04:17:36 -05:00
|
|
|
{
|
2019-10-09 02:21:28 -05:00
|
|
|
resampleInterval = featureUi.resampleInterval();
|
2016-09-19 04:17:36 -05:00
|
|
|
}
|
|
|
|
|
2019-10-09 02:21:28 -05:00
|
|
|
std::vector<QString> wellNames;
|
|
|
|
std::vector<double> rkbDiffs;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( featureUi.exportTvdrkb )
|
2016-10-14 06:30:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
lasExporter.wellPathsAndRkbDiff( &wellNames, &rkbDiffs );
|
2016-10-14 06:30:04 -05:00
|
|
|
std::vector<double> userDefRkbDiff;
|
2019-09-06 03:40:57 -05:00
|
|
|
featureUi.tvdrkbDiffForWellPaths( &userDefRkbDiff );
|
2019-10-09 02:21:28 -05:00
|
|
|
rkbDiffs = userDefRkbDiff;
|
2016-10-14 06:30:04 -05:00
|
|
|
}
|
|
|
|
|
2019-10-09 02:21:28 -05:00
|
|
|
exportToLasFiles( featureUi.exportFolder(),
|
|
|
|
featureUi.filePrefix(),
|
|
|
|
curves,
|
|
|
|
wellNames,
|
|
|
|
rkbDiffs,
|
|
|
|
featureUi.capitalizeFileName,
|
2020-01-08 07:52:28 -06:00
|
|
|
false,
|
2019-10-09 02:21:28 -05:00
|
|
|
resampleInterval );
|
2015-10-15 04:27:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-10-15 04:27:12 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicExportToLasFileFeature::setupActionLook( QAction* actionToSetup )
|
2015-10-15 04:27:12 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Export To LAS Files..." );
|
2015-10-15 04:27:12 -05:00
|
|
|
}
|