Skip to content

Commit

Permalink
#1288 Do not show command if no flow solution is available
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Mar 10, 2017
1 parent a87ad2e commit 1e1c5b0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "RicShowContributingWellsFeatureImpl.h"

#include "RimEclipseCellColors.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimEclipseWell.h"
Expand All @@ -41,8 +42,32 @@ bool RicShowContributingWellsFeature::isCommandEnabled()
{
std::vector<RimEclipseWell*> collection;
caf::SelectionManager::instance()->objectsByType(&collection);

if (collection.size() == 1) return true;
if (collection.size() == 1)
{
RimEclipseWell* well = collection[0];
RimEclipseView* eclipseView = nullptr;
well->firstAncestorOrThisOfType(eclipseView);

if (eclipseView)
{
RimFlowDiagSolution* flowDiagSolution = eclipseView->cellResult()->flowDiagSolution();
if (!flowDiagSolution)
{
RimEclipseResultCase* eclipseResultCase = nullptr;
well->firstAncestorOrThisOfTypeAsserted(eclipseResultCase);

if (eclipseResultCase)
{
flowDiagSolution = eclipseResultCase->defaultFlowDiagSolution();
}
}

if (flowDiagSolution)
{
return true;
}
}
}

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@

#include "RiuMainWindow.h"

#include "cafAssert.h"
#include "cafCmdFeature.h"
#include "cafCmdFeatureManager.h"
#include "cafPdmUiPropertyViewDialog.h"

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclipseResultCase* wellAllocationResultCase, QString wellName, int timeStep)
RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclipseResultCase* eclipseResultCase, QString wellName, int timeStep)
{
const QString lastUsedViewKey("lastUsedViewKey");

Expand All @@ -60,7 +59,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
RimEclipseResultCase* lastUsedViewResultCase = nullptr;
lastUsedView->firstAncestorOrThisOfTypeAsserted(lastUsedViewResultCase);

if (lastUsedViewResultCase == wellAllocationResultCase)
if (lastUsedViewResultCase == eclipseResultCase)
{
defaultSelectedView = lastUsedView;
}
Expand All @@ -74,15 +73,15 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
RimEclipseResultCase* activeViewResultCase = nullptr;
activeView->firstAncestorOrThisOfTypeAsserted(activeViewResultCase);

if (activeViewResultCase == wellAllocationResultCase)
if (activeViewResultCase == eclipseResultCase)
{
defaultSelectedView = activeView;
}
else
{
if (wellAllocationResultCase->views().size() > 0)
if (eclipseResultCase->views().size() > 0)
{
defaultSelectedView = dynamic_cast<RimEclipseView*>(wellAllocationResultCase->views()[0]);
defaultSelectedView = dynamic_cast<RimEclipseView*>(eclipseResultCase->views()[0]);
}
}
}
Expand All @@ -96,7 +95,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
}
else
{
featureUi.setCase(wellAllocationResultCase);
featureUi.setCase(eclipseResultCase);
}

caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Show Contributing Wells in View", "");
Expand All @@ -107,12 +106,12 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
RimEclipseView* viewToManipulate = nullptr;
if (featureUi.createNewView())
{
RimEclipseView* createdView = wellAllocationResultCase->createAndAddReservoirView();
RimEclipseView* createdView = eclipseResultCase->createAndAddReservoirView();
createdView->name = featureUi.newViewName();

// Must be run before buildViewItems, as wells are created in this function
createdView->loadDataAndUpdate();
wellAllocationResultCase->updateConnectedEditors();
eclipseResultCase->updateConnectedEditors();

viewToManipulate = createdView;
}
Expand All @@ -121,7 +120,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
viewToManipulate = featureUi.selectedView();
}

CAF_ASSERT(viewToManipulate);
CVF_ASSERT(viewToManipulate);


RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(viewToManipulate, wellName, timeStep);
Expand All @@ -143,7 +142,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
//--------------------------------------------------------------------------------------------------
void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimEclipseView* viewToModify, const QString& wellName, int timeStep)
{
CAF_ASSERT(viewToModify);
CVF_ASSERT(viewToModify);

RimEclipseWell* selectedWell = nullptr;

Expand All @@ -155,7 +154,7 @@ void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimE
}
}

CAF_ASSERT(selectedWell);
CVF_ASSERT(selectedWell);

RimEclipseResultCase* eclipseResultCase = nullptr;
selectedWell->firstAncestorOrThisOfTypeAsserted(eclipseResultCase);
Expand All @@ -167,7 +166,8 @@ void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimE
flowDiagSolution = eclipseResultCase->defaultFlowDiagSolution();
}

CAF_ASSERT(flowDiagSolution);
//assert(flowDiagSolution);
CVF_ASSERT(flowDiagSolution);

RimFlowDiagSolution::TracerStatusType tracerStatus = flowDiagSolution->tracerStatusInTimeStep(selectedWell->name(), timeStep);
if (!(tracerStatus == RimFlowDiagSolution::INJECTOR || tracerStatus == RimFlowDiagSolution::PRODUCER))
Expand Down

0 comments on commit 1e1c5b0

Please sign in to comment.