2017-11-29 04:55:29 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-11-29 04:55:29 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-11-29 04:55:29 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-11-29 04:55:29 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicEclipseHideFaultFeature.h"
|
|
|
|
|
|
|
|
#include "RicEclipsePropertyFilterFeatureImpl.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RicEclipsePropertyFilterNewExec.h"
|
2017-11-29 04:55:29 -06:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "Rim3dView.h"
|
2017-11-29 04:55:29 -06:00
|
|
|
#include "RimEclipseCellColors.h"
|
|
|
|
#include "RimEclipsePropertyFilterCollection.h"
|
|
|
|
#include "RimEclipseView.h"
|
|
|
|
#include "RimFaultInView.h"
|
|
|
|
#include "RimFaultInViewCollection.h"
|
|
|
|
|
|
|
|
#include "RigFault.h"
|
|
|
|
#include "RigMainGrid.h"
|
|
|
|
|
|
|
|
#include "cafCmdExecCommandManager.h"
|
|
|
|
#include "cvfStructGrid.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicEclipseHideFaultFeature, "RicEclipseHideFaultFeature" );
|
2017-11-29 04:55:29 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-29 04:55:29 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicEclipseHideFaultFeature::isCommandEnabled()
|
|
|
|
{
|
2018-01-09 03:11:28 -06:00
|
|
|
Rim3dView* view = RiaApplication::instance()->activeReservoirView();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !view ) return false;
|
|
|
|
|
|
|
|
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>( view );
|
|
|
|
if ( !eclView ) return false;
|
2017-11-29 04:55:29 -06:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-29 04:55:29 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicEclipseHideFaultFeature::onActionTriggered( bool isChecked )
|
2017-11-29 04:55:29 -06:00
|
|
|
{
|
|
|
|
QVariant userData = this->userData();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !userData.isNull() && userData.type() == QVariant::List )
|
2017-11-29 04:55:29 -06:00
|
|
|
{
|
2019-10-18 08:49:10 -05:00
|
|
|
Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !view ) return;
|
|
|
|
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>( view );
|
|
|
|
if ( !eclView ) return;
|
2017-11-29 04:55:29 -06:00
|
|
|
|
|
|
|
QVariantList list = userData.toList();
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_ASSERT( list.size() == 2 );
|
2017-11-29 04:55:29 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
size_t currentCellIndex = static_cast<size_t>( list[0].toULongLong() );
|
|
|
|
int currentFaceIndex = list[1].toInt();
|
2017-11-29 04:55:29 -06:00
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
const RigFault* fault =
|
|
|
|
eclView->mainGrid()->findFaultFromCellIndexAndCellFace( currentCellIndex,
|
|
|
|
cvf::StructGridInterface::FaceType( currentFaceIndex ) );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fault )
|
2017-11-29 04:55:29 -06:00
|
|
|
{
|
|
|
|
QString faultName = fault->name();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RimFaultInView* rimFault = eclView->faultCollection()->findFaultByName( faultName );
|
|
|
|
if ( rimFault )
|
2017-11-29 04:55:29 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
rimFault->showFault.setValueWithFieldChanged( !rimFault->showFault );
|
2017-11-29 04:55:29 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-29 04:55:29 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicEclipseHideFaultFeature::setupActionLook( QAction* actionToSetup )
|
2017-11-29 04:55:29 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/draw_style_faults_24x24.png" ) );
|
2017-11-29 04:55:29 -06:00
|
|
|
}
|