Skip to content

Commit

Permalink
Add command to create linked property filter
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Dec 17, 2024
1 parent ef9c3d1 commit 6d3ed7b
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseEnsemblesFromFilesFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicAddLinkedEclipsePropertyFilterFeature.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand All @@ -48,6 +49,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseEnsemblesFromFilesFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAddLinkedEclipsePropertyFilterFeature.cpp
)

list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- Equinor 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 "RicAddLinkedEclipsePropertyFilterFeature.h"

#include "RicEclipsePropertyFilterFeatureImpl.h"

#include "RimEclipsePropertyFilter.h"
#include "RimEclipsePropertyFilterCollection.h"

#include "Riu3DMainWindowTools.h"

#include <QAction>

CAF_CMD_SOURCE_INIT( RicAddLinkedEclipsePropertyFilterFeature, "RicAddLinkedEclipsePropertyFilterFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAddLinkedEclipsePropertyFilterFeature::isCommandEnabled() const
{
auto filterCollections = RicEclipsePropertyFilterFeatureImpl::selectedPropertyFilterCollections();
if ( filterCollections.size() == 1 )
{
return RicEclipsePropertyFilterFeatureImpl::isPropertyFilterCommandAvailable( filterCollections[0] );
}

return false;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAddLinkedEclipsePropertyFilterFeature::onActionTriggered( bool isChecked )
{
auto filterCollections = RicEclipsePropertyFilterFeatureImpl::selectedPropertyFilterCollections();

if ( filterCollections.size() == 1 )
{
auto coll = filterCollections[0];
auto filter = coll->addFilterLinkedToCellResult();
coll->updateAllRequiredEditors();

Riu3DMainWindowTools::setExpanded( filter );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAddLinkedEclipsePropertyFilterFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/CellFilter_Values.png" ) );
actionToSetup->setText( "Add Property Filter Linked to Cell Result" );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- Equinor 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 RicAddLinkedEclipsePropertyFilterFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include "RiuMainWindow.h"

#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiSliderEditor.h"
#include "cafPdmUiTreeAttributes.h"
Expand All @@ -66,6 +67,7 @@ RimEclipsePropertyFilter::RimEclipsePropertyFilter()
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );

CAF_PDM_InitFieldNoDefault( &m_linkedWithCellResult, "LinkedWithCellResult", "Linked With Cell Result" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_linkedWithCellResult );

CAF_PDM_InitField( &m_rangeLabelText, "Dummy_keyword", QString( "Range Type" ), "Range Type" );
m_rangeLabelText.xmlCapability()->disableIO();
Expand Down Expand Up @@ -225,9 +227,15 @@ void RimEclipsePropertyFilter::defineUiOrdering( QString uiConfigName, caf::PdmU
// Fields declared in RimCellFilter
uiOrdering.add( &m_name );

uiOrdering.add( &m_linkedWithCellResult );
if ( m_linkedWithCellResult )
{
uiOrdering.skipRemainingFields( true );
return;
}

// Fields declared in Rimm_resultDefinition
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" );
group1->add( &m_linkedWithCellResult );

if ( !m_linkedWithCellResult )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,22 @@ void RimEclipsePropertyFilterCollection::updateDefaultResult( const RimEclipseCe
filter->setToDefaultValues();
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipsePropertyFilter* RimEclipsePropertyFilterCollection::addFilterLinkedToCellResult()
{
RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
propertyFilter->setLinkedWithCellResult( true );
m_propertyFilters.push_back( propertyFilter );

auto view = reservoirView();
if ( view && view->eclipseCase() )
{
propertyFilter->resultDefinition()->setEclipseCase( view->eclipseCase() );
updateDefaultResult( view->cellResult() );
}

return propertyFilter;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class RimEclipsePropertyFilterCollection : public RimPropertyFilterCollection
void updateIconState() override;
void updateFromCurrentTimeStep();

void updateDefaultResult( const RimEclipseCellColors* result );
void updateDefaultResult( const RimEclipseCellColors* result );
RimEclipsePropertyFilter* addFilterLinkedToCellResult();

protected:
void initAfterRead() override;
Expand Down

0 comments on commit 6d3ed7b

Please sign in to comment.