diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 7eb6bd43ad..720c3e0e6d 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -47,7 +47,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h ${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h ${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h - +${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h # General delete of any object in a child array field ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h @@ -95,6 +95,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.cpp ${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp +${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp # General delete of any object in a child array field diff --git a/ApplicationCode/Commands/RicExportToLasFileFeature.cpp b/ApplicationCode/Commands/RicExportToLasFileFeature.cpp new file mode 100644 index 0000000000..f54d5d371a --- /dev/null +++ b/ApplicationCode/Commands/RicExportToLasFileFeature.cpp @@ -0,0 +1,80 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicExportToLasFileFeature.h" + +#include "RimWellLogPlotCurve.h" +#include "RigWellLogFile.h" + +#include "RiuMainWindow.h" + +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicExportToLasFileFeature, "RicExportToLasFileFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportToLasFileFeature::isCommandEnabled() +{ + return selectedWellLogPlotCurve() != NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportToLasFileFeature::onActionTriggered(bool isChecked) +{ + RimWellLogPlotCurve* curve = selectedWellLogPlotCurve(); + if (curve) + { + QString fileName = QFileDialog::getSaveFileName(RiuMainWindow::instance(), tr("Export Curve Data To LAS File"), "", tr("LAS Files (*.las);;All files(*.*)")); + if (!fileName.isEmpty()) + { + RigWellLogFile::exportToLasFile(curve, fileName); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportToLasFileFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Export To LAS File..."); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlotCurve* RicExportToLasFileFeature::selectedWellLogPlotCurve() const +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); + + if (selection.size() > 0) + { + return selection[0]; + } + + return NULL; +} diff --git a/ApplicationCode/Commands/RicExportToLasFileFeature.h b/ApplicationCode/Commands/RicExportToLasFileFeature.h new file mode 100644 index 0000000000..527fb64169 --- /dev/null +++ b/ApplicationCode/Commands/RicExportToLasFileFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimWellLogPlotCurve; + +//================================================================================================== +/// +//================================================================================================== +class RicExportToLasFileFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + RimWellLogPlotCurve* selectedWellLogPlotCurve() const; +}; + + diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index b23700f9f2..b1a3f71ffb 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -826,6 +826,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu) } else if (dynamic_cast(uiItem)) { + commandIds << "RicExportToLasFileFeature"; commandIds << "RicDeleteItemFeature"; } else if (dynamic_cast(uiItem)) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 093c0cdc60..8bbf1fc3db 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -195,9 +195,8 @@ void RimWellLogExtractionCurve::updatePlotData() cvf::ref eclExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, eclipseCase); cvf::ref geomExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, geomCase); - std::vector filteredValues; - std::vector filteredDepths; - std::vector< std::pair > plotIntervals; + std::vector values; + std::vector depthValues; if (eclExtractor.notNull()) { @@ -205,7 +204,7 @@ void RimWellLogExtractionCurve::updatePlotData() firstAnchestorOrThisOfType(wellLogPlot); CVF_ASSERT(wellLogPlot); - const std::vector& depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? eclExtractor->measuredDepth() : eclExtractor->trueVerticalDepth(); + depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? eclExtractor->measuredDepth() : eclExtractor->trueVerticalDepth(); RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel()); m_eclipseResultDefinition->loadResult(); @@ -216,19 +215,10 @@ void RimWellLogExtractionCurve::updatePlotData() m_timeStep, m_eclipseResultDefinition->resultVariable()); - std::vector values; - if (resAcc.notNull()) { eclExtractor->curveData(resAcc.p(), &values); } - - if (values.size() > 0 && values.size() == depthValues.size()) - { - RimWellLogCurveImpl::validCurvePointIntervals(depthValues, values, plotIntervals); - RimWellLogCurveImpl::addValuesFromIntervals(depthValues, plotIntervals, &filteredDepths); - RimWellLogCurveImpl::addValuesFromIntervals(values, plotIntervals, &filteredValues); - } } else if (geomExtractor.notNull()) // geomExtractor { @@ -236,32 +226,22 @@ void RimWellLogExtractionCurve::updatePlotData() firstAnchestorOrThisOfType(wellLogPlot); CVF_ASSERT(wellLogPlot); - const std::vector& depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? geomExtractor->measuredDepth() : geomExtractor->trueVerticalDepth(); + depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? geomExtractor->measuredDepth() : geomExtractor->trueVerticalDepth(); m_geomResultDefinition->loadResult(); - std::vector values; geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, &values); - - if (values.size() > 0 && values.size() == depthValues.size()) - { - RimWellLogCurveImpl::validCurvePointIntervals(depthValues, values, plotIntervals); - RimWellLogCurveImpl::addValuesFromIntervals(depthValues, plotIntervals, &filteredDepths); - RimWellLogCurveImpl::addValuesFromIntervals(values, plotIntervals, &filteredValues); - } } - m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredValues.size()); + m_curveData = new RigWellLogCurveData; - std::vector< std::pair > fltrIntervals; - RimWellLogCurveImpl::filteredIntervals(plotIntervals, &fltrIntervals); - - m_plotCurve->setPlotIntervals(fltrIntervals); - - if (filteredValues.size()) + if (values.size() == depthValues.size()) { - updateTrackAndPlotFromCurveData(); + m_curveData->setPoints(values, depthValues); } + m_plotCurve->setCurveData(m_curveData.p()); + updateTrackAndPlotFromCurveData(); + if (m_plot) m_plot->replot(); } } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp index a6f43287e3..445cb8a61c 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -72,6 +72,8 @@ void RimWellLogFileCurve::updatePlotData() if (isCurveVisibile()) { + m_curveData = new RigWellLogCurveData; + if (m_wellPath) { RimWellLogFile* logFileInfo = m_wellPath->m_wellLogFile; @@ -83,25 +85,9 @@ void RimWellLogFileCurve::updatePlotData() std::vector values = wellLogFile->values(m_wellLogChannnelName); std::vector depthValues = wellLogFile->depthValues(); - if (values.size() > 0 && depthValues.size() > 0) - { - std::vector< std::pair > valuesIntervals; - RimWellLogCurveImpl::calculateIntervalsOfValidValues(values, valuesIntervals); - - std::vector filteredValues; - std::vector filteredDepths; - RimWellLogCurveImpl::addValuesFromIntervals(values, valuesIntervals, &filteredValues); - RimWellLogCurveImpl::addValuesFromIntervals(depthValues, valuesIntervals, &filteredDepths); - - std::vector< std::pair > fltrIntervals; - RimWellLogCurveImpl::filteredIntervals(valuesIntervals, &fltrIntervals); - - m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredDepths.size()); - m_plotCurve->setPlotIntervals(fltrIntervals); - } - else + if (values.size() == depthValues.size()) { - m_plotCurve->setSamples(NULL, NULL, 0); + m_curveData->setPoints(values, depthValues); } } @@ -111,10 +97,8 @@ void RimWellLogFileCurve::updatePlotData() } } } - else - { - m_plotCurve->setSamples(NULL, NULL, 0); - } + + m_plotCurve->setCurveData(m_curveData.p()); updateTrackAndPlotFromCurveData(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp index 260be442b2..5c6a0f12d9 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp @@ -291,3 +291,11 @@ void RimWellLogPlotCurve::updateOptionSensitivity() { m_curveName.uiCapability()->setUiReadOnly(m_autoName); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigWellLogCurveData* RimWellLogPlotCurve::curveData() const +{ + return m_curveData.p(); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h index d4e467d7e0..06408eea96 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h @@ -23,8 +23,11 @@ #include "cafPdmFieldCvfColor.h" #include "cafPdmObject.h" +#include "RigWellLogCurveData.h" + #include +class RigWellLogCurveData; class RiuWellLogTrackPlot; class RiuWellLogPlotCurve; class QwtPlotCurve; @@ -51,8 +54,10 @@ public: bool isCurveVisibile(); - QwtPlotCurve* plotCurve() const; + QwtPlotCurve* plotCurve() const; + const RigWellLogCurveData* curveData() const; + QString name() const { return m_curveName; } void updateCurveName(); void updatePlotTitle(); @@ -73,8 +78,9 @@ protected: virtual void initAfterRead(); - RiuWellLogTrackPlot* m_plot; - RiuWellLogPlotCurve* m_plotCurve; + RiuWellLogTrackPlot* m_plot; + RiuWellLogPlotCurve* m_plotCurve; + cvf::ref m_curveData; caf::PdmField m_showCurve; caf::PdmField m_curveName; diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 62e27b2eb8..21ddac0704 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -36,7 +36,7 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h ${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.h ${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.h -${CEE_CURRENT_LIST_DIR}RigWellLogFile.h +${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -67,7 +67,7 @@ ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp ${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp +${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake index ac7dea5e41..eba1c35116 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake @@ -7,11 +7,13 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.h ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.h + ${CEE_CURRENT_LIST_DIR}RigWellLogFile.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.cpp ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.cpp + ${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp new file mode 100644 index 0000000000..fe5bbbfaf9 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -0,0 +1,187 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigWellLogCurveData.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellLogCurveData::RigWellLogCurveData() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellLogCurveData::~RigWellLogCurveData() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigWellLogCurveData::setPoints(const std::vector& xValues, const std::vector& yValues) +{ + CVF_ASSERT(xValues.size() == yValues.size()); + + m_xValues = xValues; + m_yValues = yValues; + + calculateValidPointIntervals(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigWellLogCurveData::xValues() const +{ + return m_xValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigWellLogCurveData::yValues() const +{ + return m_yValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector< std::pair >& RigWellLogCurveData::intervals() const +{ + return m_validPointIntervals; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellLogCurveData::validXValues() const +{ + std::vector filteredValues; + addValuesFromIntervals(m_xValues, m_validPointIntervals, &filteredValues); + + return filteredValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellLogCurveData::validYValues() const +{ + std::vector filteredValues; + addValuesFromIntervals(m_yValues, m_validPointIntervals, &filteredValues); + + return filteredValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector< std::pair > RigWellLogCurveData::validPointsIntervals() const +{ + std::vector< std::pair > intervals; + filteredIntervals(m_validPointIntervals, &intervals); + + return intervals; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigWellLogCurveData::calculateValidPointIntervals() +{ + calculateIntervalsOfValidValues(m_xValues, &m_validPointIntervals); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigWellLogCurveData::calculateIntervalsOfValidValues(const std::vector& values, std::vector< std::pair >* intervals) +{ + CVF_ASSERT(intervals); + + int startIdx = -1; + size_t vIdx = 0; + + size_t valueCount = values.size(); + while (vIdx < valueCount) + { + double value = values[vIdx]; + if (value == HUGE_VAL || value == -HUGE_VAL || value != value) + { + if (startIdx >= 0) + { + intervals->push_back(std::make_pair(startIdx, vIdx - 1)); + startIdx = -1; + } + } + else if (startIdx < 0) + { + startIdx = (int)vIdx; + } + + vIdx++; + } + + if (startIdx >= 0 && startIdx < ((int)valueCount)) + { + intervals->push_back(std::make_pair(startIdx, valueCount - 1)); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigWellLogCurveData::addValuesFromIntervals(const std::vector& values, const std::vector< std::pair >& intervals, std::vector* filteredValues) +{ + CVF_ASSERT(filteredValues); + + for (size_t intIdx = 0; intIdx < intervals.size(); intIdx++) + { + for (size_t vIdx = intervals[intIdx].first; vIdx <= intervals[intIdx].second; vIdx++) + { + filteredValues->push_back(values[vIdx]); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigWellLogCurveData::filteredIntervals(const std::vector< std::pair >& intervals, std::vector< std::pair >* fltrIntervals) +{ + CVF_ASSERT(fltrIntervals); + + const size_t intervalCount = intervals.size(); + if (intervalCount < 1) return; + + size_t index = 0; + for (size_t intIdx = 0; intIdx < intervalCount; intIdx++) + { + size_t intervalSize = intervals[intIdx].second - intervals[intIdx].first + 1; + fltrIntervals->push_back(std::make_pair(index, index + intervalSize - 1)); + + index += intervalSize; + } +} diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.h b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.h new file mode 100644 index 0000000000..ba3d50da05 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.h @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RigWellLogCurveData : public cvf::Object +{ +public: + RigWellLogCurveData(); + virtual ~RigWellLogCurveData(); + + void setPoints(const std::vector& xValues, const std::vector& yValues); + + const std::vector& xValues() const; + const std::vector& yValues() const; + const std::vector< std::pair >& intervals() const; + + std::vector validXValues() const; + std::vector validYValues() const; + std::vector< std::pair > validPointsIntervals() const; + +private: + void calculateValidPointIntervals(); + + static void calculateIntervalsOfValidValues(const std::vector& values, std::vector< std::pair >* intervals); + static void addValuesFromIntervals(const std::vector& values, const std::vector< std::pair >& intervals, std::vector* filteredValues); + static void filteredIntervals(const std::vector< std::pair >& intervals, std::vector< std::pair >* fltrIntervals); + +private: + std::vector m_xValues; + std::vector m_yValues; + std::vector< std::pair > m_validPointIntervals; +}; diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp index b2cc8c41a7..2f3a5838e9 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp @@ -19,6 +19,8 @@ #include "RigWellLogFile.h" +#include "RimWellLogPlotCurve.h" + #include "well.hpp" #include "laswell.hpp" @@ -234,3 +236,43 @@ QString RigWellLogFile::wellLogChannelUnit(const QString& wellLogChannelName) co return unit; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellLogFile::exportToLasFile(const RimWellLogPlotCurve* curve, const QString& fileName) +{ + CVF_ASSERT(curve); + + const RigWellLogCurveData* curveData = curve->curveData(); + if (!curveData) + { + return false; + } + + double minX, maxX; + curve->valueRange(&minX, &maxX); + + // Might want to use a different way to find an absent/"null" value, maybe use the default if possible + double absentValue = ((size_t) maxX) + 1000; + + std::vector wellLogValues = curveData->xValues(); + for (size_t vIdx = 0; vIdx < wellLogValues.size(); vIdx++) + { + double value = wellLogValues[vIdx]; + if (value == HUGE_VAL || value == -HUGE_VAL || value != value) + { + wellLogValues[vIdx] = absentValue; + } + } + + NRLib::LasWell lasFile; + lasFile.AddLog("DEPTH", "m", "Depth [m]", curveData->yValues()); + lasFile.AddLog(curve->name().trimmed().toStdString(), "NO_UNIT", "PARAMETERINFO", wellLogValues); + lasFile.SetMissing(absentValue); + + std::vector commentHeader; + lasFile.WriteToFile(fileName.toStdString(), commentHeader); + + return true; +} diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogFile.h b/ApplicationCode/ReservoirDataModel/RigWellLogFile.h index da04e972fb..348e1da03f 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogFile.h +++ b/ApplicationCode/ReservoirDataModel/RigWellLogFile.h @@ -30,6 +30,7 @@ namespace NRLib class Well; } +class RimWellLogPlotCurve; //================================================================================================== /// @@ -51,6 +52,8 @@ public: QString depthUnit() const; QString wellLogChannelUnit(const QString& wellLogChannelName) const; + static bool exportToLasFile(const RimWellLogPlotCurve* curve, const QString& fileName); + private: void close(); diff --git a/ApplicationCode/UserInterface/RiuWellLogPlotCurve.cpp b/ApplicationCode/UserInterface/RiuWellLogPlotCurve.cpp index 20db8dbdc2..f4d96a57b3 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlotCurve.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlotCurve.cpp @@ -19,6 +19,9 @@ #include "RiuWellLogPlotCurve.h" +#include "RigWellLogCurveData.h" + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -33,14 +36,6 @@ RiuWellLogPlotCurve::~RiuWellLogPlotCurve() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellLogPlotCurve::setPlotIntervals(const std::vector >& intervals) -{ - m_intervals = intervals; -}; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -58,3 +53,17 @@ void RiuWellLogPlotCurve::drawCurve(QPainter* p, int style, } else QwtPlotCurve::drawCurve(p, style, xMap, yMap, canvasRect, from, to); }; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellLogPlotCurve::setCurveData(const RigWellLogCurveData* curveData) +{ + CVF_ASSERT(curveData); + + std::vector validXValues = curveData->validXValues(); + std::vector validYValues = curveData->validYValues(); + + setSamples(validXValues.data(), validYValues.data(), (int) validXValues.size()); + m_intervals = curveData->validPointsIntervals(); +} diff --git a/ApplicationCode/UserInterface/RiuWellLogPlotCurve.h b/ApplicationCode/UserInterface/RiuWellLogPlotCurve.h index 187a2d75a3..a862ec1f33 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlotCurve.h +++ b/ApplicationCode/UserInterface/RiuWellLogPlotCurve.h @@ -23,6 +23,8 @@ #include +class RigWellLogCurveData; + //================================================================================================== /// /// @@ -30,10 +32,11 @@ class RiuWellLogPlotCurve : public QwtPlotCurve { public: + RiuWellLogPlotCurve(); virtual ~RiuWellLogPlotCurve(); - void setPlotIntervals(const std::vector >& intervals); + void setCurveData(const RigWellLogCurveData* curveData); protected: @@ -42,5 +45,5 @@ protected: const QRectF& canvasRect, int from, int to) const; private: - std::vector< std::pair > m_intervals; + std::vector< std::pair > m_intervals; };