#2162 Context menu: Move new property filter slot to command feature

This commit is contained in:
Rebecca Cox
2017-11-29 11:06:46 +01:00
parent 48b165e2aa
commit c0615134a9
5 changed files with 124 additions and 33 deletions

View File

@@ -20,6 +20,8 @@ ${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseTimeStepFilterFeature.h
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewInViewFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -38,6 +40,7 @@ ${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseTimeStepFilterFeature.cpp
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewInViewFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicEclipsePropertyFilterNewInViewFeature.h"
#include "RicEclipsePropertyFilterNewExec.h"
#include "RicEclipsePropertyFilterFeatureImpl.h"
#include "RiaApplication.h"
#include "RimEclipseCellColors.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseView.h"
#include "RimView.h"
#include "cafCmdExecCommandManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicEclipsePropertyFilterNewInViewFeature, "RicEclipsePropertyFilterNewInViewFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEclipsePropertyFilterNewInViewFeature::isCommandEnabled()
{
RimView* view = RiaApplication::instance()->activeReservoirView();
if (!view) return false;
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(view);
if (!eclView) return false;
RimEclipseCellColors* cellColors = eclView->cellResult().p();
if (!cellColors) return false;
if (RiaDefines::isPerCellFaceResult(cellColors->resultVariable())) return false;
RimEclipsePropertyFilterCollection* filterCollection = eclView->eclipsePropertyFilterCollection();
if (filterCollection)
{
return RicEclipsePropertyFilterFeatureImpl::isPropertyFilterCommandAvailable(filterCollection);
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterNewInViewFeature::onActionTriggered(bool isChecked)
{
RimView* view = RiaApplication::instance()->activeReservoirView();
if (!view) return;
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(view);
if (!eclView) return;
RicEclipsePropertyFilterNewExec* filterExec = new RicEclipsePropertyFilterNewExec(eclView->eclipsePropertyFilterCollection());
caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterNewInViewFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/CellFilter_Values.png"));
actionToSetup->setText("New Property Filter");
}

View File

@@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RicEclipsePropertyFilterNewInViewFeature : 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

@@ -245,28 +245,11 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
menu.addSeparator();
menuBuilder << "RicEclipsePropertyFilterNewInViewFeature";
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
if (eclipseView)
{
RimEclipseCellColors* cellColors = eclipseView->cellResult().p();
if (cellColors)
{
QAction* propertyAction = new QAction(QIcon(":/CellFilter_Values.png"), QString("Add Property Filter"), this);
connect(propertyAction, SIGNAL(triggered()), SLOT(slotAddEclipsePropertyFilter()));
bool isPerCellFaceResult = RiaDefines::isPerCellFaceResult(cellColors->resultVariable());
if (isPerCellFaceResult)
{
propertyAction->setEnabled(false);
}
if (!viewController || !viewController->isPropertyFilterOveridden())
{
menu.addAction(propertyAction);
}
}
// Hide faults command
const RigFault* fault = eclipseView->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
if (fault)
@@ -405,20 +388,6 @@ void RiuViewerCommands::slotHideFault()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::slotAddEclipsePropertyFilter()
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
if (eclipseView)
{
RimEclipsePropertyFilterCollection* filterCollection = eclipseView->eclipsePropertyFilterCollection();
RicEclipsePropertyFilterNewExec* propCmdExe = new RicEclipsePropertyFilterNewExec(filterCollection);
caf::CmdExecCommandManager::instance()->processExecuteCommand(propCmdExe);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -63,7 +63,6 @@ public:
private slots:
void slotHideFault();
void slotAddEclipsePropertyFilter();
void slotAddGeoMechPropertyFilter();
void slotHideIntersection();