From e4212a11357d0987c8a51150f67d828dda1a4dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Hagen?= Date: Tue, 15 Sep 2015 15:23:25 +0200 Subject: [PATCH] (#436) Added feature that creates a plot with a given LAS file log --- .../Commands/CMakeLists_files.cmake | 2 + .../Commands/RicAddWellLogToPlotFeature.cpp | 155 ++++++++++++++++++ .../Commands/RicAddWellLogToPlotFeature.h | 56 +++++++ .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/RimProject.cpp | 5 + ApplicationCode/ProjectDataModel/RimWellLog.h | 3 +- .../ProjectDataModel/RimWellLogFileCurve.cpp | 56 +++++++ .../ProjectDataModel/RimWellLogFileCurve.h | 43 +++++ 8 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 ApplicationCode/Commands/RicAddWellLogToPlotFeature.cpp create mode 100644 ApplicationCode/Commands/RicAddWellLogToPlotFeature.h create mode 100644 ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index ef0bd08480..f7ae141c3e 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -46,6 +46,7 @@ ${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.h ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTraceFeature.h ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotCurveFeature.h +${CEE_CURRENT_LIST_DIR}RicAddWellLogToPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h @@ -104,6 +105,7 @@ ${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTraceFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotCurveFeature.cpp +${CEE_CURRENT_LIST_DIR}RicAddWellLogToPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp diff --git a/ApplicationCode/Commands/RicAddWellLogToPlotFeature.cpp b/ApplicationCode/Commands/RicAddWellLogToPlotFeature.cpp new file mode 100644 index 0000000000..4e2d1b9af8 --- /dev/null +++ b/ApplicationCode/Commands/RicAddWellLogToPlotFeature.cpp @@ -0,0 +1,155 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicAddWellLogToPlotFeature.h" + +#include "RimWellLasFileInfo.h" +#include "RimWellLog.h" +#include "RimWellLogPlot.h" +#include "RimWellLogPlotTrace.h" +#include "RimWellLogFileCurve.h" +#include "RimProject.h" +#include "RimMainPlotCollection.h" +#include "RimWellLogPlotCollection.h" + +#include "RiaApplication.h" +#include "RiuMainWindow.h" +#include "RiuWellLogTracePlot.h" + +#include "cafSelectionManager.h" + +#include + +namespace caf +{ + CAF_CMD_SOURCE_INIT(RicAddWellLogToPlotFeature, "RicAddWellLogToPlotFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAddWellLogToPlotFeature::isCommandEnabled() +{ + std::vector selection = selectedWellLogs(); + return selection.size() > 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) +{ + std::vector selection = selectedWellLogs(); + if (selection.size() < 1) return; + + RimWellLogPlot* plot = createWellLogPlot(); + + RimWellLogPlotTrace* plotTrace = new RimWellLogPlotTrace(); + plot->addTrace(plotTrace); + + plot->loadDataAndUpdate(); + + for (size_t wlIdx = 0; wlIdx < selection.size(); wlIdx++) + { + RimWellLog* wellLog = selection[wlIdx]; + + RimWellLasFileInfo* lasFileInfo; + wellLog->firstAnchestorOrThisOfType(lasFileInfo); + if (lasFileInfo) + { + RimWellLogFileCurve* curve = new RimWellLogFileCurve; + plotTrace->addCurve(curve); + + curve->setCurveData(lasFileInfo->logValues(wellLog->name()), lasFileInfo->depthValues()); + curve->setDescription(wellLog->name()); + curve->updatePlotData(); + } + } + + RiaApplication::instance()->project()->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAddWellLogToPlotFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Add To Plot"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicAddWellLogToPlotFeature::selectedWellLogs() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); + return selection; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimMainPlotCollection* RicAddWellLogToPlotFeature::mainPlotCollection() +{ + RimProject* project = RiaApplication::instance()->project(); + CVF_ASSERT(project); + + RimMainPlotCollection* mainPlotColl = project->mainPlotCollection(); + if (!mainPlotColl) + { + project->recreateMainPlotCollection(); + } + + return project->mainPlotCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlotCollection* RicAddWellLogToPlotFeature::wellLogPlotCollection() +{ + RimMainPlotCollection* mainPlotColl = mainPlotCollection(); + CVF_ASSERT(mainPlotColl); + + RimWellLogPlotCollection* wellLogPlotColl = mainPlotColl->wellLogPlotCollection(); + if (!wellLogPlotColl) + { + mainPlotColl->recreateWellLogPlotCollection(); + } + + return mainPlotColl->wellLogPlotCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlot* RicAddWellLogToPlotFeature::createWellLogPlot() +{ + RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection(); + CVF_ASSERT(wellLogPlotColl); + + RimWellLogPlot* plot = new RimWellLogPlot(); + wellLogPlotColl->wellLogPlots().push_back(plot); + + return plot; +} + +} // end namespace caf diff --git a/ApplicationCode/Commands/RicAddWellLogToPlotFeature.h b/ApplicationCode/Commands/RicAddWellLogToPlotFeature.h new file mode 100644 index 0000000000..dc64430673 --- /dev/null +++ b/ApplicationCode/Commands/RicAddWellLogToPlotFeature.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 RimMainPlotCollection; +class RimWellLogPlotCollection; +class RimWellLogPlot; +class RimWellLog; + +namespace caf +{ + +//================================================================================================== +/// +//================================================================================================== +class RicAddWellLogToPlotFeature : public CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + std::vector selectedWellLogs(); + RimMainPlotCollection* mainPlotCollection(); + RimWellLogPlotCollection* wellLogPlotCollection(); + RimWellLogPlot* createWellLogPlot(); +}; + + + +} // end namespace caf diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 5932e2adea..11b7a4f060 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -70,6 +70,7 @@ ${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.h ${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.h ${CEE_CURRENT_LIST_DIR}RimWellLasFileInfo.h ${CEE_CURRENT_LIST_DIR}RimWellLog.h +${CEE_CURRENT_LIST_DIR}RimWellLogFileCurve.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -138,6 +139,7 @@ ${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.cpp ${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.cpp ${CEE_CURRENT_LIST_DIR}RimWellLasFileInfo.cpp ${CEE_CURRENT_LIST_DIR}RimWellLog.cpp +${CEE_CURRENT_LIST_DIR}RimWellLogFileCurve.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 59d2f37f22..03e3a98a13 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -627,6 +627,7 @@ void RimProject::computeUtmAreaOfInterest() #include "RimWellLogPlot.h" #include "RimWellLogPlotTrace.h" #include "RimWellLogPlotCurve.h" +#include "RimWellLog.h" #include @@ -824,6 +825,10 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu) { commandIds << "RicDeleteItemFeature"; } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicAddWellLogToPlotFeature"; + } } if (RicToggleItemsFeatureImpl::isToggleCommandsAvailable()) diff --git a/ApplicationCode/ProjectDataModel/RimWellLog.h b/ApplicationCode/ProjectDataModel/RimWellLog.h index 785caa1108..1aa688028b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLog.h +++ b/ApplicationCode/ProjectDataModel/RimWellLog.h @@ -35,7 +35,8 @@ class RimWellLog : public caf::PdmObject public: RimWellLog(); - void setName(const QString& name); + void setName(const QString& name); + QString name() const { return m_name; } virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp new file mode 100644 index 0000000000..8875bff827 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimWellLogFileCurve.h" + +#include "qwt_plot_curve.h" + + +CAF_PDM_SOURCE_INIT(RimWellLogFileCurve, "WellLogFileCurve"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogFileCurve::RimWellLogFileCurve() +{ + CAF_PDM_InitObject("Well Log File Curve", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogFileCurve::~RimWellLogFileCurve() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFileCurve::updatePlotData() +{ + RimWellLogPlotCurve::updatePlotData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFileCurve::setCurveData(const std::vector& values, const std::vector& depthValues) +{ + m_plotCurve->setSamples(values.data(), depthValues.data(), (int) depthValues.size()); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h new file mode 100644 index 0000000000..565f9da454 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.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 "RimWellLogPlotCurve.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogFileCurve : public RimWellLogPlotCurve +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLogFileCurve(); + virtual ~RimWellLogFileCurve(); + + virtual void updatePlotData(); + + void setCurveData(const std::vector& values, const std::vector& depthValues); +}; + +