diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp index 6332124856..1ad9176a8f 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp @@ -41,6 +41,8 @@ #include #include +#include "RimEclipseWell.h" +#include "RiuSelectionManager.h" CAF_CMD_SOURCE_INIT(RicNewWellLogCurveExtractionFeature, "RicNewWellLogCurveExtractionFeature"); @@ -51,8 +53,8 @@ CAF_CMD_SOURCE_INIT(RicNewWellLogCurveExtractionFeature, "RicNewWellLogCurveExtr bool RicNewWellLogCurveExtractionFeature::isCommandEnabled() { if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return false; - - return (selectedWellLogPlotTrack() != NULL || selectedWellPath() != NULL) && caseAvailable(); + int branchIndex; + return (selectedWellLogPlotTrack() != nullptr || selectedWellPath() != nullptr || selectedSimulationWell(&branchIndex) != nullptr) && caseAvailable(); } //-------------------------------------------------------------------------------------------------- @@ -65,15 +67,17 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered(bool isChecked) RimWellLogTrack* wellLogPlotTrack = selectedWellLogPlotTrack(); if (wellLogPlotTrack) { - addCurve(wellLogPlotTrack, NULL, NULL); + addCurve(wellLogPlotTrack, NULL, NULL, nullptr, -1); } else { RimWellPath* wellPath = selectedWellPath(); - if (wellPath) + int branchIndex = -1; + RimEclipseWell* simWell = selectedSimulationWell(&branchIndex); + if (wellPath || simWell) { RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); - RimWellLogExtractionCurve* plotCurve = addCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath); + RimWellLogExtractionCurve* plotCurve = addCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath, simWell, branchIndex); plotCurve->loadDataAndUpdate(); @@ -118,6 +122,27 @@ RimWellPath* RicNewWellLogCurveExtractionFeature::selectedWellPath() const return selection.size() > 0 ? selection[0] : NULL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseWell* RicNewWellLogCurveExtractionFeature::selectedSimulationWell(int * branchIndex) const +{ + RiuSelectionItem* selItem = RiuSelectionManager::instance()->selectedItem(RiuSelectionManager::RUI_TEMPORARY); + RiuSimWellSelectionItem* simWellSelItem = dynamic_cast(selItem); + if (simWellSelItem) + { + (*branchIndex) = static_cast(simWellSelItem->m_branchIndex); + return simWellSelItem->m_simWell; + } + else + { + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); + (*branchIndex) = 0; + return selection.size() > 0 ? selection[0] : NULL; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -132,14 +157,16 @@ bool RicNewWellLogCurveExtractionFeature::caseAvailable() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath) +RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimEclipseWell* simWell, int branchIndex) { CVF_ASSERT(plotTrack); RimWellLogExtractionCurve* curve = new RimWellLogExtractionCurve(); cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plotTrack->curveCount()); curve->setColor(curveColor); - curve->setWellPath(wellPath); + if (wellPath) curve->setWellPath(wellPath); + if (simWell) curve->setFromSimulationWellName(simWell->name(), branchIndex); + curve->setPropertiesFromView(view); plotTrack->addCurve(curve); diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.h b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.h index 97d33a9b70..223d3ba079 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.h +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.h @@ -21,10 +21,11 @@ #include "cafCmdFeature.h" +class RimEclipseWell; +class RimView; class RimWellLogExtractionCurve; class RimWellLogTrack; class RimWellPath; -class RimView; //================================================================================================== /// @@ -34,7 +35,7 @@ class RicNewWellLogCurveExtractionFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static RimWellLogExtractionCurve* addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath); + static RimWellLogExtractionCurve* addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimEclipseWell* simWell, int branchIndex); protected: @@ -46,5 +47,6 @@ protected: private: RimWellLogTrack* selectedWellLogPlotTrack() const; RimWellPath* selectedWellPath() const; + RimEclipseWell* selectedSimulationWell(int * branchIndex) const; bool caseAvailable() const; }; diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp index a743d82381..55cef779f9 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp @@ -51,7 +51,7 @@ bool RicNewWellLogPlotFeature::isCommandEnabled() void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked) { RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); - RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL); + RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL, nullptr, -1); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp index 47bf135c86..a487cf97de 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp @@ -57,7 +57,7 @@ void RicNewWellLogPlotTrackFeature::onActionTriggered(bool isChecked) plotTrack->setDescription(QString("Track %1").arg(wellLogPlot->trackCount())); wellLogPlot->updateConnectedEditors(); - RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL); + RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL, nullptr, -1); } } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 55c0ad4896..ab09094d4c 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -59,6 +59,7 @@ #include "cafUtils.h" #include +#include "RimEclipseWell.h" //================================================================================================== /// @@ -147,6 +148,18 @@ RimWellPath* RimWellLogExtractionCurve::wellPath() const return m_wellPath; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogExtractionCurve::setFromSimulationWellName(const QString& simWellName, int branchIndex) +{ + m_trajectoryType = SIMULATION_WELL; + m_simWellName = simWellName; + m_branchIndex = branchIndex; + + clearGeneratedSimWellPaths(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -675,8 +688,10 @@ QString RimWellLogExtractionCurve::createCurveAutoName() if (m_addWellNameToCurveName ) { generatedCurveName += wellName(); - - // Todo: Branch + if (m_trajectoryType == SIMULATION_WELL && m_generatedSimulationWellPathBranches.size() > 1) + { + generatedCurveName += " Br" + QString::number(m_branchIndex + 1); + } } if (m_addCaseNameToCurveName && m_case()) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h index f314989fc4..0c05ad8545 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h @@ -48,6 +48,8 @@ public: void setWellPath(RimWellPath* wellPath); RimWellPath* wellPath() const; + void setFromSimulationWellName(const QString& simWellName, int branchIndex); + void setCase(RimCase* rimCase); RimCase* rimCase() const; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 39c48f0a22..f6dc88ae91 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -294,8 +294,9 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) { caf::SelectionManager::instance()->setSelectedItem(wellPath); - commandIds << "RicNewWellLogFileCurveFeature"; commandIds << "RicNewWellLogCurveExtractionFeature"; + commandIds << "RicNewWellLogFileCurveFeature"; + commandIds << "Separator"; commandIds << "RicNewWellPathIntersectionFeature"; } } @@ -308,10 +309,16 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) { caf::SelectionManager::instance()->setSelectedItem(well); - commandIds << "RicNewSimWellIntersectionFeature"; + commandIds << "RicNewWellLogCurveExtractionFeature"; commandIds << "RicShowWellAllocationPlotFeature"; - commandIds << "RicShowContributingWellsFeature"; commandIds << "RicPlotProductionRateFeature"; + commandIds << "Separator"; + commandIds << "RicShowContributingWellsFeature"; + commandIds << "Separator"; + commandIds << "RicNewSimWellIntersectionFeature"; + + RiuSelectionItem* selItem = new RiuSimWellSelectionItem(eclipseWellSourceInfo->well(), m_currentPickPositionInDomainCoords, eclipseWellSourceInfo->branchIndex()); + RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); } } @@ -333,7 +340,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu); - if (menu.actions().size() > 0) + if (!menu.isEmpty()) { menu.exec(event->globalPos()); }