#3214 Use template function to get referencing objects of specified type

This commit is contained in:
Magne Sjaastad 2018-08-15 12:55:45 +02:00
parent 97c3b9efea
commit 59f9d189e5
8 changed files with 45 additions and 58 deletions

View File

@ -112,16 +112,16 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file
// Replace all occurrences of file sum with ecl sum
std::vector<caf::PdmObjectHandle*> referringObjects;
existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects);
std::vector<RimSummaryCurve*> objects;
existingFileSummaryCase->objectsWithReferringPtrFieldsOfType(objects);
// UI settings of a curve filter is updated based
// on the new case association for the curves in the curve filter
// UI is updated by loadDataAndUpdate()
for (caf::PdmObjectHandle* objHandle : referringObjects)
for (RimSummaryCurve* summaryCurve : objects)
{
RimSummaryCurve* summaryCurve = dynamic_cast<RimSummaryCurve*>(objHandle);
if (summaryCurve)
{
RimSummaryCurveCollection* parentCollection = nullptr;

View File

@ -767,17 +767,7 @@ double RimFractureTemplate::computeFractureWidth(const RimFracture* fractureInst
std::vector<RimFracture*> RimFractureTemplate::fracturesUsingThisTemplate() const
{
std::vector<RimFracture*> fractures;
std::vector<caf::PdmObjectHandle*> objects;
this->objectsWithReferringPtrFields(objects);
for (auto object : objects)
{
auto f = dynamic_cast<RimFracture*>(object);
if (f)
{
fractures.push_back(f);
}
}
this->objectsWithReferringPtrFieldsOfType(fractures);
return fractures;
}

View File

@ -227,12 +227,11 @@ void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUni
{
RimFractureTemplate* templateWithMatchingUnit = nullptr;
std::vector<caf::PdmObjectHandle*> referringObjects;
fractureTemplate->objectsWithReferringPtrFields(referringObjects);
std::vector<RimFracture*> referringObjects;
fractureTemplate->objectsWithReferringPtrFieldsOfType(referringObjects);
for (auto refObj : referringObjects)
for (auto fracture : referringObjects)
{
auto fracture = dynamic_cast<RimFracture*>(refObj);
if (fracture && fracture->fractureUnit() != fractureTemplate->fractureTemplateUnit())
{
if (!templateWithMatchingUnit)

View File

@ -546,11 +546,10 @@ void RimEclipseView::createDisplayModel()
updateLegends();
}
std::vector<caf::PdmFieldHandle*> objects;
this->referringPtrFields(objects);
for (auto object : objects)
std::vector<RimFlowCharacteristicsPlot*> objects;
this->objectsWithReferringPtrFieldsOfType(objects);
for (auto plot : objects)
{
RimFlowCharacteristicsPlot* plot = dynamic_cast<RimFlowCharacteristicsPlot*>(object->ownerObject());
if (plot != nullptr)
{
plot->viewGeometryUpdated();

View File

@ -118,11 +118,11 @@ QString RimFormationNames::fileNameWoPath()
//--------------------------------------------------------------------------------------------------
void RimFormationNames::updateConnectedViews()
{
std::vector<caf::PdmObjectHandle*> usingObjs;
this->objectsWithReferringPtrFields(usingObjs);
for (caf::PdmObjectHandle* obj: usingObjs)
std::vector<RimCase*> objects;
this->objectsWithReferringPtrFieldsOfType(objects);
for (RimCase* caseObj : objects)
{
RimCase* caseObj = dynamic_cast<RimCase*>(obj);
if (caseObj)
{
caseObj->updateFormationNamesData();

View File

@ -221,17 +221,18 @@ void RimGridView::replaceRangeFilterCollectionWithOverride()
//--------------------------------------------------------------------------------------------------
RimViewController* RimGridView::viewController() const
{
RimViewController* viewController = nullptr;
std::vector<caf::PdmObjectHandle*> reffingObjs;
std::vector<RimViewController*> objects;
this->objectsWithReferringPtrFieldsOfType(objects);
this->objectsWithReferringPtrFields(reffingObjs);
for (size_t i = 0; i < reffingObjs.size(); ++i)
for (auto v : objects)
{
viewController = dynamic_cast<RimViewController*>(reffingObjs[i]);
if (viewController) break;
if (v)
{
return v;
}
}
return viewController;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@ -352,18 +353,18 @@ void RimGridView::selectOverlayInfoConfig()
//--------------------------------------------------------------------------------------------------
RimViewLinker* RimGridView::viewLinkerIfMasterView() const
{
RimViewLinker* viewLinker = nullptr;
std::vector<caf::PdmObjectHandle*> reffingObjs;
std::vector<RimViewLinker*> objects;
this->objectsWithReferringPtrFieldsOfType(objects);
this->objectsWithReferringPtrFields(reffingObjs);
for (size_t i = 0; i < reffingObjs.size(); ++i)
for (auto viewLinker : objects)
{
viewLinker = dynamic_cast<RimViewLinker*>(reffingObjs[i]);
if (viewLinker) break;
if (viewLinker)
{
return viewLinker;
}
}
return viewLinker;
return nullptr;
}

View File

@ -744,16 +744,16 @@ void RimIntersection::appendPointToPolyLine(const cvf::Vec3d& point)
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionView* RimIntersection::correspondingIntersectionView()
{
std::vector<caf::PdmObjectHandle*> objects;
this->objectsWithReferringPtrFields(objects);
Rim2dIntersectionView* isectView = nullptr;
for (auto obj : objects)
std::vector<Rim2dIntersectionView*> objects;
this->objectsWithReferringPtrFieldsOfType(objects);
for (auto isectView : objects)
{
isectView = dynamic_cast<Rim2dIntersectionView*>(obj);
if (isectView) break;
if (isectView)
{
return isectView;
}
}
return isectView;
return nullptr;
}

View File

@ -96,11 +96,10 @@ void RimSummaryCaseCollection::addCase(RimSummaryCase* summaryCase, bool updateC
m_cases.push_back(summaryCase);
// Update derived ensemble cases (if any)
std::vector<caf::PdmObjectHandle*> referringObjects;
objectsWithReferringPtrFields(referringObjects);
for (auto refObj : referringObjects)
std::vector<RimDerivedEnsembleCaseCollection*> referringObjects;
objectsWithReferringPtrFieldsOfType(referringObjects);
for (auto derEnsemble : referringObjects)
{
auto derEnsemble = dynamic_cast<RimDerivedEnsembleCaseCollection*>(refObj);
if (!derEnsemble) continue;
derEnsemble->updateDerivedEnsembleCases();
@ -421,12 +420,11 @@ void RimSummaryCaseCollection::onLoadDataAndUpdate()
void RimSummaryCaseCollection::updateReferringCurveSets()
{
// Update curve set referring to this group
std::vector<PdmObjectHandle*> referringObjects;
objectsWithReferringPtrFields(referringObjects);
std::vector<RimEnsembleCurveSet*> referringObjects;
objectsWithReferringPtrFieldsOfType(referringObjects);
for (PdmObjectHandle* obj : referringObjects)
for (auto curveSet : referringObjects)
{
RimEnsembleCurveSet* curveSet = dynamic_cast<RimEnsembleCurveSet*>(obj);
if (curveSet) curveSet->updateAllCurves();
}
}