#1183 Property Filter: Context command : Apply As Cell Result - Eclipse

This commit is contained in:
Magne Sjaastad 2017-02-21 15:25:36 +01:00
parent 0b806c7664
commit 738e44ed46
4 changed files with 117 additions and 0 deletions

View File

@ -23,6 +23,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -44,6 +45,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicApplyPropertyFilterAsCellResultFeature.h"
#include "RimEclipseCellColors.h"
#include "RimEclipsePropertyFilter.h"
#include "RimEclipseView.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicApplyPropertyFilterAsCellResultFeature, "RicApplyPropertyFilterAsCellResultFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicApplyPropertyFilterAsCellResultFeature::isCommandEnabled()
{
std::vector<RimEclipsePropertyFilter*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
if (objects.size() == 1)
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicApplyPropertyFilterAsCellResultFeature::onActionTriggered(bool isChecked)
{
std::vector<RimEclipsePropertyFilter*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
if (objects.size() == 1)
{
RimEclipsePropertyFilter* propertyFilter = objects[0];
if (!propertyFilter) return;
RimEclipseView* rimEclipseView = nullptr;
propertyFilter->firstAncestorOrThisOfType(rimEclipseView);
if (!rimEclipseView) return;
rimEclipseView->cellResult()->simpleCopy(propertyFilter->resultDefinition());
rimEclipseView->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicApplyPropertyFilterAsCellResultFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Apply As Cell Result");
actionToSetup->setIcon(QIcon(":/CellResult.png"));
}

View File

@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicApplyPropertyFilterAsCellResultFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};

View File

@ -189,6 +189,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
else if (dynamic_cast<RimEclipsePropertyFilter*>(uiItem))
{
commandIds << "RicEclipsePropertyFilterInsertFeature";
commandIds << "RicApplyPropertyFilterAsCellResultFeature";
}
else if (dynamic_cast<RimGeoMechPropertyFilterCollection*>(uiItem))
{