#3154 Implement Common Data Source for Well Log Plots

This commit is contained in:
Gaute Lindkvist
2018-07-10 12:44:58 +02:00
parent 714aafc05c
commit 06e3ca238a
14 changed files with 692 additions and 209 deletions

View File

@@ -19,7 +19,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogTrackFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeatureUi.h
${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportWellLogPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.h
@@ -51,7 +50,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogTrackFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeatureUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportWellLogPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.cpp

View File

@@ -18,11 +18,11 @@
#include "RicChangeDataSourceFeature.h"
#include "RicChangeDataSourceFeatureUi.h"
#include "RicWellLogPlotCurveFeatureImpl.h"
#include "RimCase.h"
#include "RimWellLogCurve.h"
#include "RimWellLogCurveCommonDataSource.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellPath.h"
@@ -30,6 +30,8 @@
#include <QAction>
#include <set>
CAF_CMD_SOURCE_INIT(RicChangeDataSourceFeature, "RicChangeDataSourceFeature");
//--------------------------------------------------------------------------------------------------
@@ -40,9 +42,9 @@ bool RicChangeDataSourceFeature::isCommandEnabled()
if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return false;
if (RicWellLogPlotCurveFeatureImpl::parentWellRftPlot()) return false;
std::vector<RimWellLogExtractionCurve*> extrCurves = extractionCurves();
std::vector<RimWellLogCurve*> curves = RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves();
return extrCurves.size() > 0;
return curves.size() > 0;
}
//--------------------------------------------------------------------------------------------------
@@ -52,24 +54,18 @@ void RicChangeDataSourceFeature::onActionTriggered(bool isChecked)
{
if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return;
std::vector<RimWellLogExtractionCurve*> extrCurves = extractionCurves();
if (extrCurves.size() == 0) return;
std::vector<RimWellLogCurve*> curves = RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves();
if (curves.size() == 0) return;
RicChangeDataSourceFeatureUi featureUi;
featureUi.wellPathToApply = extrCurves[0]->wellPath();
featureUi.caseToApply = extrCurves[0]->rimCase();
RimWellLogCurveCommonDataSource featureUi;
featureUi.updateDefaultOptions(curves);
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Change Data Source for Selected Curves", "");
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Change Data Source for Multiple Curves", "");
propertyDialog.resize(QSize(500, 200));
if (propertyDialog.exec() == QDialog::Accepted)
{
for (RimWellLogExtractionCurve* extractionCurve : extrCurves)
{
extractionCurve->setWellPath(featureUi.wellPathToApply);
extractionCurve->setCase(featureUi.caseToApply);
extractionCurve->loadDataAndUpdate(true);
}
featureUi.updateCurves(curves);
}
}
@@ -78,26 +74,6 @@ void RicChangeDataSourceFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
void RicChangeDataSourceFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Change Data Source");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellLogExtractionCurve*> RicChangeDataSourceFeature::extractionCurves()
{
std::vector<RimWellLogExtractionCurve*> extrCurves;
std::vector<RimWellLogCurve*> curves = RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves();
for (RimWellLogCurve* c : curves)
{
if (dynamic_cast<RimWellLogExtractionCurve*>(c))
{
extrCurves.push_back(dynamic_cast<RimWellLogExtractionCurve*>(c));
}
}
return extrCurves;
actionToSetup->setText("Change Common Data Source");
}

View File

@@ -22,20 +22,16 @@
#include <vector>
class RimWellLogExtractionCurve;
class RimWellLogCurve;
//==================================================================================================
///
//==================================================================================================
class RicChangeDataSourceFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
CAF_CMD_HEADER_INIT;
protected:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook(QAction* actionToSetup) override;
private:
static std::vector<RimWellLogExtractionCurve*> extractionCurves();
};

View File

@@ -1,72 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicChangeDataSourceFeatureUi.h"
#include "RimCase.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimTools.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RiaApplication.h"
CAF_PDM_SOURCE_INIT(RicChangeDataSourceFeatureUi, "ChangeDataSourceFeatureUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicChangeDataSourceFeatureUi::RicChangeDataSourceFeatureUi()
{
CAF_PDM_InitObject("Change Data Source", "", "", "");
CAF_PDM_InitFieldNoDefault(&wellPathToApply, "CurveWellPath", "Well Path", "", "", "");
CAF_PDM_InitFieldNoDefault(&caseToApply, "CurveCase", "Case", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RicChangeDataSourceFeatureUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &caseToApply)
{
RimTools::caseOptionItems(&options);
}
else if (fieldNeedingOptions == &wellPathToApply)
{
RimTools::wellPathOptionItems(&options);
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicChangeDataSourceFeatureUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup("Apply the following for all selected curves");
group->add(&caseToApply);
group->add(&wellPathToApply);
}

View File

@@ -1,46 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cafPdmUiOrdering.h"
class RimCase;
class RimWellPath;
//==================================================================================================
///
//==================================================================================================
class RicChangeDataSourceFeatureUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicChangeDataSourceFeatureUi();
caf::PdmPtrField<RimCase*> caseToApply;
caf::PdmPtrField<RimWellPath*> wellPathToApply;
protected:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
};

View File

@@ -109,6 +109,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h
${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveNameConfig.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveCommonDataSource.h
)
@@ -222,6 +223,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp
${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveNameConfig.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveCommonDataSource.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -925,6 +925,24 @@ void RimEclipseCase::setFormationNames(RimFormationNames* formationNames)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<QString> RimEclipseCase::sortedSimWellNames() const
{
std::set<QString> sortedWellNames;
if (eclipseCaseData())
{
const cvf::Collection<RigSimWellData>& simWellData = eclipseCaseData()->wellResults();
for (size_t wIdx = 0; wIdx < simWellData.size(); ++wIdx)
{
sortedWellNames.insert(simWellData[wIdx]->m_wellName);
}
}
return sortedWellNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -34,6 +34,8 @@
#include "cvfObject.h"
#include "cvfColor3.h"
#include <set>
class QString;
class RigEclipseCaseData;
@@ -112,6 +114,8 @@ public:
virtual void setFormationNames(RimFormationNames* formationNames) override;
std::set<QString> sortedSimWellNames() const;
protected:
virtual void initAfterRead();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );

View File

@@ -0,0 +1,465 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellLogCurveCommonDataSource.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimTools.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RiaApplication.h"
#include "RiaSimWellBranchTools.h"
#include "cafPdmUiCheckBoxTristateEditor.h"
CAF_PDM_SOURCE_INIT(RimWellLogCurveCommonDataSource, "ChangeDataSourceFeatureUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource()
{
CAF_PDM_InitObject("Change Common Data Source", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_trajectoryType, "TrajectoryType", "Trajectory Type", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellPath, "CurveWellPath", "Well Name", "", "", "");
CAF_PDM_InitField(&m_simWellName, "SimulationWellName", QString("None"), "Well Name", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_branchDetection, "BranchDetection", "Branch Detection", "",
"Compute branches based on how simulation well cells are organized", "");
m_branchDetection.v() = caf::Tristate::State::PartiallyTrue;
m_branchDetection.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_branchIndex, "Branch", -1, "Branch Index", "", "", "");
CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", -1, "Time Step", "", "", "");
m_case = nullptr;
m_wellPath = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RimWellLogCurveCommonDataSource::caseToApply() const
{
return m_case;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::setCaseToApply(RimCase* val)
{
m_case = val;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimWellLogCurveCommonDataSource::wellPathToApply() const
{
return m_wellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::setWellPathToApply(RimWellPath* val)
{
m_wellPath = val;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellLogCurveCommonDataSource::timeStepToApply() const
{
return m_timeStep;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::setTimeStepToApply(int val)
{
m_timeStep = val;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::updateDefaultOptions(const std::vector<RimWellLogCurve*>& curves)
{
// Check to see if the parameters are unique
std::set<RimCase*> uniqueCases;
std::set<int> uniqueTrajectoryTypes;
std::set<RimWellPath*> uniqueWellPaths;
std::set<QString> uniqueWellNames;
std::set<int> uniqueTimeSteps;
std::set<bool> uniqueBranchDetection;
std::set<int> uniqueBranchIndex;
for (RimWellLogCurve* curve : curves)
{
RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>(curve);
if (extractionCurve)
{
uniqueCases.insert(extractionCurve->rimCase());
uniqueTrajectoryTypes.insert(static_cast<int>(extractionCurve->trajectoryType()));
uniqueWellPaths.insert(extractionCurve->wellPath());
uniqueWellNames.insert(extractionCurve->wellName());
uniqueTimeSteps.insert(extractionCurve->currentTimeStep());
uniqueBranchDetection.insert(extractionCurve->branchDetection());
uniqueBranchIndex.insert(extractionCurve->branchIndex());
}
}
if (uniqueCases.size() == 1u)
{
setCaseToApply(*uniqueCases.begin());
}
else
{
setCaseToApply(nullptr);
}
if (uniqueTrajectoryTypes.size() == 1u)
{
m_trajectoryType = *uniqueTrajectoryTypes.begin();
if (uniqueWellPaths.size() == 1u)
{
setWellPathToApply(*uniqueWellPaths.begin());
}
else
{
setWellPathToApply(nullptr);
}
if (uniqueWellNames.size() == 1u)
{
m_simWellName = *uniqueWellNames.begin();
if (uniqueBranchDetection.size() == 1u)
{
m_branchDetection.v() = *uniqueBranchDetection.begin() == true ?
caf::Tristate::State::True : caf::Tristate::State::False;
}
else
{
m_branchDetection.v() = caf::Tristate::State::PartiallyTrue;
}
}
else
{
m_simWellName = QString("");
}
}
else
{
setWellPathToApply(nullptr);
m_simWellName = QString("");
}
if (uniqueTimeSteps.size() == 1u)
{
setTimeStepToApply(*uniqueTimeSteps.begin());
}
else
{
setTimeStepToApply(-1);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::updateDefaultOptions()
{
RimWellLogPlot* parentPlot = nullptr;
this->firstAncestorOrThisOfType(parentPlot);
if (parentPlot)
{
std::vector<RimWellLogCurve*> curves;
parentPlot->descendantsIncludingThisOfType(curves);
this->updateDefaultOptions(curves);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::updateCurves(std::vector<RimWellLogCurve*>& curves)
{
std::set<RimWellLogPlot*> plots;
for (RimWellLogCurve* curve : curves)
{
RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>(curve);
if (extractionCurve)
{
bool updatedSomething = false;
if (caseToApply() != nullptr)
{
extractionCurve->setCase(caseToApply());
updatedSomething = true;
}
if (wellPathToApply() != nullptr)
{
extractionCurve->setWellPath(wellPathToApply());
updatedSomething = true;
}
if (m_trajectoryType() != -1)
{
extractionCurve->setTrajectoryType(static_cast<RimWellLogExtractionCurve::TrajectoryType>(m_trajectoryType()));
if (m_trajectoryType() == (int)RimWellLogExtractionCurve::SIMULATION_WELL)
{
if (m_branchDetection().isTrue())
{
extractionCurve->setBranchDetection(true);
}
else if (m_branchDetection().isFalse())
{
extractionCurve->setBranchDetection(false);
}
if (m_branchIndex() != -1)
{
extractionCurve->setBranchIndex(m_branchIndex());
}
if (m_simWellName() != QString(""))
{
extractionCurve->setWellName(m_simWellName());
}
}
updatedSomething = true;
}
if (timeStepToApply() != -1)
{
extractionCurve->setCurrentTimeStep(timeStepToApply());
updatedSomething = true;
}
if (updatedSomething)
{
RimWellLogPlot* parentPlot = nullptr;
extractionCurve->firstAncestorOrThisOfTypeAsserted(parentPlot);
plots.insert(parentPlot);
}
}
}
for (RimWellLogPlot* plot : plots)
{
plot->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
RimWellLogPlot* parentPlot = nullptr;
this->firstAncestorOrThisOfType(parentPlot);
if (changedField == &m_branchDetection)
{
if (m_branchDetection().isPartiallyTrue())
{
// The Tristate is cycled from false -> partially true -> true
// Partially true is used for "Mixed state" and is not settable by the user so cycle on to true.
m_branchDetection.v() = caf::Tristate::State::True;
}
}
if (parentPlot)
{
std::vector<RimWellLogCurve*> wellLogCurves;
parentPlot->descendantsIncludingThisOfType(wellLogCurves);
this->updateCurves(wellLogCurves);
parentPlot->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellLogCurveCommonDataSource::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
RimWellLogPlot* parentPlot = nullptr;
this->firstAncestorOrThisOfType(parentPlot);
if (parentPlot)
{
std::vector<RimWellLogCurve*> wellLogCurves;
parentPlot->descendantsIncludingThisOfType(wellLogCurves);
this->updateDefaultOptions(wellLogCurves);
}
if (fieldNeedingOptions == &m_case)
{
RimTools::caseOptionItems(&options);
if (caseToApply() == nullptr)
{
options.push_front(caf::PdmOptionItemInfo("Mixed Cases", nullptr));
}
}
else if (fieldNeedingOptions == &m_trajectoryType)
{
if (m_trajectoryType() == -1)
{
options.push_back(caf::PdmOptionItemInfo("Mixed Trajectory Types", -1));
}
std::vector<RimWellLogExtractionCurve::TrajectoryType> trajectoryTypes =
{ RimWellLogExtractionCurve::WELL_PATH, RimWellLogExtractionCurve::SIMULATION_WELL };
for (RimWellLogExtractionCurve::TrajectoryType trajectoryType : trajectoryTypes)
{
caf::PdmOptionItemInfo item(caf::AppEnum<RimWellLogExtractionCurve::TrajectoryType>::uiText(trajectoryType),
static_cast<int>(trajectoryType));
options.push_back(item);
}
}
else if (fieldNeedingOptions == &m_wellPath)
{
RimTools::wellPathOptionItems(&options);
if (wellPathToApply() == nullptr)
{
options.push_front(caf::PdmOptionItemInfo("Mixed Well Paths", nullptr));
}
}
else if (fieldNeedingOptions == &m_timeStep)
{
QStringList timeStepNames;
if (m_case)
{
timeStepNames = m_case->timeStepStrings();
}
for (int i = 0; i < timeStepNames.size(); i++)
{
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
}
if (timeStepToApply() == -1)
{
options.push_front(caf::PdmOptionItemInfo("Mixed Time Steps", -1));
}
}
else if (fieldNeedingOptions == &m_simWellName)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
if (eclipseCase)
{
std::set<QString> sortedWellNames = eclipseCase->sortedSimWellNames();
QIcon simWellIcon(":/Well.png");
for (const QString& wname : sortedWellNames)
{
options.push_back(caf::PdmOptionItemInfo(wname, wname, false, simWellIcon));
}
if (options.size() == 0)
{
options.push_front(caf::PdmOptionItemInfo("None", "None"));
}
if (m_simWellName == QString(""))
{
options.push_front(caf::PdmOptionItemInfo("Mixed Well Names", ""));
}
}
}
else if (fieldNeedingOptions == &m_branchIndex)
{
bool hasCommonBranchDetection = !m_branchDetection().isPartiallyTrue();
if (hasCommonBranchDetection)
{
bool doBranchDetection = m_branchDetection().isTrue();
auto branches = RiaSimWellBranchTools::simulationWellBranches(m_simWellName, doBranchDetection);
options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(branches);
if (m_branchIndex() == -1)
{
options.push_front(caf::PdmOptionItemInfo("Mixed Branches", -1));
}
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
updateDefaultOptions();
caf::PdmUiGroup* group = uiOrdering.addNewGroup("Common Data Source");
group->add(&m_case);
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
if (eclipseCase)
{
group->add(&m_trajectoryType);
if (m_trajectoryType() == RimWellLogExtractionCurve::WELL_PATH)
{
group->add(&m_wellPath);
}
else
{
group->add(&m_simWellName);
if (RiaSimWellBranchTools::simulationWellBranches(m_simWellName(), true).size() > 1)
{
group->add(&m_branchDetection);
bool hasCommonBranchDetection = !m_branchDetection().isPartiallyTrue();
if (hasCommonBranchDetection)
{
bool doBranchDetection = m_branchDetection().isTrue();
if (RiaSimWellBranchTools::simulationWellBranches(m_simWellName(), doBranchDetection).size() > 1)
{
group->add(&m_branchIndex);
}
}
}
}
}
else
{
group->add(&m_wellPath);
}
group->add(&m_timeStep);
uiOrdering.skipRemainingFields(true);
}

View File

@@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimWellPath.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cafPdmUiOrdering.h"
#include "cafTristate.h"
class RimCase;
class RimWellLogCurve;
class RimWellLogPlot;
class RimWellPath;
//==================================================================================================
///
//==================================================================================================
class RimWellLogCurveCommonDataSource : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimWellLogCurveCommonDataSource();
RimCase* caseToApply() const;
void setCaseToApply(RimCase* val);
RimWellPath* wellPathToApply() const;
void setWellPathToApply(RimWellPath* val);
int timeStepToApply() const;
void setTimeStepToApply(int val);
void updateDefaultOptions(const std::vector<RimWellLogCurve*>& curves);
void updateDefaultOptions();
void updateCurves(std::vector<RimWellLogCurve*>& curves);
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
protected:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
private:
caf::PdmPtrField<RimCase*> m_case;
caf::PdmField<int> m_trajectoryType;
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmField<QString> m_simWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<caf::Tristate> m_branchDetection;
caf::PdmField<int> m_timeStep;
};

View File

@@ -88,12 +88,12 @@ RimWellLogExtractionCurve::RimWellLogExtractionCurve()
{
CAF_PDM_InitObject("Well Log Curve", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_trajectoryType, "TrajectoryType", "Trajectory", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_trajectoryType, "TrajectoryType", "Trajectory Type", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellPath, "CurveWellPath", " ", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellPath, "CurveWellPath", "Well Name", "", "", "");
m_wellPath.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitField(&m_simWellName, "SimulationWellName", QString("None"), " ", "", "", "");
CAF_PDM_InitField(&m_simWellName, "SimulationWellName", QString("None"), "Well Name", "", "", "");
CAF_PDM_InitField(&m_branchDetection, "BranchDetection", true, "Branch Detection", "",
"Compute branches based on how simulation well cells are organized", "");
CAF_PDM_InitField(&m_branchIndex, "Branch", 0, "Branch Index", "", "", "");
@@ -211,6 +211,14 @@ void RimWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view)
clearGeneratedSimWellPaths();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogExtractionCurve::TrajectoryType RimWellLogExtractionCurve::trajectoryType() const
{
return m_trajectoryType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -230,7 +238,7 @@ void RimWellLogExtractionCurve::clampTimestep()
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::clampBranchIndex()
{
int branchCount = static_cast<int>(simulationWellBranches().size());
int branchCount = static_cast<int>(RiaSimWellBranchTools::simulationWellBranches(m_simWellName, m_branchDetection).size());
if ( branchCount > 0 )
{
if ( m_branchIndex >= branchCount ) m_branchIndex = branchCount - 1;
@@ -253,7 +261,7 @@ void RimWellLogExtractionCurve::fieldChangedByUi(const caf::PdmFieldHandle* chan
{
clampTimestep();
auto wellNameSet = findSortedWellNames();
auto wellNameSet = sortedSimWellNames();
if (!wellNameSet.count(m_simWellName())) m_simWellName = "None";
clearGeneratedSimWellPaths();
@@ -332,7 +340,7 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate(bool updateParentPlot)
}
else
{
std::vector<const RigWellPath*> simWellBranches = simulationWellBranches();
std::vector<const RigWellPath*> simWellBranches = RiaSimWellBranchTools::simulationWellBranches(m_simWellName, m_branchDetection);
if (m_branchIndex >= 0 && m_branchIndex < static_cast<int>(simWellBranches.size()))
{
auto wellBranch = simWellBranches[m_branchIndex];
@@ -457,19 +465,13 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate(bool updateParentPlot)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<QString> RimWellLogExtractionCurve::findSortedWellNames()
std::set<QString> RimWellLogExtractionCurve::sortedSimWellNames()
{
std::set<QString> sortedWellNames;
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
if ( eclipseCase && eclipseCase->eclipseCaseData() )
if (eclipseCase)
{
const cvf::Collection<RigSimWellData>& simWellData = eclipseCase->eclipseCaseData()->wellResults();
for ( size_t wIdx = 0; wIdx < simWellData.size(); ++wIdx )
{
sortedWellNames.insert(simWellData[wIdx]->m_wellName);
}
sortedWellNames = eclipseCase->sortedSimWellNames();
}
return sortedWellNames;
@@ -497,14 +499,6 @@ void RimWellLogExtractionCurve::clearGeneratedSimWellPaths()
m_wellPathsWithExtractors.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<const RigWellPath*> RimWellLogExtractionCurve::simulationWellBranches() const
{
return RiaSimWellBranchTools::simulationWellBranches(m_simWellName, m_branchDetection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -543,7 +537,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogExtractionCurve::calculateValueOptions(c
}
else if (fieldNeedingOptions == &m_simWellName)
{
std::set<QString> sortedWellNames = this->findSortedWellNames();
std::set<QString> sortedWellNames = this->sortedSimWellNames();
QIcon simWellIcon(":/Well.png");
for ( const QString& wname: sortedWellNames )
@@ -558,7 +552,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogExtractionCurve::calculateValueOptions(c
}
else if (fieldNeedingOptions == &m_branchIndex)
{
auto branches = simulationWellBranches();
auto branches = RiaSimWellBranchTools::simulationWellBranches(m_simWellName, m_branchDetection);
options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(branches);
}
@@ -580,28 +574,28 @@ void RimWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::PdmU
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
curveDataGroup->add(&m_trajectoryType);
if (m_trajectoryType() == WELL_PATH)
{
curveDataGroup->add(&m_wellPath);
}
else
{
curveDataGroup->add(&m_simWellName);
RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName(curveDataGroup,
m_simWellName,
m_branchDetection,
m_branchIndex);
}
if (eclipseCase)
{
curveDataGroup->add(&m_trajectoryType);
if (m_trajectoryType() == WELL_PATH)
{
curveDataGroup->add(&m_wellPath);
}
else
{
curveDataGroup->add(&m_simWellName);
RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName(curveDataGroup,
m_simWellName,
m_branchDetection,
m_branchIndex);
}
m_eclipseResultDefinition->uiOrdering(uiConfigName, *curveDataGroup);
}
else if (geomCase)
{
curveDataGroup->add(&m_wellPath);
m_geomResultDefinition->uiOrdering(uiConfigName, *curveDataGroup);
}
@@ -691,7 +685,7 @@ QString RimWellLogExtractionCurve::createCurveAutoName()
if (!wellName().isEmpty())
{
generatedCurveName += wellName();
if (m_trajectoryType == SIMULATION_WELL && simulationWellBranches().size() > 1)
if (m_trajectoryType == SIMULATION_WELL && RiaSimWellBranchTools::simulationWellBranches(m_simWellName, m_branchDetection).size() > 1)
{
generatedCurveName.push_back(" Br" + QString::number(m_branchIndex + 1));
}
@@ -824,6 +818,22 @@ QString RimWellLogExtractionCurve::wellDate() const
return (m_timeStep >= 0 && m_timeStep < timeStepNames.size()) ? timeStepNames[m_timeStep] : "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellLogExtractionCurve::branchIndex() const
{
return m_branchIndex();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogExtractionCurve::branchDetection() const
{
return m_branchDetection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -894,3 +904,35 @@ void RimWellLogExtractionCurve::setGeoMechResultAddress(const RigFemResultAddres
{
m_geomResultDefinition->setResultAddress(resAddr);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::setTrajectoryType(TrajectoryType trajectoryType)
{
m_trajectoryType = trajectoryType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::setWellName(QString wellName)
{
m_simWellName = wellName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::setBranchDetection(bool branchDetection)
{
m_branchDetection = branchDetection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::setBranchIndex(int index)
{
m_branchIndex = index;
}

View File

@@ -56,9 +56,12 @@ public:
void setPropertiesFromView(Rim3dView* view);
TrajectoryType trajectoryType() const;
virtual QString wellName() const;
virtual QString wellLogChannelName() const;
virtual QString wellDate() const;
int branchIndex() const;
bool branchDetection() const;
bool isEclipseCurve() const;
QString caseName() const;
@@ -70,6 +73,11 @@ public:
void setEclipseResultVariable(const QString& resVarname);
void setGeoMechResultAddress(const RigFemResultAddress& resAddr);
void setTrajectoryType(TrajectoryType trajectoryType);
void setWellName(QString wellName);
void setBranchDetection(bool branchDetection);
void setBranchIndex(int index);
protected:
virtual QString createCurveAutoName() override;
virtual void onLoadDataAndUpdate(bool updateParentPlot) override;
@@ -84,9 +92,8 @@ private:
void setLogScaleFromSelectedResult();
void clampTimestep();
void clampBranchIndex();
std::set<QString> findSortedWellNames();
std::set<QString> sortedSimWellNames();
void clearGeneratedSimWellPaths();
std::vector<const RigWellPath*> simulationWellBranches() const;
private:
caf::PdmPtrField<RimCase*> m_case;

View File

@@ -25,6 +25,7 @@
#include "RimWellAllocationPlot.h"
#include "RimWellLogCurve.h"
#include "RimWellLogCurveCommonDataSource.h"
#include "RimWellLogTrack.h"
#include "RimWellRftPlot.h"
#include "RimWellPltPlot.h"
@@ -79,6 +80,12 @@ RimWellLogPlot::RimWellLogPlot()
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Well Log Plot"),"Name", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_commonDataSource, "CommonDataSource", "Common Data Source", "", "Change the Data Source of All Curves in the Plot", "");
m_commonDataSource = new RimWellLogCurveCommonDataSource;
m_commonDataSource.uiCapability()->setUiTreeHidden(true);
m_commonDataSource.uiCapability()->setUiTreeChildrenHidden(true);
m_commonDataSource.xmlCapability()->disableIO();
caf::AppEnum< RimWellLogPlot::DepthTypeEnum > depthType = MEASURED_DEPTH;
CAF_PDM_InitField(&m_depthType, "DepthType", depthType, "Type", "", "", "");
@@ -112,6 +119,7 @@ RimWellLogPlot::~RimWellLogPlot()
m_tracks.deleteAllChildObjects();
deleteViewWidget();
delete m_commonDataSource;
}
//--------------------------------------------------------------------------------------------------
@@ -610,6 +618,7 @@ void RimWellLogPlot::depthZoomMinMax(double* minimumDepth, double* maximumDepth)
void RimWellLogPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_userName);
m_commonDataSource->uiOrdering(uiConfigName, uiOrdering);
uiOrderingForDepthAxis(uiOrdering);
uiOrderingForPlotSettings(uiOrdering);
@@ -775,6 +784,14 @@ void RimWellLogPlot::deleteViewWidget()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::initAfterRead()
{
m_commonDataSource->updateDefaultOptions();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -19,16 +19,18 @@
#pragma once
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"
#include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RiaDefines.h"
#include "RimViewWindow.h"
#include <QPointer>
class RimWellLogCurveCommonDataSource;
class RiuWellLogPlot;
class RimWellLogTrack;
class RimWellRftPlot;
@@ -133,6 +135,9 @@ protected:
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
virtual void deleteViewWidget() override;
virtual void initAfterRead() override;
private:
void applyZoomAllDepths();
void applyDepthZoomFromVisibleDepth();
@@ -144,6 +149,7 @@ private:
private:
caf::PdmField<QString> m_userName;
caf::PdmChildField<RimWellLogCurveCommonDataSource*> m_commonDataSource;
caf::PdmChildArrayField<RimWellLogTrack*> m_tracks;
caf::PdmField< caf::AppEnum<DepthTypeEnum>> m_depthType;