mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Change API for PdmObjectHandle and PdmFieldHandle
* Refactor interface to PdmObjectHandle and PdmFieldHandle Return objects instead of passing in structures as parameters * Add nodiscard to several functions * Remove redundant this-> * Rename to ptrReferencedObjectsByType
This commit is contained in:
@@ -213,8 +213,7 @@ void RimCellFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
|
||||
bool readOnlyState = isFilterControlled();
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> objFields;
|
||||
this->fields( objFields );
|
||||
std::vector<caf::PdmFieldHandle*> objFields = fields();
|
||||
for ( auto& objField : objFields )
|
||||
{
|
||||
objField->uiCapability()->setUiReadOnly( readOnlyState );
|
||||
@@ -235,8 +234,7 @@ QString RimCellFilter::modeString() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::StructGridInterface* RimCellFilter::selectedGrid() const
|
||||
{
|
||||
RimCase* rimCase = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( rimCase );
|
||||
auto rimCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
|
||||
|
||||
int clampedIndex = gridIndex();
|
||||
if ( clampedIndex >= RigReservoirGridTools::gridCount( rimCase ) )
|
||||
@@ -256,8 +254,7 @@ QList<caf::PdmOptionItemInfo> RimCellFilter::calculateValueOptions( const caf::P
|
||||
|
||||
if ( &m_gridIndex == fieldNeedingOptions )
|
||||
{
|
||||
RimCase* rimCase = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( rimCase );
|
||||
auto rimCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
|
||||
|
||||
for ( int gIdx = 0; gIdx < RigReservoirGridTools::gridCount( rimCase ); ++gIdx )
|
||||
{
|
||||
@@ -284,8 +281,7 @@ QList<caf::PdmOptionItemInfo> RimCellFilter::calculateValueOptions( const caf::P
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCellFilter::isFilterControlled() const
|
||||
{
|
||||
Rim3dView* rimView = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted( rimView );
|
||||
auto rimView = firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
||||
|
||||
bool isFilterControlled = false;
|
||||
if ( rimView && rimView->viewController() && rimView->viewController()->isCellFiltersControlled() )
|
||||
|
||||
@@ -104,7 +104,7 @@ void RimCellFilterCollection::setCase( RimCase* theCase )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimCellFilter*> RimCellFilterCollection::filters() const
|
||||
{
|
||||
return m_cellFilters.children();
|
||||
return m_cellFilters.childrenByType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -157,8 +157,7 @@ void RimCellFilterCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTr
|
||||
{
|
||||
PdmObject::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
|
||||
|
||||
Rim3dView* rimView = nullptr;
|
||||
this->firstAncestorOrThisOfType( rimView );
|
||||
auto rimView = firstAncestorOrThisOfType<Rim3dView>();
|
||||
RimViewController* viewController = rimView->viewController();
|
||||
if ( viewController && ( viewController->isPropertyFilterOveridden() || viewController->isVisibleCellsOveridden() ) )
|
||||
{
|
||||
@@ -179,8 +178,7 @@ void RimCellFilterCollection::updateIconState()
|
||||
{
|
||||
bool activeIcon = true;
|
||||
|
||||
Rim3dView* rimView = nullptr;
|
||||
this->firstAncestorOrThisOfType( rimView );
|
||||
auto rimView = firstAncestorOrThisOfType<Rim3dView>();
|
||||
RimViewController* viewController = rimView->viewController();
|
||||
|
||||
bool isControlled = viewController && ( viewController->isCellFiltersControlled() || viewController->isVisibleCellsOveridden() );
|
||||
@@ -340,8 +338,7 @@ void RimCellFilterCollection::connectToFilterUpdates( RimCellFilter* filter )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellFilterCollection::onFilterUpdated( const SignalEmitter* emitter )
|
||||
{
|
||||
Rim3dView* view = nullptr;
|
||||
firstAncestorOrThisOfType( view );
|
||||
auto view = firstAncestorOrThisOfType<Rim3dView>();
|
||||
if ( !view ) return;
|
||||
|
||||
if ( view->isMasterView() )
|
||||
|
||||
@@ -175,12 +175,9 @@ void RimCellRangeFilter::setDefaultValues( int sliceDirection, int defaultSlice
|
||||
|
||||
if ( !grid ) return;
|
||||
|
||||
Rim3dView* rimView = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( rimView );
|
||||
auto rimView = firstAncestorOrThisOfType<Rim3dView>();
|
||||
auto actCellInfo = RigReservoirGridTools::activeCellInfo( rimView );
|
||||
|
||||
RimCase* rimCase = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( rimCase );
|
||||
auto rimCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
|
||||
|
||||
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid( rimCase );
|
||||
|
||||
@@ -277,12 +274,10 @@ void RimCellRangeFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
|
||||
|
||||
const cvf::StructGridInterface* grid = selectedGrid();
|
||||
|
||||
RimCase* rimCase = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( rimCase );
|
||||
auto rimCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
|
||||
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid( rimCase );
|
||||
|
||||
Rim3dView* rimView = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( rimView );
|
||||
auto rimView = firstAncestorOrThisOfType<Rim3dView>();
|
||||
auto actCellInfo = RigReservoirGridTools::activeCellInfo( rimView );
|
||||
|
||||
if ( grid == mainGrid && actCellInfo )
|
||||
|
||||
@@ -162,10 +162,7 @@ void RimEclipsePropertyFilter::fieldChangedByUi( const caf::PdmFieldHandle* chan
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipsePropertyFilterCollection* RimEclipsePropertyFilter::parentContainer()
|
||||
{
|
||||
RimEclipsePropertyFilterCollection* propFilterColl = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( propFilterColl );
|
||||
|
||||
return propFilterColl;
|
||||
return firstAncestorOrThisOfTypeAsserted<RimEclipsePropertyFilterCollection>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -241,8 +238,7 @@ void RimEclipsePropertyFilter::updateReadOnlyStateOfAllFields()
|
||||
{
|
||||
bool readOnlyState = isPropertyFilterControlled();
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> objFields;
|
||||
this->fields( objFields );
|
||||
std::vector<caf::PdmFieldHandle*> objFields = fields();
|
||||
|
||||
// Include fields declared in Rimm_resultDefinition
|
||||
objFields.push_back( &( m_resultDefinition->m_resultTypeUiField ) );
|
||||
@@ -277,8 +273,7 @@ void RimEclipsePropertyFilter::updateRangeLabel()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipsePropertyFilter::isPropertyFilterControlled()
|
||||
{
|
||||
Rim3dView* rimView = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted( rimView );
|
||||
auto rimView = firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
||||
|
||||
bool isPropertyFilterControlled = false;
|
||||
|
||||
@@ -353,8 +348,7 @@ void RimEclipsePropertyFilter::defineObjectEditorAttribute( QString uiConfigName
|
||||
{
|
||||
if ( !m_isDuplicatedFromLinkedView ) return;
|
||||
|
||||
Rim3dView* rimView = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted( rimView );
|
||||
auto rimView = firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
||||
|
||||
RimViewController* vc = rimView->viewController();
|
||||
if ( vc && vc->isPropertyFilterDuplicationActive() )
|
||||
@@ -385,8 +379,7 @@ void RimEclipsePropertyFilter::computeResultValueRange()
|
||||
|
||||
if ( m_resultDefinition->isFlowDiagOrInjectionFlooding() )
|
||||
{
|
||||
Rim3dView* view;
|
||||
this->firstAncestorOrThisOfType( view );
|
||||
auto view = firstAncestorOrThisOfType<Rim3dView>();
|
||||
|
||||
int timeStep = 0;
|
||||
if ( view ) timeStep = view->currentTimeStep();
|
||||
@@ -490,8 +483,7 @@ void RimEclipsePropertyFilter::updateFromCurrentTimeStep()
|
||||
|
||||
clearCategories();
|
||||
|
||||
Rim3dView* view = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( view );
|
||||
auto view = firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
||||
|
||||
int timeStep = view->currentTimeStep();
|
||||
RigFlowDiagResultAddress resAddr = m_resultDefinition->flowDiagResAddress();
|
||||
|
||||
@@ -57,10 +57,7 @@ RimEclipsePropertyFilterCollection::~RimEclipsePropertyFilterCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView* RimEclipsePropertyFilterCollection::reservoirView()
|
||||
{
|
||||
RimEclipseView* eclipseView = nullptr;
|
||||
firstAncestorOrThisOfType( eclipseView );
|
||||
|
||||
return eclipseView;
|
||||
return firstAncestorOrThisOfType<RimEclipseView>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -79,7 +76,7 @@ void RimEclipsePropertyFilterCollection::setIsDuplicatedFromLinkedView()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimEclipsePropertyFilter*> RimEclipsePropertyFilterCollection::propertyFilters() const
|
||||
{
|
||||
return m_propertyFilters.children();
|
||||
return m_propertyFilters.childrenByType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -169,8 +166,7 @@ void RimEclipsePropertyFilterCollection::updateIconState()
|
||||
{
|
||||
bool activeIcon = true;
|
||||
|
||||
RimEclipseView* view = nullptr;
|
||||
this->firstAncestorOrThisOfType( view );
|
||||
auto view = firstAncestorOrThisOfType<RimEclipseView>();
|
||||
if ( view )
|
||||
{
|
||||
RimViewController* viewController = view->viewController();
|
||||
|
||||
@@ -167,8 +167,7 @@ void RimGeoMechPropertyFilter::updateReadOnlyStateOfAllFields()
|
||||
{
|
||||
bool readOnlyState = isPropertyFilterControlled();
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> objFields;
|
||||
this->fields( objFields );
|
||||
std::vector<caf::PdmFieldHandle*> objFields = fields();
|
||||
|
||||
// Include fields declared in RimResultDefinition
|
||||
objFields.push_back( &( resultDefinition->m_resultPositionTypeUiField ) );
|
||||
@@ -188,9 +187,7 @@ bool RimGeoMechPropertyFilter::isPropertyFilterControlled()
|
||||
{
|
||||
bool isPropertyFilterControlled = false;
|
||||
|
||||
Rim3dView* rimView = nullptr;
|
||||
firstAncestorOrThisOfType( rimView );
|
||||
CVF_ASSERT( rimView );
|
||||
auto rimView = firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
||||
if ( rimView )
|
||||
{
|
||||
RimViewController* vc = rimView->viewController();
|
||||
|
||||
@@ -53,10 +53,7 @@ RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechView* RimGeoMechPropertyFilterCollection::reservoirView()
|
||||
{
|
||||
RimGeoMechView* geoMechView = nullptr;
|
||||
firstAncestorOrThisOfType( geoMechView );
|
||||
|
||||
return geoMechView;
|
||||
return firstAncestorOrThisOfType<RimGeoMechView>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -138,8 +135,7 @@ void RimGeoMechPropertyFilterCollection::updateIconState()
|
||||
{
|
||||
bool activeIcon = true;
|
||||
|
||||
RimGeoMechView* view = nullptr;
|
||||
this->firstAncestorOrThisOfType( view );
|
||||
RimGeoMechView* view = reservoirView();
|
||||
if ( view )
|
||||
{
|
||||
RimViewController* viewController = view->viewController();
|
||||
|
||||
@@ -257,7 +257,7 @@ QString RimPolygonFilter::fullName() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPolylineTarget*> RimPolygonFilter::activeTargets() const
|
||||
{
|
||||
return m_targets.children();
|
||||
return m_targets.childrenByType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -412,8 +412,7 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
|
||||
|
||||
bool readOnlyState = isFilterControlled();
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> objFields;
|
||||
this->fields( objFields );
|
||||
std::vector<caf::PdmFieldHandle*> objFields = this->fields();
|
||||
for ( auto& objField : objFields )
|
||||
{
|
||||
objField->uiCapability()->setUiReadOnly( readOnlyState );
|
||||
|
||||
@@ -46,9 +46,7 @@ RimPropertyFilterCollection::~RimPropertyFilterCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPropertyFilterCollection::updateDisplayModelNotifyManagedViews( RimPropertyFilter* changedFilter ) const
|
||||
{
|
||||
Rim3dView* view = nullptr;
|
||||
this->firstAncestorOrThisOfType( view );
|
||||
CVF_ASSERT( view );
|
||||
auto view = firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
||||
if ( !view ) return;
|
||||
|
||||
if ( view->isMasterView() )
|
||||
@@ -109,8 +107,7 @@ void RimPropertyFilterCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering&
|
||||
{
|
||||
PdmObject::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
|
||||
|
||||
Rim3dView* rimView = nullptr;
|
||||
this->firstAncestorOrThisOfType( rimView );
|
||||
auto rimView = firstAncestorOrThisOfType<Rim3dView>();
|
||||
RimViewController* viewController = rimView->viewController();
|
||||
if ( viewController && ( viewController->isPropertyFilterOveridden() || viewController->isVisibleCellsOveridden() ) )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user