Rename ApplicationCode to ApplicationLibCode

This commit is contained in:
Gaute Lindkvist
2021-01-06 14:55:29 +01:00
parent 751df1a421
commit 81699db187
3242 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimCellFilter.h
${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.h
${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilter.h
${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilter.h
${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilter.h
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilterCollection.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimCellFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilterCollection.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "ProjectDataModel\\CellFilters" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@@ -0,0 +1,96 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// 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 "RimCellFilter.h"
#include "RiaGuiApplication.h"
#include <QPainter>
namespace caf
{
template <>
void caf::AppEnum<RimCellFilter::FilterModeType>::setUp()
{
addItem( RimCellFilter::INCLUDE, "INCLUDE", "Include" );
addItem( RimCellFilter::EXCLUDE, "EXCLUDE", "Exclude" );
setDefault( RimCellFilter::INCLUDE );
}
} // namespace caf
CAF_PDM_SOURCE_INIT( RimCellFilter, "CellFilter" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellFilter::RimCellFilter()
{
CAF_PDM_InitObject( "Cell Filter", "", "", "" );
CAF_PDM_InitField( &name, "UserDescription", QString( "Filter Name" ), "Name", "", "", "" );
CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" );
isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &filterMode, "FilterType", "Filter Type", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellFilter::~RimCellFilter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimCellFilter::userDescriptionField()
{
return &name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellFilter::updateIconState()
{
caf::IconProvider iconProvider = this->uiIconProvider();
if ( !iconProvider.valid() ) return;
if ( filterMode() == INCLUDE )
{
iconProvider.setOverlayResourceString( ":/Plus.png" );
}
else
{
iconProvider.setOverlayResourceString( ":/Minus.png" );
}
iconProvider.setActive( isActive && !isActive.uiCapability()->isUiReadOnly() );
this->setUiIcon( iconProvider );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimCellFilter::objectToggleField()
{
return &isActive;
}

View File

@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// 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 "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
//==================================================================================================
///
///
//==================================================================================================
class RimCellFilter : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
enum FilterModeType
{
INCLUDE,
EXCLUDE
};
RimCellFilter();
~RimCellFilter() override;
caf::PdmField<QString> name;
caf::PdmField<bool> isActive;
caf::PdmField<caf::AppEnum<FilterModeType>> filterMode;
void updateIconState();
protected:
caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmFieldHandle* objectToggleField() override;
};

View File

@@ -0,0 +1,436 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RimCellRangeFilter.h"
#include "RiaApplication.h"
#include "RigActiveCellInfo.h"
#include "RigReservoirGridTools.h"
#include "RimCellRangeFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimViewController.h"
#include "cafPdmUiSliderEditor.h"
#include "cvfAssert.h"
#include "cvfStructGrid.h"
CAF_PDM_SOURCE_INIT( RimCellRangeFilter, "CellRangeFilter" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellRangeFilter::RimCellRangeFilter()
{
CAF_PDM_InitObject( "Cell Range Filter", ":/CellFilter_Range.png", "", "" );
CAF_PDM_InitField( &m_gridIndex, "GridIndex", 0, "Grid", "", "", "" );
CAF_PDM_InitField( &propagateToSubGrids, "PropagateToSubGrids", true, "Apply to Subgrids", "", "", "" );
CAF_PDM_InitField( &startIndexI, "StartIndexI", 1, "Start Index I", "", "", "" );
startIndexI.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &cellCountI, "CellCountI", 1, "Cell Count I", "", "", "" );
cellCountI.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &startIndexJ, "StartIndexJ", 1, "Start Index J", "", "", "" );
startIndexJ.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &cellCountJ, "CellCountJ", 1, "Cell Count J", "", "", "" );
cellCountJ.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &startIndexK, "StartIndexK", 1, "Start Index K", "", "", "" );
startIndexK.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &cellCountK, "CellCountK", 1, "Cell Count K", "", "", "" );
cellCountK.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_useIndividualCellIndices, "UseIndividualCellIndices", false, "Use Individual Cell Indices", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_individualCellIndices,
"IndividualCellIndices",
"Cell Indices",
"",
"Use Ctrl-C for copy and Ctrl-V for paste",
"" );
updateIconState();
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellRangeFilter::~RimCellRangeFilter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::setGridIndex( int gridIndex )
{
m_gridIndex = gridIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimCellRangeFilter::gridIndex() const
{
return m_gridIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_gridIndex )
{
const cvf::StructGridInterface* grid = selectedGrid();
if ( grid && grid->cellCountI() > 0 && grid->cellCountJ() > 0 && grid->cellCountK() > 0 )
{
cellCountI = static_cast<int>( grid->cellCountI() );
startIndexI = 1;
cellCountJ = static_cast<int>( grid->cellCountJ() );
startIndexJ = 1;
cellCountK = static_cast<int>( grid->cellCountK() );
startIndexK = 1;
}
parentContainer()->updateDisplayModeNotifyManagedViews( this );
return;
}
if ( changedField != &name )
{
computeAndSetValidValues();
parentContainer()->updateDisplayModeNotifyManagedViews( this );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::computeAndSetValidValues()
{
CVF_ASSERT( parentContainer() );
const cvf::StructGridInterface* grid = selectedGrid();
if ( grid && grid->cellCountI() > 0 && grid->cellCountJ() > 0 && grid->cellCountK() > 0 )
{
cellCountI = cvf::Math::clamp( cellCountI.v(), 1, static_cast<int>( grid->cellCountI() ) );
startIndexI = cvf::Math::clamp( startIndexI.v(), 1, static_cast<int>( grid->cellCountI() ) );
cellCountJ = cvf::Math::clamp( cellCountJ.v(), 1, static_cast<int>( grid->cellCountJ() ) );
startIndexJ = cvf::Math::clamp( startIndexJ.v(), 1, static_cast<int>( grid->cellCountJ() ) );
cellCountK = cvf::Math::clamp( cellCountK.v(), 1, static_cast<int>( grid->cellCountK() ) );
startIndexK = cvf::Math::clamp( startIndexK.v(), 1, static_cast<int>( grid->cellCountK() ) );
}
this->updateIconState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::updateActiveState()
{
isActive.uiCapability()->setUiReadOnly( isRangeFilterControlled() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCellRangeFilter::useIndividualCellIndices() const
{
return m_useIndividualCellIndices();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<cvf::Vec3d>& RimCellRangeFilter::individualCellIndices() const
{
return m_individualCellIndices.v();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::setDefaultValues()
{
CVF_ASSERT( parentContainer() );
const cvf::StructGridInterface* grid = selectedGrid();
if ( !grid ) return;
Rim3dView* rimView = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimView );
auto actCellInfo = RigReservoirGridTools::activeCellInfo( rimView );
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimCase );
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid( rimCase );
if ( grid == mainGrid && actCellInfo )
{
cvf::Vec3st min, max;
actCellInfo->IJKBoundingBox( min, max );
// Adjust to Eclipse indexing
min.x() = min.x() + 1;
min.y() = min.y() + 1;
min.z() = min.z() + 1;
max.x() = max.x() + 1;
max.y() = max.y() + 1;
max.z() = max.z() + 1;
startIndexI = static_cast<int>( min.x() );
startIndexJ = static_cast<int>( min.y() );
startIndexK = static_cast<int>( min.z() );
cellCountI = static_cast<int>( max.x() - min.x() + 1 );
cellCountJ = static_cast<int>( max.y() - min.y() + 1 );
cellCountK = static_cast<int>( max.z() - min.z() + 1 );
}
else
{
startIndexI = 1;
startIndexJ = 1;
startIndexK = 1;
cellCountI = static_cast<int>( grid->cellCountI() );
cellCountJ = static_cast<int>( grid->cellCountJ() );
cellCountK = static_cast<int>( grid->cellCountK() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellRangeFilterCollection* RimCellRangeFilter::parentContainer()
{
return dynamic_cast<RimCellRangeFilterCollection*>( this->parentField()->ownerObject() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
caf::PdmUiSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiSliderEditorAttribute*>( attribute );
if ( !myAttr || !parentContainer() )
{
return;
}
const cvf::StructGridInterface* grid = selectedGrid();
if ( !grid ) return;
if ( field == &startIndexI || field == &cellCountI )
{
myAttr->m_minimum = 1;
myAttr->m_maximum = static_cast<int>( grid->cellCountI() );
}
else if ( field == &startIndexJ || field == &cellCountJ )
{
myAttr->m_minimum = 1;
myAttr->m_maximum = static_cast<int>( grid->cellCountJ() );
}
else if ( field == &startIndexK || field == &cellCountK )
{
myAttr->m_minimum = 1;
myAttr->m_maximum = static_cast<int>( grid->cellCountK() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
bool readOnlyState = isRangeFilterControlled();
std::vector<caf::PdmFieldHandle*> objFields;
this->fields( objFields );
for ( auto& objField : objFields )
{
objField->uiCapability()->setUiReadOnly( readOnlyState );
}
const cvf::StructGridInterface* grid = selectedGrid();
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimCase );
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid( rimCase );
Rim3dView* rimView = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimView );
auto actCellInfo = RigReservoirGridTools::activeCellInfo( rimView );
if ( grid == mainGrid && actCellInfo )
{
cvf::Vec3st min, max;
actCellInfo->IJKBoundingBox( min, max );
// Adjust to Eclipse indexing
min.x() = min.x() + 1;
min.y() = min.y() + 1;
min.z() = min.z() + 1;
max.x() = max.x() + 1;
max.y() = max.y() + 1;
max.z() = max.z() + 1;
startIndexI.uiCapability()->setUiName( QString( "I Start (%1)" ).arg( min.x() ) );
startIndexJ.uiCapability()->setUiName( QString( "J Start (%1)" ).arg( min.y() ) );
startIndexK.uiCapability()->setUiName( QString( "K Start (%1)" ).arg( min.z() ) );
cellCountI.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max.x() - min.x() + 1 ) );
cellCountJ.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max.y() - min.y() + 1 ) );
cellCountK.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max.z() - min.z() + 1 ) );
}
else
{
startIndexI.uiCapability()->setUiName( QString( "I Start" ) );
startIndexJ.uiCapability()->setUiName( QString( "J Start" ) );
startIndexK.uiCapability()->setUiName( QString( "K Start" ) );
cellCountI.uiCapability()->setUiName( QString( " Width" ) );
cellCountJ.uiCapability()->setUiName( QString( " Width" ) );
cellCountK.uiCapability()->setUiName( QString( " Width" ) );
}
uiOrdering.add( &name );
uiOrdering.add( &filterMode );
uiOrdering.add( &m_gridIndex );
uiOrdering.add( &propagateToSubGrids );
uiOrdering.add( &startIndexI );
uiOrdering.add( &cellCountI );
uiOrdering.add( &startIndexJ );
uiOrdering.add( &cellCountJ );
uiOrdering.add( &startIndexK );
uiOrdering.add( &cellCountK );
if ( RiaApplication::enableDevelopmentFeatures() )
{
auto group = uiOrdering.addNewGroup( "Single Cell Filtering (TEST)" );
group->setCollapsedByDefault( true );
group->add( &m_useIndividualCellIndices );
group->add( &m_individualCellIndices );
m_individualCellIndices.uiCapability()->setUiReadOnly( !m_useIndividualCellIndices );
}
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
RimCellFilter::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
updateActiveState();
updateIconState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimCellRangeFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( useOptionsOnly ) ( *useOptionsOnly ) = true;
if ( &m_gridIndex == fieldNeedingOptions )
{
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimCase );
for ( int gIdx = 0; gIdx < RigReservoirGridTools::gridCount( rimCase ); ++gIdx )
{
QString gridName;
gridName += RigReservoirGridTools::gridName( rimCase, gIdx );
if ( gIdx == 0 )
{
if ( gridName.isEmpty() )
gridName += "Main Grid";
else
gridName += " (Main Grid)";
}
caf::PdmOptionItemInfo item( gridName, (int)gIdx );
options.push_back( item );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCellRangeFilter::isRangeFilterControlled() const
{
Rim3dView* rimView = nullptr;
firstAncestorOrThisOfTypeAsserted( rimView );
bool isRangeFilterControlled = false;
if ( rimView && rimView->viewController() && rimView->viewController()->isRangeFiltersControlled() )
{
isRangeFilterControlled = true;
}
return isRangeFilterControlled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RimCellRangeFilter::selectedGrid()
{
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimCase );
int clampedIndex = gridIndex();
if ( clampedIndex >= RigReservoirGridTools::gridCount( rimCase ) )
{
clampedIndex = 0;
}
return RigReservoirGridTools::gridByIndex( rimCase, clampedIndex );
}

View File

@@ -0,0 +1,91 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RimCellFilter.h"
#include "cafPdmFieldCvfVec3d.h"
class RigGridBase;
class RigMainGrid;
class RimCellRangeFilterCollection;
class RimEclipseView;
namespace cvf
{
class CellRangeFilter;
class StructGridInterface;
} // namespace cvf
//==================================================================================================
///
///
//==================================================================================================
class RimCellRangeFilter : public RimCellFilter
{
CAF_PDM_HEADER_INIT;
public:
RimCellRangeFilter();
~RimCellRangeFilter() override;
void setGridIndex( int gridIndex );
int gridIndex() const;
private:
caf::PdmField<int> m_gridIndex; // The index of the grid that this filter applies to
public:
caf::PdmField<bool> propagateToSubGrids; // Do propagate the effects to the sub-grids
caf::PdmField<int> startIndexI; // Eclipse indexing, first index is 1
caf::PdmField<int> startIndexJ; // Eclipse indexing, first index is 1
caf::PdmField<int> startIndexK; // Eclipse indexing, first index is 1
caf::PdmField<int> cellCountI;
caf::PdmField<int> cellCountJ;
caf::PdmField<int> cellCountK;
void setDefaultValues();
void updateActiveState();
bool useIndividualCellIndices() const;
const std::vector<cvf::Vec3d>& individualCellIndices() const;
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
private:
RimCellRangeFilterCollection* parentContainer();
bool isRangeFilterControlled() const;
void computeAndSetValidValues();
const cvf::StructGridInterface* selectedGrid();
caf::PdmField<bool> m_useIndividualCellIndices;
caf::PdmField<std::vector<cvf::Vec3d>> m_individualCellIndices;
};

View File

@@ -0,0 +1,264 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RimCellRangeFilterCollection.h"
#include "Rim3dView.h"
#include "RimCellRangeFilter.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "cafPdmUiEditorHandle.h"
#include "cvfStructGridGeometryGenerator.h"
CAF_PDM_SOURCE_INIT( RimCellRangeFilterCollection, "CellRangeFilterCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellRangeFilterCollection::RimCellRangeFilterCollection()
{
CAF_PDM_InitObject( "Range Filters", ":/CellFilter_Range.png", "", "" );
CAF_PDM_InitFieldNoDefault( &rangeFilters, "RangeFilters", "Range Filters", "", "", "" );
rangeFilters.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" );
isActive.uiCapability()->setUiHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellRangeFilterCollection::~RimCellRangeFilterCollection()
{
rangeFilters.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
/// RimCellRangeFilter is using Eclipse 1-based indexing, adjust filter values before
// populating cvf::CellRangeFilter (which is 0-based)
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilterCollection::compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const
{
CVF_ASSERT( cellRangeFilter );
for ( size_t i = 0; i < rangeFilters.size(); i++ )
{
RimCellRangeFilter* rangeFilter = rangeFilters[i];
if ( rangeFilter && rangeFilter->isActive() && static_cast<size_t>( rangeFilter->gridIndex() ) == gridIndex )
{
if ( rangeFilter->filterMode == RimCellFilter::INCLUDE )
{
if ( rangeFilter->useIndividualCellIndices() )
{
for ( const auto& cellIndex : rangeFilter->individualCellIndices() )
{
cellRangeFilter->addCellInclude( cellIndex.x() - 1,
cellIndex.y() - 1,
cellIndex.z() - 1,
rangeFilter->propagateToSubGrids() );
}
}
else
{
cellRangeFilter->addCellIncludeRange( rangeFilter->startIndexI - 1,
rangeFilter->startIndexJ - 1,
rangeFilter->startIndexK - 1,
rangeFilter->startIndexI - 1 + rangeFilter->cellCountI,
rangeFilter->startIndexJ - 1 + rangeFilter->cellCountJ,
rangeFilter->startIndexK - 1 + rangeFilter->cellCountK,
rangeFilter->propagateToSubGrids() );
}
}
else
{
if ( rangeFilter->useIndividualCellIndices() )
{
for ( const auto& cellIndex : rangeFilter->individualCellIndices() )
{
cellRangeFilter->addCellExclude( cellIndex.x() - 1,
cellIndex.y() - 1,
cellIndex.z() - 1,
rangeFilter->propagateToSubGrids() );
}
}
else
{
cellRangeFilter->addCellExcludeRange( rangeFilter->startIndexI - 1,
rangeFilter->startIndexJ - 1,
rangeFilter->startIndexK - 1,
rangeFilter->startIndexI - 1 + rangeFilter->cellCountI,
rangeFilter->startIndexJ - 1 + rangeFilter->cellCountJ,
rangeFilter->startIndexK - 1 + rangeFilter->cellCountK,
rangeFilter->propagateToSubGrids() );
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilterCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
updateIconState();
uiCapability()->updateConnectedEditors();
updateDisplayModeNotifyManagedViews( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilterCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
updateDisplayModeNotifyManagedViews( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews( RimCellRangeFilter* changedRangeFilter )
{
Rim3dView* view = nullptr;
firstAncestorOrThisOfType( view );
if ( !view ) return;
if ( view->isMasterView() )
{
RimViewLinker* viewLinker = view->assosiatedViewLinker();
if ( viewLinker )
{
// Update data for range filter
// Update of display model is handled by view->scheduleGeometryRegen, also for managed views
viewLinker->updateRangeFilters( changedRangeFilter );
}
}
view->scheduleGeometryRegen( VISIBLE_WELL_CELLS );
view->scheduleGeometryRegen( RANGE_FILTERED );
view->scheduleGeometryRegen( RANGE_FILTERED_INACTIVE );
view->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCellRangeFilterCollection::hasActiveFilters() const
{
if ( !isActive() ) return false;
for ( size_t i = 0; i < rangeFilters.size(); i++ )
{
if ( rangeFilters[i]->isActive() ) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimCellRangeFilterCollection::objectToggleField()
{
return &isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCellRangeFilterCollection::hasActiveIncludeFilters() const
{
if ( !isActive ) return false;
for ( size_t i = 0; i < rangeFilters.size(); i++ )
{
if ( rangeFilters[i]->isActive() && rangeFilters[i]->filterMode() == RimCellFilter::INCLUDE ) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dView* RimCellRangeFilterCollection::baseView() const
{
Rim3dView* rimView = nullptr;
firstAncestorOrThisOfType( rimView );
return rimView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilterCollection::updateIconState()
{
bool activeIcon = true;
RimViewController* viewController = baseView()->viewController();
if ( viewController && ( viewController->isRangeFiltersControlled() || viewController->isVisibleCellsOveridden() ) )
{
activeIcon = false;
}
if ( !isActive )
{
activeIcon = false;
}
updateUiIconFromState( activeIcon );
for ( size_t i = 0; i < rangeFilters.size(); i++ )
{
RimCellRangeFilter* rangeFilter = rangeFilters[i];
rangeFilter->updateActiveState();
rangeFilter->updateIconState();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilterCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
PdmObject::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
RimViewController* viewController = baseView()->viewController();
if ( viewController && viewController->isRangeFiltersControlled() )
{
isActive.uiCapability()->setUiReadOnly( true );
}
else
{
isActive.uiCapability()->setUiReadOnly( false );
}
updateIconState();
}

View File

@@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// 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 "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
class Rim3dView;
class RimCellRangeFilter;
namespace cvf
{
class CellRangeFilter;
};
//==================================================================================================
///
///
//==================================================================================================
class RimCellRangeFilterCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimCellRangeFilterCollection();
~RimCellRangeFilterCollection() override;
// Fields
caf::PdmField<bool> isActive;
caf::PdmChildArrayField<RimCellRangeFilter*> rangeFilters;
// Methods
void compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const;
bool hasActiveFilters() const;
bool hasActiveIncludeFilters() const;
void updateDisplayModeNotifyManagedViews( RimCellRangeFilter* changedRangeFilter );
void updateIconState();
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
caf::PdmFieldHandle* objectToggleField() override;
private:
Rim3dView* baseView() const;
};

View File

@@ -0,0 +1,586 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RimEclipsePropertyFilter.h"
#include "RiaDefines.h"
#include "RiaFieldHandleTools.h"
#include "RiaGuiApplication.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigFlowDiagResults.h"
#include "RigFormationNames.h"
#include "RimEclipseCase.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimFlowDiagSolution.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimViewController.h"
#include "RiuMainWindow.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cvfAssert.h"
#include "cvfMath.h"
#include <cmath> // Needed for HUGE_VAL on Linux
namespace caf
{ // Obsolete stuff
template <>
void caf::AppEnum<RimEclipsePropertyFilter::EvaluationRegionType>::setUp()
{
addItem( RimEclipsePropertyFilter::RANGE_FILTER_REGION, "RANGE_FILTER_REGION", "Range filter cells" );
addItem( RimEclipsePropertyFilter::GLOBAL_REGION, "GLOBAL_REGION", "All cells" );
setDefault( RimEclipsePropertyFilter::RANGE_FILTER_REGION );
}
} // namespace caf
CAF_PDM_SOURCE_INIT( RimEclipsePropertyFilter, "CellPropertyFilter" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipsePropertyFilter::RimEclipsePropertyFilter()
{
CAF_PDM_InitObject( "Cell Property Filter", ":/CellFilter_Values.png", "", "" );
CAF_PDM_InitFieldNoDefault( &obsoleteField_evaluationRegion, "EvaluationRegion", "Evaluation Region", "", "", "" );
RiaFieldhandleTools::disableWriteAndSetFieldHidden( &obsoleteField_evaluationRegion );
CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" );
m_resultDefinition = new RimEclipseResultDefinition();
m_resultDefinition->setDiffResultOptionsEnabled( true );
// Set to hidden to avoid this item to been displayed as a child item
// Fields in this object are displayed using defineUiOrdering()
m_resultDefinition.uiCapability()->setUiHidden( true );
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitField( &m_rangeLabelText, "Dummy_keyword", QString( "Range Type" ), "Range Type", "", "", "" );
m_rangeLabelText.xmlCapability()->disableIO();
m_rangeLabelText.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_lowerBound, "LowerBound", 0.0, "Min", "", "", "" );
m_lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_upperBound, "UpperBound", 0.0, "Max", "", "", "" );
m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_useCategorySelection, "CategorySelection", false, "Category Selection", "", "", "" );
m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
// HEADLESS HACK
if ( RiaGuiApplication::isRunning() )
{
updateIconState();
}
m_minimumResultValue = cvf::UNDEFINED_DOUBLE;
m_maximumResultValue = cvf::UNDEFINED_DOUBLE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipsePropertyFilter::~RimEclipsePropertyFilter()
{
delete m_resultDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseResultDefinition* RimEclipsePropertyFilter::resultDefinition() const
{
return m_resultDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::rangeValues( double* lower, double* upper ) const
{
*lower = this->m_lowerBound;
*upper = this->m_upperBound;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilter::isCategorySelectionActive() const
{
if ( m_resultDefinition->hasCategoryResult() && m_useCategorySelection )
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
// clang-format off
if ( &m_lowerBound == changedField
|| &m_upperBound == changedField
|| &obsoleteField_evaluationRegion == changedField
|| &isActive == changedField
|| &filterMode == changedField
|| &m_selectedCategoryValues == changedField
|| &m_useCategorySelection == changedField)
{
this->m_resultDefinition->loadResult();
this->computeResultValueRange();
updateFilterName();
this->updateIconState();
this->uiCapability()->updateConnectedEditors();
parentContainer()->updateDisplayModelNotifyManagedViews(this);
}
// clang-format on
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipsePropertyFilterCollection* RimEclipsePropertyFilter::parentContainer()
{
RimEclipsePropertyFilterCollection* propFilterColl = nullptr;
this->firstAncestorOrThisOfTypeAsserted( propFilterColl );
return propFilterColl;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::setToDefaultValues()
{
CVF_ASSERT( parentContainer() );
computeResultValueRange();
m_lowerBound = m_minimumResultValue;
m_upperBound = m_maximumResultValue;
m_selectedCategoryValues = m_categoryValues;
m_useCategorySelection = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
// Fields declared in RimCellFilter
uiOrdering.add( &name );
// Fields declared in Rimm_resultDefinition
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" );
m_resultDefinition->uiOrdering( uiConfigName, *group1 );
caf::PdmUiGroup& group2 = *( uiOrdering.addNewGroup( "Filter Settings" ) );
// Fields declared in RimCellFilter
group2.add( &filterMode );
group2.add( &m_rangeLabelText );
if ( m_resultDefinition->hasCategoryResult() )
{
group2.add( &m_useCategorySelection );
}
if ( m_resultDefinition->hasCategoryResult() && m_useCategorySelection() )
{
group2.add( &m_selectedCategoryValues );
}
else
{
group2.add( &m_lowerBound );
group2.add( &m_upperBound );
}
uiOrdering.skipRemainingFields( true );
updateReadOnlyStateOfAllFields();
updateRangeLabel();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
PdmObject::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
updateActiveState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateReadOnlyStateOfAllFields()
{
bool readOnlyState = isPropertyFilterControlled();
std::vector<caf::PdmFieldHandle*> objFields;
this->fields( objFields );
// Include fields declared in Rimm_resultDefinition
objFields.push_back( &( m_resultDefinition->m_resultTypeUiField ) );
objFields.push_back( &( m_resultDefinition->m_porosityModelUiField ) );
objFields.push_back( &( m_resultDefinition->m_resultVariableUiField ) );
for ( auto f : objFields )
{
if ( f == &m_rangeLabelText ) continue;
f->uiCapability()->setUiReadOnly( readOnlyState );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateRangeLabel()
{
if ( m_resultDefinition->isFlowDiagOrInjectionFlooding() )
{
m_rangeLabelText = "Current Timestep";
}
else
{
m_rangeLabelText = "All Timesteps";
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilter::isPropertyFilterControlled()
{
Rim3dView* rimView = nullptr;
firstAncestorOrThisOfTypeAsserted( rimView );
bool isPropertyFilterControlled = false;
RimViewController* vc = rimView->viewController();
if ( vc && vc->isPropertyFilterOveridden() )
{
isPropertyFilterControlled = true;
}
return isPropertyFilterControlled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::setCategoriesFromTracerNames( const std::vector<QString>& tracerNames )
{
std::vector<std::pair<QString, int>> tracerNameValuesSorted;
{
std::set<std::pair<QString, int>> tracerNameSet;
for ( size_t i = 0; i < tracerNames.size(); i++ )
{
tracerNameSet.insert( std::make_pair( tracerNames[i], static_cast<int>( i ) ) );
}
for ( const auto& it : tracerNameSet )
{
tracerNameValuesSorted.push_back( it );
}
}
setCategoryNamesAndValues( tracerNameValuesSorted );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateActiveState()
{
isActive.uiCapability()->setUiReadOnly( isPropertyFilterControlled() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE )
{
return;
}
if ( field == &m_lowerBound || field == &m_upperBound )
{
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( !myAttr )
{
return;
}
myAttr->m_minimum = m_minimumResultValue;
myAttr->m_maximum = m_maximumResultValue;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::computeResultValueRange()
{
CVF_ASSERT( parentContainer() );
double min = HUGE_VAL;
double max = -HUGE_VAL;
clearCategories();
if ( m_resultDefinition->isFlowDiagOrInjectionFlooding() )
{
Rim3dView* view;
this->firstAncestorOrThisOfType( view );
int timeStep = 0;
if ( view ) timeStep = view->currentTimeStep();
RigFlowDiagResultAddress resAddr = m_resultDefinition->flowDiagResAddress();
if ( m_resultDefinition->flowDiagSolution() )
{
RigFlowDiagResults* results = m_resultDefinition->flowDiagSolution()->flowDiagResults();
results->minMaxScalarValues( resAddr, timeStep, &min, &max );
if ( m_resultDefinition->hasCategoryResult() )
{
setCategoriesFromTracerNames( m_resultDefinition->flowDiagSolution()->tracerNames() );
}
}
}
else
{
RigEclipseResultAddress scalarIndex = m_resultDefinition->eclipseResultAddress();
if ( scalarIndex.isValid() )
{
RigCaseCellResultsData* results = m_resultDefinition->currentGridCellResults();
if ( results )
{
results->minMaxCellScalarValues( scalarIndex, min, max );
if ( m_resultDefinition->hasCategoryResult() )
{
if ( m_resultDefinition->resultType() == RiaDefines::ResultCatType::FORMATION_NAMES )
{
CVF_ASSERT( parentContainer()->reservoirView()->eclipseCase()->eclipseCaseData() );
const std::vector<QString> fnVector =
parentContainer()->reservoirView()->eclipseCase()->eclipseCaseData()->formationNames();
setCategoryNames( fnVector );
}
else if ( m_resultDefinition->resultVariable() == RiaDefines::completionTypeResultName() )
{
std::vector<RiaDefines::WellPathComponentType> componentTypes =
{ RiaDefines::WellPathComponentType::WELL_PATH,
RiaDefines::WellPathComponentType::PERFORATION_INTERVAL,
RiaDefines::WellPathComponentType::FISHBONES,
RiaDefines::WellPathComponentType::FRACTURE };
std::vector<std::pair<QString, int>> ctNamesAndValues;
for ( RiaDefines::WellPathComponentType type : componentTypes )
{
ctNamesAndValues.push_back(
std::make_pair( caf::AppEnum<RiaDefines::WellPathComponentType>::uiText( type ),
static_cast<int>( type ) ) );
}
setCategoryNamesAndValues( ctNamesAndValues );
}
else
{
setCategoryValues( results->uniqueCellScalarValues( scalarIndex ) );
}
}
}
}
}
m_maximumResultValue = max;
m_minimumResultValue = min;
m_lowerBound.uiCapability()->setUiName( QString( "Min (%1)" ).arg( min ) );
m_upperBound.uiCapability()->setUiName( QString( "Max (%1)" ).arg( max ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateFromCurrentTimeStep()
{
// Update range for flow diagnostics values when time step changes
// Range for flow is always current time step, not computed across all time steps
// If upper/lower slider is set to available extrema, the filter values will be
// updated with the min/max values for the current time step
//
// If the user manually has set a filter value, this value is left untouched
if ( !m_resultDefinition->isFlowDiagOrInjectionFlooding() )
{
return;
}
double threshold = 1e-6;
bool followMin = false;
if ( fabs( m_lowerBound - m_minimumResultValue ) < threshold || m_minimumResultValue == HUGE_VAL )
{
followMin = true;
}
bool followMax = false;
if ( fabs( m_upperBound - m_maximumResultValue ) < threshold || m_maximumResultValue == -HUGE_VAL )
{
followMax = true;
}
double min = HUGE_VAL;
double max = -HUGE_VAL;
clearCategories();
Rim3dView* view = nullptr;
this->firstAncestorOrThisOfTypeAsserted( view );
int timeStep = view->currentTimeStep();
RigFlowDiagResultAddress resAddr = m_resultDefinition->flowDiagResAddress();
if ( m_resultDefinition->flowDiagSolution() )
{
RigFlowDiagResults* results = m_resultDefinition->flowDiagSolution()->flowDiagResults();
results->minMaxScalarValues( resAddr, timeStep, &min, &max );
if ( m_resultDefinition->hasCategoryResult() )
{
setCategoriesFromTracerNames( m_resultDefinition->flowDiagSolution()->tracerNames() );
}
}
if ( min == HUGE_VAL && max == -HUGE_VAL )
{
m_lowerBound.uiCapability()->setUiName( QString( "Min (inf)" ) );
m_upperBound.uiCapability()->setUiName( QString( "Max (inf)" ) );
}
else
{
m_maximumResultValue = max;
m_minimumResultValue = min;
if ( followMin )
{
m_lowerBound = min;
}
if ( followMax )
{
m_upperBound = m_maximumResultValue;
}
m_lowerBound.uiCapability()->setUiName( QString( "Min (%1)" ).arg( min ) );
m_upperBound.uiCapability()->setUiName( QString( "Max (%1)" ).arg( max ) );
}
m_lowerBound.uiCapability()->updateConnectedEditors();
m_upperBound.uiCapability()->updateConnectedEditors();
updateFilterName();
this->name.uiCapability()->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateFilterName()
{
QString newFiltername = m_resultDefinition->resultVariableUiShortName();
if ( isCategorySelectionActive() )
{
if ( m_categoryNames.empty() )
{
newFiltername += " (";
if ( !m_selectedCategoryValues().empty() && m_selectedCategoryValues().size() == m_categoryValues.size() )
{
newFiltername += QString::number( m_selectedCategoryValues()[0] );
newFiltername += "..";
newFiltername += QString::number( m_selectedCategoryValues()[m_selectedCategoryValues().size() - 1] );
}
else
{
for ( size_t i = 0; i < m_selectedCategoryValues().size(); i++ )
{
int val = m_selectedCategoryValues()[i];
newFiltername += QString::number( val );
if ( i < m_selectedCategoryValues().size() - 1 )
{
newFiltername += ", ";
}
}
}
newFiltername += ")";
}
}
else
{
newFiltername += " (" + QString::number( m_lowerBound ) + " .. " + QString::number( m_upperBound ) + ")";
}
this->name = newFiltername;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::initAfterRead()
{
m_resultDefinition->initAfterRead();
m_resultDefinition->setEclipseCase( parentContainer()->reservoirView()->eclipseCase() );
updateIconState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateUiFieldsFromActiveResult()
{
m_resultDefinition->updateUiFieldsFromActiveResult();
}

View File

@@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RimPropertyFilter.h"
#include "cafPdmChildField.h"
class RimEclipsePropertyFilterCollection;
class RimEclipseResultDefinition;
//==================================================================================================
///
///
//==================================================================================================
class RimEclipsePropertyFilter : public RimPropertyFilter
{
CAF_PDM_HEADER_INIT;
public:
RimEclipsePropertyFilter();
~RimEclipsePropertyFilter() override;
RimEclipseResultDefinition* resultDefinition() const;
void rangeValues( double* lower, double* upper ) const;
bool isCategorySelectionActive() const;
void setToDefaultValues();
void updateFilterName();
void computeResultValueRange();
void updateFromCurrentTimeStep();
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void initAfterRead() override;
void updateUiFieldsFromActiveResult();
private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
private:
friend class RimEclipsePropertyFilterCollection;
friend class RicEclipsePropertyFilterFeatureImpl;
void updateActiveState();
void updateReadOnlyStateOfAllFields();
void updateRangeLabel();
bool isPropertyFilterControlled();
void setCategoriesFromTracerNames( const std::vector<QString>& tracerNames );
RimEclipsePropertyFilterCollection* parentContainer();
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_useCategorySelection;
double m_minimumResultValue;
double m_maximumResultValue;
public:
// Obsolete stuff
enum EvaluationRegionType
{
RANGE_FILTER_REGION,
GLOBAL_REGION
};
private:
caf::PdmField<caf::AppEnum<EvaluationRegionType>> obsoleteField_evaluationRegion;
};

View File

@@ -0,0 +1,178 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseCellColors.h"
#include "RimEclipsePropertyFilter.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "cafPdmUiEditorHandle.h"
CAF_PDM_SOURCE_INIT( RimEclipsePropertyFilterCollection, "CellPropertyFilters" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipsePropertyFilterCollection::RimEclipsePropertyFilterCollection()
{
CAF_PDM_InitObject( "Property Filters", ":/CellFilter_Values.png", "", "" );
CAF_PDM_InitFieldNoDefault( &propertyFilters, "PropertyFilters", "Property Filters", "", "", "" );
propertyFilters.uiCapability()->setUiHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipsePropertyFilterCollection::~RimEclipsePropertyFilterCollection()
{
propertyFilters.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseView* RimEclipsePropertyFilterCollection::reservoirView()
{
RimEclipseView* eclipseView = nullptr;
firstAncestorOrThisOfType( eclipseView );
return eclipseView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::loadAndInitializePropertyFilters()
{
for ( RimEclipsePropertyFilter* propertyFilter : propertyFilters )
{
propertyFilter->resultDefinition()->setEclipseCase( reservoirView()->eclipseCase() );
propertyFilter->initAfterRead();
if ( isActive() && propertyFilter->isActive() )
{
propertyFilter->resultDefinition()->loadResult();
propertyFilter->computeResultValueRange();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::initAfterRead()
{
updateIconState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilterCollection::hasActiveFilters() const
{
if ( !isActive ) return false;
for ( RimEclipsePropertyFilter* propertyFilter : propertyFilters )
{
if ( propertyFilter->isActive() && propertyFilter->resultDefinition()->hasResult() ) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Returns whether any of the active property filters are based on a dynamic result
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilterCollection::hasActiveDynamicFilters() const
{
if ( !isActive ) return false;
for ( RimEclipsePropertyFilter* propertyFilter : propertyFilters )
{
if ( propertyFilter->isActive() && propertyFilter->resultDefinition()->hasDynamicResult() ) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilterCollection::isUsingFormationNames() const
{
if ( !isActive ) return false;
for ( RimEclipsePropertyFilter* propertyFilter : propertyFilters )
{
if ( propertyFilter->isActive() &&
propertyFilter->resultDefinition()->resultType() == RiaDefines::ResultCatType::FORMATION_NAMES &&
propertyFilter->resultDefinition()->resultVariable() != RiaDefines::undefinedResultName() )
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::updateIconState()
{
bool activeIcon = true;
RimEclipseView* view = nullptr;
this->firstAncestorOrThisOfType( view );
if ( view )
{
RimViewController* viewController = view->viewController();
if ( viewController && ( viewController->isPropertyFilterOveridden() || viewController->isVisibleCellsOveridden() ) )
{
activeIcon = false;
}
}
if ( !isActive )
{
activeIcon = false;
}
updateUiIconFromState( activeIcon );
for ( RimEclipsePropertyFilter* cellFilter : propertyFilters )
{
cellFilter->updateActiveState();
cellFilter->updateIconState();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::updateFromCurrentTimeStep()
{
for ( RimEclipsePropertyFilter* cellFilter : propertyFilters() )
{
cellFilter->updateFromCurrentTimeStep();
}
}

View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RimPropertyFilterCollection.h"
#include "cafPdmChildArrayField.h"
class RimEclipsePropertyFilter;
class RimEclipseView;
//==================================================================================================
///
///
//==================================================================================================
class RimEclipsePropertyFilterCollection : public RimPropertyFilterCollection
{
CAF_PDM_HEADER_INIT;
public:
RimEclipsePropertyFilterCollection();
~RimEclipsePropertyFilterCollection() override;
RimEclipseView* reservoirView();
// Fields:
caf::PdmChildArrayField<RimEclipsePropertyFilter*> propertyFilters;
// Methods
bool hasActiveFilters() const override;
bool hasActiveDynamicFilters() const override;
bool isUsingFormationNames() const;
void loadAndInitializePropertyFilters() override;
void updateIconState() override;
void updateFromCurrentTimeStep();
protected:
// Overridden methods
void initAfterRead() override;
};

View File

@@ -0,0 +1,330 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RimGeoMechPropertyFilter.h"
#include "RigFemPartResultsCollection.h"
#include "RigFormationNames.h"
#include "RigGeoMechCaseData.h"
#include "RimGeoMechPropertyFilterCollection.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "RimViewController.h"
#include "RiuMainWindow.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cvfAssert.h"
#include "cvfMath.h"
CAF_PDM_SOURCE_INIT( RimGeoMechPropertyFilter, "GeoMechPropertyFilter" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechPropertyFilter::RimGeoMechPropertyFilter()
: m_parentContainer( nullptr )
{
CAF_PDM_InitObject( "Property Filter", ":/CellFilter_Values.png", "", "" );
CAF_PDM_InitFieldNoDefault( &resultDefinition, "ResultDefinition", "Result Definition", "", "", "" );
resultDefinition = new RimGeoMechResultDefinition();
// Set to hidden to avoid this item to been displayed as a child item
// Fields in this object are displayed using defineUiOrdering()
resultDefinition.uiCapability()->setUiHidden( true );
resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitField( &lowerBound, "LowerBound", 0.0, "Min", "", "", "" );
lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &upperBound, "UpperBound", 0.0, "Max", "", "", "" );
upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
updateIconState();
m_minimumResultValue = cvf::UNDEFINED_DOUBLE;
m_maximumResultValue = cvf::UNDEFINED_DOUBLE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechPropertyFilter::~RimGeoMechPropertyFilter()
{
delete resultDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( &lowerBound == changedField || &upperBound == changedField || &isActive == changedField ||
&filterMode == changedField || &m_selectedCategoryValues == changedField )
{
this->updateIconState();
this->updateFilterName();
this->uiCapability()->updateConnectedEditors();
parentContainer()->updateDisplayModelNotifyManagedViews( this );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::setParentContainer( RimGeoMechPropertyFilterCollection* parentContainer )
{
m_parentContainer = parentContainer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechPropertyFilterCollection* RimGeoMechPropertyFilter::parentContainer()
{
return m_parentContainer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::setToDefaultValues()
{
CVF_ASSERT( m_parentContainer );
computeResultValueRange();
lowerBound = m_minimumResultValue;
upperBound = m_maximumResultValue;
m_selectedCategoryValues = m_categoryValues;
this->updateFilterName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &name );
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" );
resultDefinition->uiOrdering( uiConfigName, *group1 );
caf::PdmUiGroup& group2 = *( uiOrdering.addNewGroup( "Filter Settings" ) );
group2.add( &filterMode );
if ( resultDefinition->hasCategoryResult() )
{
group2.add( &m_selectedCategoryValues );
}
else
{
group2.add( &lowerBound );
group2.add( &upperBound );
}
updateReadOnlyStateOfAllFields();
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
PdmObject::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
updateActiveState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::updateReadOnlyStateOfAllFields()
{
bool readOnlyState = isPropertyFilterControlled();
std::vector<caf::PdmFieldHandle*> objFields;
this->fields( objFields );
// Include fields declared in RimResultDefinition
objFields.push_back( &( resultDefinition->m_resultPositionTypeUiField ) );
objFields.push_back( &( resultDefinition->m_resultVariableUiField ) );
objFields.push_back( &( resultDefinition->m_timeLapseBaseTimestep ) );
for ( size_t i = 0; i < objFields.size(); i++ )
{
objFields[i]->uiCapability()->setUiReadOnly( readOnlyState );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechPropertyFilter::isPropertyFilterControlled()
{
bool isPropertyFilterControlled = false;
Rim3dView* rimView = nullptr;
firstAncestorOrThisOfType( rimView );
CVF_ASSERT( rimView );
if ( rimView )
{
RimViewController* vc = rimView->viewController();
if ( vc && vc->isPropertyFilterOveridden() )
{
isPropertyFilterControlled = true;
}
}
return isPropertyFilterControlled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::updateActiveState()
{
isActive.uiCapability()->setUiReadOnly( isPropertyFilterControlled() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechPropertyFilter::isActiveAndHasResult()
{
if ( this->isActive() && this->resultDefinition->hasResult() )
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE )
{
return;
}
if ( field == &lowerBound || field == &upperBound )
{
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( !myAttr )
{
return;
}
myAttr->m_minimum = m_minimumResultValue;
myAttr->m_maximum = m_maximumResultValue;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::computeResultValueRange()
{
CVF_ASSERT( m_parentContainer );
double min = 0.0;
double max = 0.0;
clearCategories();
RigFemResultAddress resultAddress = resultDefinition->resultAddress();
if ( resultAddress.isValid() && resultDefinition->ownerCaseData() )
{
if ( resultDefinition->hasCategoryResult() )
{
std::vector<QString> fnVector = resultDefinition->ownerCaseData()->femPartResults()->formationNames();
setCategoryNames( fnVector );
}
else
{
resultDefinition->ownerCaseData()->femPartResults()->minMaxScalarValues( resultAddress, &min, &max );
}
}
m_maximumResultValue = max;
m_minimumResultValue = min;
lowerBound.uiCapability()->setUiName( QString( "Min (%1)" ).arg( min ) );
upperBound.uiCapability()->setUiName( QString( "Max (%1)" ).arg( max ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilter::updateFilterName()
{
RigFemResultAddress resultAddress = resultDefinition->resultAddress();
QString newFiltername;
if ( resultAddress.resultPosType == RIG_FORMATION_NAMES )
{
newFiltername = resultDefinition->resultFieldName();
}
else
{
QString posName;
switch ( resultAddress.resultPosType )
{
case RIG_NODAL:
posName = "N";
break;
case RIG_ELEMENT_NODAL:
posName = "EN";
break;
case RIG_INTEGRATION_POINT:
posName = "IP";
break;
case RIG_ELEMENT:
posName = "E";
break;
}
QString fieldUiName = resultDefinition->resultFieldUiName();
QString compoUiName = resultDefinition->resultComponentUiName();
newFiltername = posName + ", " + fieldUiName + ", " + compoUiName + " (" + QString::number( lowerBound() ) +
" .. " + QString::number( upperBound ) + ")";
}
this->name = newFiltername;
uiCapability()->updateConnectedEditors();
}

View File

@@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RimPropertyFilter.h"
#include "cafPdmChildField.h"
class RimGeoMechResultDefinition;
class RimGeoMechPropertyFilterCollection;
//==================================================================================================
///
///
//==================================================================================================
class RimGeoMechPropertyFilter : public RimPropertyFilter
{
CAF_PDM_HEADER_INIT;
public:
RimGeoMechPropertyFilter();
~RimGeoMechPropertyFilter() override;
caf::PdmChildField<RimGeoMechResultDefinition*> resultDefinition;
caf::PdmField<double> lowerBound;
caf::PdmField<double> upperBound;
void setParentContainer( RimGeoMechPropertyFilterCollection* parentContainer );
RimGeoMechPropertyFilterCollection* parentContainer();
void setToDefaultValues();
void updateFilterName();
void computeResultValueRange();
void updateActiveState();
bool isActiveAndHasResult();
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
private:
void updateReadOnlyStateOfAllFields();
bool isPropertyFilterControlled();
private:
RimGeoMechPropertyFilterCollection* m_parentContainer;
double m_minimumResultValue;
double m_maximumResultValue;
};

View File

@@ -0,0 +1,165 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RimGeoMechPropertyFilterCollection.h"
#include "RimGeoMechPropertyFilter.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "cvfAssert.h"
CAF_PDM_SOURCE_INIT( RimGeoMechPropertyFilterCollection, "GeoMechPropertyFilters" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechPropertyFilterCollection::RimGeoMechPropertyFilterCollection()
{
CAF_PDM_InitObject( "Property Filters", ":/CellFilter_Values.png", "", "" );
CAF_PDM_InitFieldNoDefault( &propertyFilters, "PropertyFilters", "Property Filters", "", "", "" );
propertyFilters.uiCapability()->setUiHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection()
{
propertyFilters.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechView* RimGeoMechPropertyFilterCollection::reservoirView()
{
RimGeoMechView* geoMechView = nullptr;
firstAncestorOrThisOfType( geoMechView );
return geoMechView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilterCollection::loadAndInitializePropertyFilters()
{
for ( size_t i = 0; i < propertyFilters.size(); i++ )
{
RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i];
propertyFilter->resultDefinition->setGeoMechCase( reservoirView()->geoMechCase() );
propertyFilter->resultDefinition->loadResult();
propertyFilter->computeResultValueRange();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilterCollection::initAfterRead()
{
for ( size_t i = 0; i < propertyFilters.size(); i++ )
{
RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i];
propertyFilter->setParentContainer( this );
propertyFilter->resultDefinition->setGeoMechCase( reservoirView()->geoMechCase() );
propertyFilter->updateIconState();
}
updateIconState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechPropertyFilterCollection::hasActiveFilters() const
{
if ( !isActive ) return false;
for ( size_t i = 0; i < propertyFilters.size(); i++ )
{
RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i];
if ( propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult() ) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Returns whether any of the active property filters are based on a dynamic result
//--------------------------------------------------------------------------------------------------
bool RimGeoMechPropertyFilterCollection::hasActiveDynamicFilters() const
{
return hasActiveFilters();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechPropertyFilterCollection::isUsingFormationNames() const
{
if ( !isActive ) return false;
for ( size_t i = 0; i < propertyFilters.size(); i++ )
{
RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i];
if ( propertyFilter->isActive() && propertyFilter->resultDefinition->resultPositionType() == RIG_FORMATION_NAMES &&
propertyFilter->resultDefinition->resultFieldName() != "" )
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilterCollection::updateIconState()
{
bool activeIcon = true;
RimGeoMechView* view = nullptr;
this->firstAncestorOrThisOfType( view );
if ( view )
{
RimViewController* viewController = view->viewController();
if ( viewController && ( viewController->isPropertyFilterOveridden() || viewController->isVisibleCellsOveridden() ) )
{
activeIcon = false;
}
}
if ( !isActive )
{
activeIcon = false;
}
updateUiIconFromState( activeIcon );
for ( size_t i = 0; i < propertyFilters.size(); i++ )
{
RimGeoMechPropertyFilter* propFilter = propertyFilters[i];
propFilter->updateActiveState();
propFilter->updateIconState();
}
}

View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RimPropertyFilterCollection.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
class RimGeoMechPropertyFilter;
class RimGeoMechView;
//==================================================================================================
///
///
//==================================================================================================
class RimGeoMechPropertyFilterCollection : public RimPropertyFilterCollection
{
CAF_PDM_HEADER_INIT;
public:
RimGeoMechPropertyFilterCollection();
~RimGeoMechPropertyFilterCollection() override;
RimGeoMechView* reservoirView();
// Fields:
caf::PdmChildArrayField<RimGeoMechPropertyFilter*> propertyFilters;
// Methods
bool hasActiveFilters() const override;
bool hasActiveDynamicFilters() const override;
bool isUsingFormationNames() const;
void loadAndInitializePropertyFilters() override;
void updateIconState() override;
protected:
// Overridden methods
void initAfterRead() override;
};

View File

@@ -0,0 +1,130 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPropertyFilter.h"
#include "RimPropertyFilterCollection.h"
CAF_PDM_SOURCE_INIT( RimPropertyFilter, "PropertyFilter" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPropertyFilter::RimPropertyFilter()
{
CAF_PDM_InitObject( "Property Filter", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_selectedCategoryValues, "SelectedValues", "Values", "", "", "" );
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPropertyFilter::~RimPropertyFilter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<int> RimPropertyFilter::selectedCategoryValues() const
{
return m_selectedCategoryValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimPropertyFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( &m_selectedCategoryValues == fieldNeedingOptions )
{
if ( useOptionsOnly ) *useOptionsOnly = true;
if ( m_categoryValues.size() == m_categoryNames.size() )
{
for ( size_t i = 0; i < m_categoryValues.size(); i++ )
{
int categoryValue = m_categoryValues[i];
QString categoryName = m_categoryNames[i];
options.push_back( caf::PdmOptionItemInfo( categoryName, categoryValue ) );
}
}
else
{
for ( auto it : m_categoryValues )
{
QString str = QString::number( it );
options.push_back( caf::PdmOptionItemInfo( str, it ) );
}
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPropertyFilter::setCategoryValues( const std::vector<int>& categoryValues )
{
m_categoryValues = categoryValues;
m_categoryNames.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPropertyFilter::setCategoryNames( const std::vector<QString>& categoryNames )
{
m_categoryNames = categoryNames;
for ( size_t i = 0; i < m_categoryNames.size(); i++ )
{
m_categoryValues.push_back( static_cast<int>( i ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPropertyFilter::setCategoryNamesAndValues( const std::vector<std::pair<QString, int>>& categoryNamesAndValues )
{
clearCategories();
for ( auto it : categoryNamesAndValues )
{
m_categoryNames.push_back( it.first );
m_categoryValues.push_back( it.second );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPropertyFilter::clearCategories()
{
m_categoryValues.clear();
m_categoryNames.clear();
}

View File

@@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimCellFilter.h"
//==================================================================================================
///
///
//==================================================================================================
class RimPropertyFilter : public RimCellFilter
{
CAF_PDM_HEADER_INIT;
public:
RimPropertyFilter();
~RimPropertyFilter() override;
std::vector<int> selectedCategoryValues() const;
protected:
void setCategoryValues( const std::vector<int>& categoryValues );
void setCategoryNames( const std::vector<QString>& categoryNames );
void setCategoryNamesAndValues( const std::vector<std::pair<QString, int>>& categoryNamesAndValues );
void clearCategories();
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
protected:
caf::PdmField<std::vector<int>> m_selectedCategoryValues;
std::vector<int> m_categoryValues;
std::vector<QString> m_categoryNames;
};

View File

@@ -0,0 +1,122 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RimPropertyFilterCollection.h"
#include "Rim3dView.h"
#include "RimPropertyFilter.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPropertyFilterCollection, "RimPropertyFilterCollection" ); // Abstract class
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPropertyFilterCollection::RimPropertyFilterCollection()
{
CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" );
isActive.uiCapability()->setUiHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPropertyFilterCollection::~RimPropertyFilterCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPropertyFilterCollection::updateDisplayModelNotifyManagedViews( RimPropertyFilter* changedFilter ) const
{
Rim3dView* view = nullptr;
this->firstAncestorOrThisOfType( view );
CVF_ASSERT( view );
if ( !view ) return;
if ( view->isMasterView() )
{
RimViewLinker* viewLinker = view->assosiatedViewLinker();
if ( viewLinker )
{
// Update data for property filter
// Update of display model is handled by view->scheduleGeometryRegen, also for managed views
viewLinker->updatePropertyFilters( changedFilter );
}
}
view->scheduleGeometryRegen( PROPERTY_FILTERED );
view->scheduleCreateDisplayModelAndRedraw();
}
void RimPropertyFilterCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
Rim3dView* view = nullptr;
this->firstAncestorOrThisOfType( view );
CVF_ASSERT( view );
if ( !view ) return;
view->scheduleGeometryRegen( PROPERTY_FILTERED );
view->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPropertyFilterCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
updateIconState();
uiCapability()->updateConnectedEditors();
updateDisplayModelNotifyManagedViews( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimPropertyFilterCollection::objectToggleField()
{
return &isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPropertyFilterCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
PdmObject::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
Rim3dView* rimView = nullptr;
this->firstAncestorOrThisOfType( rimView );
RimViewController* viewController = rimView->viewController();
if ( viewController && ( viewController->isPropertyFilterOveridden() || viewController->isVisibleCellsOveridden() ) )
{
isActive.uiCapability()->setUiReadOnly( true, uiConfigName );
}
else
{
isActive.uiCapability()->setUiReadOnly( false, uiConfigName );
}
updateIconState();
}

View File

@@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "cafPdmField.h"
#include "cafPdmObject.h"
class RimPropertyFilter;
//==================================================================================================
///
///
//==================================================================================================
class RimPropertyFilterCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimPropertyFilterCollection();
~RimPropertyFilterCollection() override;
// Fields:
caf::PdmField<bool> isActive;
// Methods
virtual bool hasActiveFilters() const = 0;
virtual bool hasActiveDynamicFilters() const = 0;
virtual void loadAndInitializePropertyFilters() = 0;
void updateDisplayModelNotifyManagedViews( RimPropertyFilter* changedFilter ) const;
virtual void updateIconState() = 0;
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
protected:
// Overridden methods
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
caf::PdmFieldHandle* objectToggleField() override;
};