Temporary LGR : Hide context menu items, remove invalid assert

This commit is contained in:
Magne Sjaastad 2018-11-09 08:13:39 +01:00
parent c334106e9c
commit fb18e9b170
2 changed files with 40 additions and 23 deletions

View File

@ -26,11 +26,11 @@
#include "RiuPlotMainWindow.h" #include "RiuPlotMainWindow.h"
#include "RimGridCollection.h"
#include "RimWellPath.h"
#include "RimProject.h"
#include "RimWellPathCollection.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimGridCollection.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "cafSelectionManagerTools.h" #include "cafSelectionManagerTools.h"
@ -43,6 +43,11 @@ CAF_CMD_SOURCE_INIT(RicExportCompletionsForTemporaryLgrsFeature, "RicExportCompl
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicExportCompletionsForTemporaryLgrsFeature::isCommandEnabled() bool RicExportCompletionsForTemporaryLgrsFeature::isCommandEnabled()
{ {
if (wellPathsAssociatedWithLgrs().empty())
{
return false;
}
std::vector<RimGridInfoCollection*> selGridInfos = caf::selectedObjectsByTypeStrict<RimGridInfoCollection*>(); std::vector<RimGridInfoCollection*> selGridInfos = caf::selectedObjectsByTypeStrict<RimGridInfoCollection*>();
return selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::temporaryGridUiName(); return selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::temporaryGridUiName();
} }
@ -53,7 +58,10 @@ bool RicExportCompletionsForTemporaryLgrsFeature::isCommandEnabled()
void RicExportCompletionsForTemporaryLgrsFeature::onActionTriggered(bool isChecked) void RicExportCompletionsForTemporaryLgrsFeature::onActionTriggered(bool isChecked)
{ {
std::vector<RimWellPath*> wellPaths = wellPathsAssociatedWithLgrs(); std::vector<RimWellPath*> wellPaths = wellPathsAssociatedWithLgrs();
CVF_ASSERT(wellPaths.size() > 0); if (wellPaths.empty())
{
return;
}
std::vector<RimSimWellInView*> simWells; std::vector<RimSimWellInView*> simWells;
QString dialogTitle = "Export Completion Data for Temporary LGRs"; QString dialogTitle = "Export Completion Data for Temporary LGRs";
@ -77,6 +85,8 @@ std::vector<RimWellPath*> RicExportCompletionsForTemporaryLgrsFeature::wellPaths
std::vector<RimWellPath*> wellPaths; std::vector<RimWellPath*> wellPaths;
auto selectedEclipseCase = caf::firstAncestorOfTypeFromSelectedObject<RimEclipseCase*>(); auto selectedEclipseCase = caf::firstAncestorOfTypeFromSelectedObject<RimEclipseCase*>();
if (selectedEclipseCase)
{
auto mainGrid = selectedEclipseCase->mainGrid(); auto mainGrid = selectedEclipseCase->mainGrid();
std::set<QString> wellPathNames; std::set<QString> wellPathNames;
@ -100,5 +110,7 @@ std::vector<RimWellPath*> RicExportCompletionsForTemporaryLgrsFeature::wellPaths
wellPaths.push_back(wellPath); wellPaths.push_back(wellPath);
} }
} }
}
return wellPaths; return wellPaths;
} }

View File

@ -47,7 +47,12 @@ void RicDeleteTemporaryLgrsFeature::deleteAllTemporaryLgrs(RimEclipseCase* eclip
bool RicDeleteTemporaryLgrsFeature::isCommandEnabled() bool RicDeleteTemporaryLgrsFeature::isCommandEnabled()
{ {
std::vector<RimGridInfoCollection*> selGridInfos = caf::selectedObjectsByTypeStrict<RimGridInfoCollection*>(); std::vector<RimGridInfoCollection*> selGridInfos = caf::selectedObjectsByTypeStrict<RimGridInfoCollection*>();
return selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::temporaryGridUiName(); if (selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::temporaryGridUiName())
{
return !selGridInfos[0]->gridInfos().empty();
}
return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------