mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5042 Add "Export Property To File" command to eclipse view.
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -190,6 +190,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicCopyReferencesToClipboardFeature";
|
||||
menuBuilder << "RicExportEclipseInputGridFeature";
|
||||
menuBuilder << "RicSaveEclipseResultAsInputPropertyFeature";
|
||||
menuBuilder << "RicExportContourMapToTextFeature";
|
||||
menuBuilder << "RicSaveEclipseInputVisibleCellsFeature";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user