#1288 Do not show command if no flow solution is available

This commit is contained in:
Magne Sjaastad 2017-03-10 14:45:07 +01:00
parent a87ad2e56e
commit 1e1c5b0398
2 changed files with 39 additions and 14 deletions

View File

@ -20,6 +20,7 @@
#include "RicShowContributingWellsFeatureImpl.h" #include "RicShowContributingWellsFeatureImpl.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultCase.h" #include "RimEclipseResultCase.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimEclipseWell.h" #include "RimEclipseWell.h"
@ -41,8 +42,32 @@ bool RicShowContributingWellsFeature::isCommandEnabled()
{ {
std::vector<RimEclipseWell*> collection; std::vector<RimEclipseWell*> collection;
caf::SelectionManager::instance()->objectsByType(&collection); caf::SelectionManager::instance()->objectsByType(&collection);
if (collection.size() == 1)
{
RimEclipseWell* well = collection[0];
RimEclipseView* eclipseView = nullptr;
well->firstAncestorOrThisOfType(eclipseView);
if (collection.size() == 1) return true; 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; return false;
} }

View File

@ -39,7 +39,6 @@
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
#include "cafAssert.h"
#include "cafCmdFeature.h" #include "cafCmdFeature.h"
#include "cafCmdFeatureManager.h" #include "cafCmdFeatureManager.h"
#include "cafPdmUiPropertyViewDialog.h" #include "cafPdmUiPropertyViewDialog.h"
@ -47,7 +46,7 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclipseResultCase* wellAllocationResultCase, QString wellName, int timeStep) RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclipseResultCase* eclipseResultCase, QString wellName, int timeStep)
{ {
const QString lastUsedViewKey("lastUsedViewKey"); const QString lastUsedViewKey("lastUsedViewKey");
@ -60,7 +59,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
RimEclipseResultCase* lastUsedViewResultCase = nullptr; RimEclipseResultCase* lastUsedViewResultCase = nullptr;
lastUsedView->firstAncestorOrThisOfTypeAsserted(lastUsedViewResultCase); lastUsedView->firstAncestorOrThisOfTypeAsserted(lastUsedViewResultCase);
if (lastUsedViewResultCase == wellAllocationResultCase) if (lastUsedViewResultCase == eclipseResultCase)
{ {
defaultSelectedView = lastUsedView; defaultSelectedView = lastUsedView;
} }
@ -74,15 +73,15 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
RimEclipseResultCase* activeViewResultCase = nullptr; RimEclipseResultCase* activeViewResultCase = nullptr;
activeView->firstAncestorOrThisOfTypeAsserted(activeViewResultCase); activeView->firstAncestorOrThisOfTypeAsserted(activeViewResultCase);
if (activeViewResultCase == wellAllocationResultCase) if (activeViewResultCase == eclipseResultCase)
{ {
defaultSelectedView = activeView; defaultSelectedView = activeView;
} }
else 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]);
} }
} }
} }
@ -96,7 +95,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
} }
else else
{ {
featureUi.setCase(wellAllocationResultCase); featureUi.setCase(eclipseResultCase);
} }
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Show Contributing Wells in View", ""); caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Show Contributing Wells in View", "");
@ -107,12 +106,12 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
RimEclipseView* viewToManipulate = nullptr; RimEclipseView* viewToManipulate = nullptr;
if (featureUi.createNewView()) if (featureUi.createNewView())
{ {
RimEclipseView* createdView = wellAllocationResultCase->createAndAddReservoirView(); RimEclipseView* createdView = eclipseResultCase->createAndAddReservoirView();
createdView->name = featureUi.newViewName(); createdView->name = featureUi.newViewName();
// Must be run before buildViewItems, as wells are created in this function // Must be run before buildViewItems, as wells are created in this function
createdView->loadDataAndUpdate(); createdView->loadDataAndUpdate();
wellAllocationResultCase->updateConnectedEditors(); eclipseResultCase->updateConnectedEditors();
viewToManipulate = createdView; viewToManipulate = createdView;
} }
@ -121,7 +120,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
viewToManipulate = featureUi.selectedView(); viewToManipulate = featureUi.selectedView();
} }
CAF_ASSERT(viewToManipulate); CVF_ASSERT(viewToManipulate);
RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(viewToManipulate, wellName, timeStep); RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(viewToManipulate, wellName, timeStep);
@ -143,7 +142,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclips
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimEclipseView* viewToModify, const QString& wellName, int timeStep) void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimEclipseView* viewToModify, const QString& wellName, int timeStep)
{ {
CAF_ASSERT(viewToModify); CVF_ASSERT(viewToModify);
RimEclipseWell* selectedWell = nullptr; RimEclipseWell* selectedWell = nullptr;
@ -155,7 +154,7 @@ void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimE
} }
} }
CAF_ASSERT(selectedWell); CVF_ASSERT(selectedWell);
RimEclipseResultCase* eclipseResultCase = nullptr; RimEclipseResultCase* eclipseResultCase = nullptr;
selectedWell->firstAncestorOrThisOfTypeAsserted(eclipseResultCase); selectedWell->firstAncestorOrThisOfTypeAsserted(eclipseResultCase);
@ -167,7 +166,8 @@ void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimE
flowDiagSolution = eclipseResultCase->defaultFlowDiagSolution(); flowDiagSolution = eclipseResultCase->defaultFlowDiagSolution();
} }
CAF_ASSERT(flowDiagSolution); //assert(flowDiagSolution);
CVF_ASSERT(flowDiagSolution);
RimFlowDiagSolution::TracerStatusType tracerStatus = flowDiagSolution->tracerStatusInTimeStep(selectedWell->name(), timeStep); RimFlowDiagSolution::TracerStatusType tracerStatus = flowDiagSolution->tracerStatusInTimeStep(selectedWell->name(), timeStep);
if (!(tracerStatus == RimFlowDiagSolution::INJECTOR || tracerStatus == RimFlowDiagSolution::PRODUCER)) if (!(tracerStatus == RimFlowDiagSolution::INJECTOR || tracerStatus == RimFlowDiagSolution::PRODUCER))