From 095d974e38cb9c6e7fa248d9870ccf5eaa03d21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Hagen?= Date: Mon, 14 Sep 2015 16:33:28 +0200 Subject: [PATCH] (#435) WIP - Reading metadata from LAS files --- .../Application/RiaApplication.cpp | 23 +++ ApplicationCode/Application/RiaApplication.h | 1 + .../Commands/CMakeLists_files.cmake | 3 + .../Commands/RicWellLogsImportFileFeature.cpp | 69 +++++++++ .../Commands/RicWellLogsImportFileFeature.h | 43 ++++++ .../ProjectDataModel/CMakeLists_files.cmake | 4 + .../ProjectDataModel/RimProject.cpp | 1 + .../ProjectDataModel/RimWellLasFileInfo.cpp | 136 ++++++++++++++++++ .../ProjectDataModel/RimWellLasFileInfo.h | 58 ++++++++ .../ProjectDataModel/RimWellLasLog.cpp | 45 ++++++ .../ProjectDataModel/RimWellLasLog.h | 45 ++++++ .../ProjectDataModel/RimWellPath.cpp | 47 +++++- .../ProjectDataModel/RimWellPath.h | 8 +- .../RimWellPathCollection.cpp | 32 ++++- .../ProjectDataModel/RimWellPathCollection.h | 6 + .../UserInterface/RiuMainWindow.cpp | 1 + CMakeLists.txt | 1 + 17 files changed, 519 insertions(+), 4 deletions(-) create mode 100644 ApplicationCode/Commands/RicWellLogsImportFileFeature.cpp create mode 100644 ApplicationCode/Commands/RicWellLogsImportFileFeature.h create mode 100644 ApplicationCode/ProjectDataModel/RimWellLasFileInfo.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimWellLasFileInfo.h create mode 100644 ApplicationCode/ProjectDataModel/RimWellLasLog.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimWellLasLog.h diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index aa14b2a862..b7a1a83798 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -465,6 +465,29 @@ void RiaApplication::addWellPathsToModel(QList wellPathFilePaths) oilField->wellPathCollection->updateConnectedEditors(); } +//-------------------------------------------------------------------------------------------------- +/// Add a list of well log file paths (LAS files) to the well path collection +//-------------------------------------------------------------------------------------------------- +void RiaApplication::addWellLogsToModel(const QList& wellLogFilePaths) +{ + if (m_project == NULL || m_project->oilFields.size() < 1) return; + + RimOilField* oilField = m_project->activeOilField(); + if (oilField == NULL) return; + + if (oilField->wellPathCollection == NULL) + { + oilField->wellPathCollection = new RimWellPathCollection(); + oilField->wellPathCollection->setProject(m_project); + + m_project->updateConnectedEditors(); + } + + if (oilField->wellPathCollection) oilField->wellPathCollection->addWellLogs(wellLogFilePaths); + + oilField->wellPathCollection->updateConnectedEditors(); +} + //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index ab2f241854..8e538cf281 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -111,6 +111,7 @@ public: bool saveProjectPromptForFileName(); bool closeProject(bool askToSaveIfDirty); void addWellPathsToModel(QList wellPathFilePaths); + void addWellLogsToModel(const QList& wellLogFilePaths); void copySnapshotToClipboard(); void saveSnapshotPromtpForFilename(); diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 0bb985310e..ef0bd08480 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -55,6 +55,7 @@ ${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.h ${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.h ${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.h +${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h # General delete of any object in a child array field ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h @@ -112,6 +113,8 @@ ${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.cpp ${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.cpp +${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.cpp + # General delete of any object in a child array field ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp ${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.cpp diff --git a/ApplicationCode/Commands/RicWellLogsImportFileFeature.cpp b/ApplicationCode/Commands/RicWellLogsImportFileFeature.cpp new file mode 100644 index 0000000000..4d4c738fd8 --- /dev/null +++ b/ApplicationCode/Commands/RicWellLogsImportFileFeature.cpp @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicWellLogsImportFileFeature.h" + +#include "RiaApplication.h" +#include "RimProject.h" +#include "RiuMainWindow.h" + +#include +#include + +namespace caf +{ + CAF_CMD_SOURCE_INIT(RicWellLogsImportFileFeature, "RicWellLogsImportFileFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellLogsImportFileFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellLogsImportFileFeature::onActionTriggered(bool isChecked) +{ + // Open dialog box to select well path files + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->defaultFileDialogDirectory("WELL_LOGS_DIR"); + QStringList wellLogFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Logs", defaultDir, "Well Logs (*.las);;All Files (*.*)"); + + if (wellLogFilePaths.size() < 1) return; + + // Remember the path to next time + app->setDefaultFileDialogDirectory("WELL_LOGS_DIR", QFileInfo(wellLogFilePaths.last()).absolutePath()); + + app->addWellLogsToModel(wellLogFilePaths); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellLogsImportFileFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Import Well &Logs from File"); + actionToSetup->setIcon(QIcon(":/Well.png")); +} + +} // end namespace caf diff --git a/ApplicationCode/Commands/RicWellLogsImportFileFeature.h b/ApplicationCode/Commands/RicWellLogsImportFileFeature.h new file mode 100644 index 0000000000..c82e9bf70e --- /dev/null +++ b/ApplicationCode/Commands/RicWellLogsImportFileFeature.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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" + +namespace caf +{ + +//================================================================================================== +/// +//================================================================================================== +class RicWellLogsImportFileFeature : public CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; + + + +} // end namespace caf diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index f5d9f9032b..ac068fc923 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -68,6 +68,8 @@ ${CEE_CURRENT_LIST_DIR}RimWellLogPlotCurve.h ${CEE_CURRENT_LIST_DIR}RimViewLinker.h ${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.h ${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.h +${CEE_CURRENT_LIST_DIR}RimWellLasFileInfo.h +${CEE_CURRENT_LIST_DIR}RimWellLasLog.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -134,6 +136,8 @@ ${CEE_CURRENT_LIST_DIR}RimWellLogPlotCurve.cpp ${CEE_CURRENT_LIST_DIR}RimViewLinker.cpp ${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.cpp ${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.cpp +${CEE_CURRENT_LIST_DIR}RimWellLasFileInfo.cpp +${CEE_CURRENT_LIST_DIR}RimWellLasLog.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 676ecbc8f6..59d2f37f22 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -776,6 +776,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu) commandIds << "RicWellPathsDeleteAllFeature"; commandIds << "RicWellPathsImportFileFeature"; commandIds << "RicWellPathsImportSsihubFeature"; + commandIds << "RicWellLogsImportFileFeature"; } else if (dynamic_cast(uiItem)) { diff --git a/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.cpp b/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.cpp new file mode 100644 index 0000000000..c60884772d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.cpp @@ -0,0 +1,136 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimWellLasFileInfo.h" +#include "RimWellLasLog.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "well.hpp" + +#include +#include + + +CAF_PDM_SOURCE_INIT(RimWellLasFileInfo, "WellLasFileInfo"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLasFileInfo::RimWellLasFileInfo() +{ + CAF_PDM_InitObject("Well LAS File Info", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_wellName, "WellName", "", "", "", ""); + m_wellName.uiCapability()->setUiReadOnly(true); + m_wellName.uiCapability()->setUiHidden(true); + m_wellName.xmlCapability()->setIOWritable(false); + + CAF_PDM_InitFieldNoDefault(&m_fileName, "FileName", "Filename", "", "", ""); + m_fileName.uiCapability()->setUiReadOnly(true); + + CAF_PDM_InitFieldNoDefault(&m_name, "Name", "", "", "", ""); + m_name.uiCapability()->setUiReadOnly(true); + m_name.uiCapability()->setUiHidden(true); + m_name.xmlCapability()->setIOWritable(false); + + CAF_PDM_InitFieldNoDefault(&m_lasFileLogs, "WellLASFileLogs", "", "", "", ""); + m_lasFileLogs.uiCapability()->setUiHidden(true); + m_lasFileLogs.xmlCapability()->setIOWritable(false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLasFileInfo::~RimWellLasFileInfo() +{ + close(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLasFileInfo::setFileName(const QString& fileName) +{ + m_fileName = fileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLasFileInfo::readFile() +{ + close(); + + int wellFormat = NRLib::Well::LAS; + NRLib::Well* well = NRLib::Well::ReadWell(m_fileName().toStdString(), wellFormat); + if (!well) + { + // TODO: Error handling + return false; + } + + m_wellName = QString::fromStdString(well->GetWellName()); + m_name = QFileInfo(m_fileName).fileName(); + + const std::map >& contLogs = well->GetContLog(); + + std::vector contLogNames; + std::map >::const_iterator itCL; + for (itCL = contLogs.begin(); itCL != contLogs.end(); itCL++) + { + RimWellLasLog* contLog = new RimWellLasLog(); + contLog->setName(QString::fromStdString(itCL->first)); + m_lasFileLogs.push_back(contLog); + } + + // TODO: Do the same for discrete logs + + RimWellPath* wellPath; + firstAnchestorOrThisOfType(wellPath); + + if (wellPath) + { + if (wellPath->filepath().isEmpty()) + { + wellPath->name = m_wellName; + } + } + + delete well; + return true; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLasFileInfo::close() +{ + m_lasFileLogs.deleteAllChildObjects(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellLasFileInfo::wellName() const +{ + return m_wellName; +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.h b/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.h new file mode 100644 index 0000000000..53b4545cb3 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.h @@ -0,0 +1,58 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafPdmObject.h" +#include "cafPdmField.h" +#include "cafPdmChildArrayField.h" + + +class RimWellLasLog; +class QString; + + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLasFileInfo : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLasFileInfo(); + virtual ~RimWellLasFileInfo(); + + void setFileName(const QString& fileName); + bool readFile(); + void close(); + + QString wellName() const; + + virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; } + +private: + caf::PdmChildArrayField m_lasFileLogs; + +private: + caf::PdmField m_wellName; + caf::PdmField m_fileName; + caf::PdmField m_name; +}; diff --git a/ApplicationCode/ProjectDataModel/RimWellLasLog.cpp b/ApplicationCode/ProjectDataModel/RimWellLasLog.cpp new file mode 100644 index 0000000000..d8fe479271 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLasLog.cpp @@ -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. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimWellLasLog.h" + +#include + + +CAF_PDM_SOURCE_INIT(RimWellLasLog, "WellLasLog"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLasLog::RimWellLasLog() +{ + CAF_PDM_InitObject("Well LAS File Log", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_name, "Name", "", "", "", ""); + m_name.uiCapability()->setUiHidden(true); + m_name.xmlCapability()->setIOWritable(false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLasLog::setName(const QString& name) +{ + m_name = name; +} \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/RimWellLasLog.h b/ApplicationCode/ProjectDataModel/RimWellLasLog.h new file mode 100644 index 0000000000..52d3d89bf2 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLasLog.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 "cafPdmObject.h" +#include "cafPdmField.h" + +class QString; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLasLog : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLasLog(); + + void setName(const QString& name); + + virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; } + +private: + caf::PdmField m_name; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 9df0477889..f222cf0d5b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -23,6 +23,7 @@ #include "RifJsonEncodeDecode.h" #include "RimProject.h" #include "RimTools.h" +#include "RimWellLasFileInfo.h" #include "RimWellPathCollection.h" #include "RivWellPathPartMgr.h" @@ -81,6 +82,9 @@ RimWellPath::RimWellPath() CAF_PDM_InitField(&wellPathRadiusScaleFactor, "WellPathRadiusScale", 1.0, "Well path radius scale", "", "", ""); CAF_PDM_InitField(&wellPathColor, "WellPathColor", cvf::Color3f(0.999f, 0.333f, 0.999f), "Well path color", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_lasFileInfo, "LasFileInfo", "Las File Info", "", "", ""); + m_lasFileInfo.uiCapability()->setUiHidden(true); + m_wellPath = NULL; m_project = NULL; } @@ -91,6 +95,10 @@ RimWellPath::RimWellPath() //-------------------------------------------------------------------------------------------------- RimWellPath::~RimWellPath() { + if (m_lasFileInfo) + { + delete m_lasFileInfo; + } } @@ -164,6 +172,29 @@ void RimWellPath::readWellPathFile() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLasFileInfo* RimWellPath::readWellLogFile(const QString& logFilePath) +{ + QFileInfo fi(logFilePath); + + RimWellLasFileInfo* lasFileInfo = NULL; + + if (fi.suffix().compare("las") == 0) + { + lasFileInfo = new RimWellLasFileInfo(); + lasFileInfo->setFileName(logFilePath); + if (!lasFileInfo->readFile()) + { + delete lasFileInfo; + lasFileInfo = NULL; + } + } + + return lasFileInfo; +} + //-------------------------------------------------------------------------------------------------- /// Read JSON file containing well path data //-------------------------------------------------------------------------------------------------- @@ -245,7 +276,6 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO ssihubGroup->add(&updateDate); ssihubGroup->add(&updateUser); ssihubGroup->add(&m_surveyType); - } //-------------------------------------------------------------------------------------------------- @@ -323,3 +353,18 @@ void RimWellPath::updateFilePathsFromProjectPath() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPath::setLogFileInfo(RimWellLasFileInfo* logFileInfo) +{ + if (m_lasFileInfo) + { + delete m_lasFileInfo; + } + + m_lasFileInfo = logFileInfo; + m_lasFileInfo->uiCapability()->setUiHidden(true); + + this->name = m_lasFileInfo->wellName(); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 928cd2fb17..edddc4d985 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -23,6 +23,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" +#include "cafPdmChildField.h" #include "cafAppEnum.h" // Include to make Pdm work for cvf::Color @@ -33,6 +34,7 @@ class RimProject; class RivWellPathPartMgr; class RimWellPathCollection; +class RimWellLasFileInfo; //================================================================================================== /// @@ -48,6 +50,7 @@ public: void setProject(RimProject* project) { m_project = project; } void setCollection(RimWellPathCollection* collection) { m_wellPathCollection = collection; } + void setLogFileInfo(RimWellLasFileInfo* logFileInfo); virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* objectToggleField(); @@ -65,10 +68,13 @@ public: caf::PdmField wellPathColor; caf::PdmField wellPathRadiusScaleFactor; + caf::PdmChildField m_lasFileInfo; + RigWellPath* wellPathGeometry() { return m_wellPath.p(); } RivWellPathPartMgr* partMgr(); void readWellPathFile(); + static RimWellLasFileInfo* readWellLogFile(const QString& logFilePath); void updateFilePathsFromProjectPath(); @@ -99,5 +105,5 @@ private: cvf::ref m_wellPath; cvf::ref m_wellPathPartMgr; caf::PdmPointer m_wellPathCollection; - RimProject* m_project; + RimProject* m_project; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index 10474f0805..9759272878 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -24,6 +24,7 @@ #include "RiaPreferences.h" #include "RimProject.h" #include "RimWellPath.h" +#include "RimWellLasFileInfo.h" #include "RivWellPathCollectionPartMgr.h" #include "cafPdmUiEditorHandle.h" @@ -81,7 +82,6 @@ RimWellPathCollection::RimWellPathCollection() m_project = NULL; m_asciiFileReader = new RimWellPathAsciiFileReader; - } @@ -127,7 +127,15 @@ void RimWellPathCollection::readWellPathFiles() for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++) { - wellPaths[wpIdx]->readWellPathFile(); + if (!wellPaths[wpIdx]->filepath().isEmpty()) + { + wellPaths[wpIdx]->readWellPathFile(); + } + + if (wellPaths[wpIdx]->m_lasFileInfo) + { + wellPaths[wpIdx]->m_lasFileInfo->readFile(); + } progress.setProgressDescription(QString("Reading file %1").arg(wellPaths[wpIdx]->name)); progress.incrementProgress(); @@ -192,6 +200,26 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths ) readWellPathFiles(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathCollection::addWellLogs(const QStringList& filePaths) +{ + foreach (QString filePath, filePaths) + { + RimWellLasFileInfo* logFileInfo = RimWellPath::readWellLogFile(filePath); + if (logFileInfo) + { + // TODO: Check for existing well paths and add log to correct well path if existing + + RimWellPath* wellPath = new RimWellPath(); + wellPath->setCollection(this); + wellPaths.push_back(wellPath); + wellPath->setLogFileInfo(logFileInfo); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h index f66a3f698d..f133ce9d6b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h @@ -81,6 +81,8 @@ public: void readWellPathFiles(); void addWellPaths(QStringList filePaths); RimWellPathAsciiFileReader* asciiFileReader() {return m_asciiFileReader;} + + void addWellLogs(const QStringList& filePaths); virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); @@ -98,6 +100,10 @@ private: }; +//================================================================================================== +/// +/// +//================================================================================================== class RimWellPathAsciiFileReader { public: diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 9f3ea0a194..de20804d68 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -423,6 +423,7 @@ void RiuMainWindow::createMenus() #endif importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(m_snapshotToFile); diff --git a/CMakeLists.txt b/CMakeLists.txt index 1745d291d1..8edd9d1037 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,7 @@ set_property(TARGET ################################################################################ add_subdirectory(ThirdParty/NRLib) +include_directories(ThirdParty/NRLib/nrlib/well) ################################################################################