From c88bdfd8231f12ce5699b9965ac059c3d7717ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Hagen?= Date: Wed, 16 Sep 2015 15:31:04 +0200 Subject: [PATCH] (#436) Added property fields. Handling project file read/write, --- .../Commands/RicAddWellLogToPlotFeature.cpp | 29 +++- .../Commands/RicAddWellLogToPlotFeature.h | 2 +- .../ProjectDataModel/RimWellLasFileInfo.h | 2 + .../ProjectDataModel/RimWellLogFileCurve.cpp | 159 +++++++++++++++++- .../ProjectDataModel/RimWellLogFileCurve.h | 19 ++- 5 files changed, 202 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/Commands/RicAddWellLogToPlotFeature.cpp b/ApplicationCode/Commands/RicAddWellLogToPlotFeature.cpp index 9be64ae096..8709ca8d54 100644 --- a/ApplicationCode/Commands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationCode/Commands/RicAddWellLogToPlotFeature.cpp @@ -30,6 +30,9 @@ #include "RimProject.h" #include "RimMainPlotCollection.h" #include "RimWellLogPlotCollection.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + #include "RigWellLogFile.h" #include "RiaApplication.h" @@ -37,6 +40,7 @@ #include "RiuWellLogTracePlot.h" #include "cafSelectionManager.h" +#include "cafPdmUiTreeView.h" #include @@ -61,7 +65,7 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) { std::vector selection = selectedWellLogs(); if (selection.size() < 1) return; - + RimWellLogPlot* plot = RicNewWellLogPlotFeatureImpl::createWellLogPlot(); RimWellLogPlotTrace* plotTrace = new RimWellLogPlotTrace(); @@ -69,10 +73,15 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) plot->loadDataAndUpdate(); + caf::PdmUiItem* uiItem = NULL; + for (size_t wlIdx = 0; wlIdx < selection.size(); wlIdx++) { RimWellLog* wellLog = selection[wlIdx]; + RimWellPath* wellPath; + wellLog->firstAnchestorOrThisOfType(wellPath); + RimWellLasFileInfo* lasFileInfo; wellLog->firstAnchestorOrThisOfType(lasFileInfo); if (lasFileInfo) @@ -85,18 +94,28 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromIndex(curveIdx); curve->setColor(curveColor); curve->setDescription(wellLog->name()); - - RigWellLogFile* wellLogFile = lasFileInfo->wellLogFile(); - - curve->setCurveData(wellLogFile->values(wellLog->name()), wellLogFile->depthValues()); + curve->setWellPath(wellPath); + curve->setWellLogChannelName(wellLog->name()); curve->updatePlotData(); + + if (wlIdx == selection.size() - 1) + { + uiItem = curve; + } } } + plot->updateAvailableDepthRange(); plot->setVisibleDepthRangeFromContents(); + plotTrace->viewer()->replot(); RiaApplication::instance()->project()->updateConnectedEditors(); + + if (uiItem) + { + RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(uiItem); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicAddWellLogToPlotFeature.h b/ApplicationCode/Commands/RicAddWellLogToPlotFeature.h index 19ebf87e87..50e8f654b0 100644 --- a/ApplicationCode/Commands/RicAddWellLogToPlotFeature.h +++ b/ApplicationCode/Commands/RicAddWellLogToPlotFeature.h @@ -45,7 +45,7 @@ protected: virtual void setupActionLook( QAction* actionToSetup ); private: - std::vector selectedWellLogs(); + std::vector selectedWellLogs(); }; diff --git a/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.h b/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.h index d27bc4323a..7cb1cb3e53 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.h +++ b/ApplicationCode/ProjectDataModel/RimWellLasFileInfo.h @@ -51,6 +51,8 @@ public: RigWellLogFile* wellLogFile() { return m_wellLogFile.p(); } + const caf::PdmChildArrayField* lasFileLogs() const { return &m_lasFileLogs; } + private: caf::PdmChildArrayField m_lasFileLogs; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp index 8875bff827..4c6821ff3f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -19,6 +19,21 @@ #include "RimWellLogFileCurve.h" +#include "RimProject.h" +#include "RimOilField.h" +#include "RimWellPathCollection.h" +#include "RimWellPath.h" +#include "RimWellLog.h" +#include "RimWellLasFileInfo.h" +#include "RimWellLogPlotTrace.h" +#include "RimWellLogPlot.h" + +#include "RiuWellLogTracePlot.h" + +#include "RiaApplication.h" + +#include "cafPdmUiTreeOrdering.h" + #include "qwt_plot_curve.h" @@ -30,6 +45,15 @@ CAF_PDM_SOURCE_INIT(RimWellLogFileCurve, "WellLogFileCurve"); RimWellLogFileCurve::RimWellLogFileCurve() { CAF_PDM_InitObject("Well Log File Curve", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_wellPath, "CurveWellPath", "Well Path", "", "", ""); + m_wellPath.uiCapability()->setUiChildrenHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_wellLogChannnelName, "CurveWellLogChannel", "Well Log Channel", "", "", ""); + + m_userName.uiCapability()->setUiHidden(true); + + m_wellPath = NULL; } //-------------------------------------------------------------------------------------------------- @@ -45,12 +69,143 @@ RimWellLogFileCurve::~RimWellLogFileCurve() void RimWellLogFileCurve::updatePlotData() { RimWellLogPlotCurve::updatePlotData(); + + if (m_showCurve) + { + if (m_wellPath) + { + RimWellLasFileInfo* logFileInfo = m_wellPath->m_lasFileInfo; + if (logFileInfo) + { + RigWellLogFile* wellLogFile = logFileInfo->wellLogFile(); + m_plotCurve->setSamples(wellLogFile->values(m_wellLogChannnelName).data(), wellLogFile->depthValues().data(), (int) wellLogFile->depthValues().size()); + m_plotCurve->setTitle(m_wellLogChannnelName); + } + } + else + { + m_plotCurve->setSamples(NULL, NULL, 0); + m_plotCurve->setTitle("None"); + } + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogFileCurve::setCurveData(const std::vector& values, const std::vector& depthValues) +void RimWellLogFileCurve::setWellPath(RimWellPath* wellPath) { - m_plotCurve->setSamples(values.data(), depthValues.data(), (int) depthValues.size()); + m_wellPath = wellPath; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFileCurve::setWellLogChannelName(const QString& name) +{ + m_wellLogChannnelName = name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimWellLogPlotCurve::fieldChangedByUi(changedField, oldValue, newValue); + + if (changedField == &m_wellPath) + { + this->updatePlotData(); + + RimWellLogPlot* wellLoglot; + firstAnchestorOrThisOfType(wellLoglot); + if (wellLoglot) + { + wellLoglot->updateAvailableDepthRange(); + wellLoglot->setVisibleDepthRangeFromContents(); + } + } + else if (changedField == &m_wellLogChannnelName) + { + this->updatePlotData(); + + RimWellLogPlot* wellLoglot; + firstAnchestorOrThisOfType(wellLoglot); + if (wellLoglot) + { + if (!wellLoglot->hasAvailableDepthRange()) + { + wellLoglot->updateAvailableDepthRange(); + wellLoglot->setVisibleDepthRangeFromContents(); + } + } + } + + m_plot->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFileCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&m_wellPath); + uiOrdering.add(&m_wellLogChannnelName); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFileCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + uiTreeOrdering.setForgetRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimWellLogFileCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList optionList; + + if (fieldNeedingOptions == &m_wellPath) + { + RimProject* proj = RiaApplication::instance()->project(); + if (proj->activeOilField()->wellPathCollection()) + { + caf::PdmChildArrayField& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths; + + for (size_t i = 0; i < wellPaths.size(); i++) + { + optionList.push_back(caf::PdmOptionItemInfo(wellPaths[i]->name(), QVariant::fromValue(caf::PdmPointer(wellPaths[i])))); + } + + if (optionList.size() > 0) + { + optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer(NULL)))); + } + } + } + + if (fieldNeedingOptions == &m_wellLogChannnelName) + { + if (m_wellPath()) + { + RimWellLasFileInfo* lasFileInfo = m_wellPath->m_lasFileInfo(); + if (lasFileInfo) + { + const caf::PdmChildArrayField* fileLogs = lasFileInfo->lasFileLogs(); + + for (size_t i = 0; i < fileLogs->size(); i++) + { + QString wellLogChannelName = (*fileLogs)[i]->name(); + optionList.push_back(caf::PdmOptionItemInfo(wellLogChannelName, wellLogChannelName)); + + } + } + } + } + + return optionList; +} + diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h index 565f9da454..7eb3a10b1c 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h @@ -21,8 +21,14 @@ #include "RimWellLogPlotCurve.h" +#include "cafPdmPtrField.h" +#include "cafPdmField.h" + #include +class RimWellPath; +class RimWellLog; + //================================================================================================== /// /// @@ -37,7 +43,18 @@ public: virtual void updatePlotData(); - void setCurveData(const std::vector& values, const std::vector& depthValues); + void setWellPath(RimWellPath* wellPath); + void setWellLogChannelName(const QString& name); + +protected: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); + +protected: + caf::PdmPtrField m_wellPath; + caf::PdmField m_wellLogChannnelName; };