Skip to content

Commit

Permalink
#11994 Allow property filter to be linked to cell result
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Dec 17, 2024
1 parent 707c5f4 commit ab8f90d
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 9 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 @@ -65,6 +66,13 @@ RimEclipsePropertyFilter::RimEclipsePropertyFilter()
// Fields in this object are displayed using defineUiOrdering()
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );

CAF_PDM_InitFieldNoDefault( &m_linkedWithCellResult,
"LinkedWithCellResult",
"Linked With Cell Result",
"",
"The selected cell result is automatically used to update the property filter." );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_linkedWithCellResult );

CAF_PDM_InitField( &m_rangeLabelText, "Dummy_keyword", QString( "Range Type" ), "Range Type" );
m_rangeLabelText.xmlCapability()->disableIO();
m_rangeLabelText.uiCapability()->setUiReadOnly( true );
Expand Down Expand Up @@ -119,6 +127,22 @@ RimEclipseResultDefinition* RimEclipsePropertyFilter::resultDefinition() const
return m_resultDefinition;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilter::isLinkedWithCellResult() const
{
return m_linkedWithCellResult();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::setLinkedWithCellResult( bool linkedWithCellResult )
{
m_linkedWithCellResult = linkedWithCellResult;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -161,7 +185,7 @@ void RimEclipsePropertyFilter::fieldChangedByUi( const caf::PdmFieldHandle* chan

if ( &m_lowerBound == changedField || &m_upperBound == changedField || &m_isActive == changedField || &m_filterMode == changedField ||
&m_selectedCategoryValues == changedField || &m_useCategorySelection == changedField || &m_integerUpperBound == changedField ||
&m_integerLowerBound == changedField )
&m_integerLowerBound == changedField || &m_linkedWithCellResult == changedField )
{
m_isDuplicatedFromLinkedView = false;

Expand Down Expand Up @@ -207,6 +231,13 @@ 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" );
m_resultDefinition->uiOrdering( uiConfigName, *group1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class RimEclipsePropertyFilter : public RimPropertyFilter, public RimFieldQuickA
~RimEclipsePropertyFilter() override;

RimEclipseResultDefinition* resultDefinition() const;
bool isLinkedWithCellResult() const;
void setLinkedWithCellResult( bool linkedWithCellResult );

void rangeValues( double* lower, double* upper ) const;
bool isCategorySelectionActive() const;
Expand Down Expand Up @@ -84,10 +86,12 @@ class RimEclipsePropertyFilter : public RimPropertyFilter, public RimFieldQuickA

private:
caf::PdmChildField<RimEclipseResultDefinition*> m_resultDefinition;
caf::PdmField<QString> m_rangeLabelText;

caf::PdmField<double> m_lowerBound;
caf::PdmField<double> m_upperBound;
caf::PdmField<bool> m_linkedWithCellResult;

caf::PdmField<QString> m_rangeLabelText;
caf::PdmField<double> m_lowerBound;
caf::PdmField<double> m_upperBound;

caf::PdmProxyValueField<int> m_integerLowerBound;
caf::PdmProxyValueField<int> m_integerUpperBound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "RimViewController.h"
#include "RimViewLinker.h"

#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiEditorHandle.h"

CAF_PDM_SOURCE_INIT( RimEclipsePropertyFilterCollection, "CellPropertyFilters" );
Expand Down Expand Up @@ -191,3 +192,55 @@ void RimEclipsePropertyFilterCollection::updateFromCurrentTimeStep()
cellFilter->updateFromCurrentTimeStep();
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::updateDefaultResult( const RimEclipseCellColors* result )
{
if ( !result ) return;
if ( m_propertyFilters.empty() ) return;

auto view = reservoirView();
for ( auto filter : m_propertyFilters )
{
if ( !filter->isLinkedWithCellResult() ) continue;

if ( view && view->eclipseCase() )
{
filter->resultDefinition()->setEclipseCase( view->eclipseCase() );
}

filter->resultDefinition()->simpleCopy( result );
filter->resultDefinition()->loadResult();
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;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicEclipsePropertyFilterNewFeature";
menuBuilder << "RicAddLinkedEclipsePropertyFilterFeature";
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

class RimEclipsePropertyFilter;
class RimEclipseView;
class RimEclipseCellColors;

//==================================================================================================
///
Expand Down Expand Up @@ -53,8 +54,12 @@ class RimEclipsePropertyFilterCollection : public RimPropertyFilterCollection
void updateIconState() override;
void updateFromCurrentTimeStep();

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

protected:
void initAfterRead() override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;

private:
caf::PdmChildArrayField<RimEclipsePropertyFilter*> m_propertyFilters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "RimEclipseFaultColors.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipsePropertyFilter.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseResultAddress.h"
#include "RimEclipseStatisticsCase.h"
#include "RimEclipseView.h"
Expand Down Expand Up @@ -317,10 +316,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicSaveEclipseInputPropertyFeature";
}
else if ( dynamic_cast<RimEclipsePropertyFilterCollection*>( firstUiItem ) )
{
menuBuilder << "RicEclipsePropertyFilterNewFeature";
}
else if ( dynamic_cast<RimEclipsePropertyFilter*>( firstUiItem ) )
{
menuBuilder << "RicEclipsePropertyFilterInsertFeature";
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ void RimEclipseView::childFieldChangedByUi( const caf::PdmFieldHandle* changedCh
if ( changedChildField == &m_cellResult )
{
updateMdiWindowTitle();

m_propertyFilterCollection->updateDefaultResult( m_cellResult() );
}
}

Expand Down

0 comments on commit ab8f90d

Please sign in to comment.