#5042 Add "Export Property To File" command to eclipse view.

This commit is contained in:
Kristian Bendiksen
2019-11-19 22:23:03 +01:00
parent c042aec22a
commit 5e480bf438
3 changed files with 52 additions and 6 deletions

View File

@@ -21,8 +21,8 @@
#include "RicSaveEclipseResultAsInputPropertyExec.h"
#include "Rim3dView.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h"
@@ -35,11 +35,40 @@ CAF_CMD_SOURCE_INIT( RicSaveEclipseResultAsInputPropertyFeature, "RicSaveEclipse
///
//--------------------------------------------------------------------------------------------------
bool RicSaveEclipseResultAsInputPropertyFeature::isCommandEnabled()
{
return selectedEclipseCellColors() != nullptr || selectedEclipseView() != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseView* RicSaveEclipseResultAsInputPropertyFeature::selectedEclipseView() const
{
std::vector<RimEclipseView*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );
if ( selection.size() > 0 )
{
return selection[0];
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCellColors* RicSaveEclipseResultAsInputPropertyFeature::selectedEclipseCellColors() const
{
std::vector<RimEclipseCellColors*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );
return selection.size() == 1;
if ( selection.size() > 0 )
{
return selection[0];
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -49,12 +78,21 @@ void RicSaveEclipseResultAsInputPropertyFeature::onActionTriggered( bool isCheck
{
this->disableModelChangeContribution();
std::vector<RimEclipseCellColors*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );
if ( selection.size() == 1 )
RimEclipseCellColors* eclipseCellColors = selectedEclipseCellColors();
if ( !eclipseCellColors )
{
// Get the cell colors from the eclipse view if possible.
RimEclipseView* eclipseView = selectedEclipseView();
if ( eclipseView )
{
eclipseCellColors = eclipseView->cellResult();
}
}
if ( eclipseCellColors )
{
RicSaveEclipseResultAsInputPropertyExec* cellResultSaveExec = new RicSaveEclipseResultAsInputPropertyExec(
selection[0] );
eclipseCellColors );
caf::CmdExecCommandManager::instance()->processExecuteCommand( cellResultSaveExec );
}
}

View File

@@ -21,6 +21,9 @@
#include "cafCmdFeature.h"
class RimEclipseView;
class RimEclipseCellColors;
//==================================================================================================
///
//==================================================================================================
@@ -33,4 +36,8 @@ protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
RimEclipseView* selectedEclipseView() const;
RimEclipseCellColors* selectedEclipseCellColors() const;
};

View File

@@ -190,6 +190,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicCopyReferencesToClipboardFeature";
menuBuilder << "RicExportEclipseInputGridFeature";
menuBuilder << "RicSaveEclipseResultAsInputPropertyFeature";
menuBuilder << "RicExportContourMapToTextFeature";
menuBuilder << "RicSaveEclipseInputVisibleCellsFeature";
}