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:
@@ -132,18 +132,16 @@ void RimAnnotationCollectionBase::scheduleRedrawOfRelevantViews()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimGridView*> RimAnnotationCollectionBase::gridViewsContainingAnnotations() const
|
||||
{
|
||||
RimProject* project = RimProject::current();
|
||||
if ( !project ) return {};
|
||||
|
||||
std::vector<RimGridView*> views;
|
||||
RimProject* project = nullptr;
|
||||
this->firstAncestorOrThisOfType( project );
|
||||
|
||||
if ( !project ) return views;
|
||||
|
||||
std::vector<RimGridView*> visibleGridViews;
|
||||
project->allVisibleGridViews( visibleGridViews );
|
||||
|
||||
for ( auto& gridView : visibleGridViews )
|
||||
{
|
||||
/*if (gridView->annotationCollection()->annotationsCount() > 0)*/ views.push_back( gridView );
|
||||
views.push_back( gridView );
|
||||
}
|
||||
return views;
|
||||
}
|
||||
|
||||
@@ -72,8 +72,7 @@ bool RimAnnotationGroupCollection::isActive() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimAnnotationGroupCollection::isVisible() const
|
||||
{
|
||||
RimAnnotationCollectionBase* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
||||
|
||||
bool visible = true;
|
||||
if ( coll ) visible = coll->isActive();
|
||||
@@ -102,7 +101,7 @@ void RimAnnotationGroupCollection::removeAnnotation( caf::PdmObject* annotation
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmObject*> RimAnnotationGroupCollection::annotations() const
|
||||
{
|
||||
return m_annotations.children();
|
||||
return m_annotations.childrenByType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -114,8 +113,7 @@ void RimAnnotationGroupCollection::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
{
|
||||
updateUiIconFromToggleField();
|
||||
|
||||
RimAnnotationCollectionBase* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
||||
if ( coll ) coll->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,9 +284,7 @@ void RimAnnotationInViewCollection::defineEditorAttribute( const caf::PdmFieldHa
|
||||
|
||||
if ( attr )
|
||||
{
|
||||
RimCase* rimCase;
|
||||
firstAncestorOrThisOfType( rimCase );
|
||||
|
||||
auto rimCase = firstAncestorOrThisOfType<RimCase>();
|
||||
if ( rimCase )
|
||||
{
|
||||
auto bb = rimCase->allCellsBoundingBox();
|
||||
|
||||
@@ -137,8 +137,7 @@ void RimAnnotationLineAppearance::defineUiOrdering( QString uiConfigName, caf::P
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnnotationLineAppearance::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
||||
{
|
||||
RimAnnotationCollection* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfType( annColl );
|
||||
auto annColl = firstAncestorOrThisOfType<RimAnnotationCollection>();
|
||||
if ( annColl ) annColl->scheduleRedrawOfRelevantViews();
|
||||
|
||||
objectChanged.send();
|
||||
|
||||
@@ -109,9 +109,7 @@ void RimAnnotationTextAppearance::defineUiOrdering( QString uiConfigName, caf::P
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnnotationTextAppearance::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
||||
{
|
||||
RimAnnotationCollectionBase* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( annColl );
|
||||
|
||||
auto annColl = firstAncestorOrThisOfTypeAsserted<RimAnnotationCollectionBase>();
|
||||
if ( annColl )
|
||||
{
|
||||
annColl->scheduleRedrawOfRelevantViews();
|
||||
|
||||
@@ -114,7 +114,6 @@ void RimPolylineTarget::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolylineTarget::triggerVisualizationUpdate() const
|
||||
{
|
||||
RimPolylinePickerInterface* ppInterface;
|
||||
firstAncestorOrThisOfTypeAsserted( ppInterface );
|
||||
auto ppInterface = firstAncestorOrThisOfTypeAsserted<RimPolylinePickerInterface>();
|
||||
if ( ppInterface ) ppInterface->updateVisualization();
|
||||
}
|
||||
|
||||
@@ -73,8 +73,7 @@ bool RimPolylinesAnnotation::isActive()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimPolylinesAnnotation::isVisible()
|
||||
{
|
||||
RimAnnotationCollectionBase* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
||||
|
||||
return coll && coll->isActive() && m_isActive;
|
||||
}
|
||||
|
||||
@@ -74,8 +74,7 @@ RimPolylinesAnnotation* RimPolylinesAnnotationInView::sourceAnnotation() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimPolylinesAnnotationInView::isVisible() const
|
||||
{
|
||||
RimAnnotationGroupCollection* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
||||
|
||||
bool visible = true;
|
||||
if ( coll ) visible = coll->isVisible();
|
||||
@@ -85,8 +84,7 @@ bool RimPolylinesAnnotationInView::isVisible() const
|
||||
|
||||
if ( visible )
|
||||
{
|
||||
RimAnnotationGroupCollection* globalColl;
|
||||
m_sourceAnnotation->firstAncestorOrThisOfType( globalColl );
|
||||
auto globalColl = m_sourceAnnotation->firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
||||
if ( globalColl ) visible = globalColl->isVisible();
|
||||
}
|
||||
}
|
||||
@@ -101,9 +99,7 @@ void RimPolylinesAnnotationInView::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
{
|
||||
if ( changedField == &m_isActive )
|
||||
{
|
||||
RimAnnotationCollectionBase* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
||||
if ( coll ) coll->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
}
|
||||
@@ -132,8 +128,7 @@ cvf::ref<RigPolyLinesData> RimPolylinesAnnotationInView::polyLinesData() const
|
||||
retval->setVisibility( false, false );
|
||||
}
|
||||
|
||||
RimAnnotationInViewCollection* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationInViewCollection>();
|
||||
if ( coll )
|
||||
{
|
||||
retval->setZPlaneLock( coll->snapAnnotations(), coll->annotationPlaneZ() );
|
||||
|
||||
@@ -219,8 +219,7 @@ void RimPolylinesFromFileAnnotation::fieldChangedByUi( const caf::PdmFieldHandle
|
||||
appearance()->setSphereFieldsHidden( !m_showSpheres() );
|
||||
}
|
||||
|
||||
RimAnnotationCollection* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( annColl );
|
||||
auto annColl = firstAncestorOrThisOfTypeAsserted<RimAnnotationCollection>();
|
||||
|
||||
annColl->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
|
||||
@@ -74,8 +74,7 @@ bool RimReachCircleAnnotation::isActive()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimReachCircleAnnotation::isVisible()
|
||||
{
|
||||
RimAnnotationCollectionBase* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
||||
|
||||
return coll && coll->isActive() && m_isActive;
|
||||
}
|
||||
@@ -152,8 +151,7 @@ void RimReachCircleAnnotation::fieldChangedByUi( const caf::PdmFieldHandle* chan
|
||||
{
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
RimAnnotationCollection* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( annColl );
|
||||
auto annColl = firstAncestorOrThisOfTypeAsserted<RimAnnotationCollection>();
|
||||
|
||||
annColl->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
|
||||
@@ -79,8 +79,7 @@ RimReachCircleAnnotation* RimReachCircleAnnotationInView::sourceAnnotation() con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimReachCircleAnnotationInView::isVisible() const
|
||||
{
|
||||
RimAnnotationGroupCollection* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
||||
|
||||
bool visible = true;
|
||||
if ( coll ) visible = coll->isVisible();
|
||||
@@ -90,8 +89,7 @@ bool RimReachCircleAnnotationInView::isVisible() const
|
||||
|
||||
if ( visible )
|
||||
{
|
||||
RimAnnotationGroupCollection* globalColl;
|
||||
m_sourceAnnotation->firstAncestorOrThisOfType( globalColl );
|
||||
auto globalColl = m_sourceAnnotation->firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
||||
if ( globalColl ) visible = globalColl->isVisible();
|
||||
}
|
||||
}
|
||||
@@ -106,8 +104,7 @@ void RimReachCircleAnnotationInView::fieldChangedByUi( const caf::PdmFieldHandle
|
||||
{
|
||||
if ( changedField == &m_isActive )
|
||||
{
|
||||
RimAnnotationCollectionBase* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
||||
|
||||
if ( coll ) coll->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
|
||||
@@ -184,9 +184,7 @@ void RimTextAnnotation::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
|
||||
RimAnnotationCollectionBase* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( annColl );
|
||||
|
||||
auto annColl = firstAncestorOrThisOfTypeAsserted<RimAnnotationCollectionBase>();
|
||||
if ( annColl ) annColl->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
|
||||
@@ -211,8 +209,7 @@ bool RimTextAnnotation::isActive()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimTextAnnotation::isVisible() const
|
||||
{
|
||||
RimAnnotationGroupCollection* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
||||
|
||||
bool visible = true;
|
||||
if ( coll ) visible = coll->isVisible();
|
||||
|
||||
@@ -79,8 +79,7 @@ RimTextAnnotation* RimTextAnnotationInView::sourceAnnotation() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimTextAnnotationInView::isVisible() const
|
||||
{
|
||||
RimAnnotationGroupCollection* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
||||
|
||||
bool visible = true;
|
||||
if ( coll ) visible = coll->isVisible();
|
||||
@@ -90,8 +89,7 @@ bool RimTextAnnotationInView::isVisible() const
|
||||
|
||||
if ( visible )
|
||||
{
|
||||
RimAnnotationGroupCollection* globalColl;
|
||||
m_sourceAnnotation->firstAncestorOrThisOfType( globalColl );
|
||||
auto globalColl = m_sourceAnnotation->firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
||||
if ( globalColl ) visible = globalColl->isVisible();
|
||||
}
|
||||
}
|
||||
@@ -106,8 +104,7 @@ void RimTextAnnotationInView::fieldChangedByUi( const caf::PdmFieldHandle* chang
|
||||
{
|
||||
if ( changedField == &m_isActive )
|
||||
{
|
||||
RimAnnotationCollectionBase* coll;
|
||||
firstAncestorOrThisOfType( coll );
|
||||
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
||||
|
||||
if ( coll ) coll->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ cvf::ref<RigPolyLinesData> RimUserDefinedPolylinesAnnotation::polyLinesData()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPolylineTarget*> RimUserDefinedPolylinesAnnotation::activeTargets() const
|
||||
{
|
||||
return m_targets.children();
|
||||
return m_targets.childrenByType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -191,8 +191,7 @@ void RimUserDefinedPolylinesAnnotation::updateEditorsAndVisualization()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUserDefinedPolylinesAnnotation::updateVisualization()
|
||||
{
|
||||
RimAnnotationCollection* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( annColl );
|
||||
auto annColl = firstAncestorOrThisOfTypeAsserted<RimAnnotationCollection>();
|
||||
if ( annColl ) annColl->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user