#821 Added export dialog with resampling support

This commit is contained in:
Magne Sjaastad 2016-09-19 11:17:36 +02:00
parent cb6d9d714b
commit 7de4f8f175
8 changed files with 200 additions and 13 deletions

View File

@ -50,6 +50,7 @@ ${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.h
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
${CEE_CURRENT_LIST_DIR}RicAddOpmInputPropertyFeature.h
@ -105,6 +106,7 @@ ${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
${CEE_CURRENT_LIST_DIR}RicAddOpmInputPropertyFeature.cpp

View File

@ -20,9 +20,11 @@
#include "RicExportToLasFileFeature.h"
#include "RiaApplication.h"
#include "RicExportToLasFileResampleUi.h"
#include "RigLasFileExporter.h"
#include "RimWellLogCurve.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
@ -49,14 +51,25 @@ void RicExportToLasFileFeature::onActionTriggered(bool isChecked)
if (curves.size() == 0) return;
QString defaultDir = RiaApplication::instance()->defaultFileDialogDirectory("WELL_LOGS_DIR");
QString exportFolder = QFileDialog::getExistingDirectory(NULL, "Select destination folder for LAS export");
if (!exportFolder.isEmpty())
RicExportToLasFileResampleUi featureUi;
featureUi.exportFolder = defaultDir;
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
if (propertyDialog.exec() == QDialog::Accepted &&
!featureUi.exportFolder().isEmpty())
{
RigLasFileExporter lasExporter(curves);
lasExporter.writeToFolder(exportFolder);
if (featureUi.activateResample)
{
lasExporter.setResamplingInterval(featureUi.resampleInterval());
}
lasExporter.writeToFolder(featureUi.exportFolder());
// Remember the path to next time
RiaApplication::instance()->setDefaultFileDialogDirectory("WELL_LOGS_DIR", exportFolder);
RiaApplication::instance()->setDefaultFileDialogDirectory("WELL_LOGS_DIR", featureUi.exportFolder());
}
}

View File

@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil 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 "RicExportToLasFileResampleUi.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RicExportToLasFileResampleUi, "RicExportToLasFileResampleUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportToLasFileResampleUi::RicExportToLasFileResampleUi(void)
{
CAF_PDM_InitObject("Resample LAS curves for export", "", "", "");
CAF_PDM_InitField(&exportFolder, "ExportFolder", QString(), "Export Folder", "", "", "");
exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&activateResample, "ActivateResample", false, "Resample Curve Data for Export", "", "", "");
CAF_PDM_InitField(&resampleInterval, "ResampleInterval", 1.0, "Resample Interval [m]", "", "", "");
updateFieldVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
updateFieldVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &exportFolder)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectDirectory = true;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::updateFieldVisibility()
{
if (activateResample)
{
resampleInterval.uiCapability()->setUiReadOnly(false);
}
else
{
resampleInterval.uiCapability()->setUiReadOnly(true);
}
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
//==================================================================================================
///
//==================================================================================================
class RicExportToLasFileResampleUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicExportToLasFileResampleUi(void);
caf::PdmField<bool> activateResample;
caf::PdmField<double> resampleInterval;
caf::PdmField<QString> exportFolder;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
private:
void updateFieldVisibility();
};

View File

@ -435,10 +435,22 @@ const RigWellLogCurveData* SingleLasFileMetaData::curveDataForFirstCurve() const
///
//--------------------------------------------------------------------------------------------------
RigLasFileExporter::RigLasFileExporter(const std::vector<RimWellLogCurve*>& curves)
: m_curves(curves)
: m_curves(curves),
m_isResampleActive(false),
m_resamplingInterval(1.0)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigLasFileExporter::setResamplingInterval(double interval)
{
m_isResampleActive = true;
m_resamplingInterval = interval;
m_resampledCurveDatas.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -577,7 +589,19 @@ void RigLasFileExporter::appendLasFileDescriptions(const std::vector<RimWellLogC
{
if (curveDef.isEqual(curve, caseNameFromCurve(curve)))
{
singleLasFileMeta.addLogData(curve->wellLogChannelName().toStdString(), "NO_UNIT", "", curve->curveData());
const RigWellLogCurveData* curveData = nullptr;
if (m_isResampleActive)
{
cvf::ref<RigWellLogCurveData> resampledData = curve->curveData()->calculateResampledCurveData(m_resamplingInterval);
m_resampledCurveDatas.push_back(resampledData.p());
curveData = resampledData.p();
}
else
{
curveData = curve->curveData();
}
singleLasFileMeta.addLogData(curve->wellLogChannelName().toStdString(), "NO_UNIT", "", curveData);
}
}

View File

@ -18,11 +18,12 @@
#pragma once
#include "cvfCollection.h"
#include <QString>
#include <vector>
class RimWellLogCurve;
class RigWellLogCurveData;
class SingleLasFileMetaData;
class RigLasFileExporter
@ -30,6 +31,8 @@ class RigLasFileExporter
public:
RigLasFileExporter(const std::vector<RimWellLogCurve*>& curves);
void setResamplingInterval(double interval);
bool writeToFolder(const QString& exportFolder);
private:
@ -40,4 +43,8 @@ private:
private:
std::vector<RimWellLogCurve*> m_curves;
bool m_isResampleActive;
double m_resamplingInterval;
cvf::Collection<RigWellLogCurveData> m_resampledCurveDatas;
};

View File

@ -178,14 +178,18 @@ std::vector< std::pair<size_t, size_t> > RigWellLogCurveData::polylineStartStopI
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateReSampeledCurveData(double newMeasuredDepthStepSize)
cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateResampledCurveData(double newMeasuredDepthStepSize) const
{
std::vector<double> xValues;
std::vector<double> measuredDepths;
bool isTvDepthsAvailable = false;
std::vector<double> tvDepths;
size_t segmentStartIdx = 0;
if (m_tvDepths.size() > 0) isTvDepthsAvailable = true;
if(m_measuredDepths.size() > 0)
{
double currentMd = m_measuredDepths[0];
@ -196,8 +200,14 @@ cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateReSampeledCurveData(
double segmentEndMd = m_measuredDepths[segmentStartIdx + 1];
double segmentStartX = m_xValues[segmentStartIdx];
double segmentEndX = m_xValues[segmentStartIdx +1];
double segmentStartTvd = tvDepths[segmentStartIdx];
double segmentEndTvd = tvDepths[segmentStartIdx +1];
double segmentStartTvd = 0.0;
double segmentEndTvd = 0.0;
if (isTvDepthsAvailable)
{
segmentStartTvd = m_tvDepths[segmentStartIdx];
segmentEndTvd = m_tvDepths[segmentStartIdx +1];
}
while(currentMd <= segmentEndMd)
{
@ -208,7 +218,10 @@ cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateReSampeledCurveData(
// The tvd calculation is a simplification. We should use the wellpath, as it might have a better resolution, and have a none-linear shape
// This is much simpler, and possibly accurate enough ?
tvDepths.push_back((1.0-endWeight) * segmentStartTvd + endWeight*segmentEndTvd);
if (isTvDepthsAvailable)
{
tvDepths.push_back((1.0-endWeight) * segmentStartTvd + endWeight*segmentEndTvd);
}
currentMd += newMeasuredDepthStepSize;
}
@ -219,7 +232,14 @@ cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateReSampeledCurveData(
cvf::ref<RigWellLogCurveData> reSampledData = new RigWellLogCurveData;
reSampledData->setValuesWithTVD(xValues, measuredDepths, tvDepths, m_depthUnit);
if (isTvDepthsAvailable)
{
reSampledData->setValuesWithTVD(xValues, measuredDepths, tvDepths, m_depthUnit);
}
else
{
reSampledData->setValuesAndMD(xValues, measuredDepths, m_depthUnit, m_isExtractionCurve);
}
return reSampledData;
}

View File

@ -59,7 +59,8 @@ public:
std::vector<double> measuredDepthPlotValues(RimDefines::DepthUnitType destinationDepthUnit) const;
std::vector< std::pair<size_t, size_t> > polylineStartStopIndices() const;
cvf::ref<RigWellLogCurveData> calculateReSampeledCurveData(double newMeasuredDepthStepSize);
cvf::ref<RigWellLogCurveData> calculateResampledCurveData(double newMeasuredDepthStepSize) const;
private:
void calculateIntervalsOfContinousValidValues();