#5068 Add "Input Property" command to menu of Cell Result and 3D view.

This commit is contained in:
Kristian Bendiksen 2020-02-05 12:57:20 +01:00 committed by Magne Sjaastad
parent 860e6641e5
commit 5dc883f1ca
3 changed files with 48 additions and 8 deletions

View File

@ -19,9 +19,11 @@
#include "RicAddEclipseInputPropertyFeature.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseInputCase.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RiaApplication.h"
#include "Riu3DMainWindowTools.h"
@ -41,7 +43,9 @@ CAF_CMD_SOURCE_INIT( RicAddEclipseInputPropertyFeature, "RicAddEclipseInputPrope
bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
{
return caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputCase>() ||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseResultCase>();
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseResultCase>() ||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCellColors>() ||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
}
//--------------------------------------------------------------------------------------------------
@ -49,8 +53,11 @@ bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
{
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>();
if ( !eclipseCase ) return;
RimEclipseCase* eclipseCase = getEclipseCase();
if ( !eclipseCase )
{
return;
}
RimEclipseInputPropertyCollection* inputPropertyCollection = eclipseCase->inputPropertyCollection();
if ( !inputPropertyCollection ) return;
@ -83,3 +90,37 @@ void RicAddEclipseInputPropertyFeature::setupActionLook( QAction* actionToSetup
actionToSetup->setText( "Add Input Property" );
actionToSetup->setIcon( QIcon( ":/EclipseInput48x48.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RicAddEclipseInputPropertyFeature::getEclipseCase() const
{
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>();
if ( eclipseCase )
{
return eclipseCase;
}
RimEclipseCellColors* cellColors = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCellColors>();
if ( cellColors )
{
cellColors->firstAncestorOrThisOfType( eclipseCase );
if ( eclipseCase )
{
return eclipseCase;
}
}
RimEclipseView* eclipseView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
if ( eclipseView )
{
eclipseView->firstAncestorOrThisOfType( eclipseCase );
if ( eclipseCase )
{
return eclipseCase;
}
}
return nullptr;
}

View File

@ -21,8 +21,7 @@
#include "cafCmdFeature.h"
class RimEclipseInputPropertyCollection;
class QStringList;
class RimEclipseCase;
//==================================================================================================
///
@ -38,7 +37,5 @@ protected:
void setupActionLook( QAction* actionToSetup ) override;
private:
RimEclipseInputPropertyCollection* selectedInputPropertyCollection() const;
static void addEclipseInputProperty( const QStringList& fileNames,
RimEclipseInputPropertyCollection* inputPropertyCollection );
RimEclipseCase* getEclipseCase() const;
};

View File

@ -207,6 +207,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicSaveEclipseResultAsInputPropertyFeature";
menuBuilder << "RicExportContourMapToTextFeature";
menuBuilder << "RicSaveEclipseInputVisibleCellsFeature";
menuBuilder << "RicAddEclipseInputPropertyFeature";
}
else if ( dynamic_cast<RimEclipseContourMapViewCollection*>( firstUiItem ) )
{
@ -269,6 +270,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicExportEclipseInputGridFeature";
menuBuilder << "RicSaveEclipseInputVisibleCellsFeature";
menuBuilder << "RicCreateGridCrossPlotFeature";
menuBuilder << "RicAddEclipseInputPropertyFeature";
}
else if ( dynamic_cast<RimEclipseInputProperty*>( firstUiItem ) )
{