#2162 Context menu: Move hide fault slot to command feature

This commit is contained in:
Rebecca Cox 2017-11-29 11:55:29 +01:00
parent 7c9a14f78c
commit 215fdf6233
5 changed files with 142 additions and 24 deletions

View File

@ -21,7 +21,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseTimeStepFilterFeature.h
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewInViewFeature.h
${CEE_CURRENT_LIST_DIR}RicEclipseHideFaultFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseTimeStepFilterFeature.cpp
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewInViewFeature.cpp
${CEE_CURRENT_LIST_DIR}RicEclipseHideFaultFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicEclipseHideFaultFeature.h"
#include "RicEclipsePropertyFilterNewExec.h"
#include "RicEclipsePropertyFilterFeatureImpl.h"
#include "RiaApplication.h"
#include "RimEclipseCellColors.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseView.h"
#include "RimFaultInView.h"
#include "RimFaultInViewCollection.h"
#include "RimView.h"
#include "RigFault.h"
#include "RigMainGrid.h"
#include "cafCmdExecCommandManager.h"
#include "cvfStructGrid.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicEclipseHideFaultFeature, "RicEclipseHideFaultFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEclipseHideFaultFeature::isCommandEnabled()
{
RimView* view = RiaApplication::instance()->activeReservoirView();
if (!view) return false;
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(view);
if (!eclView) return false;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipseHideFaultFeature::onActionTriggered(bool isChecked)
{
QVariant userData = this->userData();
if (!userData.isNull() && userData.type() == QVariant::List)
{
RimView* view = RiaApplication::instance()->activeReservoirView();
if (!view) return;
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(view);
if (!eclView) return;
QVariantList list = userData.toList();
CAF_ASSERT(list.size() == 2);
size_t currentCellIndex = list[0].toUInt();
int currentFaceIndex = list[1].toInt();
const RigFault* fault = eclView->mainGrid()->findFaultFromCellIndexAndCellFace(currentCellIndex, cvf::StructGridInterface::FaceType(currentFaceIndex));
if (fault)
{
QString faultName = fault->name();
RimFaultInView* rimFault = eclView->faultCollection()->findFaultByName(faultName);
if (rimFault)
{
rimFault->showFault.setValueWithFieldChanged(!rimFault->showFault);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipseHideFaultFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/draw_style_faults_24x24.png"));
}

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 RicEclipseHideFaultFeature : 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

@ -257,7 +257,12 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
menu.addSeparator();
QString faultName = fault->name();
menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault()));
QVariantList hideFaultList;
hideFaultList.push_back(m_currentCellIndex);
hideFaultList.push_back(m_currentFaceIndex);
menuBuilder.addCmdFeatureWithUserData("RicEclipseHideFaultFeature", QString("Hide ") + faultName, hideFaultList);
}
}
@ -367,27 +372,6 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
RiuSelectionManager::instance()->deleteAllItems(RiuSelectionManager::RUI_TEMPORARY);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::slotHideFault()
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
if(!eclipseView) return;
const RigFault* fault = eclipseView->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
if (fault)
{
QString faultName = fault->name();
RimFaultInView* rimFault = eclipseView->faultCollection()->findFaultByName(faultName);
if (rimFault)
{
rimFault->showFault.setValueWithFieldChanged(!rimFault->showFault);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -62,7 +62,6 @@ public:
caf::PdmObject* currentPickedObject() const;
private slots:
void slotHideFault();
void slotAddGeoMechPropertyFilter();
void slotHideIntersection();