From 8f4fa4592a91f3ec50eb41924c4e154611077c17 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 26 Jan 2017 17:41:34 +0100 Subject: [PATCH 01/43] #1078 Improved well cells and well cell fence settings --- .../ProjectDataModel/RimEclipseView.cpp | 6 +-- .../ProjectDataModel/RimEclipseWell.cpp | 4 +- .../RimEclipseWellCollection.cpp | 52 ++++++++++++++----- .../RimEclipseWellCollection.h | 8 +-- .../UserInterface/RiuMainWindow.cpp | 26 ++++------ ApplicationCode/UserInterface/RiuMainWindow.h | 4 +- 6 files changed, 62 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index d6d3f926ac..7546f3855e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1131,7 +1131,7 @@ void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleC visibleCells->setAll(false); // If all wells are forced off, return - if (this->wellCollection()->wellCellsToRangeFilterMode() == RimEclipseWellCollection::RANGE_ADD_NONE) return; + if (!this->wellCollection()->showWellCells()) return; RigActiveCellInfo* activeCellInfo = this->currentActiveCellInfo(); @@ -1141,7 +1141,7 @@ void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleC for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { RimEclipseWell* well = this->wellCollection()->wells()[wIdx]; - if (this->wellCollection()->wellCellsToRangeFilterMode() == RimEclipseWellCollection::RANGE_ADD_ALL || (well->showWell() && well->showWellCells()) ) + if (this->wellCollection()->showWellCells() && well->showWell() && well->showWellCells()) { RigSingleWellResultsData* wres = well->wellResults(); if (!wres) continue; @@ -1180,7 +1180,7 @@ void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleC (*visibleCells)[gridCellIndex] = true; // Calculate well fence cells - if (well->showWellCellFence() || this->wellCollection()->showWellCellFences()) + if (well->showWellCellFence() && this->wellCollection()->showWellCellFence()) { size_t i, j, k; grid->ijkFromCellIndex(gridCellIndex, &i, &j, &k); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index 4dfc009cb0..7c012fc7d4 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -51,8 +51,8 @@ RimEclipseWell::RimEclipseWell() CAF_PDM_InitField(&pipeScaleFactor, "WellPipeRadiusScale", 1.0, "Well Pipe Scale Factor", "", "", ""); CAF_PDM_InitField(&wellPipeColor, "WellPipeColor", cvf::Color3f(0.588f, 0.588f, 0.804f), "Well pipe color", "", "", ""); - CAF_PDM_InitField(&showWellCells, "ShowWellCells", true, "Add cells to range filter", "", "", ""); - CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Use well fence", "", "", ""); + CAF_PDM_InitField(&showWellCells, "ShowWellCells", true, "Show Well Cells", "", "", ""); + CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Show Well Cell Fence", "", "", ""); name.uiCapability()->setUiHidden(true); name.uiCapability()->setUiReadOnly(true); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index b954a20af7..dc42726e59 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -28,6 +28,7 @@ #include "RimEclipseView.h" #include "RimEclipseWell.h" +#include "RiuMainWindow.h" #include "RivReservoirViewPartMgr.h" #include "cafPdmUiPushButtonEditor.h" @@ -49,6 +50,7 @@ namespace caf namespace caf { + // OBSOLETE enum template<> void RimEclipseWellCollection::WellCellsRangeFilterEnum::setUp() { @@ -142,9 +144,9 @@ RimEclipseWellCollection::RimEclipseWellCollection() pipeCrossSectionVertexCount.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&wellPipeCoordType, "WellPipeCoordType", WellPipeCoordEnum(WELLPIPE_INTERPOLATED), "Well Pipe Geometry", "", "", ""); - CAF_PDM_InitField(&wellCellsToRangeFilterMode, "GlobalWellCellVisibility", WellCellsRangeFilterEnum(RANGE_ADD_NONE), "Add cells to range filter", "", "", ""); - CAF_PDM_InitField(&showWellCellFences, "ShowWellFences", false, "Use well fence", "", "", ""); - CAF_PDM_InitField(&wellCellFenceType, "DefaultWellFenceDirection", WellFenceEnum(K_DIRECTION), "Well Fence direction", "", "", ""); + CAF_PDM_InitField(&showWellCells, "ShowWellCells", false, "Show Well Cells", "", "", ""); + CAF_PDM_InitField(&showWellCellFence, "ShowWellFences", false, "Show Well Cell Fence", "", "", ""); + CAF_PDM_InitField(&wellCellFenceType, "DefaultWellFenceDirection", WellFenceEnum(K_DIRECTION), "Well Fence Direction", "", "", ""); CAF_PDM_InitField(&wellCellTransparencyLevel, "WellCellTransparency", 0.5, "Well Cell Transparency", "", "", ""); CAF_PDM_InitField(&isAutoDetectingBranches, "IsAutoDetectingBranches", true, "Branch Detection", "", "Toggle wether the well pipe visualization will try to detect when a part of the well \nis really a branch, and thus is starting from wellhead", ""); @@ -156,6 +158,10 @@ RimEclipseWellCollection::RimEclipseWellCollection() CAF_PDM_InitField(&obsoleteField_wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(PIPES_OPEN_IN_VISIBLE_CELLS), "Global well pipe visibility", "", "", ""); obsoleteField_wellPipeVisibility.uiCapability()->setUiHidden(true); obsoleteField_wellPipeVisibility.xmlCapability()->setIOWritable(false); + + CAF_PDM_InitField(&obsoleteField_wellCellsToRangeFilterMode, "GlobalWellCellVisibility", WellCellsRangeFilterEnum(RANGE_ADD_NONE), "Add cells to range filter", "", "", ""); + obsoleteField_wellCellsToRangeFilterMode.uiCapability()->setUiHidden(true); + obsoleteField_wellCellsToRangeFilterMode.xmlCapability()->setIOWritable(false); m_reservoirView = NULL; } @@ -189,14 +195,14 @@ RimEclipseWell* RimEclipseWellCollection::findWell(QString name) bool RimEclipseWellCollection::hasVisibleWellCells() { if (!this->isActive()) return false; - if (this->wellCellsToRangeFilterMode() == RANGE_ADD_NONE) return false; + if (!this->showWellCells()) return false; if (this->wells().size() == 0 ) return false; bool hasCells = false; for (size_t i = 0 ; !hasCells && i < this->wells().size(); ++i) { RimEclipseWell* well = this->wells()[i]; - if ( well && well->wellResults() && ((well->showWell() && well->showWellCells()) || this->wellCellsToRangeFilterMode() == RANGE_ADD_ALL) ) + if ( well && well->wellResults() && ((well->showWell() && well->showWellCells())) ) { for (size_t tIdx = 0; !hasCells && tIdx < well->wellResults()->m_wellCellsTimeSteps.size(); ++tIdx ) { @@ -211,8 +217,6 @@ bool RimEclipseWellCollection::hasVisibleWellCells() if (!hasCells) return false; - if (this->wellCellsToRangeFilterMode() == RANGE_ADD_INDIVIDUAL || this->wellCellsToRangeFilterMode() == RANGE_ADD_ALL) return true; - // Todo: Handle range filter intersection return true; @@ -243,8 +247,8 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang { if ( &isActive == changedField || &showWellLabel == changedField - || &wellCellsToRangeFilterMode == changedField - || &showWellCellFences == changedField + || &showWellCells == changedField + || &showWellCellFence == changedField || &wellCellFenceType == changedField) { m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); @@ -317,6 +321,11 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang m_applySingleColorToWells = false; } + + if (&showWellCells == changedField) + { + RiuMainWindow::instance()->refreshDrawStyleActions(); + } } //-------------------------------------------------------------------------------------------------- @@ -362,9 +371,10 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi uiOrdering.add(&wellHeadPosition); - caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well range filter"); - filterGroup->add(&wellCellsToRangeFilterMode); - filterGroup->add(&showWellCellFences); + caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well Cells"); + filterGroup->add(&obsoleteField_wellCellsToRangeFilterMode); + filterGroup->add(&showWellCells); + filterGroup->add(&showWellCellFence); filterGroup->add(&wellCellFenceType); } @@ -408,6 +418,24 @@ void RimEclipseWellCollection::initAfterRead() { showWellsIntersectingVisibleCells = false; } + + if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_NONE) + { + showWellCells = false; + } + else if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_ALL) + { + showWellCells = true; + + for (RimEclipseWell* w : wells) + { + w->showWellCells = true; + } + } + else if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_INDIVIDUAL) + { + showWellCells = true; + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index 5d2d31ab1b..552119a521 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -101,9 +101,8 @@ public: caf::PdmField wellLabelColor; caf::PdmField showConnectionStatusColors; - - caf::PdmField wellCellsToRangeFilterMode; - caf::PdmField showWellCellFences; + caf::PdmField showWellCells; + caf::PdmField showWellCellFence; caf::PdmField wellCellFenceType; caf::PdmField wellCellTransparencyLevel; @@ -145,5 +144,6 @@ private: caf::PdmField m_applyIndividualColorsToWells; // Obsolete fields - caf::PdmField obsoleteField_wellPipeVisibility; + caf::PdmField obsoleteField_wellPipeVisibility; + caf::PdmField obsoleteField_wellCellsToRangeFilterMode; }; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index dc8b0cc2e3..eff8cd68cb 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -289,11 +289,10 @@ void RiuMainWindow::createActions() m_toggleFaultsLabelAction->setCheckable(true); connect(m_toggleFaultsLabelAction, SIGNAL(toggled(bool)), SLOT(slotToggleFaultLabelsAction(bool))); - m_addWellCellsToRangeFilterAction = new QAction(QIcon(":/draw_style_WellCellsToRangeFilter_24x24.png"), "&Add Well Cells To Range Filter", this); - m_addWellCellsToRangeFilterAction->setCheckable(true); - m_addWellCellsToRangeFilterAction->setToolTip("Add Well Cells To Range Filter based on the individual settings"); - connect(m_addWellCellsToRangeFilterAction, SIGNAL(toggled(bool)), SLOT(slotAddWellCellsToRangeFilterAction(bool))); - + m_showWellCellsAction = new QAction(QIcon(":/draw_style_WellCellsToRangeFilter_24x24.png"), "&Show Well Cells", this); + m_showWellCellsAction->setCheckable(true); + m_showWellCellsAction->setToolTip("Show Well Cells"); + connect(m_showWellCellsAction, SIGNAL(toggled(bool)), SLOT(slotShowWellCellsAction(bool))); } //-------------------------------------------------------------------------------------------------- @@ -474,7 +473,7 @@ void RiuMainWindow::createToolBars() dsToolBar->addAction(m_disableLightingAction); dsToolBar->addAction(m_drawStyleHideGridCellsAction); dsToolBar->addAction(m_toggleFaultsLabelAction); - dsToolBar->addAction(m_addWellCellsToRangeFilterAction); + dsToolBar->addAction(m_showWellCellsAction); } // Create animation toolbar @@ -1376,7 +1375,7 @@ void RiuMainWindow::refreshDrawStyleActions() enable = enable && eclView; m_toggleFaultsLabelAction->setEnabled(enable); - m_addWellCellsToRangeFilterAction->setEnabled(enable); + m_showWellCellsAction->setEnabled(enable); if (enable) { @@ -1384,9 +1383,9 @@ void RiuMainWindow::refreshDrawStyleActions() m_toggleFaultsLabelAction->setChecked(eclView->faultCollection()->showFaultLabel()); m_toggleFaultsLabelAction->blockSignals(false); - m_addWellCellsToRangeFilterAction->blockSignals(true); - m_addWellCellsToRangeFilterAction->setChecked(eclView->wellCollection()->wellCellsToRangeFilterMode() != RimEclipseWellCollection::RANGE_ADD_NONE); - m_addWellCellsToRangeFilterAction->blockSignals(false); + m_showWellCellsAction->blockSignals(true); + m_showWellCellsAction->setChecked(eclView->wellCollection()->showWellCells()); + m_showWellCellsAction->blockSignals(false); } } @@ -1573,15 +1572,12 @@ void RiuMainWindow::setDefaultWindowSize() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainWindow::slotAddWellCellsToRangeFilterAction(bool doAdd) +void RiuMainWindow::slotShowWellCellsAction(bool doAdd) { RimEclipseView* riv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (riv) { - caf::AppEnum rangeAddType; - rangeAddType = doAdd ? RimEclipseWellCollection::RANGE_ADD_INDIVIDUAL : RimEclipseWellCollection::RANGE_ADD_NONE; - - riv->wellCollection()->wellCellsToRangeFilterMode.setValueWithFieldChanged(rangeAddType); + riv->wellCollection()->showWellCells.setValueWithFieldChanged(doAdd); } } diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 6f1b4123cd..11b90ff4e6 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -191,7 +191,7 @@ private slots: void slotToggleFaultLabelsAction(bool); void slotDisableLightingAction(bool); - void slotAddWellCellsToRangeFilterAction(bool doAdd); + void slotShowWellCellsAction(bool doAdd); // Debug slots void slotUseShaders(bool enable); @@ -246,7 +246,7 @@ private: QAction* m_drawStyleLinesSolidAction; QAction* m_drawStyleFaultLinesSolidAction; QAction* m_drawStyleSurfOnlyAction; - QAction* m_addWellCellsToRangeFilterAction; + QAction* m_showWellCellsAction; std::vector > additionalProjectViews; From ccc7345706603cf3d2cd721411ef89d96082b385 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 26 Jan 2017 17:52:13 +0100 Subject: [PATCH 02/43] #1078 Added context menu for well cells and well cell fence --- .../RicEclipseWellShowFeatures.cpp | 119 ++++++++++++++++++ .../EclipseWell/RicEclipseWellShowFeatures.h | 28 +++++ .../RimContextCommandBuilder.cpp | 2 + 3 files changed, 149 insertions(+) diff --git a/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.cpp b/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.cpp index 3d325545fa..486abe5634 100644 --- a/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.cpp +++ b/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.cpp @@ -267,3 +267,122 @@ bool RicEclipseWellShowSpheresFeature::isCommandChecked() } + + + + + + +CAF_CMD_SOURCE_INIT(RicEclipseWellShowWellCellsFeature, "RicEclipseWellShowWellCellsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicEclipseWellShowWellCellsFeature::onActionTriggered(bool isChecked) +{ + std::vector selection = RicEclipseWellFeatureImpl::selectedWells(); + for (RimEclipseWell* w : selection) + { + w->showWellCells.setValueWithFieldChanged(isChecked); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicEclipseWellShowWellCellsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Show Well Cells"); + actionToSetup->setCheckable(true); + actionToSetup->setChecked(isCommandChecked()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicEclipseWellShowWellCellsFeature::isCommandEnabled() +{ + RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection(); + if (wellColl && !wellColl->showWellCells()) + { + return false; + } + + return RicEclipseWellFeatureImpl::isAnyWellSelected(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicEclipseWellShowWellCellsFeature::isCommandChecked() +{ + std::vector selection = RicEclipseWellFeatureImpl::selectedWells(); + if (selection.size() > 0) + { + RimEclipseWell* well = selection[0]; + + return well->showWellCells(); + } + + return false; +} + + + + + + + +CAF_CMD_SOURCE_INIT(RicEclipseWellShowWellCellFenceFeature, "RicEclipseWellShowWellCellFenceFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicEclipseWellShowWellCellFenceFeature::onActionTriggered(bool isChecked) +{ + std::vector selection = RicEclipseWellFeatureImpl::selectedWells(); + for (RimEclipseWell* w : selection) + { + w->showWellCellFence.setValueWithFieldChanged(isChecked); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicEclipseWellShowWellCellFenceFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Show Well Cell Fence"); + actionToSetup->setCheckable(true); + actionToSetup->setChecked(isCommandChecked()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicEclipseWellShowWellCellFenceFeature::isCommandEnabled() +{ + RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection(); + if (wellColl && !(wellColl->showWellCells() || wellColl->showWellCellFence())) + { + return false; + } + + return RicEclipseWellFeatureImpl::isAnyWellSelected(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicEclipseWellShowWellCellFenceFeature::isCommandChecked() +{ + std::vector selection = RicEclipseWellFeatureImpl::selectedWells(); + if (selection.size() > 0) + { + RimEclipseWell* well = selection[0]; + + return well->showWellCellFence(); + } + + return false; +} diff --git a/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.h b/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.h index 590f706a39..2b794d3256 100644 --- a/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.h +++ b/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.h @@ -77,3 +77,31 @@ protected: virtual bool isCommandChecked() override; }; +//================================================================================================== +/// +//================================================================================================== +class RicEclipseWellShowWellCellsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + virtual bool isCommandEnabled() override; + virtual bool isCommandChecked() override; +}; + +//================================================================================================== +/// +//================================================================================================== +class RicEclipseWellShowWellCellFenceFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + virtual bool isCommandEnabled() override; + virtual bool isCommandChecked() override; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index f9119bafda..6092ebdeda 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -409,6 +409,8 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicEclipseWellShowHeadFeature"; commandIds << "RicEclipseWellShowPipeFeature"; commandIds << "RicEclipseWellShowSpheresFeature"; + commandIds << "RicEclipseWellShowWellCellsFeature"; + commandIds << "RicEclipseWellShowWellCellFenceFeature"; } } From 1e20a61d4c251822b004db7af2210df1ecc165ec Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 26 Jan 2017 18:01:00 +0100 Subject: [PATCH 03/43] #1078 Updated enabled state of well cells and well cell fence --- ApplicationCode/ProjectDataModel/RimEclipseWell.cpp | 7 ++++++- .../ProjectDataModel/RimEclipseWellCollection.cpp | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index 7c012fc7d4..f98fdd568a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -211,7 +211,7 @@ void RimEclipseWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& pipeGroup->add(&wellPipeColor); - caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Range filter"); + caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well Cells"); filterGroup->add(&showWellCells); filterGroup->add(&showWellCellFence); @@ -223,6 +223,11 @@ void RimEclipseWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& showWellHead.uiCapability()->setUiReadOnly(!wellColl->showWellHead()); showWellPipe.uiCapability()->setUiReadOnly(!wellColl->showWellPipe()); showWellSpheres.uiCapability()->setUiReadOnly(!wellColl->showWellSpheres()); + showWellCells.uiCapability()->setUiReadOnly(!wellColl->showWellCells()); + + bool isFenceEnabled = false; + if (wellColl->showWellCells() && wellColl->showWellCellFence()) isFenceEnabled = true; + showWellCellFence.uiCapability()->setUiReadOnly(!isFenceEnabled); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index dc42726e59..1d8ff29a06 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -376,6 +376,9 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi filterGroup->add(&showWellCells); filterGroup->add(&showWellCellFence); filterGroup->add(&wellCellFenceType); + + showWellCellFence.uiCapability()->setUiReadOnly(!showWellCells()); + wellCellFenceType.uiCapability()->setUiReadOnly(!showWellCells()); } //-------------------------------------------------------------------------------------------------- From 23eeacde37c31b373f96fc455cc386736e53918b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Jan 2017 15:19:18 +0100 Subject: [PATCH 04/43] #1094 Improved constness and use of range based for --- .../ProjectDataModel/RimEclipseWell.cpp | 50 +++++++++++-------- .../ProjectDataModel/RimEclipseWell.h | 21 ++++---- .../RimIntersectionCollection.cpp | 2 +- .../RimIntersectionCollection.h | 2 +- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index f98fdd568a..eb724d4a51 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -140,7 +140,7 @@ void RimEclipseWell::calculateWellPipeDynamicCenterLine(size_t timeStepIdx, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimEclipseWell::visibleCellsInstersectsWell(size_t frameIndex) +bool RimEclipseWell::intersectsVisibleCells(size_t frameIndex) const { if (this->wellResults() == nullptr) return false; @@ -152,10 +152,10 @@ bool RimEclipseWell::visibleCellsInstersectsWell(size_t frameIndex) const std::vector& visGridParts = m_reservoirView->visibleGridParts(); cvf::cref rvMan = m_reservoirView->reservoirGridPartManager(); - for (size_t gpIdx = 0; gpIdx < visGridParts.size(); ++gpIdx) - { - const RigWellResultFrame& wrsf = this->wellResults()->wellResultFrame(frameIndex); + const RigWellResultFrame& wrsf = this->wellResults()->wellResultFrame(frameIndex); + for (const RivCellSetEnum& visGridPart : visGridParts) + { // First check the wellhead: size_t gridIndex = wrsf.m_wellHead.m_gridIndex; @@ -163,7 +163,7 @@ bool RimEclipseWell::visibleCellsInstersectsWell(size_t frameIndex) if (gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T) { - cvf::cref cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex); + cvf::cref cellVisibility = rvMan->cellVisibility(visGridPart, gridIndex, frameIndex); if ((*cellVisibility)[gridCellIndex]) { return true; @@ -173,17 +173,17 @@ bool RimEclipseWell::visibleCellsInstersectsWell(size_t frameIndex) // Then check the rest of the well, with all the branches const std::vector& wellResSegments = wrsf.m_wellResultBranches; - for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx) + for (const RigWellResultBranch& branchSegment : wellResSegments) { - const std::vector& wsResCells = wellResSegments[wsIdx].m_branchResultPoints; - for (size_t cIdx = 0; cIdx < wsResCells.size(); ++cIdx) + const std::vector& wsResCells = branchSegment.m_branchResultPoints; + for (const RigWellResultPoint& wellResultPoint : wsResCells) { - if (wsResCells[cIdx].isCell()) + if (wellResultPoint.isCell()) { - gridIndex = wsResCells[cIdx].m_gridIndex; - gridCellIndex = wsResCells[cIdx].m_gridCellIndex; + gridIndex = wellResultPoint.m_gridIndex; + gridCellIndex = wellResultPoint.m_gridCellIndex; - cvf::cref cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex); + cvf::cref cellVisibility = rvMan->cellVisibility(visGridPart, gridIndex, frameIndex); if ((*cellVisibility)[gridCellIndex]) { return true; @@ -234,9 +234,9 @@ void RimEclipseWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimEclipseWell::isWellPipeVisible(size_t frameIndex) +bool RimEclipseWell::isWellPipeVisible(size_t frameIndex) const { - RimEclipseView* reservoirView = nullptr; + const RimEclipseView* reservoirView = nullptr; this->firstAncestorOrThisOfType(reservoirView); if (reservoirView == nullptr) return false; @@ -270,7 +270,7 @@ bool RimEclipseWell::isWellPipeVisible(size_t frameIndex) if (reservoirView->wellCollection()->showWellsIntersectingVisibleCells()) { - return visibleCellsInstersectsWell(frameIndex); + return intersectsVisibleCells(frameIndex); } else { @@ -281,9 +281,9 @@ bool RimEclipseWell::isWellPipeVisible(size_t frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimEclipseWell::isWellSpheresVisible(size_t frameIndex) +bool RimEclipseWell::isWellSpheresVisible(size_t frameIndex) const { - RimEclipseView* m_reservoirView = nullptr; + const RimEclipseView* m_reservoirView = nullptr; this->firstAncestorOrThisOfType(m_reservoirView); if (m_reservoirView == nullptr) return false; @@ -317,7 +317,7 @@ bool RimEclipseWell::isWellSpheresVisible(size_t frameIndex) if (m_reservoirView->wellCollection()->showWellsIntersectingVisibleCells()) { - return visibleCellsInstersectsWell(frameIndex); + return intersectsVisibleCells(frameIndex); } else { @@ -332,9 +332,9 @@ bool RimEclipseWell::isWellSpheresVisible(size_t frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimEclipseWell::isUsingCellCenterForPipe() +bool RimEclipseWell::isUsingCellCenterForPipe() const { - RimEclipseWellCollection* wellColl = nullptr; + const RimEclipseWellCollection* wellColl = nullptr; this->firstAncestorOrThisOfType(wellColl); return (wellColl && wellColl->wellPipeCoordType() == RimEclipseWellCollection::WELLPIPE_CELLCENTER); @@ -360,7 +360,15 @@ RigSingleWellResultsData* RimEclipseWell::wellResults() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RimEclipseWell::resultWellIndex() +const RigSingleWellResultsData* RimEclipseWell::wellResults() const +{ + return m_wellResults.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimEclipseWell::resultWellIndex() const { return m_resultWellIndex; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.h b/ApplicationCode/ProjectDataModel/RimEclipseWell.h index 5635330bf8..2ce9fe629c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.h @@ -46,16 +46,16 @@ public: void setWellResults(RigSingleWellResultsData* wellResults, size_t resultWellIndex); RigSingleWellResultsData* wellResults(); - size_t resultWellIndex(); + const RigSingleWellResultsData* wellResults() const; + size_t resultWellIndex() const; - bool isWellPipeVisible(size_t frameIndex); - bool isWellSpheresVisible(size_t frameIndex); - bool isUsingCellCenterForPipe(); + bool isWellPipeVisible(size_t frameIndex) const; + bool isWellSpheresVisible(size_t frameIndex) const; + bool isUsingCellCenterForPipe() const; - bool visibleCellsInstersectsWell(size_t frameIndex); - virtual caf::PdmFieldHandle* userDescriptionField(); - virtual caf::PdmFieldHandle* objectToggleField(); + virtual caf::PdmFieldHandle* userDescriptionField() override; + virtual caf::PdmFieldHandle* objectToggleField() override; void calculateWellPipeStaticCenterLine( std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds); @@ -81,8 +81,11 @@ public: caf::PdmField showWellCellFence; protected: - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + +private: + bool intersectsVisibleCells(size_t frameIndex) const; private: cvf::ref m_wellResults; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index 350d3bd606..096c392e18 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -191,7 +191,7 @@ void RimIntersectionCollection::fieldChangedByUi(const caf::PdmFieldHandle* chan //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimIntersectionCollection::hasActiveIntersectionForSimulationWell(RimEclipseWell* eclipseWell) const +bool RimIntersectionCollection::hasActiveIntersectionForSimulationWell(const RimEclipseWell* eclipseWell) const { if (!isActive) return false; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index 29866d3f11..7ff1b7bd0e 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -51,7 +51,7 @@ public: void appendIntersection(RimIntersection* intersection); void appendIntersectionBox(RimIntersectionBox* intersectionBox); - bool hasActiveIntersectionForSimulationWell(RimEclipseWell* eclipseWell) const; + bool hasActiveIntersectionForSimulationWell(const RimEclipseWell* eclipseWell) const; void updateIntersectionBoxGeometry(); From bd14f97a2b28a36eb660a3f391d0fa96eb7d1394 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Jan 2017 15:48:56 +0100 Subject: [PATCH 05/43] #1094 Use range based for --- .../ProjectDataModel/RimEclipseWellCollection.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index 1d8ff29a06..ee9fba0270 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -504,12 +504,12 @@ void RimEclipseWellCollection::calculateWellGeometryVisibility(size_t frameIndex if (m_framesOfResultWellPipeVisibilities[frameIndex].size() <= wells().size()) m_framesOfResultWellPipeVisibilities[frameIndex].resize(wells().size(), false); - for (size_t i = 0; i < wells().size(); ++i) + for (const RimEclipseWell* well : wells()) { - bool wellPipeVisible = wells[i]->isWellPipeVisible(frameIndex); - bool wellSphereVisible = wells[i]->isWellSpheresVisible(frameIndex); + bool wellPipeVisible = well->isWellPipeVisible(frameIndex); + bool wellSphereVisible = well->isWellSpheresVisible(frameIndex); - m_framesOfResultWellPipeVisibilities[frameIndex][wells[i]->resultWellIndex()] = wellPipeVisible || wellSphereVisible; + m_framesOfResultWellPipeVisibilities[frameIndex][well->resultWellIndex()] = wellPipeVisible || wellSphereVisible; } } From 7b6574327e90bb6b3cea1583066c9edd2b09598d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Jan 2017 15:50:17 +0100 Subject: [PATCH 06/43] #1094 Gray out wells not visible because they do not intersect visible cells --- .../ProjectDataModel/RimEclipseView.cpp | 7 ++++++ .../ProjectDataModel/RimEclipseWell.cpp | 25 +++++++++++++++++++ .../ProjectDataModel/RimEclipseWell.h | 1 + 3 files changed, 33 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 7546f3855e..4b441e6994 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -791,6 +791,13 @@ void RimEclipseView::updateDisplayModelVisibility() m_viewer->update(); faultCollection->updateConnectedEditors(); + + // This is required to update the read-only state of simulation wells + // when a range filter is manipulated and visible simulation wells might change + // + // The visibility is controlled by RimEclipseWell::defineUiTreeOrdering + // updateConnectedEditors will call recursively on child objects + wellCollection->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index eb724d4a51..553d2b8829 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -231,6 +231,31 @@ void RimEclipseWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseWell::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + const RimEclipseView* reservoirView = nullptr; + this->firstAncestorOrThisOfType(reservoirView); + if (!reservoirView) return; + + const RimEclipseWellCollection* wellColl = nullptr; + this->firstAncestorOrThisOfType(wellColl); + if (!wellColl) return; + + if (wellColl->showWellsIntersectingVisibleCells() && !this->intersectsVisibleCells(static_cast(reservoirView->currentTimeStep()))) + { + // Mark well as read only if well is not intersecting visible cells + + this->uiCapability()->setUiReadOnly(true); + } + else + { + this->uiCapability()->setUiReadOnly(false); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.h b/ApplicationCode/ProjectDataModel/RimEclipseWell.h index 2ce9fe629c..5946d6ef57 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.h @@ -83,6 +83,7 @@ public: protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; private: bool intersectsVisibleCells(size_t frameIndex) const; From 301c36d80905700ecc171498f9aec5d176d217e6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Jan 2017 14:50:45 +0100 Subject: [PATCH 07/43] #1148 Always show connection status color for well spheres --- ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp index 47250bbf5a..f673e5c41d 100644 --- a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp @@ -194,7 +194,7 @@ cvf::Color3f RivWellSpheresPartMgr::wellCellColor(const RigWellResultFrame& well m_rimWell->firstAncestorOrThisOfType(wellColl); } - if (wellColl && wellColl->showConnectionStatusColors()) + if (wellColl) { if (wellResultPoint.m_isOpen) { From 9aa273e3a2b13120b932efea18500efed4a4de77 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Jan 2017 14:53:20 +0100 Subject: [PATCH 08/43] #1148 Rename and reorder of items in panel --- .../ProjectDataModel/RimEclipseWellCollection.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index ee9fba0270..ec6d99aade 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -121,7 +121,7 @@ RimEclipseWellCollection::RimEclipseWellCollection() // Color cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor(); - CAF_PDM_InitField(&wellLabelColor, "WellLabelColor", defWellLabelColor, "Well label color", "", "", ""); + CAF_PDM_InitField(&wellLabelColor, "WellLabelColor", defWellLabelColor, "Well Label Color", "", "", ""); CAF_PDM_InitField(&showConnectionStatusColors, "ShowConnectionStatusColors", true, "Show Connection Status Colors Along Well", "", "", ""); @@ -142,7 +142,7 @@ RimEclipseWellCollection::RimEclipseWellCollection() CAF_PDM_InitField(&pipeCrossSectionVertexCount, "WellPipeVertexCount", 12, "Pipe vertex count", "", "", ""); pipeCrossSectionVertexCount.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&wellPipeCoordType, "WellPipeCoordType", WellPipeCoordEnum(WELLPIPE_INTERPOLATED), "Well Pipe Geometry", "", "", ""); + CAF_PDM_InitField(&wellPipeCoordType, "WellPipeCoordType", WellPipeCoordEnum(WELLPIPE_INTERPOLATED), "Type", "", "", ""); CAF_PDM_InitField(&showWellCells, "ShowWellCells", false, "Show Well Cells", "", "", ""); CAF_PDM_InitField(&showWellCellFence, "ShowWellFences", false, "Show Well Cell Fence", "", "", ""); @@ -343,7 +343,7 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi { uiOrdering.add(&showWellsIntersectingVisibleCells); - caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Visibility"); appearanceGroup->add(&showWellLabel); appearanceGroup->add(&showWellHead); appearanceGroup->add(&showWellPipe); @@ -363,13 +363,13 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi colorGroup->add(&showConnectionStatusColors); - uiOrdering.add(&wellPipeCoordType); + caf::PdmUiGroup* wellPipeGroup = uiOrdering.addNewGroup("Well Pipe Geometry"); + wellPipeGroup->add(&wellPipeCoordType); + wellPipeGroup->add(&isAutoDetectingBranches); caf::PdmUiGroup* advancedGroup = uiOrdering.addNewGroup("Advanced"); - advancedGroup->add(&isAutoDetectingBranches); advancedGroup->add(&wellCellTransparencyLevel); - - uiOrdering.add(&wellHeadPosition); + advancedGroup->add(&wellHeadPosition); caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well Cells"); filterGroup->add(&obsoleteField_wellCellsToRangeFilterMode); From f2a4fee68f4e46dfcb1f6557dad5fc6ed4fae58d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Jan 2017 14:59:10 +0100 Subject: [PATCH 09/43] Added missing updateConnectedEditors --- ApplicationCode/ProjectDataModel/RimEclipseView.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 4b441e6994..6b7406a2d7 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -633,6 +633,10 @@ void RimEclipseView::updateCurrentTimeStep() } m_overlayInfoConfig()->update3DInfo(); + + // Invisible Wells are marked as read only when "show wells intersecting visible cells" is enabled + // Visibility of wells differ betweeen time steps, so trigger a rebuild of tree state items + wellCollection->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- From b75fdb4a6d2848a8737564bb19b64f8d0175fe50 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 31 Jan 2017 09:58:11 +0100 Subject: [PATCH 10/43] #1152 Replace space in filenames with underscore --- ApplicationCode/Commands/RicExportMultipleSnapshotsFeature.cpp | 3 +++ ApplicationCode/Commands/RicSnapshotViewToClipboardFeature.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/ApplicationCode/Commands/RicExportMultipleSnapshotsFeature.cpp b/ApplicationCode/Commands/RicExportMultipleSnapshotsFeature.cpp index bddf2dfeed..1cbf5b6b0a 100644 --- a/ApplicationCode/Commands/RicExportMultipleSnapshotsFeature.cpp +++ b/ApplicationCode/Commands/RicExportMultipleSnapshotsFeature.cpp @@ -239,6 +239,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri { QString fileName = viewCaseResultString + "_" + timeStepString; QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png"); + absoluteFileName.replace(" ", "_"); RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, rimView); } @@ -275,6 +276,8 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri rimView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews(rangeFilter); QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png"); + absoluteFileName.replace(" ", "_"); + RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, rimView); } diff --git a/ApplicationCode/Commands/RicSnapshotViewToClipboardFeature.cpp b/ApplicationCode/Commands/RicSnapshotViewToClipboardFeature.cpp index 774ce09d64..6c0e0f3f42 100644 --- a/ApplicationCode/Commands/RicSnapshotViewToClipboardFeature.cpp +++ b/ApplicationCode/Commands/RicSnapshotViewToClipboardFeature.cpp @@ -211,6 +211,7 @@ void RicSnapshotAllPlotsToFileFeature::createSnapshotOfAllPlotsInFolder(QString fileName = caf::Utils::makeValidFileBasename(fileName); QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png"); + absoluteFileName.replace(" ", "_"); RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, wellLogPlot); } @@ -229,6 +230,7 @@ void RicSnapshotAllPlotsToFileFeature::createSnapshotOfAllPlotsInFolder(QString fileName = caf::Utils::makeValidFileBasename(fileName); QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png"); + absoluteFileName.replace(" ", "_"); RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, summaryPlot); } From d3f1c9d6fafa8da8fc80db4d0512ad1ca9d49f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 31 Jan 2017 15:28:15 +0100 Subject: [PATCH 11/43] #1112 Calculation of accumulated well flow is now implemented. Tracers are handled, as well as MSW's. --- .../Flow/RimWellAllocationPlot.cpp | 287 ++++++------------ .../Flow/RimWellFlowRateCurve.cpp | 9 +- .../Flow/RimWellFlowRateCurve.h | 4 +- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../RigAccWellFlowCalculator.cpp | 231 ++++++++++++++ .../RigAccWellFlowCalculator.h | 96 ++++++ .../RigSingleWellResultsData.h | 12 + 7 files changed, 450 insertions(+), 191 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.h diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 1c6743aec3..ae49638eb6 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -39,136 +39,15 @@ #include "RiuMainPlotWindow.h" #include "RiuWellAllocationPlot.h" +#include "RigAccWellFlowCalculator.h" CAF_PDM_SOURCE_INIT(RimWellAllocationPlot, "WellAllocationPlot"); -//================================================================================================== + +//-------------------------------------------------------------------------------------------------- /// -/// -//================================================================================================== - -class RigAccWellFlowCalculator -{ - -public: - RigAccWellFlowCalculator(const std::vector< std::vector >& pipeBranchesCLCoords, - const std::vector< std::vector >& pipeBranchesCellIds): - m_pipeBranchesCLCoords(pipeBranchesCLCoords), m_pipeBranchesCellIds(pipeBranchesCellIds) - { - m_accConnectionFlowPrBranch.resize(m_pipeBranchesCellIds.size()); - - calculateAccumulatedFlowPrConnection(0,1); - } - - // Returned pair is connection number from top of well with accumulated flow - - const std::vector >& accumulatedFlowPrConnection(size_t branchIdx) - { - return m_accConnectionFlowPrBranch[branchIdx]; - } - -private: - - - - const std::vector >& calculateAccumulatedFlowPrConnection(size_t branchIdx, size_t startConnectionNumberFromTop) - { - std::vector >& accConnectionFlow = m_accConnectionFlowPrBranch[branchIdx]; - - const std::vector& branchCells = m_pipeBranchesCellIds[branchIdx]; - int clSegIdx = static_cast( branchCells.size()) - 1; - double accFlow = 0.0; - - size_t prevGridIdx = -1; - size_t prevGridCellIdx = -1; - - std::vector resPointToConnectionIndexFromBottom; - resPointToConnectionIndexFromBottom.resize(branchCells.size(), -1); - - size_t connIdxFromBottom = 0; - - while (clSegIdx >= 0) - { - resPointToConnectionIndexFromBottom[clSegIdx] = connIdxFromBottom; - - if ( branchCells[clSegIdx].m_gridIndex != prevGridIdx - && branchCells[clSegIdx].m_gridCellIndex != prevGridIdx ) - { - ++connIdxFromBottom; - } - - prevGridIdx = branchCells[clSegIdx].m_gridIndex ; - prevGridCellIdx = branchCells[clSegIdx].m_gridCellIndex; - - --clSegIdx; - } - - size_t prevConnIndx = -1; - clSegIdx = static_cast( branchCells.size()) - 1; - - while (clSegIdx >= 0) - { - // Skip point if referring to the same cell as in the previous point did - { - if (resPointToConnectionIndexFromBottom[clSegIdx] == prevConnIndx) - { - --clSegIdx; - continue; - } - - prevConnIndx = resPointToConnectionIndexFromBottom[clSegIdx]; - } - - size_t connNumFromTop = connecionIdxFromTop(resPointToConnectionIndexFromBottom, clSegIdx) + startConnectionNumberFromTop; - - accFlow += branchCells[clSegIdx].m_flowRate; - std::vector downstreamBranches = findDownstreamBranchIdxs(branchCells[clSegIdx]); - for (size_t dsBidx : downstreamBranches ) - { - if ( dsBidx != branchIdx && m_accConnectionFlowPrBranch[dsBidx].size() == 0) // Not this branch or already calculated - { - const std::pair & brancFlowPair = calculateAccumulatedFlowPrConnection(dsBidx, connNumFromTop).back(); - accFlow += brancFlowPair.second; - } - } - - accConnectionFlow.push_back(std::make_pair(connNumFromTop, accFlow)); - - --clSegIdx; - } - - return m_accConnectionFlowPrBranch[branchIdx]; - } - - static size_t connecionIdxFromTop( std::vector resPointToConnectionIndexFromBottom, size_t clSegIdx) - { - return resPointToConnectionIndexFromBottom.front() - resPointToConnectionIndexFromBottom[clSegIdx]; - } - - std::vector findDownstreamBranchIdxs(const RigWellResultPoint& connectionPoint) - { - std::vector downStreamBranchIdxs; - - for (size_t bIdx = 0; bIdx < m_pipeBranchesCellIds.size(); ++bIdx) - { - if ( m_pipeBranchesCellIds[bIdx][0].m_gridIndex == connectionPoint.m_gridIndex - && m_pipeBranchesCellIds[bIdx][0].m_gridCellIndex == connectionPoint.m_gridCellIndex) - { - downStreamBranchIdxs.push_back(bIdx); - } - } - return downStreamBranchIdxs; - } - - - const std::vector< std::vector >& m_pipeBranchesCLCoords; - const std::vector< std::vector >& m_pipeBranchesCellIds; - - std::vector< std::vector > > m_accConnectionFlowPrBranch; - -}; - +//-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- /// @@ -250,30 +129,6 @@ void RimWellAllocationPlot::deleteViewWidget() //-------------------------------------------------------------------------------------------------- void RimWellAllocationPlot::updateFromWell() { - if (!m_case) return; - - const RigSingleWellResultsData* wellResults = nullptr; - wellResults = m_case->reservoirData()->findWellResult(m_wellName); - - if (!wellResults) return; - - - const RigWellResultFrame* wellResultFrame = nullptr; - std::vector< std::vector > pipeBranchesCLCoords; - std::vector< std::vector > pipeBranchesCellIds; - - RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(m_case->reservoirData(), - wellResults, - m_timeStep, - true, - true, - pipeBranchesCLCoords, - pipeBranchesCellIds); - - accumulatedWellFlowPlot()->setDescription("Accumulated Well Flow (" + m_wellName + ")"); - - RigAccWellFlowCalculator wfCalculator(pipeBranchesCLCoords, pipeBranchesCellIds); - // Delete existing tracks { std::vector tracks; @@ -288,9 +143,75 @@ void RimWellAllocationPlot::updateFromWell() CVF_ASSERT(accumulatedWellFlowPlot()->trackCount() == 0); + accumulatedWellFlowPlot()->setDescription("Accumulated Well Flow (" + m_wellName + ")"); + + if (!m_case) return; + + const RigSingleWellResultsData* wellResults = nullptr; + wellResults = m_case->reservoirData()->findWellResult(m_wellName); + + if (!wellResults) return; + + std::vector< std::vector > pipeBranchesCLCoords; + std::vector< std::vector > pipeBranchesCellIds; + + RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(m_case->reservoirData(), + wellResults, + m_timeStep, + true, + true, + pipeBranchesCLCoords, + pipeBranchesCellIds); + std::unique_ptr< RigAccWellFlowCalculator > wfCalculator; + std::map* > tracerCellFractionValues; + + if ( m_flowDiagSolution ) + { + RimFlowDiagSolution::TracerStatusType requestedTracerType = RimFlowDiagSolution::UNDEFINED; + + const RigWellResultFrame& wellResultFrame = wellResults->wellResultFrame(m_timeStep); + if (wellResultFrame.m_productionType == RigWellResultFrame::PRODUCER) + { + requestedTracerType = RimFlowDiagSolution::INJECTOR; + } + else + { + requestedTracerType = RimFlowDiagSolution::PRODUCER; + } + + + std::vector tracerNames = m_flowDiagSolution->tracerNames(); + for ( const QString& tracerName : tracerNames ) + { + if (m_flowDiagSolution->tracerStatusInTimeStep(tracerName, m_timeStep) == requestedTracerType) + { + RigFlowDiagResultAddress resAddr(RIG_FLD_CELL_FRACTION_RESNAME, tracerName.toStdString()); + const std::vector* tracerCellFractions = m_flowDiagSolution->flowDiagResults()->resultValues(resAddr, m_timeStep); + tracerCellFractionValues[tracerName] = tracerCellFractions; + } + } + + RigEclCellIndexCalculator cellIdxCalc(m_case->reservoirData()->mainGrid(), m_case->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)); + wfCalculator.reset(new RigAccWellFlowCalculator(pipeBranchesCLCoords, + pipeBranchesCellIds, + tracerCellFractionValues, + cellIdxCalc)); + + } + else + { + wfCalculator.reset(new RigAccWellFlowCalculator(pipeBranchesCLCoords, + pipeBranchesCellIds)); + + + } + size_t branchCount = pipeBranchesCLCoords.size(); for (size_t brIdx = 0; brIdx < branchCount; ++brIdx) { + // Skip Tiny dummy branches + if (pipeBranchesCellIds[brIdx].size() <= 3) continue; + RimWellLogTrack* plotTrack = new RimWellLogTrack(); // TODO: Description is overwritten by RimWellLogPlot::updateTrackNames() @@ -299,54 +220,48 @@ void RimWellAllocationPlot::updateFromWell() accumulatedWellFlowPlot()->addTrack(plotTrack); - #if 0 - std::vector curveCoords; - std::vector flowRate; + + if ( m_flowDiagSolution ) { - std::vector branchCoords = pipeBranchesCLCoords[brIdx]; - std::vector branchResultPoints = pipeBranchesCellIds[brIdx]; - - RigWellResultPoint prevResultPoint; - - for (size_t i = 0; i < branchResultPoints.size(); i++) + std::vector connNumbers; { - const RigWellResultPoint& resultPoint = branchResultPoints[i]; + const std::vector& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx); + for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast(conNumb)); + } - if (i > 0 && prevResultPoint.m_gridCellIndex != resultPoint.m_gridCellIndex) - { - // Add an extra curve point when a cell transition is detected - curveCoords.push_back(branchCoords[i]); - flowRate.push_back(prevResultPoint.m_flowRate); - } + std::vector tracerNames = wfCalculator->tracerNames(); + for (const QString& tracerName: tracerNames) + { + std::vector accFlow; - curveCoords.push_back(branchCoords[i]); - flowRate.push_back(branchResultPoints[i].m_flowRate); + accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, brIdx); - prevResultPoint = resultPoint; + RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; + curve->setFlowValues(tracerName, connNumbers, accFlow); + + plotTrack->addCurve(curve); + curve->loadDataAndUpdate(); } } - - RigSimulationWellCoordsAndMD helper(curveCoords); - #endif - - const std::vector >& flowPrConnection = wfCalculator.accumulatedFlowPrConnection(brIdx); - - std::vector connNumbers; - std::vector accFlow; - - for (const std::pair & flowPair: flowPrConnection) + else { - connNumbers.push_back(flowPair.first); - accFlow.push_back(flowPair.second); + std::vector connNumbers; + std::vector accFlow; + + accFlow = wfCalculator->accumulatedTotalFlowPrConnection(brIdx); + + const std::vector& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx); + for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast(conNumb)); + + RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; + curve->setFlowValues("Total", connNumbers, accFlow); + + plotTrack->addCurve(curve); + + curve->loadDataAndUpdate(); } - RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; - curve->setFlowValues(connNumbers, accFlow); - - plotTrack->addCurve(curve); - - curve->loadDataAndUpdate(); } setDescription("Well Allocation (" + m_wellName + ")"); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp index bdd2126d40..b9ff26b170 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp @@ -76,7 +76,7 @@ QString RimWellFlowRateCurve::wellName() const //-------------------------------------------------------------------------------------------------- QString RimWellFlowRateCurve::wellLogChannelName() const { - return "Flow Rate"; + return "AccumulatedFlowRate"; } //-------------------------------------------------------------------------------------------------- @@ -84,8 +84,7 @@ QString RimWellFlowRateCurve::wellLogChannelName() const //-------------------------------------------------------------------------------------------------- QString RimWellFlowRateCurve::createCurveAutoName() { - return QString("%1 (%2)").arg(wellLogChannelName()).arg(wellName()); - + return m_tracerName; } //-------------------------------------------------------------------------------------------------- @@ -127,9 +126,11 @@ RimWellAllocationPlot* RimWellFlowRateCurve::wellAllocationPlot() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellFlowRateCurve::setFlowValues(const std::vector& measuredDepths, const std::vector& flowRates) +void RimWellFlowRateCurve::setFlowValues(const QString& tracerName, const std::vector& measuredDepths, const std::vector& flowRates) { m_curveData = new RigWellLogCurveData; m_curveData->setValuesAndMD(flowRates, measuredDepths, RimDefines::UNIT_METER, false); + + m_tracerName = tracerName; } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h index 598f899184..d92cbe2347 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h @@ -38,7 +38,7 @@ public: RimWellFlowRateCurve(); virtual ~RimWellFlowRateCurve(); - void setFlowValues(const std::vector& measuredDepths, const std::vector& flowRates); + void setFlowValues(const QString& tracerName , const std::vector& measuredDepths, const std::vector& flowRates); virtual QString wellName() const override; virtual QString wellLogChannelName() const override; @@ -49,5 +49,7 @@ protected: private: RimWellAllocationPlot* wellAllocationPlot() const; + + QString m_tracerName; }; diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 09380fbc9c..f4e9eb5681 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -27,6 +27,7 @@ ${CEE_CURRENT_LIST_DIR}RigFlowDiagSolverInterface.h ${CEE_CURRENT_LIST_DIR}RigFlowDiagInterfaceTools.h ${CEE_CURRENT_LIST_DIR}RigFlowDiagStatCalc.h ${CEE_CURRENT_LIST_DIR}RigFlowDiagVisibleCellsStatCalc.h +${CEE_CURRENT_LIST_DIR}RigAccWellFlowCalculator.h ${CEE_CURRENT_LIST_DIR}RigWellLogExtractor.h ${CEE_CURRENT_LIST_DIR}RigEclipseWellLogExtractor.h ${CEE_CURRENT_LIST_DIR}RigLocalGrid.h @@ -73,6 +74,7 @@ ${CEE_CURRENT_LIST_DIR}RigFlowDiagResultFrames.cpp ${CEE_CURRENT_LIST_DIR}RigFlowDiagSolverInterface.cpp ${CEE_CURRENT_LIST_DIR}RigFlowDiagStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigFlowDiagVisibleCellsStatCalc.cpp +${CEE_CURRENT_LIST_DIR}RigAccWellFlowCalculator.cpp ${CEE_CURRENT_LIST_DIR}RigWellLogExtractor.cpp ${CEE_CURRENT_LIST_DIR}RigEclipseWellLogExtractor.cpp ${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp new file mode 100644 index 0000000000..b1e1ee07cf --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp @@ -0,0 +1,231 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigAccWellFlowCalculator.h" + +#include "RigSingleWellResultsData.h" + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vector >& pipeBranchesCLCoords, const std::vector< std::vector >& pipeBranchesCellIds, const std::map* >& tracerCellFractionValues, const RigEclCellIndexCalculator cellIndexCalculator): + m_pipeBranchesCLCoords(pipeBranchesCLCoords), + m_pipeBranchesCellIds(pipeBranchesCellIds), + m_tracerCellFractionValues(&tracerCellFractionValues), + m_cellIndexCalculator(cellIndexCalculator) +{ + m_accConnectionFlowPrBranch.resize(m_pipeBranchesCellIds.size()); + for ( const auto& it: (*m_tracerCellFractionValues) ) m_tracerNames.push_back(it.first); + calculateAccumulatedFlowPrConnection(0, 1); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vector >& pipeBranchesCLCoords, const std::vector< std::vector >& pipeBranchesCellIds): + m_pipeBranchesCLCoords(pipeBranchesCLCoords), + m_pipeBranchesCellIds(pipeBranchesCellIds), + m_tracerCellFractionValues(nullptr), + m_cellIndexCalculator(RigEclCellIndexCalculator(nullptr, nullptr)) +{ + m_accConnectionFlowPrBranch.resize(m_pipeBranchesCellIds.size()); + m_tracerNames.push_back("GrandTotalOnly"); + calculateAccumulatedFlowPrConnection(0, 1); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigAccWellFlowCalculator::accumulatedTotalFlowPrConnection(size_t branchIdx) +{ + CVF_ASSERT(m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.find("GrandTotalOnly") != m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.end()); + + return m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer["GrandTotalOnly"]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigAccWellFlowCalculator::accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx) +{ + CVF_ASSERT(m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.find(tracerName) != m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.end()); + + return m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer[tracerName]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigAccWellFlowCalculator::connectionNumbersFromTop(size_t branchIdx) +{ + return m_accConnectionFlowPrBranch[branchIdx].connectionNumbersFromTop; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigAccWellFlowCalculator::calculateAccumulatedFlowPrConnection(size_t branchIdx, size_t startConnectionNumberFromTop) +{ + const std::vector& branchCells = m_pipeBranchesCellIds[branchIdx]; + + std::vector resPointToConnectionIndexFromBottom = wrpToConnectionIndexFromBottom(branchCells); + + size_t prevConnIndx = -1; + int clSegIdx = static_cast(branchCells.size()) - 1; + + std::map >& accConnFlowFractionsPrTracer = m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer; + std::vector& connNumbersFromTop = m_accConnectionFlowPrBranch[branchIdx].connectionNumbersFromTop; + + std::vector accFlow; + accFlow.resize(m_tracerNames.size(), 0.0); + + while ( clSegIdx >= 0 ) + { + // Skip point if referring to the same cell as the previous centerline segment did + { + if ( resPointToConnectionIndexFromBottom[clSegIdx] == prevConnIndx ) + { + --clSegIdx; + continue; + } + + prevConnIndx = resPointToConnectionIndexFromBottom[clSegIdx]; + } + + // Accumulate the connection-cell's fraction flows + + if ( m_tracerCellFractionValues ) + { + size_t resCellIndex = m_cellIndexCalculator.resultCellIndex(branchCells[clSegIdx].m_gridIndex, + branchCells[clSegIdx].m_gridCellIndex); + size_t tracerIdx = 0; + for ( const auto & tracerFractionIt: (*m_tracerCellFractionValues) ) + { + accFlow[tracerIdx] += (*tracerFractionIt.second)[resCellIndex] * branchCells[clSegIdx].flowRate(); + tracerIdx++; + } + } + else + { + accFlow[0] += branchCells[clSegIdx].flowRate(); + } + + // Add the total accumulated (fraction) flows from any branches connected to this cell + + size_t connNumFromTop = connectionIndexFromTop(resPointToConnectionIndexFromBottom, clSegIdx) + startConnectionNumberFromTop; + + std::vector downstreamBranches = findDownstreamBranchIdxs(branchCells[clSegIdx]); + for ( size_t dsBidx : downstreamBranches ) + { + if ( dsBidx != branchIdx && m_accConnectionFlowPrBranch[dsBidx].connectionNumbersFromTop.size() == 0 ) // Not this branch or already calculated + { + calculateAccumulatedFlowPrConnection(dsBidx, connNumFromTop); + BranchResult& accConnFlowFractionsDsBranch = m_accConnectionFlowPrBranch[dsBidx]; + + size_t tracerIdx = 0; + for ( const auto & tracerName: m_tracerNames ) + { + accFlow[tracerIdx] += accConnFlowFractionsDsBranch.accConnFlowFractionsPrTracer[tracerName].back(); + tracerIdx++; + } + } + } + + // Push back the accumulated result into the storage + + size_t tracerIdx = 0; + for ( const auto & tracerName: m_tracerNames ) + { + accConnFlowFractionsPrTracer[tracerName].push_back(accFlow[tracerIdx]); + tracerIdx++; + } + + connNumbersFromTop.push_back(connNumFromTop); + + --clSegIdx; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigAccWellFlowCalculator::wrpToConnectionIndexFromBottom(const std::vector &branchCells) +{ + std::vector resPointToConnectionIndexFromBottom; + resPointToConnectionIndexFromBottom.resize(branchCells.size(), -1); + + size_t connIdxFromBottom = 0; + int clSegIdx = static_cast(branchCells.size()) - 1; + + if (clSegIdx < 0) return resPointToConnectionIndexFromBottom; + + size_t prevGridIdx = branchCells[clSegIdx].m_gridIndex; + size_t prevGridCellIdx = branchCells[clSegIdx].m_gridCellIndex; + int prevErtSegId = branchCells[clSegIdx].m_ertSegmentId; + int prevErtBranchId = branchCells[clSegIdx].m_ertBranchId; + + while ( clSegIdx >= 0 ) + { + if ( branchCells[clSegIdx].m_gridIndex != prevGridIdx + || branchCells[clSegIdx].m_gridCellIndex != prevGridCellIdx + || branchCells[clSegIdx].m_ertSegmentId != prevErtSegId + || branchCells[clSegIdx].m_ertBranchId != prevErtBranchId) + { + ++connIdxFromBottom; + + prevGridIdx = branchCells[clSegIdx].m_gridIndex ; + prevGridCellIdx = branchCells[clSegIdx].m_gridCellIndex; + } + + resPointToConnectionIndexFromBottom[clSegIdx] = connIdxFromBottom; + + --clSegIdx; + } + + return resPointToConnectionIndexFromBottom; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigAccWellFlowCalculator::connectionIndexFromTop(const std::vector& resPointToConnectionIndexFromBottom, size_t clSegIdx) +{ + return resPointToConnectionIndexFromBottom.front() - resPointToConnectionIndexFromBottom[clSegIdx]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigAccWellFlowCalculator::findDownstreamBranchIdxs(const RigWellResultPoint& connectionPoint) +{ + std::vector downStreamBranchIdxs; + + for ( size_t bIdx = 0; bIdx < m_pipeBranchesCellIds.size(); ++bIdx ) + { + if ( m_pipeBranchesCellIds[bIdx][0].m_gridIndex == connectionPoint.m_gridIndex + && m_pipeBranchesCellIds[bIdx][0].m_gridCellIndex == connectionPoint.m_gridCellIndex + && m_pipeBranchesCellIds[bIdx][0].m_ertBranchId == connectionPoint.m_ertBranchId + && m_pipeBranchesCellIds[bIdx][0].m_ertSegmentId == connectionPoint.m_ertSegmentId) + { + downStreamBranchIdxs.push_back(bIdx); + } + } + return downStreamBranchIdxs; +} diff --git a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.h b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.h new file mode 100644 index 0000000000..ee274473c8 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.h @@ -0,0 +1,96 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +//================================================================================================== +/// +/// +//================================================================================================== +#include "RigActiveCellInfo.h" +#include "RigMainGrid.h" +#include "RigFlowDiagResults.h" + +struct RigWellResultPoint; + +class RigEclCellIndexCalculator +{ +public: + RigEclCellIndexCalculator(const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo) + : m_mainGrid(mainGrid), m_activeCellInfo(activeCellInfo) + {} + + size_t resultCellIndex(size_t gridIndex, size_t gridCellIndex) const + { + const RigGridBase* grid = m_mainGrid->gridByIndex(gridIndex); + size_t reservoirCellIndex = grid->reservoirCellIndex(gridCellIndex); + + return m_activeCellInfo->cellResultIndex(reservoirCellIndex); + } + +private: + const RigMainGrid* m_mainGrid; + const RigActiveCellInfo* m_activeCellInfo; +}; + +//================================================================================================== +/// +/// +//================================================================================================== + +class RigAccWellFlowCalculator +{ + +public: + RigAccWellFlowCalculator(const std::vector< std::vector >& pipeBranchesCLCoords, + const std::vector< std::vector >& pipeBranchesCellIds, + const std::map* >& tracerCellFractionValues, + const RigEclCellIndexCalculator cellIndexCalculator); + + RigAccWellFlowCalculator(const std::vector< std::vector >& pipeBranchesCLCoords, + const std::vector< std::vector >& pipeBranchesCellIds); + + + const std::vector& accumulatedTotalFlowPrConnection( size_t branchIdx); + const std::vector& accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx); + const std::vector& connectionNumbersFromTop(size_t branchIdx); + const std::vector& tracerNames() { return m_tracerNames;} +private: + + void calculateAccumulatedFlowPrConnection( size_t branchIdx, size_t startConnectionNumberFromTop); + std::vector wrpToConnectionIndexFromBottom( const std::vector &branchCells); + static size_t connectionIndexFromTop( const std::vector& resPointToConnectionIndexFromBottom, size_t clSegIdx); + std::vector findDownstreamBranchIdxs( const RigWellResultPoint& connectionPoint); + + + const std::vector< std::vector >& m_pipeBranchesCLCoords; + const std::vector< std::vector >& m_pipeBranchesCellIds; + const std::map* >* m_tracerCellFractionValues; + RigEclCellIndexCalculator m_cellIndexCalculator; + std::vector m_tracerNames; + + struct BranchResult + { + std::vector connectionNumbersFromTop; + std::map > accConnFlowFractionsPrTracer; + }; + + std::vector< BranchResult > m_accConnectionFlowPrBranch; +}; + + diff --git a/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h index 6e3d7a6ea7..b489762d45 100644 --- a/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h @@ -58,6 +58,18 @@ struct RigWellResultPoint return isCell() || isPointValid(); } + double flowRate() const + { + if ( isCell() && m_isOpen) + { + return m_flowRate; + } + else + { + return 0.0; + } + } + size_t m_gridIndex; size_t m_gridCellIndex; //< Index to cell which is included in the well From 3f091aa884449276d9f71cca3c79f307f0cce2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 31 Jan 2017 16:35:49 +0100 Subject: [PATCH 12/43] #1112 Guard against none-connection segments in accumulation calculation --- .../RigAccWellFlowCalculator.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp index b1e1ee07cf..08ab74d23f 100644 --- a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp @@ -113,13 +113,16 @@ void RigAccWellFlowCalculator::calculateAccumulatedFlowPrConnection(size_t branc if ( m_tracerCellFractionValues ) { - size_t resCellIndex = m_cellIndexCalculator.resultCellIndex(branchCells[clSegIdx].m_gridIndex, - branchCells[clSegIdx].m_gridCellIndex); - size_t tracerIdx = 0; - for ( const auto & tracerFractionIt: (*m_tracerCellFractionValues) ) + if ( branchCells[clSegIdx].isCell() && branchCells[clSegIdx].m_isOpen ) { - accFlow[tracerIdx] += (*tracerFractionIt.second)[resCellIndex] * branchCells[clSegIdx].flowRate(); - tracerIdx++; + size_t resCellIndex = m_cellIndexCalculator.resultCellIndex(branchCells[clSegIdx].m_gridIndex, + branchCells[clSegIdx].m_gridCellIndex); + size_t tracerIdx = 0; + for ( const auto & tracerFractionIt: (*m_tracerCellFractionValues) ) + { + accFlow[tracerIdx] += (*tracerFractionIt.second)[resCellIndex] * branchCells[clSegIdx].flowRate(); + tracerIdx++; + } } } else From 929e9ad09b5bfad4761e08d775258b3496c20106 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 31 Jan 2017 10:58:32 +0100 Subject: [PATCH 13/43] Guard for index out of range --- ApplicationCode/ProjectDataModel/RimEclipseWell.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index 553d2b8829..0e9b21369f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -164,7 +164,7 @@ bool RimEclipseWell::intersectsVisibleCells(size_t frameIndex) const if (gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T) { cvf::cref cellVisibility = rvMan->cellVisibility(visGridPart, gridIndex, frameIndex); - if ((*cellVisibility)[gridCellIndex]) + if (gridCellIndex < cellVisibility->size() && (*cellVisibility)[gridCellIndex]) { return true; } @@ -184,7 +184,7 @@ bool RimEclipseWell::intersectsVisibleCells(size_t frameIndex) const gridCellIndex = wellResultPoint.m_gridCellIndex; cvf::cref cellVisibility = rvMan->cellVisibility(visGridPart, gridIndex, frameIndex); - if ((*cellVisibility)[gridCellIndex]) + if (gridCellIndex < cellVisibility->size() && (*cellVisibility)[gridCellIndex]) { return true; } From ddd72b486666ac950ff5f28feebbb17ab876b393 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 31 Jan 2017 11:15:14 +0100 Subject: [PATCH 14/43] #1148 Added well head scale factor to EclipseWell --- .../ModelVisualization/RivWellHeadPartMgr.cpp | 2 +- .../ProjectDataModel/RimEclipseWell.cpp | 60 ++++++++----------- .../ProjectDataModel/RimEclipseWell.h | 1 + 3 files changed, 26 insertions(+), 37 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 6517e91041..20275602db 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -197,7 +197,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) } } - double arrowLength = characteristicCellSize * m_rimReservoirView->wellCollection()->wellHeadScaleFactor(); + double arrowLength = characteristicCellSize * m_rimReservoirView->wellCollection()->wellHeadScaleFactor() * m_rimWell->wellHeadScaleFactor(); cvf::Vec3d textPosition = arrowPosition; textPosition.z() += 1.2 * arrowLength; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index 0e9b21369f..9091b6a25a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -41,21 +41,18 @@ RimEclipseWell::RimEclipseWell() CAF_PDM_InitFieldNoDefault(&name, "WellName", "Name", "", "", ""); CAF_PDM_InitField(&showWell, "ShowWell", true, "Show well ", "", "", ""); - showWell.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, "Show well label", "", "", ""); - CAF_PDM_InitField(&showWellHead, "ShowWellHead", true, "Show well head", "", "", ""); - CAF_PDM_InitField(&showWellPipe, "ShowWellPipe", true, "Show well pipe", "", "", ""); - CAF_PDM_InitField(&showWellSpheres, "ShowWellSpheres", false, "Show well spheres", "", "", ""); + CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, "Label", "", "", ""); + CAF_PDM_InitField(&showWellHead, "ShowWellHead", true, "Well head", "", "", ""); + CAF_PDM_InitField(&showWellPipe, "ShowWellPipe", true, "Pipe", "", "", ""); + CAF_PDM_InitField(&showWellSpheres, "ShowWellSpheres", false, "Spheres", "", "", ""); - CAF_PDM_InitField(&pipeScaleFactor, "WellPipeRadiusScale", 1.0, "Well Pipe Scale Factor", "", "", ""); - CAF_PDM_InitField(&wellPipeColor, "WellPipeColor", cvf::Color3f(0.588f, 0.588f, 0.804f), "Well pipe color", "", "", ""); + CAF_PDM_InitField(&wellHeadScaleFactor, "WellHeadScaleFactor", 1.0, "Well Head Scale Factor", "", "", ""); + CAF_PDM_InitField(&pipeScaleFactor, "WellPipeRadiusScale", 1.0, "Pipe Scale Factor", "", "", ""); + CAF_PDM_InitField(&wellPipeColor, "WellPipeColor", cvf::Color3f(0.588f, 0.588f, 0.804f), "Pipe color", "", "", ""); - CAF_PDM_InitField(&showWellCells, "ShowWellCells", true, "Show Well Cells", "", "", ""); - CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Show Well Cell Fence", "", "", ""); - - name.uiCapability()->setUiHidden(true); - name.uiCapability()->setUiReadOnly(true); + CAF_PDM_InitField(&showWellCells, "ShowWellCells", true, "Well Cells", "", "", ""); + CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Well Cell Fence", "", "", ""); m_resultWellIndex = cvf::UNDEFINED_SIZE_T; } @@ -100,7 +97,8 @@ void RimEclipseWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } - else if (&pipeScaleFactor == changedField) + else if ( &pipeScaleFactor == changedField + || &wellHeadScaleFactor == changedField) { if (m_reservoirView) { @@ -201,34 +199,24 @@ bool RimEclipseWell::intersectsVisibleCells(size_t frameIndex) const //-------------------------------------------------------------------------------------------------- void RimEclipseWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* pipeGroup = uiOrdering.addNewGroup("Appearance"); - pipeGroup->add(&showWellLabel); - pipeGroup->add(&showWellHead); - pipeGroup->add(&showWellPipe); - pipeGroup->add(&showWellSpheres); + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Visibility"); + appearanceGroup->add(&showWellLabel); + appearanceGroup->add(&showWellHead); + appearanceGroup->add(&showWellPipe); + appearanceGroup->add(&showWellSpheres); - pipeGroup->add(&pipeScaleFactor); + caf::PdmUiGroup* sizeScalingGroup = uiOrdering.addNewGroup("Size Scaling"); + sizeScalingGroup->add(&pipeScaleFactor); + sizeScalingGroup->add(&wellHeadScaleFactor); - pipeGroup->add(&wellPipeColor); + uiOrdering.add(&wellPipeColor); - caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well Cells"); - filterGroup->add(&showWellCells); - filterGroup->add(&showWellCellFence); + uiOrdering.add(&showWellCells); + uiOrdering.add(&showWellCellFence); - RimEclipseWellCollection* wellColl = nullptr; - this->firstAncestorOrThisOfType(wellColl); - if (wellColl) - { - showWellLabel.uiCapability()->setUiReadOnly(!wellColl->showWellLabel()); - showWellHead.uiCapability()->setUiReadOnly(!wellColl->showWellHead()); - showWellPipe.uiCapability()->setUiReadOnly(!wellColl->showWellPipe()); - showWellSpheres.uiCapability()->setUiReadOnly(!wellColl->showWellSpheres()); - showWellCells.uiCapability()->setUiReadOnly(!wellColl->showWellCells()); + showWellCellFence.uiCapability()->setUiReadOnly(!showWellCells()); - bool isFenceEnabled = false; - if (wellColl->showWellCells() && wellColl->showWellCellFence()) isFenceEnabled = true; - showWellCellFence.uiCapability()->setUiReadOnly(!isFenceEnabled); - } + uiOrdering.setForgetRemainingFields(true); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.h b/ApplicationCode/ProjectDataModel/RimEclipseWell.h index 5946d6ef57..f74b1aa82b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.h @@ -73,6 +73,7 @@ public: caf::PdmField showWellPipe; caf::PdmField showWellSpheres; + caf::PdmField wellHeadScaleFactor; caf::PdmField pipeScaleFactor; caf::PdmField wellPipeColor; From bd732d95641af0dc27c9d1178f37e3591e57fd8c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 31 Jan 2017 14:15:25 +0100 Subject: [PATCH 15/43] #1148 Always show context menus --- .../RicEclipseWellShowFeatures.cpp | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.cpp b/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.cpp index 486abe5634..d4daa955a9 100644 --- a/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.cpp +++ b/ApplicationCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellShowFeatures.cpp @@ -56,12 +56,6 @@ void RicEclipseWellShowLabelFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- bool RicEclipseWellShowLabelFeature::isCommandEnabled() { - RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection(); - if (wellColl && !wellColl->showWellLabel()) - { - return false; - } - return RicEclipseWellFeatureImpl::isAnyWellSelected(); } @@ -117,12 +111,6 @@ void RicEclipseWellShowHeadFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- bool RicEclipseWellShowHeadFeature::isCommandEnabled() { - RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection(); - if (wellColl && !wellColl->showWellHead()) - { - return false; - } - return RicEclipseWellFeatureImpl::isAnyWellSelected(); } @@ -179,12 +167,6 @@ void RicEclipseWellShowPipeFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- bool RicEclipseWellShowPipeFeature::isCommandEnabled() { - RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection(); - if (wellColl && !wellColl->showWellPipe()) - { - return false; - } - return RicEclipseWellFeatureImpl::isAnyWellSelected(); } @@ -241,12 +223,6 @@ void RicEclipseWellShowSpheresFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- bool RicEclipseWellShowSpheresFeature::isCommandEnabled() { - RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection(); - if (wellColl && !wellColl->showWellSpheres()) - { - return false; - } - return RicEclipseWellFeatureImpl::isAnyWellSelected(); } @@ -302,12 +278,6 @@ void RicEclipseWellShowWellCellsFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- bool RicEclipseWellShowWellCellsFeature::isCommandEnabled() { - RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection(); - if (wellColl && !wellColl->showWellCells()) - { - return false; - } - return RicEclipseWellFeatureImpl::isAnyWellSelected(); } @@ -362,12 +332,6 @@ void RicEclipseWellShowWellCellFenceFeature::setupActionLook(QAction* actionToSe //-------------------------------------------------------------------------------------------------- bool RicEclipseWellShowWellCellFenceFeature::isCommandEnabled() { - RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection(); - if (wellColl && !(wellColl->showWellCells() || wellColl->showWellCellFence())) - { - return false; - } - return RicEclipseWellFeatureImpl::isAnyWellSelected(); } From 8c01c23e5e6ebd881ebb33b8b26ee2ec2b5fe21d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 31 Jan 2017 16:08:04 +0100 Subject: [PATCH 16/43] #1156 Added tristate class and checkbox editor with tristate support --- .../cafPdmCore/CMakeLists.txt | 3 + .../cafPdmCore/cafTristate.cpp | 158 ++++++++++++++++++ .../cafPdmCore/cafTristate.h | 53 ++++++ Fwk/AppFwk/cafUserInterface/CMakeLists.txt | 3 + .../cafPdmUiCheckBoxTristateEditor.cpp | 113 +++++++++++++ .../cafPdmUiCheckBoxTristateEditor.h | 38 +++++ 6 files changed, 368 insertions(+) create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafTristate.cpp create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafTristate.h create mode 100644 Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.cpp create mode 100644 Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.h diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt index ed65edd58e..7491d8f709 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt @@ -41,6 +41,9 @@ set( PROJECT_FILES cafNotificationCenter.cpp cafNotificationCenter.h + + cafTristate.cpp + cafTristate.h ) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafTristate.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafTristate.cpp new file mode 100644 index 0000000000..a916bdcbfb --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafTristate.cpp @@ -0,0 +1,158 @@ +#include "cafTristate.h" + +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::Tristate::Tristate() + : m_state(State::False) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::Tristate::operator=(const Tristate& other) +{ + m_state = other.m_state; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::Tristate::operator=(const State& state) +{ + m_state = state; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::Tristate::operator==(const Tristate& other) const +{ + return m_state == other.m_state; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::Tristate::operator==(State state) const +{ + return m_state == state; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::Tristate::operator!=(const Tristate& other) const +{ + return !(m_state == other.m_state); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::Tristate::State caf::Tristate::state() const +{ + return m_state; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::Tristate::isTrue() const +{ + return m_state == State::True; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::Tristate::isPartiallyTrue() const +{ + return m_state == State::PartiallyTrue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::Tristate::isFalse() const +{ + return m_state == State::False; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString caf::Tristate::text() const +{ + QString txt; + + switch (m_state) + { + case Tristate::State::False: + txt = "False"; + break; + case Tristate::State::PartiallyTrue: + txt = "PartiallyTrue"; + break; + case Tristate::State::True: + txt = "True"; + break; + default: + break; + } + + return txt; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::Tristate::setFromText(const QString& valueText) +{ + QString lowerCase = valueText.toLower(); + + if (lowerCase == "false") + { + m_state = State::False; + } + else if (lowerCase == "partiallytrue") + { + m_state = State::PartiallyTrue; + } + else if (lowerCase == "true") + { + m_state = State::True; + } +} + + + + + + + + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void operator >> (QTextStream& str, caf::Tristate& triplet) +{ + QString text; + str >> text; + triplet.setFromText(text); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void operator << (QTextStream& str, const caf::Tristate& triplet) +{ + str << triplet.text(); +} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafTristate.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafTristate.h new file mode 100644 index 0000000000..8f9eec190c --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafTristate.h @@ -0,0 +1,53 @@ + + +#pragma once + +#include + +class QTextStream; + + +namespace caf +{ + +//================================================================================================== +//================================================================================================== +class Tristate +{ +public: + enum class State {False, PartiallyTrue, True}; + +public: + Tristate(); + + void operator=(const Tristate& other); + void operator=(const State& state); + + bool operator==(const Tristate& other) const; + bool operator==(State state) const; + bool operator!=(const Tristate& other) const; + + State state() const; + + bool isTrue() const; + bool isPartiallyTrue() const; + bool isFalse() const; + + QString text() const; + void setFromText(const QString& valueText); + +protected: + State m_state; +}; + + +} // end namespace caf + + +//================================================================================================== +// Overload of QTextStream for caf::Triplet +//================================================================================================== +void operator >> (QTextStream& str, caf::Tristate& triplet); +void operator << (QTextStream& str, const caf::Tristate& triplet); + +Q_DECLARE_METATYPE(caf::Tristate); diff --git a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt index a8bedae088..23e2f98704 100644 --- a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt @@ -20,6 +20,7 @@ include_directories ( set( QOBJECT_HEADERS cafPdmUiCheckBoxDelegate.h cafPdmUiCheckBoxEditor.h + cafPdmUiCheckBoxTristateEditor.h cafPdmUiColorEditor.h cafPdmUiComboBoxEditor.h cafPdmUiDoubleSliderEditor.h @@ -55,6 +56,8 @@ set( PROJECT_FILES cafPdmUiCheckBoxDelegate.h cafPdmUiCheckBoxEditor.cpp cafPdmUiCheckBoxEditor.h + cafPdmUiCheckBoxTristateEditor.cpp + cafPdmUiCheckBoxTristateEditor.h cafPdmUiColorEditor.cpp cafPdmUiColorEditor.h cafPdmUiComboBoxEditor.cpp diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.cpp new file mode 100644 index 0000000000..07fd6e9884 --- /dev/null +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.cpp @@ -0,0 +1,113 @@ + + +#include "cafPdmUiCheckBoxTristateEditor.h" + +#include "cafPdmUiDefaultObjectEditor.h" + +#include "cafPdmObject.h" +#include "cafPdmUiFieldEditorHandle.h" +#include "cafPdmUiOrdering.h" +#include "cafPdmField.h" + +#include "cafFactory.h" +#include "cafTristate.h" + +#include + + +namespace caf +{ + +CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiCheckBoxTristateEditor); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiCheckBoxTristateEditor::configureAndUpdateUi(const QString& uiConfigName) +{ + assert(!m_checkBox.isNull()); + assert(!m_label.isNull()); + + { + QIcon ic = field()->uiIcon(uiConfigName); + if (!ic.isNull()) + { + m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64)))); + } + else + { + m_label->setText(field()->uiName(uiConfigName)); + } + } + + m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_label->setToolTip(field()->uiToolTip(uiConfigName)); + + m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_checkBox->setToolTip(field()->uiToolTip(uiConfigName)); + + Tristate state = field()->uiValue().value(); + + if (state == Tristate::State::True) + { + m_checkBox->setCheckState(Qt::Checked); + } + else if (state == Tristate::State::PartiallyTrue) + { + m_checkBox->setCheckState(Qt::PartiallyChecked); + } + else if (state == Tristate::State::False) + { + m_checkBox->setCheckState(Qt::Unchecked); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiCheckBoxTristateEditor::createEditorWidget(QWidget * parent) +{ + m_checkBox = new QCheckBox(parent); + m_checkBox->setTristate(true); + + connect(m_checkBox, SIGNAL(clicked(bool)), this, SLOT(slotClicked(bool))); + return m_checkBox; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiCheckBoxTristateEditor::createLabelWidget(QWidget * parent) +{ + m_label = new QLabel(parent); + return m_label; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiCheckBoxTristateEditor::slotClicked(bool) +{ + Tristate state; + + if (m_checkBox->checkState() == Qt::Checked) + { + state = Tristate::State::True; + } + else if (m_checkBox->checkState() == Qt::PartiallyChecked) + { + state = Tristate::State::PartiallyTrue; + } + else if (m_checkBox->checkState() == Qt::Unchecked) + { + state = Tristate::State::False; + } + + QVariant v = QVariant::fromValue(state); + + this->setValueToField(v); +} + + +} // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.h new file mode 100644 index 0000000000..e372c1bde4 --- /dev/null +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.h @@ -0,0 +1,38 @@ + + +#pragma once + +#include "cafPdmUiFieldEditorHandle.h" + +#include +#include +#include +#include + +namespace caf +{ + +class PdmUiCheckBoxTristateEditor : public PdmUiFieldEditorHandle +{ + Q_OBJECT + CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT; + +public: + PdmUiCheckBoxTristateEditor() {} + virtual ~PdmUiCheckBoxTristateEditor() {} + +protected: + virtual QWidget* createEditorWidget(QWidget* parent); + virtual QWidget* createLabelWidget(QWidget* parent); + virtual void configureAndUpdateUi(const QString& uiConfigName); + +protected slots: + void slotClicked(bool); + +private: + QPointer m_checkBox; + QPointer m_label; +}; + + +} // end namespace caf From a4ce5f532dc366b418a81cb6782610fb8015d33a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 1 Feb 2017 08:16:30 +0100 Subject: [PATCH 17/43] #1148 Use tristate to indicate visibility of simulation well geometry --- .../ModelVisualization/RivWellHeadPartMgr.cpp | 8 +- .../ProjectDataModel/RimEclipseWell.cpp | 6 - .../RimEclipseWellCollection.cpp | 131 +++++++++++++++--- .../RimEclipseWellCollection.h | 19 +-- 4 files changed, 129 insertions(+), 35 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 20275602db..e60b86d2b5 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -293,7 +293,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) m_wellHeadArrowPart = part; } - if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel() && !well->name().isEmpty()) + if (well->showWellLabel() && !well->name().isEmpty()) { cvf::Font* font = RiaApplication::instance()->customFont(); @@ -355,15 +355,13 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); if (m_wellHeadPipeSurfacePart.notNull()) model->addPart(m_wellHeadPipeSurfacePart.p()); - if (wellCollection->showWellLabel() && - m_rimWell->showWellLabel() && + if (m_rimWell->showWellLabel() && m_wellHeadLabelPart.notNull()) { model->addPart(m_wellHeadLabelPart.p()); } - if (wellCollection->showWellHead() && - m_rimWell->showWellHead() && + if (m_rimWell->showWellHead() && m_wellHeadArrowPart.notNull()) { model->addPart(m_wellHeadArrowPart.p()); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index 9091b6a25a..b694aa9622 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -275,9 +275,6 @@ bool RimEclipseWell::isWellPipeVisible(size_t frameIndex) const if (!this->showWellPipe()) return false; - if (!reservoirView->wellCollection()->showWellPipe()) - return false; - if (reservoirView->crossSectionCollection()->hasActiveIntersectionForSimulationWell(this)) return true; @@ -319,9 +316,6 @@ bool RimEclipseWell::isWellSpheresVisible(size_t frameIndex) const if (!this->showWell()) return false; - if (!m_reservoirView->wellCollection()->showWellSpheres()) - return false; - if (!this->showWellSpheres()) return false; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index ec6d99aade..0faffc650f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -32,6 +32,7 @@ #include "RivReservoirViewPartMgr.h" #include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiCheckBoxTristateEditor.h" namespace caf @@ -109,10 +110,26 @@ RimEclipseWellCollection::RimEclipseWellCollection() CAF_PDM_InitField(&showWellsIntersectingVisibleCells, "ShowWellsIntersectingVisibleCells", true, "Show Wells Intersecting Visible Cells", "", "", ""); // Appearance - CAF_PDM_InitField(&showWellHead, "ShowWellHead", true, "Show Well Head", "", "", ""); - CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, "Show Well Label", "", "", ""); - CAF_PDM_InitField(&showWellPipe, "ShowWellPipe", true, "Show Well Pipe", "", "", ""); - CAF_PDM_InitField(&showWellSpheres, "ShowWellSpheres", true, "Show Well Spheres", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellHead, "ShowWellHead", "Show Well Head", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellLabel, "ShowWellLabel", "Show Well Label", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellPipe, "ShowWellPipe", "Show Well Pipe", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellSpheres, "ShowWellSpheres", "Show Well Spheres", "", "", ""); + + m_showWellHead.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); + m_showWellHead.xmlCapability()->setIOReadable(false); + m_showWellHead.xmlCapability()->setIOWritable(false); + + m_showWellLabel.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); + m_showWellLabel.xmlCapability()->setIOReadable(false); + m_showWellLabel.xmlCapability()->setIOWritable(false); + + m_showWellPipe.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); + m_showWellPipe.xmlCapability()->setIOReadable(false); + m_showWellPipe.xmlCapability()->setIOWritable(false); + + m_showWellSpheres.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); + m_showWellSpheres.xmlCapability()->setIOReadable(false); + m_showWellSpheres.xmlCapability()->setIOWritable(false); // Scaling CAF_PDM_InitField(&wellHeadScaleFactor, "WellHeadScale", 1.0, "Well Head Scale Factor", "", "", ""); @@ -243,10 +260,43 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang this->updateUiIconFromToggleField(); } + if (&m_showWellLabel == changedField) + { + for (RimEclipseWell* w : wells) + { + w->showWellLabel = !(m_showWellLabel().isFalse()); + } + } + + if (&m_showWellHead == changedField) + { + for (RimEclipseWell* w : wells) + { + w->showWellHead = !(m_showWellHead().isFalse()); + } + } + + if (&m_showWellPipe == changedField) + { + for (RimEclipseWell* w : wells) + { + w->showWellPipe = !(m_showWellPipe().isFalse()); + } + } + + if (&m_showWellSpheres == changedField) + { + for (RimEclipseWell* w : wells) + { + w->showWellSpheres = !(m_showWellSpheres().isFalse()); + } + } + + if (m_reservoirView) { if ( &isActive == changedField - || &showWellLabel == changedField + || &m_showWellLabel == changedField || &showWellCells == changedField || &showWellCellFence == changedField || &wellCellFenceType == changedField) @@ -259,7 +309,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } else if ( &spheresScaleFactor == changedField - || &showWellSpheres == changedField + || &m_showWellSpheres == changedField || &showConnectionStatusColors == changedField) { m_reservoirView->schedulePipeGeometryRegen(); @@ -268,23 +318,23 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang else if ( &pipeCrossSectionVertexCount == changedField || &pipeScaleFactor == changedField || &wellHeadScaleFactor == changedField - || &showWellHead == changedField + || &m_showWellHead == changedField || &isAutoDetectingBranches == changedField || &wellHeadPosition == changedField || &wellLabelColor == changedField || &showWellsIntersectingVisibleCells == changedField || &wellPipeCoordType == changedField - || &showWellPipe == changedField) + || &m_showWellPipe == changedField) { m_reservoirView->schedulePipeGeometryRegen(); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } } - if ( &showWellPipe == changedField - || &showWellSpheres == changedField - || &showWellHead == changedField - || &showWellLabel == changedField) + if ( &m_showWellPipe == changedField + || &m_showWellSpheres == changedField + || &m_showWellHead == changedField + || &m_showWellLabel == changedField) { for (RimEclipseWell* w : wells) { @@ -341,13 +391,15 @@ void RimEclipseWellCollection::setReservoirView(RimEclipseView* ownerReservoirVi //-------------------------------------------------------------------------------------------------- void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { + updateStateForVisibilityCheckboxes(); + uiOrdering.add(&showWellsIntersectingVisibleCells); caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Visibility"); - appearanceGroup->add(&showWellLabel); - appearanceGroup->add(&showWellHead); - appearanceGroup->add(&showWellPipe); - appearanceGroup->add(&showWellSpheres); + appearanceGroup->add(&m_showWellLabel); + appearanceGroup->add(&m_showWellHead); + appearanceGroup->add(&m_showWellPipe); + appearanceGroup->add(&m_showWellSpheres); caf::PdmUiGroup* sizeScalingGroup = uiOrdering.addNewGroup("Size Scaling"); sizeScalingGroup->add(&wellHeadScaleFactor); @@ -381,6 +433,53 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi wellCellFenceType.uiCapability()->setUiReadOnly(!showWellCells()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseWellCollection::updateStateForVisibilityCheckboxes() +{ + size_t showLabelCount = 0; + size_t showWellHeadCount = 0; + size_t showPipeCount = 0; + size_t showSphereCount = 0; + + for (RimEclipseWell* w : wells) + { + if (w->showWellLabel()) showLabelCount++; + if (w->showWellHead()) showWellHeadCount++; + if (w->showWellPipe()) showPipeCount++; + if (w->showWellSpheres()) showSphereCount++; + } + + updateStateFromEnabledChildCount(showLabelCount, &m_showWellLabel); + updateStateFromEnabledChildCount(showWellHeadCount, &m_showWellHead); + updateStateFromEnabledChildCount(showPipeCount, &m_showWellPipe); + updateStateFromEnabledChildCount(showSphereCount, &m_showWellSpheres); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseWellCollection::updateStateFromEnabledChildCount(size_t enabledChildCount, caf::PdmField* fieldToUpdate) +{ + caf::Tristate tristate; + + if (enabledChildCount == 0) + { + tristate = caf::Tristate::State::False; + } + else if (enabledChildCount == wells.size()) + { + tristate = caf::Tristate::State::True; + } + else + { + tristate = caf::Tristate::State::PartiallyTrue; + } + + fieldToUpdate->setValue(tristate); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index 552119a521..bb5299ae34 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -23,11 +23,10 @@ #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" +#include "cafPdmFieldCvfColor.h" // Include to make Pdm work for cvf::Color #include "cafPdmObject.h" #include "cafPdmPointer.h" - -// Include to make Pdm work for cvf::Color -#include "cafPdmFieldCvfColor.h" +#include "cafTristate.h" class RimEclipseView; class RimEclipseWell; @@ -89,11 +88,6 @@ public: caf::PdmField isActive; caf::PdmField showWellsIntersectingVisibleCells; - caf::PdmField showWellLabel; - caf::PdmField showWellHead; - caf::PdmField showWellPipe; - caf::PdmField showWellSpheres; - caf::PdmField wellHeadScaleFactor; caf::PdmField pipeScaleFactor; caf::PdmField spheresScaleFactor; @@ -126,6 +120,8 @@ public: protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + virtual caf::PdmFieldHandle* objectToggleField() override; virtual void initAfterRead() override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; @@ -133,6 +129,8 @@ protected: private: void calculateWellGeometryVisibility(size_t frameIndex); static cvf::Color3f cycledPaletteColor(size_t colorIndex); + void updateStateForVisibilityCheckboxes(); + void updateStateFromEnabledChildCount(size_t showLabelCount, caf::PdmField* fieldToUpdate); private: RimEclipseView* m_reservoirView; @@ -143,6 +141,11 @@ private: caf::PdmField m_applySingleColorToWells; caf::PdmField m_applyIndividualColorsToWells; + caf::PdmField m_showWellLabel; + caf::PdmField m_showWellHead; + caf::PdmField m_showWellPipe; + caf::PdmField m_showWellSpheres; + // Obsolete fields caf::PdmField obsoleteField_wellPipeVisibility; caf::PdmField obsoleteField_wellCellsToRangeFilterMode; From 8e4e7f098f4e457b03d1eee785fb753e31a11ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 1 Feb 2017 19:17:56 +0100 Subject: [PATCH 18/43] #1113, #1112 Made stacked curves. Now the accumulated well flow by connection graphs is up to speed. --- .../Flow/RimWellAllocationPlot.cpp | 20 +++--- .../Flow/RimWellFlowRateCurve.cpp | 69 +++++++++++++++++-- .../Flow/RimWellFlowRateCurve.h | 2 + .../ProjectDataModel/RimPlotCurve.h | 2 +- .../ProjectDataModel/RimWellLogTrack.cpp | 22 ++++++ .../ProjectDataModel/RimWellLogTrack.h | 2 + .../RigAccWellFlowCalculator.cpp | 6 +- 7 files changed, 104 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index ae49638eb6..bddef3cd95 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -152,6 +152,8 @@ void RimWellAllocationPlot::updateFromWell() if (!wellResults) return; + // Set up the Accumulated Well Flow Calculator + std::vector< std::vector > pipeBranchesCLCoords; std::vector< std::vector > pipeBranchesCellIds; @@ -206,6 +208,8 @@ void RimWellAllocationPlot::updateFromWell() } + // Create tracks and curves from the calculated data + size_t branchCount = pipeBranchesCLCoords.size(); for (size_t brIdx = 0; brIdx < branchCount; ++brIdx) { @@ -220,8 +224,6 @@ void RimWellAllocationPlot::updateFromWell() accumulatedWellFlowPlot()->addTrack(plotTrack); - - if ( m_flowDiagSolution ) { std::vector connNumbers; @@ -233,9 +235,7 @@ void RimWellAllocationPlot::updateFromWell() std::vector tracerNames = wfCalculator->tracerNames(); for (const QString& tracerName: tracerNames) { - std::vector accFlow; - - accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, brIdx); + const std::vector& accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, brIdx); RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; curve->setFlowValues(tracerName, connNumbers, accFlow); @@ -247,12 +247,12 @@ void RimWellAllocationPlot::updateFromWell() else { std::vector connNumbers; - std::vector accFlow; + { + const std::vector& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx); + for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast(conNumb)); + } - accFlow = wfCalculator->accumulatedTotalFlowPrConnection(brIdx); - - const std::vector& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx); - for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast(conNumb)); + const std::vector& accFlow = wfCalculator->accumulatedTotalFlowPrConnection(brIdx); RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; curve->setFlowValues("Total", connNumbers, accFlow); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp index b9ff26b170..29692a465d 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp @@ -24,6 +24,8 @@ #include "qwt_plot.h" #include "RimWellLogPlot.h" +#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" +#include "RimWellLogTrack.h" @@ -40,6 +42,7 @@ CAF_PDM_SOURCE_INIT(RimWellFlowRateCurve, "RimWellFlowRateCurve"); RimWellFlowRateCurve::RimWellFlowRateCurve() { CAF_PDM_InitObject("Flow Rate Curve", "", "", ""); + m_curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(); } //-------------------------------------------------------------------------------------------------- @@ -96,15 +99,9 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate() if (isCurveVisible()) { - RimWellLogPlot* wellLogPlot; - firstAncestorOrThisOfType(wellLogPlot); - CVF_ASSERT(wellLogPlot); - m_qwtPlotCurve->setTitle(createCurveAutoName()); - RimDefines::DepthUnitType displayUnit = RimDefines::UNIT_METER; - m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->measuredDepthPlotValues(displayUnit).data(), static_cast(m_curveData->xPlotValues().size())); - m_qwtPlotCurve->setLineSegmentStartStopIndices(m_curveData->polylineStartStopIndices()); + updateStackedPlotData(); updateZoomInParentPlot(); @@ -112,6 +109,64 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate() } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellFlowRateCurve::updateCurveAppearance() +{ + RimWellLogCurve::updateCurveAppearance(); + + m_qwtPlotCurve->setStyle(QwtPlotCurve::Steps); + QColor curveQColor = QColor (m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte()); + m_qwtPlotCurve->setBrush(QBrush( curveQColor)); + + QPen curvePen = m_qwtPlotCurve->pen(); + curvePen.setColor(curveQColor.darker()); + m_qwtPlotCurve->setPen(curvePen); + m_qwtPlotCurve->setOrientation(Qt::Horizontal); + m_qwtPlotCurve->setBaseline(0.0); + m_qwtPlotCurve->setCurveAttribute(QwtPlotCurve::Inverted, true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellFlowRateCurve::updateStackedPlotData() +{ + RimWellLogTrack* wellLogTrack; + firstAncestorOrThisOfType(wellLogTrack); + + RimDefines::DepthUnitType displayUnit = RimDefines::UNIT_METER; + + std::vector depthValues = m_curveData->measuredDepthPlotValues(displayUnit); + if (depthValues.size()) depthValues.insert(depthValues.begin(), depthValues[0]); // Insert the first depth position again, to make room for a real 0 value + std::vector stackedValues(depthValues.size(), 0.0); + + std::vector stackedCurves = wellLogTrack->visibleStackedCurves(); + double zPos = -0.1; + for ( RimWellFlowRateCurve * stCurve: stackedCurves ) + { + std::vector values = stCurve->curveData()->xPlotValues(); + for ( size_t i = 0; i < values.size(); ++i ) + { + stackedValues[i+1] += values[i]; + } + + if ( stCurve == this ) break; + zPos -= 1.0; + } + + + m_qwtPlotCurve->setSamples(stackedValues.data(), depthValues.data(), static_cast(depthValues.size())); + + std::vector< std::pair > polyLineStartStopIndices = m_curveData->polylineStartStopIndices(); + polyLineStartStopIndices.front().second += 1; + m_qwtPlotCurve->setLineSegmentStartStopIndices(polyLineStartStopIndices); + + m_qwtPlotCurve->setZ(zPos); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h index d92cbe2347..1fc4b02ee2 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h @@ -39,6 +39,7 @@ public: virtual ~RimWellFlowRateCurve(); void setFlowValues(const QString& tracerName , const std::vector& measuredDepths, const std::vector& flowRates); + void updateStackedPlotData(); virtual QString wellName() const override; virtual QString wellLogChannelName() const override; @@ -46,6 +47,7 @@ public: protected: virtual QString createCurveAutoName() override; virtual void onLoadDataAndUpdate() override; + virtual void updateCurveAppearance() override; private: RimWellAllocationPlot* wellAllocationPlot() const; diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index 599431c181..775f076cb4 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -86,7 +86,7 @@ protected: virtual void onLoadDataAndUpdate() = 0; void updateCurvePresentation(); - void updateCurveAppearance(); + virtual void updateCurveAppearance(); void updateOptionSensitivity(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 486b8bc51f..8da63e6517 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -34,6 +34,7 @@ #include "qwt_scale_engine.h" #include +#include "RimWellFlowRateCurve.h" #define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0 #define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0 @@ -311,6 +312,9 @@ void RimWellLogTrack::updateXZoomAndParentPlotDepthZoom() //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::updateXZoom() { + std::vector stackCurves = visibleStackedCurves(); + for (RimWellFlowRateCurve* stCurve: stackCurves) stCurve->updateStackedPlotData(); + if (!m_isAutoScaleXEnabled()) { m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax); @@ -459,3 +463,21 @@ void RimWellLogTrack::setLogarithmicScale(bool enable) updateAxisScaleEngine(); computeAndSetXRangeMinForLogarithmicScale(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellLogTrack::visibleStackedCurves() +{ + std::vector stackedCurves; + for (RimWellLogCurve* curve: curves) + { + if (curve && curve->isCurveVisible() ) + { + RimWellFlowRateCurve* wfrCurve = dynamic_cast(curve); + if (wfrCurve) stackedCurves.push_back(wfrCurve); + } + } + + return stackedCurves; +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index fb23a715ea..2d834791da 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -29,6 +29,7 @@ class RimWellLogCurve; class RiuWellLogTrack; +class RimWellFlowRateCurve; class QwtPlotCurve; @@ -66,6 +67,7 @@ public: void setLogarithmicScale(bool enable); + std::vector visibleStackedCurves(); protected: // Overridden PDM methods virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); diff --git a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp index 08ab74d23f..259ff0bade 100644 --- a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp @@ -120,7 +120,11 @@ void RigAccWellFlowCalculator::calculateAccumulatedFlowPrConnection(size_t branc size_t tracerIdx = 0; for ( const auto & tracerFractionIt: (*m_tracerCellFractionValues) ) { - accFlow[tracerIdx] += (*tracerFractionIt.second)[resCellIndex] * branchCells[clSegIdx].flowRate(); + double cellTracerFraction = (*tracerFractionIt.second)[resCellIndex]; + if (cellTracerFraction != HUGE_VAL && cellTracerFraction == cellTracerFraction) + { + accFlow[tracerIdx] += (*tracerFractionIt.second)[resCellIndex] * branchCells[clSegIdx].flowRate(); + } tracerIdx++; } } From b26bd116742cb24e6a3ea796c15b06e3a2de0f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 2 Feb 2017 09:56:39 +0100 Subject: [PATCH 19/43] #1113 Made tracer colors consistent, and son to be consistent with default well colors --- .../Flow/RimFlowDiagSolution.cpp | 26 +++++++++++++++++++ .../Flow/RimFlowDiagSolution.h | 2 ++ .../Flow/RimWellAllocationPlot.cpp | 3 +++ .../RimEclipseWellCollection.h | 3 ++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp b/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp index 2077557008..fa2988dd04 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp @@ -26,6 +26,7 @@ #include "RigFlowDiagResults.h" #include "RigMainGrid.h" #include "RigSingleWellResultsData.h" +#include "RimEclipseWellCollection.h" CAF_PDM_SOURCE_INIT(RimFlowDiagSolution, "FlowDiagSolution"); @@ -270,6 +271,31 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeSte return UNDEFINED; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RimFlowDiagSolution::tracerColor(QString tracerName) +{ + RimEclipseResultCase* eclCase; + this->firstAncestorOrThisOfType(eclCase); + + if ( eclCase ) + { + const cvf::Collection& wellResults = eclCase->reservoirData()->wellResults(); + + for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx ) + { + if ( wellResults[wIdx]->m_wellName == tracerName ) + { + + return RimEclipseWellCollection::cycledPaletteColor(wIdx); + } + } + } + + return cvf::Color3f::DARK_GRAY; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.h b/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.h index 42edf3cf0e..e13272a3c7 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.h @@ -25,6 +25,7 @@ #include "cvfBase.h" #include "cvfObject.h" +#include "cvfColor3.h" class RimEclipseWell; class RigFlowDiagResults; @@ -57,6 +58,7 @@ public: TracerStatusType tracerStatusOverall(QString tracerName); TracerStatusType tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex); + cvf::Color3f tracerColor(QString tracerName); protected: diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index bddef3cd95..137066547f 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -239,8 +239,10 @@ void RimWellAllocationPlot::updateFromWell() RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; curve->setFlowValues(tracerName, connNumbers, accFlow); + curve->setColor( m_flowDiagSolution->tracerColor(tracerName)); plotTrack->addCurve(curve); + curve->loadDataAndUpdate(); } } @@ -256,6 +258,7 @@ void RimWellAllocationPlot::updateFromWell() RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; curve->setFlowValues("Total", connNumbers, accFlow); + curve->setColor( cvf::Color3f::DARK_GRAY); plotTrack->addCurve(curve); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index bb5299ae34..3a46d4b4fc 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -116,6 +116,8 @@ public: const std::vector& resultWellGeometryVisibilities(size_t frameIndex); void scheduleIsWellPipesVisibleRecalculation(); + + static cvf::Color3f cycledPaletteColor(size_t colorIndex); protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -128,7 +130,6 @@ protected: private: void calculateWellGeometryVisibility(size_t frameIndex); - static cvf::Color3f cycledPaletteColor(size_t colorIndex); void updateStateForVisibilityCheckboxes(); void updateStateFromEnabledChildCount(size_t showLabelCount, caf::PdmField* fieldToUpdate); From fad0974b3f8413f527e1b08b422f302729c776ab Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 08:26:27 +0100 Subject: [PATCH 20/43] #1148 Use tristate for well cell visibility --- .../ProjectDataModel/RimEclipseView.cpp | 5 +- .../ProjectDataModel/RimEclipseWell.cpp | 64 ++++++++++------- .../RimEclipseWellCollection.cpp | 68 +++++++++++++++---- .../RimEclipseWellCollection.h | 8 ++- .../UserInterface/RiuMainWindow.cpp | 3 +- 5 files changed, 103 insertions(+), 45 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 6b7406a2d7..da02b4e166 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1141,9 +1141,6 @@ void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleC } visibleCells->setAll(false); - // If all wells are forced off, return - if (!this->wellCollection()->showWellCells()) return; - RigActiveCellInfo* activeCellInfo = this->currentActiveCellInfo(); CVF_ASSERT(activeCellInfo); @@ -1152,7 +1149,7 @@ void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleC for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { RimEclipseWell* well = this->wellCollection()->wells()[wIdx]; - if (this->wellCollection()->showWellCells() && well->showWell() && well->showWellCells()) + if (well->showWell() && well->showWellCells()) { RigSingleWellResultsData* wres = well->wellResults(); if (!wres) continue; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index b694aa9622..8b254b2ee2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -27,6 +27,8 @@ #include "RimEclipseWellCollection.h" #include "RimIntersectionCollection.h" +#include "RiuMainWindow.h" + #include "cvfMath.h" CAF_PDM_SOURCE_INIT(RimEclipseWell, "Well"); @@ -51,7 +53,7 @@ RimEclipseWell::RimEclipseWell() CAF_PDM_InitField(&pipeScaleFactor, "WellPipeRadiusScale", 1.0, "Pipe Scale Factor", "", "", ""); CAF_PDM_InitField(&wellPipeColor, "WellPipeColor", cvf::Color3f(0.588f, 0.588f, 0.804f), "Pipe color", "", "", ""); - CAF_PDM_InitField(&showWellCells, "ShowWellCells", true, "Well Cells", "", "", ""); + CAF_PDM_InitField(&showWellCells, "ShowWellCells", false, "Well Cells", "", "", ""); CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Well Cell Fence", "", "", ""); m_resultWellIndex = cvf::UNDEFINED_SIZE_T; @@ -77,34 +79,44 @@ caf::PdmFieldHandle* RimEclipseWell::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimEclipseWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - RimEclipseView* m_reservoirView = nullptr; - this->firstAncestorOrThisOfType(m_reservoirView); - if (!m_reservoirView) return; - - if (&showWellLabel == changedField || - &showWellHead == changedField || - &showWellPipe == changedField || - &showWellSpheres == changedField || - &wellPipeColor == changedField) + RimEclipseView* reservoirView = nullptr; + this->firstAncestorOrThisOfType(reservoirView); + if (reservoirView) { - m_reservoirView->scheduleCreateDisplayModelAndRedraw(); - } - else if (&showWell == changedField || - &showWellCells == changedField || - &showWellCellFence == changedField) - - { - m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); - m_reservoirView->scheduleCreateDisplayModelAndRedraw(); - } - else if ( &pipeScaleFactor == changedField - || &wellHeadScaleFactor == changedField) - { - if (m_reservoirView) + if (&showWellLabel == changedField || + &showWellHead == changedField || + &showWellPipe == changedField || + &showWellSpheres == changedField || + &wellPipeColor == changedField) { - m_reservoirView->schedulePipeGeometryRegen(); - m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + reservoirView->scheduleCreateDisplayModelAndRedraw(); } + else if (&showWell == changedField || + &showWellCells == changedField || + &showWellCellFence == changedField) + + { + reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); + reservoirView->scheduleCreateDisplayModelAndRedraw(); + } + else if ( &pipeScaleFactor == changedField + || &wellHeadScaleFactor == changedField) + { + if (reservoirView) + { + reservoirView->schedulePipeGeometryRegen(); + reservoirView->scheduleCreateDisplayModelAndRedraw(); + } + } + } + + RimEclipseWellCollection* wellColl = nullptr; + this->firstAncestorOrThisOfType(wellColl); + if (wellColl) + { + wellColl->updateStateForVisibilityCheckboxes(); + + RiuMainWindow::instance()->refreshDrawStyleActions(); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index 0faffc650f..e149f8d7e7 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -161,7 +161,11 @@ RimEclipseWellCollection::RimEclipseWellCollection() pipeCrossSectionVertexCount.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&wellPipeCoordType, "WellPipeCoordType", WellPipeCoordEnum(WELLPIPE_INTERPOLATED), "Type", "", "", ""); - CAF_PDM_InitField(&showWellCells, "ShowWellCells", false, "Show Well Cells", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellCells, "ShowWellCells", "Show Well Cells", "", "", ""); + m_showWellCells.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); + m_showWellCells.xmlCapability()->setIOReadable(false); + m_showWellCells.xmlCapability()->setIOWritable(false); + CAF_PDM_InitField(&showWellCellFence, "ShowWellFences", false, "Show Well Cell Fence", "", "", ""); CAF_PDM_InitField(&wellCellFenceType, "DefaultWellFenceDirection", WellFenceEnum(K_DIRECTION), "Well Fence Direction", "", "", ""); @@ -191,6 +195,40 @@ RimEclipseWellCollection::~RimEclipseWellCollection() wells.deleteAllChildObjects(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseWellCollection::setShowWellCellsState(bool enable) +{ + for (RimEclipseWell* w : wells) + { + w->showWellCells = enable; + } + + updateConnectedEditors(); + + if (m_reservoirView) + { + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); + m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseWellCollection::showWellCells() +{ + if (m_showWellCells().isFalse()) + { + return false; + } + else + { + return true; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -212,7 +250,6 @@ RimEclipseWell* RimEclipseWellCollection::findWell(QString name) bool RimEclipseWellCollection::hasVisibleWellCells() { if (!this->isActive()) return false; - if (!this->showWellCells()) return false; if (this->wells().size() == 0 ) return false; bool hasCells = false; @@ -292,12 +329,19 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang } } + if (&m_showWellCells == changedField) + { + for (RimEclipseWell* w : wells) + { + w->showWellCells = !(m_showWellCells().isFalse()); + } + } if (m_reservoirView) { if ( &isActive == changedField || &m_showWellLabel == changedField - || &showWellCells == changedField + || &m_showWellCells == changedField || &showWellCellFence == changedField || &wellCellFenceType == changedField) { @@ -372,7 +416,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang m_applySingleColorToWells = false; } - if (&showWellCells == changedField) + if (&m_showWellCells == changedField) { RiuMainWindow::instance()->refreshDrawStyleActions(); } @@ -425,7 +469,7 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well Cells"); filterGroup->add(&obsoleteField_wellCellsToRangeFilterMode); - filterGroup->add(&showWellCells); + filterGroup->add(&m_showWellCells); filterGroup->add(&showWellCellFence); filterGroup->add(&wellCellFenceType); @@ -442,6 +486,7 @@ void RimEclipseWellCollection::updateStateForVisibilityCheckboxes() size_t showWellHeadCount = 0; size_t showPipeCount = 0; size_t showSphereCount = 0; + size_t showWellCellsCount = 0; for (RimEclipseWell* w : wells) { @@ -449,12 +494,14 @@ void RimEclipseWellCollection::updateStateForVisibilityCheckboxes() if (w->showWellHead()) showWellHeadCount++; if (w->showWellPipe()) showPipeCount++; if (w->showWellSpheres()) showSphereCount++; + if (w->showWellCells()) showWellCellsCount++; } updateStateFromEnabledChildCount(showLabelCount, &m_showWellLabel); updateStateFromEnabledChildCount(showWellHeadCount, &m_showWellHead); updateStateFromEnabledChildCount(showPipeCount, &m_showWellPipe); updateStateFromEnabledChildCount(showSphereCount, &m_showWellSpheres); + updateStateFromEnabledChildCount(showWellCellsCount, &m_showWellCells); } //-------------------------------------------------------------------------------------------------- @@ -523,21 +570,18 @@ void RimEclipseWellCollection::initAfterRead() if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_NONE) { - showWellCells = false; + for (RimEclipseWell* w : wells) + { + w->showWell = false; + } } else if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_ALL) { - showWellCells = true; - for (RimEclipseWell* w : wells) { w->showWellCells = true; } } - else if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_INDIVIDUAL) - { - showWellCells = true; - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index 3a46d4b4fc..fa9d5a05d9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -95,7 +95,9 @@ public: caf::PdmField wellLabelColor; caf::PdmField showConnectionStatusColors; - caf::PdmField showWellCells; + void setShowWellCellsState(bool enable); + bool showWellCells(); + caf::PdmField showWellCellFence; caf::PdmField wellCellFenceType; caf::PdmField wellCellTransparencyLevel; @@ -116,6 +118,8 @@ public: const std::vector& resultWellGeometryVisibilities(size_t frameIndex); void scheduleIsWellPipesVisibleRecalculation(); + void updateStateForVisibilityCheckboxes(); + static cvf::Color3f cycledPaletteColor(size_t colorIndex); @@ -130,7 +134,6 @@ protected: private: void calculateWellGeometryVisibility(size_t frameIndex); - void updateStateForVisibilityCheckboxes(); void updateStateFromEnabledChildCount(size_t showLabelCount, caf::PdmField* fieldToUpdate); private: @@ -146,6 +149,7 @@ private: caf::PdmField m_showWellHead; caf::PdmField m_showWellPipe; caf::PdmField m_showWellSpheres; + caf::PdmField m_showWellCells; // Obsolete fields caf::PdmField obsoleteField_wellPipeVisibility; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index eff8cd68cb..e2f9925e76 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1384,6 +1384,7 @@ void RiuMainWindow::refreshDrawStyleActions() m_toggleFaultsLabelAction->blockSignals(false); m_showWellCellsAction->blockSignals(true); + eclView->wellCollection()->updateStateForVisibilityCheckboxes(); m_showWellCellsAction->setChecked(eclView->wellCollection()->showWellCells()); m_showWellCellsAction->blockSignals(false); } @@ -1577,7 +1578,7 @@ void RiuMainWindow::slotShowWellCellsAction(bool doAdd) RimEclipseView* riv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (riv) { - riv->wellCollection()->showWellCells.setValueWithFieldChanged(doAdd); + riv->wellCollection()->setShowWellCellsState(doAdd); } } From 53bccf3d0f082b8dd0a2bd46f6c30fee8569b3fc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 09:10:34 +0100 Subject: [PATCH 21/43] #1148 Improved obsolete field behaviour for well head, label and well cells --- .../RimEclipseWellCollection.cpp | 52 ++++++++++++++++--- .../RimEclipseWellCollection.h | 4 ++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index e149f8d7e7..28bbd6a50e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -110,10 +110,10 @@ RimEclipseWellCollection::RimEclipseWellCollection() CAF_PDM_InitField(&showWellsIntersectingVisibleCells, "ShowWellsIntersectingVisibleCells", true, "Show Wells Intersecting Visible Cells", "", "", ""); // Appearance - CAF_PDM_InitFieldNoDefault(&m_showWellHead, "ShowWellHead", "Show Well Head", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_showWellLabel, "ShowWellLabel", "Show Well Label", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_showWellPipe, "ShowWellPipe", "Show Well Pipe", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_showWellSpheres, "ShowWellSpheres", "Show Well Spheres", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellHead, "ShowWellHeadTristate", "Show Well Head", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellLabel, "ShowWellLabelTristate", "Show Well Label", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellPipe, "ShowWellPipe", "Show Well Pipe", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellSpheres, "ShowWellSpheres", "Show Well Spheres", "", "", ""); m_showWellHead.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); m_showWellHead.xmlCapability()->setIOReadable(false); @@ -161,7 +161,7 @@ RimEclipseWellCollection::RimEclipseWellCollection() pipeCrossSectionVertexCount.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&wellPipeCoordType, "WellPipeCoordType", WellPipeCoordEnum(WELLPIPE_INTERPOLATED), "Type", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_showWellCells, "ShowWellCells", "Show Well Cells", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellCells, "ShowWellCellsTristate", "Show Well Cells", "", "", ""); m_showWellCells.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); m_showWellCells.xmlCapability()->setIOReadable(false); m_showWellCells.xmlCapability()->setIOWritable(false); @@ -184,6 +184,18 @@ RimEclipseWellCollection::RimEclipseWellCollection() obsoleteField_wellCellsToRangeFilterMode.uiCapability()->setUiHidden(true); obsoleteField_wellCellsToRangeFilterMode.xmlCapability()->setIOWritable(false); + CAF_PDM_InitFieldNoDefault(&obsoleteField_showWellHead, "ShowWellHead", "Show Well Head", "", "", ""); + CAF_PDM_InitFieldNoDefault(&obsoleteField_showWellLabel, "ShowWellLabel", "Show Well Label", "", "", ""); + CAF_PDM_InitFieldNoDefault(&obsoleteField_showWellCells, "ShowWellCells", "Show Well Cells", "", "", ""); + + obsoleteField_showWellHead.uiCapability()->setUiHidden(true); + obsoleteField_showWellLabel.uiCapability()->setUiHidden(true); + obsoleteField_showWellCells.uiCapability()->setUiHidden(true); + + obsoleteField_showWellHead.xmlCapability()->setIOWritable(false); + obsoleteField_showWellLabel.xmlCapability()->setIOWritable(false); + obsoleteField_showWellCells.xmlCapability()->setIOWritable(false); + m_reservoirView = NULL; } @@ -551,7 +563,7 @@ void RimEclipseWellCollection::initAfterRead() for (RimEclipseWell* w : wells) { - w->showWell = false; + w->showWellPipe = false; } } else if (obsoleteField_wellPipeVisibility() == PIPES_FORCE_ALL_ON) @@ -560,7 +572,7 @@ void RimEclipseWellCollection::initAfterRead() for (RimEclipseWell* w : wells) { - w->showWell = true; + w->showWellPipe = true; } } else if (obsoleteField_wellPipeVisibility() == PIPES_INDIVIDUALLY) @@ -572,7 +584,7 @@ void RimEclipseWellCollection::initAfterRead() { for (RimEclipseWell* w : wells) { - w->showWell = false; + w->showWellCells = false; } } else if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_ALL) @@ -582,6 +594,30 @@ void RimEclipseWellCollection::initAfterRead() w->showWellCells = true; } } + + if (!obsoleteField_showWellLabel()) + { + for (RimEclipseWell* w : wells) + { + w->showWellLabel = false; + } + } + + if (!obsoleteField_showWellHead()) + { + for (RimEclipseWell* w : wells) + { + w->showWellHead = false; + } + } + + if (!obsoleteField_showWellCells()) + { + for (RimEclipseWell* w : wells) + { + w->showWellCells = false; + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index fa9d5a05d9..35efb5bd85 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -154,4 +154,8 @@ private: // Obsolete fields caf::PdmField obsoleteField_wellPipeVisibility; caf::PdmField obsoleteField_wellCellsToRangeFilterMode; + + caf::PdmField obsoleteField_showWellLabel; + caf::PdmField obsoleteField_showWellHead; + caf::PdmField obsoleteField_showWellCells; }; From c4d9c1d780b38e49a100967cc8053e9e4c83c394 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 09:56:49 +0100 Subject: [PATCH 22/43] #1148 Made tristate of well cell fence --- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../RimEclipseWellCollection.cpp | 54 +++++++++++-------- .../RimEclipseWellCollection.h | 4 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index da02b4e166..ce8f155e1f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1188,7 +1188,7 @@ void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleC (*visibleCells)[gridCellIndex] = true; // Calculate well fence cells - if (well->showWellCellFence() && this->wellCollection()->showWellCellFence()) + if (well->showWellCellFence()) { size_t i, j, k; grid->ijkFromCellIndex(gridCellIndex, &i, &j, &k); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index 28bbd6a50e..52dcc93967 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -166,7 +166,6 @@ RimEclipseWellCollection::RimEclipseWellCollection() m_showWellCells.xmlCapability()->setIOReadable(false); m_showWellCells.xmlCapability()->setIOWritable(false); - CAF_PDM_InitField(&showWellCellFence, "ShowWellFences", false, "Show Well Cell Fence", "", "", ""); CAF_PDM_InitField(&wellCellFenceType, "DefaultWellFenceDirection", WellFenceEnum(K_DIRECTION), "Well Fence Direction", "", "", ""); CAF_PDM_InitField(&wellCellTransparencyLevel, "WellCellTransparency", 0.5, "Well Cell Transparency", "", "", ""); @@ -176,6 +175,11 @@ RimEclipseWellCollection::RimEclipseWellCollection() CAF_PDM_InitFieldNoDefault(&wells, "Wells", "Wells", "", "", ""); wells.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_showWellCellFence, "ShowWellCellFenceTristate", "Show Well Cell Fence", "", "", ""); + m_showWellCellFence.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); + m_showWellCellFence.xmlCapability()->setIOReadable(false); + m_showWellCellFence.xmlCapability()->setIOWritable(false); + CAF_PDM_InitField(&obsoleteField_wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(PIPES_OPEN_IN_VISIBLE_CELLS), "Global well pipe visibility", "", "", ""); obsoleteField_wellPipeVisibility.uiCapability()->setUiHidden(true); obsoleteField_wellPipeVisibility.xmlCapability()->setIOWritable(false); @@ -184,17 +188,17 @@ RimEclipseWellCollection::RimEclipseWellCollection() obsoleteField_wellCellsToRangeFilterMode.uiCapability()->setUiHidden(true); obsoleteField_wellCellsToRangeFilterMode.xmlCapability()->setIOWritable(false); - CAF_PDM_InitFieldNoDefault(&obsoleteField_showWellHead, "ShowWellHead", "Show Well Head", "", "", ""); - CAF_PDM_InitFieldNoDefault(&obsoleteField_showWellLabel, "ShowWellLabel", "Show Well Label", "", "", ""); - CAF_PDM_InitFieldNoDefault(&obsoleteField_showWellCells, "ShowWellCells", "Show Well Cells", "", "", ""); + CAF_PDM_InitField(&obsoleteField_showWellHead, "ShowWellHead", true, "Show Well Head", "", "", ""); + CAF_PDM_InitField(&obsoleteField_showWellLabel, "ShowWellLabel", true, "Show Well Label", "", "", ""); + CAF_PDM_InitField(&obsoleteField_showWellCellFence, "ShowWellFences", false, "Show Well Cell Fence", "", "", ""); obsoleteField_showWellHead.uiCapability()->setUiHidden(true); obsoleteField_showWellLabel.uiCapability()->setUiHidden(true); - obsoleteField_showWellCells.uiCapability()->setUiHidden(true); + obsoleteField_showWellCellFence.uiCapability()->setUiHidden(true); obsoleteField_showWellHead.xmlCapability()->setIOWritable(false); obsoleteField_showWellLabel.xmlCapability()->setIOWritable(false); - obsoleteField_showWellCells.xmlCapability()->setIOWritable(false); + obsoleteField_showWellCellFence.xmlCapability()->setIOWritable(false); m_reservoirView = NULL; } @@ -314,6 +318,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang for (RimEclipseWell* w : wells) { w->showWellLabel = !(m_showWellLabel().isFalse()); + w->updateConnectedEditors(); } } @@ -322,6 +327,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang for (RimEclipseWell* w : wells) { w->showWellHead = !(m_showWellHead().isFalse()); + w->updateConnectedEditors(); } } @@ -330,6 +336,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang for (RimEclipseWell* w : wells) { w->showWellPipe = !(m_showWellPipe().isFalse()); + w->updateConnectedEditors(); } } @@ -338,6 +345,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang for (RimEclipseWell* w : wells) { w->showWellSpheres = !(m_showWellSpheres().isFalse()); + w->updateConnectedEditors(); } } @@ -346,6 +354,16 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang for (RimEclipseWell* w : wells) { w->showWellCells = !(m_showWellCells().isFalse()); + w->updateConnectedEditors(); + } + } + + if (&m_showWellCellFence == changedField) + { + for (RimEclipseWell* w : wells) + { + w->showWellCellFence = !(m_showWellCellFence().isFalse()); + w->updateConnectedEditors(); } } @@ -354,7 +372,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang if ( &isActive == changedField || &m_showWellLabel == changedField || &m_showWellCells == changedField - || &showWellCellFence == changedField + || &m_showWellCellFence == changedField || &wellCellFenceType == changedField) { m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); @@ -387,17 +405,6 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang } } - if ( &m_showWellPipe == changedField - || &m_showWellSpheres == changedField - || &m_showWellHead == changedField - || &m_showWellLabel == changedField) - { - for (RimEclipseWell* w : wells) - { - w->updateConnectedEditors(); - } - } - if (&m_applyIndividualColorsToWells == changedField) { for (size_t i = 0; i < wells.size(); i++) @@ -482,10 +489,10 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well Cells"); filterGroup->add(&obsoleteField_wellCellsToRangeFilterMode); filterGroup->add(&m_showWellCells); - filterGroup->add(&showWellCellFence); + filterGroup->add(&m_showWellCellFence); filterGroup->add(&wellCellFenceType); - showWellCellFence.uiCapability()->setUiReadOnly(!showWellCells()); + m_showWellCellFence.uiCapability()->setUiReadOnly(!showWellCells()); wellCellFenceType.uiCapability()->setUiReadOnly(!showWellCells()); } @@ -499,6 +506,7 @@ void RimEclipseWellCollection::updateStateForVisibilityCheckboxes() size_t showPipeCount = 0; size_t showSphereCount = 0; size_t showWellCellsCount = 0; + size_t showWellCellFenceCount = 0; for (RimEclipseWell* w : wells) { @@ -507,6 +515,7 @@ void RimEclipseWellCollection::updateStateForVisibilityCheckboxes() if (w->showWellPipe()) showPipeCount++; if (w->showWellSpheres()) showSphereCount++; if (w->showWellCells()) showWellCellsCount++; + if (w->showWellCellFence()) showWellCellFenceCount++; } updateStateFromEnabledChildCount(showLabelCount, &m_showWellLabel); @@ -514,6 +523,7 @@ void RimEclipseWellCollection::updateStateForVisibilityCheckboxes() updateStateFromEnabledChildCount(showPipeCount, &m_showWellPipe); updateStateFromEnabledChildCount(showSphereCount, &m_showWellSpheres); updateStateFromEnabledChildCount(showWellCellsCount, &m_showWellCells); + updateStateFromEnabledChildCount(showWellCellFenceCount, &m_showWellCellFence); } //-------------------------------------------------------------------------------------------------- @@ -611,11 +621,11 @@ void RimEclipseWellCollection::initAfterRead() } } - if (!obsoleteField_showWellCells()) + if (obsoleteField_showWellCellFence()) { for (RimEclipseWell* w : wells) { - w->showWellCells = false; + w->showWellCellFence = true; } } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index 35efb5bd85..ef90310eb1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -98,7 +98,6 @@ public: void setShowWellCellsState(bool enable); bool showWellCells(); - caf::PdmField showWellCellFence; caf::PdmField wellCellFenceType; caf::PdmField wellCellTransparencyLevel; @@ -150,6 +149,7 @@ private: caf::PdmField m_showWellPipe; caf::PdmField m_showWellSpheres; caf::PdmField m_showWellCells; + caf::PdmField m_showWellCellFence; // Obsolete fields caf::PdmField obsoleteField_wellPipeVisibility; @@ -157,5 +157,5 @@ private: caf::PdmField obsoleteField_showWellLabel; caf::PdmField obsoleteField_showWellHead; - caf::PdmField obsoleteField_showWellCells; + caf::PdmField obsoleteField_showWellCellFence; }; From b90b2fbc044716edcde461a8065a979f2b2d7621 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 10:34:32 +0100 Subject: [PATCH 23/43] Use ordering of RigSingleWellResultsData when assigning well colors --- .../RimEclipseWellCollection.cpp | 39 +++++++++++++++---- .../RimEclipseWellCollection.h | 3 ++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index 52dcc93967..5e0923d324 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -23,12 +23,15 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RigEclipseCaseData.h" #include "RigSingleWellResultsData.h" +#include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimEclipseWell.h" #include "RiuMainWindow.h" + #include "RivReservoirViewPartMgr.h" #include "cafPdmUiPushButtonEditor.h" @@ -407,14 +410,8 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang if (&m_applyIndividualColorsToWells == changedField) { - for (size_t i = 0; i < wells.size(); i++) - { - cvf::Color3f col = cycledPaletteColor(i); + assignDefaultWellColors(); - wells[i]->wellPipeColor = col; - wells[i]->updateConnectedEditors(); - } - if (m_reservoirView) m_reservoirView->scheduleCreateDisplayModelAndRedraw(); m_applyIndividualColorsToWells = false; @@ -441,6 +438,34 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseWellCollection::assignDefaultWellColors() +{ + // The wells are sorted, use ordering of single well results data to assign colors + + RimEclipseCase* rimEclipseCase = nullptr; + this->firstAncestorOrThisOfType(rimEclipseCase); + if (!rimEclipseCase) return; + + if (!rimEclipseCase->reservoirData()) return; + + cvf::Collection wellResults = rimEclipseCase->reservoirData()->wellResults(); + + for (size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx) + { + RimEclipseWell* well = this->findWell(wellResults[wIdx]->m_wellName); + if (well) + { + cvf::Color3f col = cycledPaletteColor(wIdx); + + well->wellPipeColor = col; + well->updateConnectedEditors(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index ef90310eb1..071127a086 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -121,9 +121,12 @@ public: static cvf::Color3f cycledPaletteColor(size_t colorIndex); + void assignDefaultWellColors(); protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; From d24bf527bfdc1f0336d15d6509ba9d794f4ebb78 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 10:35:15 +0100 Subject: [PATCH 24/43] Assign default colors to wells when importing case from file --- ApplicationCode/Application/RiaApplication.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 234f1b9b92..565c427f8d 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -868,6 +868,8 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas riv->loadDataAndUpdate(); + riv->wellCollection()->assignDefaultWellColors(); + // Add a corresponding summary case if it exists { RimSummaryCaseCollection* sumCaseColl = m_project->activeOilField() ? m_project->activeOilField()->summaryCaseCollection() : NULL; From 7c86482af33ff98b3bac63b5757ab218e32ff6f4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 11:11:03 +0100 Subject: [PATCH 25/43] #1107 Added calculateValueOptions for case and flow diag solution --- .../Flow/RimWellAllocationPlot.cpp | 28 +++++++++++++++++++ .../Flow/RimWellAllocationPlot.h | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 137066547f..13b1fc891b 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -40,6 +40,7 @@ #include "RiuMainPlotWindow.h" #include "RiuWellAllocationPlot.h" #include "RigAccWellFlowCalculator.h" +#include "RimProject.h" CAF_PDM_SOURCE_INIT(RimWellAllocationPlot, "WellAllocationPlot"); @@ -347,6 +348,33 @@ QList RimWellAllocationPlot::calculateValueOptions(const options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i)); } } + else if (fieldNeedingOptions == &m_case) + { + RimProject* proj = nullptr; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + std::vector cases; + proj->descendantsIncludingThisOfType(cases); + + for (RimEclipseResultCase* c : cases) + { + options.push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c, false, c->uiIcon())); + } + } + } + else if (fieldNeedingOptions == &m_flowDiagSolution) + { + if (m_case) + { + std::vector flowSols = m_case->flowDiagSolutions(); + + for (RimFlowDiagSolution* flowSol : flowSols) + { + options.push_back(caf::PdmOptionItemInfo(flowSol->userDescription(), flowSol, false, flowSol->uiIcon())); + } + } + } return options; } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h index 91752e9d7b..c361a00eb4 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h @@ -64,7 +64,6 @@ public: RimWellLogPlot* accumulatedWellFlowPlot(); RimTotalWellAllocationPlot* totalWellFlowPlot(); - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; QString wellName() const; @@ -74,6 +73,7 @@ protected: // Overridden PDM methods virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; } virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual QImage snapshotWindowContent() override; From 7abdc38d92da5d671aade2253a42f94e99fcf04c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 11:27:55 +0100 Subject: [PATCH 26/43] #1148 Fixed issue causing well cells to always be enabled --- .../ProjectDataModel/RimEclipseWellCollection.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index 5e0923d324..808dba29e8 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -183,11 +183,11 @@ RimEclipseWellCollection::RimEclipseWellCollection() m_showWellCellFence.xmlCapability()->setIOReadable(false); m_showWellCellFence.xmlCapability()->setIOWritable(false); - CAF_PDM_InitField(&obsoleteField_wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(PIPES_OPEN_IN_VISIBLE_CELLS), "Global well pipe visibility", "", "", ""); + CAF_PDM_InitField(&obsoleteField_wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(PIPES_INDIVIDUALLY), "Global well pipe visibility", "", "", ""); obsoleteField_wellPipeVisibility.uiCapability()->setUiHidden(true); obsoleteField_wellPipeVisibility.xmlCapability()->setIOWritable(false); - CAF_PDM_InitField(&obsoleteField_wellCellsToRangeFilterMode, "GlobalWellCellVisibility", WellCellsRangeFilterEnum(RANGE_ADD_NONE), "Add cells to range filter", "", "", ""); + CAF_PDM_InitField(&obsoleteField_wellCellsToRangeFilterMode, "GlobalWellCellVisibility", WellCellsRangeFilterEnum(RANGE_ADD_INDIVIDUAL), "Add cells to range filter", "", "", ""); obsoleteField_wellCellsToRangeFilterMode.uiCapability()->setUiHidden(true); obsoleteField_wellCellsToRangeFilterMode.xmlCapability()->setIOWritable(false); @@ -610,10 +610,6 @@ void RimEclipseWellCollection::initAfterRead() w->showWellPipe = true; } } - else if (obsoleteField_wellPipeVisibility() == PIPES_INDIVIDUALLY) - { - showWellsIntersectingVisibleCells = false; - } if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_NONE) { From eee43ccf0fd16cd905f3026a316312fc69553b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 2 Feb 2017 11:22:02 +0100 Subject: [PATCH 27/43] #1108, #1110, #1116 Pie chart Well Allocation Factors now working. --- .../Flow/RimTotalWellAllocationPlot.cpp | 132 ++++-------------- .../Flow/RimTotalWellAllocationPlot.h | 28 ++-- .../Flow/RimWellAllocationPlot.cpp | 91 ++++++++---- .../Flow/RimWellAllocationPlot.h | 6 + 4 files changed, 105 insertions(+), 152 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp index 25c8a01bdf..1d2a2aecc0 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp @@ -32,6 +32,7 @@ #include "RiuMainPlotWindow.h" #include "RiuNightchartsWidget.h" #include "RiuWellAllocationPlot.h" +#include "cvfColor3.h" CAF_PDM_SOURCE_INIT(RimTotalWellAllocationPlot, "TotalWellAllocationPlot"); @@ -48,7 +49,6 @@ RimTotalWellAllocationPlot::RimTotalWellAllocationPlot() m_userName.uiCapability()->setUiReadOnly(true); CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_simulationWell, "SimulationWell", "Simulation Well", "", "", ""); } @@ -62,15 +62,6 @@ RimTotalWellAllocationPlot::~RimTotalWellAllocationPlot() deleteViewWidget(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimTotalWellAllocationPlot::setSimulationWell(RimEclipseWell* simWell) -{ - m_simulationWell = simWell; - - updateFromWell(); -} //-------------------------------------------------------------------------------------------------- /// @@ -84,60 +75,6 @@ void RimTotalWellAllocationPlot::deleteViewWidget() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimTotalWellAllocationPlot::updateFromWell() -{ -/* - QString simName = "None"; - int branchCount = 0; - - const RigWellResultFrame* wellResultFrame = nullptr; - - if (m_simulationWell && m_simulationWell->wellResults() )// && Timestep Ok ) - { - simName = m_simulationWell->name(); - wellResultFrame = &(m_simulationWell->wellResults()->wellResultFrame(1)); - branchCount = static_cast( wellResultFrame->m_wellResultBranches.size()); - // // Todo : Use this instead, and use to calculate accumulated flow - // - // size_t timeStep = 0; // make field - // std::vector< std::vector > pipeBranchesCLCoords; - // std::vector< std::vector > pipeBranchesCellIds; - // m_simulationWell->calculateWellPipeDynamicCenterLine(timeStep, pipeBranchesCLCoords, pipeBranchesCellIds); - // branchCount = static_cast( pipeBranchesCLCoords.size()); - } - - int existingTrackCount = static_cast(accumulatedWellFlowPlot()->trackCount()); - accumulatedWellFlowPlot()->setDescription("Accumulated Well Flow (" + simName + ")"); - - int neededExtraTrackCount = branchCount - existingTrackCount; - for (int etc = 0; etc < neededExtraTrackCount; ++etc) - { - RimWellLogTrack* plotTrack = new RimWellLogTrack(); - accumulatedWellFlowPlot()->addTrack(plotTrack); - } - - for (int etc = branchCount; etc < existingTrackCount; ++etc) - { - accumulatedWellFlowPlot()->removeTrackByIndex(accumulatedWellFlowPlot()->trackCount()- 1); - } - - - for (size_t brIdx = 0; brIdx < branchCount; ++brIdx) - { - RimWellLogTrack* plotTrack = accumulatedWellFlowPlot()->trackByIndex(brIdx); - - plotTrack->setDescription(QString("Branch %1").arg(brIdx+1)); - - } - - setDescription("Well Allocation (" + simName + ")"); - accumulatedWellFlowPlot()->updateConnectedEditors(); -*/ -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -153,39 +90,6 @@ void RimTotalWellAllocationPlot::zoomAll() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList RimTotalWellAllocationPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) -{ - QList options; - - if (fieldNeedingOptions == &m_simulationWell) - { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); - RimEclipseView* eclView = dynamic_cast(activeView); - - if (eclView && eclView->wellCollection()) - { - RimEclipseWellCollection* coll = eclView->wellCollection(); - - caf::PdmChildArrayField& eclWells = coll->wells; - - QIcon simWellIcon(":/Well.png"); - for (RimEclipseWell* eclWell : eclWells) - { - options.push_back(caf::PdmOptionItemInfo(eclWell->name(), eclWell, false, simWellIcon)); - } - } - - if (options.size() == 0) - { - options.push_front(caf::PdmOptionItemInfo("None", nullptr)); - } - } - - return options; -} //-------------------------------------------------------------------------------------------------- /// @@ -199,10 +103,7 @@ void RimTotalWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* cha { updateMdiWindowTitle(); } - else if (changedField == &m_simulationWell) - { - updateFromWell(); - } + } @@ -235,13 +136,34 @@ QString RimTotalWellAllocationPlot::description() const return m_userName(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTotalWellAllocationPlot::addSlice(const QString& name, const cvf::Color3f& color, float value) +{ + QColor sliceColor(color.rByte(), color.gByte(), color.bByte()); + + m_wellTotalAllocationPlotWidget->addItem(name, sliceColor, value); + m_wellTotalAllocationPlotWidget->update(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTotalWellAllocationPlot::clearSlices() +{ + m_wellTotalAllocationPlotWidget->clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimTotalWellAllocationPlot::loadDataAndUpdate() { updateMdiWindowVisibility(); - updateFromWell(); + } //-------------------------------------------------------------------------------------------------- @@ -250,12 +172,6 @@ void RimTotalWellAllocationPlot::loadDataAndUpdate() QWidget* RimTotalWellAllocationPlot::createViewWidget(QWidget* mainWindowParent) { m_wellTotalAllocationPlotWidget = new RiuNightchartsWidget(mainWindowParent); - m_wellTotalAllocationPlotWidget->addItem("Item1", QColor(200, 10, 50), 34); - m_wellTotalAllocationPlotWidget->addItem("Item2", Qt::green, 27); - m_wellTotalAllocationPlotWidget->addItem("Item3", Qt::cyan, 14); - m_wellTotalAllocationPlotWidget->addItem("Item4", Qt::yellow, 7); - m_wellTotalAllocationPlotWidget->addItem("Item5", Qt::blue, 4); - return m_wellTotalAllocationPlotWidget; } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.h index 8bca8116ea..5cf541f367 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.h @@ -36,6 +36,10 @@ namespace caf { class PdmOptionItemInfo; } +namespace cvf { + class cvf::Color3f; +} + //================================================================================================== /// @@ -49,39 +53,31 @@ public: RimTotalWellAllocationPlot(); virtual ~RimTotalWellAllocationPlot(); - void setSimulationWell(RimEclipseWell* simWell); - void setDescription(const QString& description); QString description() const; - void loadDataAndUpdate(); + void addSlice(const QString& name, const cvf::Color3f& color, float value); + void clearSlices(); + // RimViewWindow overrides virtual QWidget* viewWidget() override; virtual void zoomAll() override; - - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; - - // RimViewWindow overrides - virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; virtual void deleteViewWidget() override; protected: + // RimViewWindow overrides + + virtual void loadDataAndUpdate() override; + virtual QImage snapshotWindowContent() override; + // Overridden PDM methods virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; } virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual QImage snapshotWindowContent() override; - -private: - void updateFromWell(); - - private: caf::PdmField m_showPlotTitle; caf::PdmField m_userName; - caf::PdmPtrField m_simulationWell; - QPointer m_wellTotalAllocationPlotWidget; }; diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 13b1fc891b..edd02b7abe 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -225,53 +225,88 @@ void RimWellAllocationPlot::updateFromWell() accumulatedWellFlowPlot()->addTrack(plotTrack); + std::vector connNumbers; + { + const std::vector& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx); + for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast(conNumb)); + } + if ( m_flowDiagSolution ) { - std::vector connNumbers; - { - const std::vector& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx); - for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast(conNumb)); - } - std::vector tracerNames = wfCalculator->tracerNames(); for (const QString& tracerName: tracerNames) { const std::vector& accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, brIdx); - - RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; - curve->setFlowValues(tracerName, connNumbers, accFlow); - curve->setColor( m_flowDiagSolution->tracerColor(tracerName)); - - plotTrack->addCurve(curve); - - curve->loadDataAndUpdate(); + addStackedCurve(tracerName, connNumbers, accFlow, plotTrack); } } else { - std::vector connNumbers; - { - const std::vector& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx); - for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast(conNumb)); - } - const std::vector& accFlow = wfCalculator->accumulatedTotalFlowPrConnection(brIdx); - - RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; - curve->setFlowValues("Total", connNumbers, accFlow); - curve->setColor( cvf::Color3f::DARK_GRAY); - - plotTrack->addCurve(curve); - - curve->loadDataAndUpdate(); + addStackedCurve("Total", connNumbers, accFlow, plotTrack); } } + /// Pie chart + + m_totalWellAllocationPlot->clearSlices(); + std::vector tracerNames = wfCalculator->tracerNames(); + std::vector > tracerWithValues; + + for (const QString& tracerName: tracerNames) + { + const std::vector& accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, 0); + tracerWithValues.push_back(std::make_pair(tracerName, accFlow.back())); + } + + float sumTracerVals = 0.0f; + for ( const auto& tracerVal:tracerWithValues) + { + sumTracerVals += tracerVal.second; + } + + if ( sumTracerVals != 0.0f ) + { + for ( const auto& tracerVal:tracerWithValues ) + { + cvf::Color3f color; + if ( m_flowDiagSolution ) + color = m_flowDiagSolution->tracerColor(tracerVal.first); + else + color = cvf::Color3f::DARK_GRAY; + + m_totalWellAllocationPlot->addSlice(tracerVal.first, color, 100*tracerVal.second/sumTracerVals); + } + } + m_totalWellAllocationPlot->updateConnectedEditors(); + + setDescription("Well Allocation (" + m_wellName + ")"); accumulatedWellFlowPlot()->updateConnectedEditors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellAllocationPlot::addStackedCurve(const QString& tracerName, + const std::vector& connNumbers, + const std::vector& accFlow, + RimWellLogTrack* plotTrack) +{ + RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; + curve->setFlowValues(tracerName, connNumbers, accFlow); + + if ( m_flowDiagSolution ) + curve->setColor(m_flowDiagSolution->tracerColor(tracerName)); + else + curve->setColor(cvf::Color3f::DARK_GRAY); + + plotTrack->addCurve(curve); + + curve->loadDataAndUpdate(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h index c361a00eb4..f94c98c512 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h @@ -33,6 +33,7 @@ class RimFlowDiagSolution; class RimTotalWellAllocationPlot; class RimWellLogPlot; class RiuWellAllocationPlot; +class RimWellLogTrack; namespace caf { class PdmOptionItemInfo; @@ -80,6 +81,11 @@ protected: private: void updateFromWell(); + void addStackedCurve(const QString& tracerName, + const std::vector& connNumbers, + const std::vector& accFlow, + RimWellLogTrack* plotTrack); + // RimViewWindow overrides virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; From e48c9c0e10226e84cadd0dd7d2fb7b7b57076ad5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 11:45:29 +0100 Subject: [PATCH 28/43] Add one and only one flow diag solution if flux is available --- ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index 1ef17af0e4..bd02e2696a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -134,8 +134,12 @@ bool RimEclipseResultCase::openEclipseGridFile() if (reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->hasFlowDiagUsableFluxes()) { - m_flowDiagSolutions.push_back( new RimFlowDiagSolution()); m_flowDagSolverInterface = new RigFlowDiagSolverInterface(this); + + if (m_flowDiagSolutions.size() == 0) + { + m_flowDiagSolutions.push_back(new RimFlowDiagSolution()); + } } return true; From a91bf5144f35203bb51edd81fcb71195da211158 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 12:10:14 +0100 Subject: [PATCH 29/43] Removed double namespace prefix --- .../ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp | 1 + .../ProjectDataModel/Flow/RimTotalWellAllocationPlot.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp index 1d2a2aecc0..9cfcdc9e8f 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp @@ -32,6 +32,7 @@ #include "RiuMainPlotWindow.h" #include "RiuNightchartsWidget.h" #include "RiuWellAllocationPlot.h" + #include "cvfColor3.h" diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.h index 5cf541f367..10f827d504 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.h @@ -37,7 +37,7 @@ namespace caf { } namespace cvf { - class cvf::Color3f; + class Color3f; } From da903575b68efeba305c724b084c24a11e7226e2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 12:31:40 +0100 Subject: [PATCH 30/43] #1164 Removed dummy objects --- ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp index bfecb6747d..6e0a59b8ea 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp @@ -38,8 +38,6 @@ RimFlowPlotCollection::RimFlowPlotCollection() defaultPlot.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&flowPlots, "FlowPlots", "Stored Plots", "", "", ""); - flowPlots.push_back(new RimWellAllocationPlot); - flowPlots.push_back(new RimWellAllocationPlot); } //-------------------------------------------------------------------------------------------------- From e8ee077501ba5e127593fa7c6e348291e1797dde Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 12:32:01 +0100 Subject: [PATCH 31/43] #1164 Added feature "Add Stored Well Allocation Plot" --- .../FlowCommands/CMakeLists_files.cmake | 2 + .../RicAddStoredWellAllocationPlotFeature.cpp | 88 +++++++++++++++++++ .../RicAddStoredWellAllocationPlotFeature.h | 38 ++++++++ .../RimContextCommandBuilder.cpp | 11 ++- 4 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp create mode 100644 ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.h diff --git a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake index bc9893057e..5b0f6da3fe 100644 --- a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake @@ -6,10 +6,12 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp new file mode 100644 index 0000000000..719164cecd --- /dev/null +++ b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp @@ -0,0 +1,88 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAddStoredWellAllocationPlotFeature.h" + +#include "RiaApplication.h" + +#include "RimFlowPlotCollection.h" +#include "RimMainPlotCollection.h" +#include "RimProject.h" +#include "RimWellAllocationPlot.h" + +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT(RicAddStoredWellAllocationPlotFeature, "RicAddStoredWellAllocationPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAddStoredWellAllocationPlotFeature::isCommandEnabled() +{ + if (RiaApplication::instance()->project()) + { + RimFlowPlotCollection* flowPlotColl = RiaApplication::instance()->project()->mainPlotCollection->flowPlotCollection(); + if (flowPlotColl) + { + RimWellAllocationPlot* wellAllocationPlot = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + if (flowPlotColl->defaultPlot() == wellAllocationPlot) + { + return true; + } + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAddStoredWellAllocationPlotFeature::onActionTriggered(bool isChecked) +{ + if (RiaApplication::instance()->project()) + { + RimFlowPlotCollection* flowPlotColl = RiaApplication::instance()->project()->mainPlotCollection->flowPlotCollection(); + if (flowPlotColl) + { + RimWellAllocationPlot* sourceObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + RimWellAllocationPlot* newObject = dynamic_cast(sourceObject->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newObject); + + flowPlotColl->flowPlots.push_back(newObject); + newObject->resolveReferencesRecursively(); + + flowPlotColl->updateConnectedEditors(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAddStoredWellAllocationPlotFeature::setupActionLook(QAction* actionToSetup) +{ + //actionToSetup->setIcon(QIcon(":/new_icon16x16.png")); + actionToSetup->setText("Add Stored Well Allocation Plot"); +} diff --git a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.h b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.h new file mode 100644 index 0000000000..651e2eaa17 --- /dev/null +++ b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + + +//================================================================================================== +/// +//================================================================================================== +class RicAddStoredWellAllocationPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; + + diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 6092ebdeda..dbe76547ef 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -23,8 +23,6 @@ #include "RimCaseCollection.h" #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "RimIntersection.h" -#include "RimIntersectionCollection.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseCellColors.h" @@ -35,6 +33,7 @@ #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" #include "RimEclipseWell.h" +#include "RimFault.h" #include "RimFormationNames.h" #include "RimFormationNamesCollection.h" #include "RimGeoMechCase.h" @@ -42,7 +41,9 @@ #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechView.h" #include "RimIdenticalGridCaseGroup.h" +#include "RimIntersection.h" #include "RimIntersectionBox.h" +#include "RimIntersectionCollection.h" #include "RimScriptCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" @@ -51,6 +52,7 @@ #include "RimSummaryPlotCollection.h" #include "RimViewController.h" #include "RimViewLinker.h" +#include "RimWellAllocationPlot.h" #include "RimWellLogCurve.h" #include "RimWellLogFileChannel.h" #include "RimWellLogPlot.h" @@ -71,7 +73,6 @@ #include #include -#include "RimFault.h" //-------------------------------------------------------------------------------------------------- /// @@ -351,6 +352,10 @@ QStringList RimContextCommandBuilder::commandsFromSelection() { commandIds << "RicExportFaultsFeature"; } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicAddStoredWellAllocationPlotFeature"; + } if (dynamic_cast(uiItem)) From 8ee7229f600c8cde910adf43dd91561d15e3c7c4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 12:37:58 +0100 Subject: [PATCH 32/43] #1163 Well Acc plot: Timestep and case changes in GUI is not handled --- .../ProjectDataModel/Flow/RimWellAllocationPlot.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index edd02b7abe..0d35643df9 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -443,7 +443,9 @@ void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedF { updateMdiWindowTitle(); } - else if (changedField == &m_wellName) + else if ( changedField == &m_wellName + || changedField == &m_case + || changedField == &m_timeStep) { updateFromWell(); } From 9493a1dfc02189b79923835fb0b633c5bd590ac0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 12:52:32 +0100 Subject: [PATCH 33/43] Use hasWellResult instead of firstResultTimeStep --- .../ModelVisualization/RivSimWellPipesPartMgr.cpp | 2 +- .../RigSingleWellResultsData.cpp | 14 -------------- .../ReservoirDataModel/RigSingleWellResultsData.h | 1 - .../UserInterface/RiuResultTextBuilder.cpp | 2 +- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index ff3237d02c..9926d01b01 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -205,7 +205,7 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) RigSingleWellResultsData* wRes = m_rimWell->wellResults(); if (wRes == NULL) return; - if (frameIndex < wRes->firstResultTimeStep()) return; // Or reset colors or something + if (!wRes->hasWellResult(frameIndex)) return; // Or reset colors or something const double closed = -0.1, producing = 1.5, water = 2.5, hcInjection = 3.5; // Closed set to -0.1 instead of 0.5 to workaround bug in the scalar mapper. diff --git a/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp index 4cb37ea4e4..5e733241e8 100644 --- a/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp @@ -95,20 +95,6 @@ bool RigSingleWellResultsData::hasWellResult(size_t resultTimeStepIndex) const return wellTimeStepIndex != cvf::UNDEFINED_SIZE_T; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigSingleWellResultsData::firstResultTimeStep() const -{ - size_t i = 0; - for(i = 0; i < m_resultTimeStepIndexToWellTimeStepIndex.size(); ++i) - { - if (m_resultTimeStepIndexToWellTimeStepIndex[i] != cvf::UNDEFINED_SIZE_T) return i; - } - - return cvf::UNDEFINED_SIZE_T; -} - bool operator== (const RigWellResultPoint& p1, const RigWellResultPoint& p2) { return diff --git a/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h index b489762d45..49fa771008 100644 --- a/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h @@ -135,7 +135,6 @@ public: bool isMultiSegmentWell() const; bool hasWellResult(size_t resultTimeStepIndex) const; - size_t firstResultTimeStep() const; const RigWellResultFrame& wellResultFrame(size_t resultTimeStepIndex) const; diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index c5ca780486..91a873e4d2 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -729,7 +729,7 @@ QString RiuResultTextBuilder::wellResultText() { RigSingleWellResultsData* singleWellResultData = wellResults.at(i); - if (m_timeStepIndex < singleWellResultData->firstResultTimeStep()) + if (!singleWellResultData->hasWellResult(m_timeStepIndex)) { continue; } From f1200af1afd3555c3ba4216cffcd1cceaf61e37d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 13:01:21 +0100 Subject: [PATCH 34/43] Repaint widget in addition to clearing of slices --- .../ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp index 9cfcdc9e8f..513cfc838e 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp @@ -156,6 +156,7 @@ void RimTotalWellAllocationPlot::addSlice(const QString& name, const cvf::Color3 void RimTotalWellAllocationPlot::clearSlices() { m_wellTotalAllocationPlotWidget->clear(); + m_wellTotalAllocationPlotWidget->update(); } //-------------------------------------------------------------------------------------------------- @@ -163,7 +164,6 @@ void RimTotalWellAllocationPlot::clearSlices() //-------------------------------------------------------------------------------------------------- void RimTotalWellAllocationPlot::loadDataAndUpdate() { - updateMdiWindowVisibility(); } From 94eb76436a177eff3ebebd5e87f96b40ca8fba27 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 13:01:57 +0100 Subject: [PATCH 35/43] Fixes #1162 Well Acc plot: Handle missing well data for timesteps (crash) --- .../ProjectDataModel/Flow/RimWellAllocationPlot.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 0d35643df9..d867b44482 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -168,7 +168,7 @@ void RimWellAllocationPlot::updateFromWell() std::unique_ptr< RigAccWellFlowCalculator > wfCalculator; std::map* > tracerCellFractionValues; - if ( m_flowDiagSolution ) + if ( m_flowDiagSolution && wellResults->hasWellResult(m_timeStep)) { RimFlowDiagSolution::TracerStatusType requestedTracerType = RimFlowDiagSolution::UNDEFINED; @@ -268,7 +268,7 @@ void RimWellAllocationPlot::updateFromWell() if ( sumTracerVals != 0.0f ) { - for ( const auto& tracerVal:tracerWithValues ) + for ( const auto& tracerVal : tracerWithValues ) { cvf::Color3f color; if ( m_flowDiagSolution ) @@ -283,6 +283,7 @@ void RimWellAllocationPlot::updateFromWell() setDescription("Well Allocation (" + m_wellName + ")"); + accumulatedWellFlowPlot()->updateConnectedEditors(); } From f3a4242826262f1059039d365a7c24b67a1bbe23 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 14:16:03 +0100 Subject: [PATCH 36/43] #1162 More guarding for no data available --- .../Flow/RimWellAllocationPlot.cpp | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index d867b44482..7c2112898a 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -203,10 +203,11 @@ void RimWellAllocationPlot::updateFromWell() } else { - wfCalculator.reset(new RigAccWellFlowCalculator(pipeBranchesCLCoords, - pipeBranchesCellIds)); - - + if (pipeBranchesCLCoords.size() > 0) + { + wfCalculator.reset(new RigAccWellFlowCalculator(pipeBranchesCLCoords, + pipeBranchesCellIds)); + } } // Create tracks and curves from the calculated data @@ -251,37 +252,40 @@ void RimWellAllocationPlot::updateFromWell() /// Pie chart m_totalWellAllocationPlot->clearSlices(); - std::vector tracerNames = wfCalculator->tracerNames(); - std::vector > tracerWithValues; - for (const QString& tracerName: tracerNames) + if (wfCalculator) { - const std::vector& accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, 0); - tracerWithValues.push_back(std::make_pair(tracerName, accFlow.back())); - } + std::vector tracerNames = wfCalculator->tracerNames(); + std::vector > tracerWithValues; - float sumTracerVals = 0.0f; - for ( const auto& tracerVal:tracerWithValues) - { - sumTracerVals += tracerVal.second; - } - - if ( sumTracerVals != 0.0f ) - { - for ( const auto& tracerVal : tracerWithValues ) + for (const QString& tracerName: tracerNames) { - cvf::Color3f color; - if ( m_flowDiagSolution ) - color = m_flowDiagSolution->tracerColor(tracerVal.first); - else - color = cvf::Color3f::DARK_GRAY; + const std::vector& accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, 0); + tracerWithValues.push_back(std::make_pair(tracerName, accFlow.back())); + } - m_totalWellAllocationPlot->addSlice(tracerVal.first, color, 100*tracerVal.second/sumTracerVals); + float sumTracerVals = 0.0f; + for ( const auto& tracerVal:tracerWithValues) + { + sumTracerVals += tracerVal.second; + } + + if ( sumTracerVals != 0.0f ) + { + for ( const auto& tracerVal : tracerWithValues ) + { + cvf::Color3f color; + if ( m_flowDiagSolution ) + color = m_flowDiagSolution->tracerColor(tracerVal.first); + else + color = cvf::Color3f::DARK_GRAY; + + m_totalWellAllocationPlot->addSlice(tracerVal.first, color, 100*tracerVal.second/sumTracerVals); + } } } m_totalWellAllocationPlot->updateConnectedEditors(); - setDescription("Well Allocation (" + m_wellName + ")"); accumulatedWellFlowPlot()->updateConnectedEditors(); From 40dbf78aa978ea8caf7602f99e24a334f3682a59 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 14:17:36 +0100 Subject: [PATCH 37/43] #1165 Added title to well allocation plot --- .../Flow/RimWellAllocationPlot.cpp | 25 +++++++++- .../Flow/RimWellAllocationPlot.h | 2 + .../UserInterface/RiuWellAllocationPlot.cpp | 48 +++++++++++++++---- .../UserInterface/RiuWellAllocationPlot.h | 8 +++- 4 files changed, 72 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 7c2112898a..091016f94e 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -312,6 +312,26 @@ void RimWellAllocationPlot::addStackedCurve(const QString& tracerName, curve->loadDataAndUpdate(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellAllocationPlot::updateWidgetTitleWindowTitle() +{ + updateMdiWindowTitle(); + + if (m_wellAllocationPlotWidget) + { + if (m_showPlotTitle) + { + m_wellAllocationPlotWidget->showTitle(m_userName); + } + else + { + m_wellAllocationPlotWidget->hideTitle(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -446,7 +466,7 @@ void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedF if (changedField == &m_userName || changedField == &m_showPlotTitle) { - updateMdiWindowTitle(); + updateWidgetTitleWindowTitle(); } else if ( changedField == &m_wellName || changedField == &m_case @@ -474,7 +494,8 @@ QImage RimWellAllocationPlot::snapshotWindowContent() void RimWellAllocationPlot::setDescription(const QString& description) { m_userName = description; - this->updateMdiWindowTitle(); + + updateWidgetTitleWindowTitle(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h index f94c98c512..c9c5ce018c 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h @@ -85,6 +85,8 @@ private: const std::vector& connNumbers, const std::vector& accFlow, RimWellLogTrack* plotTrack); + + void updateWidgetTitleWindowTitle(); // RimViewWindow overrides diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index 60e0134d54..94e8696a88 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -25,27 +25,41 @@ #include "RimWellLogTrack.h" #include "RimTotalWellAllocationPlot.h" -#include "QBoxLayout" +#include +#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent) - : QFrame(parent) +RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent) + : m_plotDefinition(plotDefinition), + QFrame(parent) { - Q_ASSERT(plotDefinition); - this->setLayout(new QHBoxLayout()); + Q_ASSERT(m_plotDefinition); + + QVBoxLayout* mainLayout = new QVBoxLayout(); + this->setLayout(mainLayout); this->layout()->setMargin(0); - m_plotDefinition = plotDefinition; + m_titleLabel = new QLabel(this); + + QFont font = m_titleLabel->font(); + font.setPointSize(36); + font.setBold(true); + m_titleLabel->setFont(font); + + mainLayout->addWidget(m_titleLabel, 1, Qt::AlignCenter); + + QHBoxLayout* plotWidgetsLayout = new QHBoxLayout(); + mainLayout->addLayout(plotWidgetsLayout, 10); QWidget* totalFlowAllocationWidget = m_plotDefinition->totalWellFlowPlot()->createViewWidget(this); - this->layout()->addWidget(totalFlowAllocationWidget); + plotWidgetsLayout->addWidget(totalFlowAllocationWidget); QWidget* wellFlowWidget = m_plotDefinition->accumulatedWellFlowPlot()->createViewWidget(this); - this->layout()->addWidget(wellFlowWidget); + plotWidgetsLayout->addWidget(wellFlowWidget); } //-------------------------------------------------------------------------------------------------- @@ -67,6 +81,24 @@ RimWellAllocationPlot* RiuWellAllocationPlot::ownerPlotDefinition() return m_plotDefinition; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellAllocationPlot::showTitle(const QString& title) +{ + m_titleLabel->show(); + + m_titleLabel->setText(title); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellAllocationPlot::hideTitle() +{ + m_titleLabel->hide(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h index 9c4dd2e7c2..a466dadc77 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h @@ -23,10 +23,12 @@ #include "cafPdmPointer.h" #include - +#include class RimWellAllocationPlot; +class QLabel; + //================================================================================================== // // @@ -41,6 +43,9 @@ public: RimWellAllocationPlot* ownerPlotDefinition(); + void showTitle(const QString& title); + void hideTitle(); + protected: virtual QSize sizeHint() const override; virtual QSize minimumSizeHint() const override; @@ -50,5 +55,6 @@ private: private: caf::PdmPointer m_plotDefinition; + QPointer m_titleLabel; }; From 45dc7a1c089d20227ea537c319434d056ac95e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 2 Feb 2017 16:03:39 +0100 Subject: [PATCH 38/43] #1165 Reduced size and spacing. --- ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index 94e8696a88..611151ad09 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -42,15 +42,16 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti QVBoxLayout* mainLayout = new QVBoxLayout(); this->setLayout(mainLayout); this->layout()->setMargin(0); + this->layout()->setSpacing(0); m_titleLabel = new QLabel(this); QFont font = m_titleLabel->font(); - font.setPointSize(36); + font.setPointSize(16); font.setBold(true); m_titleLabel->setFont(font); - mainLayout->addWidget(m_titleLabel, 1, Qt::AlignCenter); + mainLayout->addWidget(m_titleLabel, 0, Qt::AlignCenter); QHBoxLayout* plotWidgetsLayout = new QHBoxLayout(); mainLayout->addLayout(plotWidgetsLayout, 10); From 6aea418084c2748573c3a75487c257e2a011684f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 2 Feb 2017 16:06:50 +0100 Subject: [PATCH 39/43] Total Well Log Allocation Pie Chart: Guarded not yet created widget --- .../Flow/RimTotalWellAllocationPlot.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp index 513cfc838e..28b5c93e82 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp @@ -143,10 +143,13 @@ QString RimTotalWellAllocationPlot::description() const //-------------------------------------------------------------------------------------------------- void RimTotalWellAllocationPlot::addSlice(const QString& name, const cvf::Color3f& color, float value) { - QColor sliceColor(color.rByte(), color.gByte(), color.bByte()); + if ( m_wellTotalAllocationPlotWidget ) + { + QColor sliceColor(color.rByte(), color.gByte(), color.bByte()); - m_wellTotalAllocationPlotWidget->addItem(name, sliceColor, value); - m_wellTotalAllocationPlotWidget->update(); + m_wellTotalAllocationPlotWidget->addItem(name, sliceColor, value); + m_wellTotalAllocationPlotWidget->update(); + } } @@ -155,8 +158,11 @@ void RimTotalWellAllocationPlot::addSlice(const QString& name, const cvf::Color3 //-------------------------------------------------------------------------------------------------- void RimTotalWellAllocationPlot::clearSlices() { - m_wellTotalAllocationPlotWidget->clear(); - m_wellTotalAllocationPlotWidget->update(); + if ( m_wellTotalAllocationPlotWidget ) + { + m_wellTotalAllocationPlotWidget->clear(); + m_wellTotalAllocationPlotWidget->update(); + } } //-------------------------------------------------------------------------------------------------- @@ -164,6 +170,7 @@ void RimTotalWellAllocationPlot::clearSlices() //-------------------------------------------------------------------------------------------------- void RimTotalWellAllocationPlot::loadDataAndUpdate() { + updateMdiWindowVisibility(); } From c613c389f3029bf89e68de69226ab009461f7d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 2 Feb 2017 16:08:37 +0100 Subject: [PATCH 40/43] #1118 When no tracer data is available, show the total well flow instead. --- .../Flow/RimWellAllocationPlot.cpp | 22 +++++++++++-------- .../ProjectDataModel/RimWellLogPlot.h | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 091016f94e..8fc067f32a 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -194,14 +194,17 @@ void RimWellAllocationPlot::updateFromWell() } } - RigEclCellIndexCalculator cellIdxCalc(m_case->reservoirData()->mainGrid(), m_case->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)); - wfCalculator.reset(new RigAccWellFlowCalculator(pipeBranchesCLCoords, - pipeBranchesCellIds, - tracerCellFractionValues, - cellIdxCalc)); - + if ( tracerCellFractionValues.size() ) + { + RigEclCellIndexCalculator cellIdxCalc(m_case->reservoirData()->mainGrid(), m_case->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)); + wfCalculator.reset(new RigAccWellFlowCalculator(pipeBranchesCLCoords, + pipeBranchesCellIds, + tracerCellFractionValues, + cellIdxCalc)); + } } - else + + if (!wfCalculator) { if (pipeBranchesCLCoords.size() > 0) { @@ -249,6 +252,8 @@ void RimWellAllocationPlot::updateFromWell() } + setDescription(m_wellName + " - Allocation"); + /// Pie chart m_totalWellAllocationPlot->clearSlices(); @@ -284,10 +289,9 @@ void RimWellAllocationPlot::updateFromWell() } } } + m_totalWellAllocationPlot->updateConnectedEditors(); - setDescription("Well Allocation (" + m_wellName + ")"); - accumulatedWellFlowPlot()->updateConnectedEditors(); } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index df7fb5881b..8c961158a1 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -74,7 +74,7 @@ public: RimWellLogTrack* trackByIndex(size_t index); - void loadDataAndUpdate(); + virtual void loadDataAndUpdate() override; void updateTracks(); void updateTrackNames(); From 01864aee094f0c41af32935bcaf3fabe89e8e958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 3 Feb 2017 08:51:43 +0100 Subject: [PATCH 41/43] Well Alloc Plot: Added case and timestep to title, Adjusted font. --- .../ProjectDataModel/Flow/RimWellAllocationPlot.cpp | 2 +- ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 8fc067f32a..aea11a7ff9 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -252,7 +252,7 @@ void RimWellAllocationPlot::updateFromWell() } - setDescription(m_wellName + " - Allocation"); + setDescription("Well Allocation: " + m_wellName +", " + m_case->timeStepStrings()[m_timeStep] + " (" + m_case->caseUserDescription() + ")"); /// Pie chart diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index 611151ad09..16c12ffb57 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -42,12 +42,12 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti QVBoxLayout* mainLayout = new QVBoxLayout(); this->setLayout(mainLayout); this->layout()->setMargin(0); - this->layout()->setSpacing(0); + this->layout()->setSpacing(2); m_titleLabel = new QLabel(this); QFont font = m_titleLabel->font(); - font.setPointSize(16); + font.setPointSize(14); font.setBold(true); m_titleLabel->setFont(font); From 8a26861c03e9d100795126491656a33711d72df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 3 Feb 2017 09:31:27 +0100 Subject: [PATCH 42/43] Version set to 2016.11.flow.8 for finalizing sprint 8 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 5ee202d1fd..28678247ac 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,7 +1,7 @@ set(RESINSIGHT_MAJOR_VERSION 2016) set(RESINSIGHT_MINOR_VERSION 11) -set(RESINSIGHT_INCREMENT_VERSION "flow.7") +set(RESINSIGHT_INCREMENT_VERSION "flow.8") # https://github.com/CRAVA/crava/tree/master/libs/nrlib From 426d42935f720c9c262bcf99b586d96e9cde8627 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 3 Feb 2017 10:23:07 +0100 Subject: [PATCH 43/43] Copy up from pre-proto --- .../RigSimulationWellCoordsAndMD.cpp | 40 +++++++++++++++++++ .../RigSimulationWellCoordsAndMD.h | 1 + 2 files changed, 41 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp index a5e116e1d9..98bbe6952c 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp @@ -18,6 +18,8 @@ #include "RigSimulationWellCoordsAndMD.h" +#include "cvfGeometryTools.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -81,6 +83,44 @@ cvf::Vec3d RigSimulationWellCoordsAndMD::interpolatedPointAlongWellPath(double m return wellPathPoint; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigSimulationWellCoordsAndMD::locationAlongWellCoords(const cvf::Vec3d& position) const +{ + double location = 0.0; + + size_t closestIndex = cvf::UNDEFINED_SIZE_T; + double closestDistance = cvf::UNDEFINED_DOUBLE; + + for (size_t i = 1; i < m_wellPathPoints.size(); i++) + { + cvf::Vec3d p1 = m_wellPathPoints[i - 1]; + cvf::Vec3d p2 = m_wellPathPoints[i - 0]; + + double candidateDistance = cvf::GeometryTools::linePointSquareDist(p1, p2, position); + if (candidateDistance < closestDistance) + { + closestDistance = candidateDistance; + closestIndex = i; + } + } + + if (closestIndex != cvf::UNDEFINED_DOUBLE) + { + cvf::Vec3d p1 = m_wellPathPoints[closestIndex - 1]; + cvf::Vec3d p2 = m_wellPathPoints[closestIndex - 0]; + + double intersection = 0.0; + cvf::GeometryTools::projectPointOnLine(p1, p2, position, &intersection); + + location = m_measuredDepths[closestIndex - 1]; + location += intersection * (p1-p2).length(); + } + + return location; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.h b/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.h index 9db9d5c861..49b93aaee9 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.h +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.h @@ -39,6 +39,7 @@ public: const std::vector& measuredDepths() const; cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth) const; + double locationAlongWellCoords(const cvf::Vec3d& position) const; private: void computeMeasuredDepths();