#906 Las Export: Fixed issue with TVDRKB export and improved UI

This commit is contained in:
Magne Sjaastad
2016-10-14 13:30:04 +02:00
parent 929c1d1633
commit 71f1966c1c
6 changed files with 241 additions and 12 deletions

View File

@@ -55,21 +55,39 @@ void RicExportToLasFileFeature::onActionTriggered(bool isChecked)
QString projectFolder = app->currentProjectPath(); QString projectFolder = app->currentProjectPath();
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("WELL_LOGS_DIR", projectFolder); QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("WELL_LOGS_DIR", projectFolder);
RigLasFileExporter lasExporter(curves);
RicExportToLasFileResampleUi featureUi; RicExportToLasFileResampleUi featureUi;
featureUi.exportFolder = defaultDir; featureUi.exportFolder = defaultDir;
{
std::vector<QString> wellNames;
std::vector<double> rkbDiffs;
lasExporter.wellPathsAndRkbDiff(&wellNames, &rkbDiffs);
featureUi.setRkbDiffs(wellNames, rkbDiffs);
}
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
propertyDialog.resize(QSize(400, 200)); propertyDialog.resize(QSize(400, 200));
if (propertyDialog.exec() == QDialog::Accepted && if (propertyDialog.exec() == QDialog::Accepted &&
!featureUi.exportFolder().isEmpty()) !featureUi.exportFolder().isEmpty())
{ {
RigLasFileExporter lasExporter(curves);
if (featureUi.activateResample) if (featureUi.activateResample)
{ {
lasExporter.setResamplingInterval(featureUi.resampleInterval()); lasExporter.setResamplingInterval(featureUi.resampleInterval());
} }
if (featureUi.exportTvdrkb)
{
std::vector<QString> wellNames;
std::vector<double> rkbDiffs;
lasExporter.wellPathsAndRkbDiff(&wellNames, &rkbDiffs);
std::vector<double> userDefRkbDiff;
featureUi.tvdrkbDiffForWellPaths(&userDefRkbDiff);
lasExporter.setRkbDiffs(wellNames, userDefRkbDiff);
}
lasExporter.writeToFolder(featureUi.exportFolder()); lasExporter.writeToFolder(featureUi.exportFolder());
// Remember the path to next time // Remember the path to next time

View File

@@ -18,6 +18,20 @@
#include "RicExportToLasFileResampleUi.h" #include "RicExportToLasFileResampleUi.h"
#include "cafPdmUiFilePathEditor.h" #include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiCheckBoxEditor.h"
CAF_PDM_SOURCE_INIT(RicExportToLasFileObj, "RicExportToLasFileObj");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportToLasFileObj::RicExportToLasFileObj(void)
{
CAF_PDM_InitObject("RicExportToLasFileObj", "", "", "");
CAF_PDM_InitField(&tvdrkbOffset, "tvdrkbOffset", 0.0, "TVDRKB offset (RKB - MSL) [m]", "", "", "");
}
CAF_PDM_SOURCE_INIT(RicExportToLasFileResampleUi, "RicExportToLasFileResampleUi"); CAF_PDM_SOURCE_INIT(RicExportToLasFileResampleUi, "RicExportToLasFileResampleUi");
@@ -32,11 +46,52 @@ RicExportToLasFileResampleUi::RicExportToLasFileResampleUi(void)
exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&activateResample, "ActivateResample", false, "Resample Curve Data", "", "", ""); CAF_PDM_InitField(&activateResample, "ActivateResample", false, "Resample Curve Data", "", "", "");
activateResample.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&resampleInterval, "ResampleInterval", 1.0, "Resample Interval [m]", "", "", ""); CAF_PDM_InitField(&resampleInterval, "ResampleInterval", 1.0, "Resample Interval [m]", "", "", "");
CAF_PDM_InitField(&exportTvdrkb, "ExportTvdrkb", false, "Export TVDRKB", "", "", "");
exportTvdrkb.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitFieldNoDefault(&m_tvdrkbOffsets, "tvdrkbOffsets", "", "", "", "");
updateFieldVisibility(); updateFieldVisibility();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportToLasFileResampleUi::~RicExportToLasFileResampleUi()
{
m_tvdrkbOffsets.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::tvdrkbDiffForWellPaths(std::vector<double>* rkbDiffs)
{
for (size_t i = 0; i < m_tvdrkbOffsets.size(); i++)
{
rkbDiffs->push_back(m_tvdrkbOffsets()[i]->tvdrkbOffset);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::setRkbDiffs(const std::vector<QString>& wellNames, const std::vector<double>& rkbDiffs)
{
for (size_t i = 0; i < wellNames.size(); i++)
{
RicExportToLasFileObj* obj = new RicExportToLasFileObj;
obj->tvdrkbOffset = rkbDiffs[i];
obj->tvdrkbOffset.uiCapability()->setUiName(wellNames[i]);
m_tvdrkbOffsets.push_back(obj);
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -58,6 +113,15 @@ void RicExportToLasFileResampleUi::defineEditorAttribute(const caf::PdmFieldHand
myAttr->m_selectDirectory = true; myAttr->m_selectDirectory = true;
} }
} }
if (field == &exportTvdrkb || field == &activateResample)
{
caf::PdmUiCheckBoxEditorAttribute* myAttr = static_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_useNativeCheckBoxLabel = true;
}
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -73,4 +137,31 @@ void RicExportToLasFileResampleUi::updateFieldVisibility()
{ {
resampleInterval.uiCapability()->setUiReadOnly(true); resampleInterval.uiCapability()->setUiReadOnly(true);
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&exportFolder);
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup("Resampling");
group->add(&activateResample);
group->add(&resampleInterval);
}
caf::PdmUiGroup* tvdrkbGroup = uiOrdering.addNewGroup("TVDRKB");
tvdrkbGroup->add(&exportTvdrkb);
caf::PdmUiGroup* group = tvdrkbGroup->addNewGroup("Difference between TVDRKB and TVDMSL");
for (auto& obj : m_tvdrkbOffsets)
{
group->add(&obj->tvdrkbOffset);
}
}

View File

@@ -20,6 +20,22 @@
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "cafPdmChildArrayField.h"
//==================================================================================================
///
//==================================================================================================
class RicExportToLasFileObj : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicExportToLasFileObj(void);
caf::PdmField<double> tvdrkbOffset;
};
//================================================================================================== //==================================================================================================
/// ///
@@ -30,15 +46,28 @@ class RicExportToLasFileResampleUi : public caf::PdmObject
public: public:
RicExportToLasFileResampleUi(void); RicExportToLasFileResampleUi(void);
~RicExportToLasFileResampleUi();
caf::PdmField<QString> exportFolder;
caf::PdmField<bool> activateResample; caf::PdmField<bool> activateResample;
caf::PdmField<double> resampleInterval; caf::PdmField<double> resampleInterval;
caf::PdmField<QString> exportFolder;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); caf::PdmField<bool> exportTvdrkb;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
void tvdrkbDiffForWellPaths(std::vector<double>* rkbDiffs);
void setRkbDiffs(const std::vector<QString>& wellNames, const std::vector<double>& rkbDiffs);
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
protected:
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
private: private:
void updateFieldVisibility(); void updateFieldVisibility();
private:
caf::PdmChildArrayField<RicExportToLasFileObj*> m_tvdrkbOffsets;
}; };

View File

@@ -642,8 +642,15 @@ double RimWellLogExtractionCurve::rkbDiff() const
{ {
if (m_wellPath && m_wellPath->wellPathGeometry()) if (m_wellPath && m_wellPath->wellPathGeometry())
{ {
return cvf::Math::abs(m_wellPath->wellPathGeometry()->m_measuredDepths[0] - m_wellPath->wellPathGeometry()->m_wellPathPoints[0].z()); RigWellPath* geo = m_wellPath->wellPathGeometry();
if (geo->m_wellPathPoints.size() > 0 && geo->m_measuredDepths.size() > 0)
{
double diff = cvf::Math::abs(cvf::Math::abs(geo->m_wellPathPoints[0].z()) - geo->m_measuredDepths[0]);
return diff;
}
} }
return HUGE_VAL; return -1.0;
} }

View File

@@ -91,7 +91,8 @@ class SingleLasFileMetaData
public: public:
SingleLasFileMetaData() SingleLasFileMetaData()
: m_minimumCurveValue(HUGE_VAL), : m_minimumCurveValue(HUGE_VAL),
m_rkbDiff(HUGE_VAL) m_rkbDiff(HUGE_VAL),
m_exportTvdrkb(false)
{ {
} }
@@ -100,6 +101,11 @@ public:
m_wellName = wellName; m_wellName = wellName;
} }
QString wellName()
{
return m_wellName;
}
void setCaseName(const QString& caseName) void setCaseName(const QString& caseName)
{ {
m_caseName = caseName; m_caseName = caseName;
@@ -115,6 +121,16 @@ public:
m_rkbDiff = rkbDiff; m_rkbDiff = rkbDiff;
} }
void enableTvdrkbExport()
{
m_exportTvdrkb = true;
}
double rkbDiff()
{
return m_rkbDiff;
}
void addLogData(const std::string& channelName, const std::string& unit, const std::string& comment, const RigWellLogCurveData* curveData) void addLogData(const std::string& channelName, const std::string& unit, const std::string& comment, const RigWellLogCurveData* curveData)
{ {
m_logCurveData.push_back(SingleChannelData(channelName, unit, comment, curveData)); m_logCurveData.push_back(SingleChannelData(channelName, unit, comment, curveData));
@@ -198,7 +214,7 @@ public:
{ {
lasFile->AddLog("TVDMSL", "M", "True vertical depth in meters", firstCurveData->tvDepths()); lasFile->AddLog("TVDMSL", "M", "True vertical depth in meters", firstCurveData->tvDepths());
if (m_rkbDiff != HUGE_VAL) if (m_exportTvdrkb && m_rkbDiff != -1.0)
{ {
// Export True Vertical Depth Rotary Kelly Bushing - TVDRKB // Export True Vertical Depth Rotary Kelly Bushing - TVDRKB
std::vector<double> tvdrkbValues = firstCurveData->tvDepths(); std::vector<double> tvdrkbValues = firstCurveData->tvDepths();
@@ -269,7 +285,9 @@ private:
QString m_wellName; QString m_wellName;
QString m_caseName; QString m_caseName;
QString m_date; QString m_date;
double m_rkbDiff; double m_rkbDiff;
double m_exportTvdrkb;
RimDefines::DepthUnitType m_depthUnit; RimDefines::DepthUnitType m_depthUnit;
std::vector<double> m_depthValues; std::vector<double> m_depthValues;
@@ -298,6 +316,49 @@ void RigLasFileExporter::setResamplingInterval(double interval)
m_resampledCurveDatas.clear(); m_resampledCurveDatas.clear();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigLasFileExporter::wellPathsAndRkbDiff(std::vector<QString>* wellNames, std::vector<double>* rkbDiffs)
{
std::vector<SingleLasFileMetaData> lasFileDescriptions = createLasFileDescriptions(m_curves);
std::set<QString> uniqueWellNames;
for (auto metaData : lasFileDescriptions)
{
QString wellName = metaData.wellName();
if (uniqueWellNames.find(wellName) == uniqueWellNames.end())
{
uniqueWellNames.insert(wellName);
wellNames->push_back(wellName);
rkbDiffs->push_back(metaData.rkbDiff());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigLasFileExporter::setRkbDiffs(const std::vector<QString>& wellNames, const std::vector<double>& rkbDiffs)
{
assert(wellNames.size() == rkbDiffs.size());
std::vector<SingleLasFileMetaData> lasFileDescriptions = createLasFileDescriptions(m_curves);
for (size_t i = 0; i < wellNames.size(); i++)
{
for (auto& metaData : lasFileDescriptions)
{
if (metaData.wellName() == wellNames[i])
{
m_userDefinedRkbOffsets.push_back(rkbDiffs[i]);
}
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -305,6 +366,8 @@ bool RigLasFileExporter::writeToFolder(const QString& exportFolder)
{ {
std::vector<SingleLasFileMetaData> lasFileDescriptions = createLasFileDescriptions(m_curves); std::vector<SingleLasFileMetaData> lasFileDescriptions = createLasFileDescriptions(m_curves);
applyUserDefinedRkbOffsets(&lasFileDescriptions);
for (auto lasFileDescr : lasFileDescriptions) for (auto lasFileDescr : lasFileDescriptions)
{ {
NRLib::LasWell lasFile; NRLib::LasWell lasFile;
@@ -494,6 +557,21 @@ double RigLasFileExporter::rkbDiff(RimWellLogCurve* curve)
return extractionCurve->rkbDiff(); return extractionCurve->rkbDiff();
} }
return HUGE_VAL; return -1.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigLasFileExporter::applyUserDefinedRkbOffsets(std::vector<SingleLasFileMetaData>* lasFileDescriptions)
{
if (m_userDefinedRkbOffsets.size() == lasFileDescriptions->size())
{
for (size_t i = 0; i < m_userDefinedRkbOffsets.size(); i++)
{
lasFileDescriptions->at(i).setRkbDiff(m_userDefinedRkbOffsets[i]);
lasFileDescriptions->at(i).enableTvdrkbExport();
}
}
} }

View File

@@ -36,6 +36,9 @@ public:
void setResamplingInterval(double interval); void setResamplingInterval(double interval);
void wellPathsAndRkbDiff(std::vector<QString>* wellNames, std::vector<double>* rkbDiffs);
void setRkbDiffs(const std::vector<QString>& wellNames, const std::vector<double>& rkbDiffs);
bool writeToFolder(const QString& exportFolder); bool writeToFolder(const QString& exportFolder);
private: private:
@@ -45,8 +48,11 @@ private:
QString caseNameFromCurve(RimWellLogCurve* curve); QString caseNameFromCurve(RimWellLogCurve* curve);
double rkbDiff(RimWellLogCurve* curve); double rkbDiff(RimWellLogCurve* curve);
void applyUserDefinedRkbOffsets(std::vector<SingleLasFileMetaData>* lasFileDescriptions);
private: private:
std::vector<RimWellLogCurve*> m_curves; std::vector<RimWellLogCurve*> m_curves;
std::vector<double> m_userDefinedRkbOffsets;
bool m_isResampleActive; bool m_isResampleActive;
double m_resamplingInterval; double m_resamplingInterval;