#5508 Phase Distribution Plot : Add to context menu of wells in project tree and 3D

This commit is contained in:
Magne Sjaastad 2020-02-11 11:52:22 +01:00
parent e571d2365c
commit 16d75b23a8
4 changed files with 99 additions and 9 deletions

View File

@ -18,7 +18,14 @@
#include "RicShowCumulativePhasePlotFeature.h"
#include "RiaApplication.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimFlowPlotCollection.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSimWellInView.h"
#include "RimWellAllocationPlot.h"
#include "RimWellDistributionPlotCollection.h"
@ -33,9 +40,12 @@ CAF_CMD_SOURCE_INIT( RicShowCumulativePhasePlotFeature, "RicShowCumulativePhaseP
//--------------------------------------------------------------------------------------------------
bool RicShowCumulativePhasePlotFeature::isCommandEnabled()
{
RimWellAllocationPlot* plot = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellAllocationPlot>();
auto plot = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellAllocationPlot>();
if ( plot != nullptr ) return true;
return plot != nullptr;
auto simWell = caf::SelectionManager::instance()->selectedItemOfType<RimSimWellInView>();
return simWell != nullptr;
}
//--------------------------------------------------------------------------------------------------
@ -43,19 +53,40 @@ bool RicShowCumulativePhasePlotFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicShowCumulativePhasePlotFeature::onActionTriggered( bool isChecked )
{
RimWellAllocationPlot* plot = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellAllocationPlot>();
RimEclipseResultCase* eclipseResultCase = nullptr;
int timeStep = 0;
QString wellName;
if ( !plot ) return;
{
auto plot = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellAllocationPlot>();
RimFlowPlotCollection* flowPlotColl = nullptr;
plot->firstAncestorOrThisOfType( flowPlotColl );
if ( plot )
{
eclipseResultCase = getDataFromWellAllocation( plot, wellName, timeStep );
}
}
{
auto simWell = caf::SelectionManager::instance()->selectedItemOfType<RimSimWellInView>();
if ( simWell )
{
eclipseResultCase = getDataFromSimWell( simWell, wellName, timeStep );
}
}
RimProject* proj = RiaApplication::instance()->project();
if ( !proj ) return;
RimFlowPlotCollection* flowPlotColl = proj->mainPlotCollection()->flowPlotCollection();
if ( !flowPlotColl ) return;
RimWellDistributionPlotCollection* wdp = flowPlotColl->wellDistributionPlotCollection();
wdp->setData( plot->rimCase(), plot->wellName(), plot->timeStep() );
wdp->setShowWindow( true );
wdp->loadDataAndUpdate();
if ( wdp && eclipseResultCase )
{
wdp->setData( eclipseResultCase, wellName, timeStep );
wdp->setShowWindow( true );
wdp->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
@ -66,3 +97,51 @@ void RicShowCumulativePhasePlotFeature::setupActionLook( QAction* actionToSetup
actionToSetup->setIcon( QIcon( ":/CumulativePhaseDist16x16.png" ) );
actionToSetup->setText( "Show Cumulative Phase Distribution Plot" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseResultCase* RicShowCumulativePhasePlotFeature::getDataFromSimWell( RimSimWellInView* simWell,
QString& wellName,
int& timeStepIndex )
{
RimEclipseResultCase* resultCase = nullptr;
if ( simWell )
{
wellName = simWell->name();
RimEclipseView* eclView = nullptr;
simWell->firstAncestorOfType( eclView );
if ( eclView )
{
timeStepIndex = eclView->currentTimeStep();
}
simWell->firstAncestorOfType( resultCase );
}
return resultCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseResultCase* RicShowCumulativePhasePlotFeature::getDataFromWellAllocation( RimWellAllocationPlot* wap,
QString& wellName,
int& timeStepIndex )
{
RimEclipseResultCase* resultCase = nullptr;
if ( wap )
{
wellName = wap->wellName();
timeStepIndex = wap->timeStep();
resultCase = wap->rimCase();
}
return resultCase;
}

View File

@ -20,6 +20,10 @@
#include "cafCmdFeature.h"
class RimSimWellInView;
class RimEclipseResultCase;
class RimWellAllocationPlot;
//==================================================================================================
///
//==================================================================================================
@ -32,4 +36,9 @@ protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static RimEclipseResultCase* getDataFromSimWell( RimSimWellInView* simWell, QString& wellName, int& timeStepIndex );
static RimEclipseResultCase*
getDataFromWellAllocation( RimWellAllocationPlot* wap, QString& wellName, int& timeStepIndex );
};

View File

@ -730,6 +730,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicPlotProductionRateFeature";
menuBuilder << "RicShowWellAllocationPlotFeature";
menuBuilder << "RicShowCumulativePhasePlotFeature";
menuBuilder.subMenuEnd();
menuBuilder << "RicExportCompletionsForVisibleSimWellsFeature";

View File

@ -567,6 +567,7 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
menuBuilder << "RicPlotProductionRateFeature";
menuBuilder << "RicShowWellAllocationPlotFeature";
menuBuilder << "RicShowCumulativePhasePlotFeature";
menuBuilder.subMenuEnd();