diff --git a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake index 5b0f6da3fe..56a32b4fd1 100644 --- a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake @@ -6,12 +6,14 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature +${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp new file mode 100644 index 0000000000..6f6870da78 --- /dev/null +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicShowContributingWellsFeature.h" + +#include "RiaApplication.h" + +#include "RimDefines.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseView.h" +#include "RimEclipseWell.h" +#include "RimEclipseWellCollection.h" +#include "RimWellAllocationPlot.h" + +#include + +CAF_CMD_SOURCE_INIT(RicShowContributingWellsFeature, "RicShowContributingWellsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowContributingWellsFeature::isCommandEnabled() +{ + RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot(); + if (!wellAllocationPlot) return false; + + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (!activeView) return false; + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowContributingWellsFeature::onActionTriggered(bool isChecked) +{ + RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot(); + if (!wellAllocationPlot) return; + + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + + if (activeView) + { + activeView->cellResult->setResultType(RimDefines::FLOW_DIAGNOSTICS); + activeView->cellResult->setResultVariable("MaxFractionTracer"); + activeView->cellResult->updateConnectedEditors(); + + const std::vector contributingTracers = wellAllocationPlot->contributingTracerNames(); + + for (RimEclipseWell* well : activeView->wellCollection()->wells()) + { + if (std::find(contributingTracers.begin(), contributingTracers.end(), well->name()) != contributingTracers.end() + || wellAllocationPlot->wellName() == well->name()) + { + well->showWell = true; + } + else + { + well->showWell = false; + } + } + + activeView->scheduleCreateDisplayModelAndRedraw(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowContributingWellsFeature::setupActionLook(QAction* actionToSetup) +{ + //actionToSetup->setIcon(QIcon(":/new_icon16x16.png")); + actionToSetup->setText("Show Contributing Wells"); +} diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.h b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.h new file mode 100644 index 0000000000..a32a043124 --- /dev/null +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.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 RicShowContributingWellsFeature : 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/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 3a9eaaf761..ce815960bf 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -221,6 +221,12 @@ void RimWellAllocationPlot::updateFromWell() } } + m_contributingTracerNames.clear(); + if (wfCalculator) + { + m_contributingTracerNames = wfCalculator->tracerNames(); + } + // Create tracks and curves from the calculated data size_t branchCount = pipeBranchesCLCoords.size(); @@ -540,6 +546,14 @@ QString RimWellAllocationPlot::wellName() const return m_wellName(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector RimWellAllocationPlot::contributingTracerNames() const +{ + return m_contributingTracerNames; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h index 31298b5f95..30f1b4a11e 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h @@ -68,6 +68,7 @@ public: QString wellName() const; + const std::vector contributingTracerNames() const; void removeFromMdiAreaAndDeleteViewWidget(); @@ -112,4 +113,5 @@ private: caf::PdmChildField m_totalWellAllocationPlot; caf::PdmChildField m_wellAllocationPlotLegend; + std::vector m_contributingTracerNames; }; diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index a1900dbbab..e632a5dff9 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -20,15 +20,20 @@ #include "RiaApplication.h" +#include "RimContextCommandBuilder.h" +#include "RimTotalWellAllocationPlot.h" #include "RimWellAllocationPlot.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" -#include "RimTotalWellAllocationPlot.h" + +#include "RiuNightchartsWidget.h" + +#include "cvfColor3.h" #include +#include #include -#include "RiuNightchartsWidget.h" -#include "cvfColor3.h" +#include @@ -157,6 +162,24 @@ QSize RiuWellAllocationPlot::minimumSizeHint() const return QSize(0, 100); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellAllocationPlot::contextMenuEvent(QContextMenuEvent* event) +{ + QMenu menu; + QStringList commandIds; + + commandIds << "RicShowContributingWellsFeature"; + + RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu); + + if (menu.actions().size() > 0) + { + menu.exec(event->globalPos()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h index 2dc1379840..6ab54ecbee 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h @@ -57,6 +57,8 @@ protected: virtual QSize sizeHint() const override; virtual QSize minimumSizeHint() const override; + virtual void contextMenuEvent(QContextMenuEvent *) override; + private: void setDefaults();