mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-14 01:12:11 -05: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:
1 parent
37e29a0f68
commit
0c90f67dcc
510 files changed
+1651
-3111
No files matched your search
+4
-9
@@ -87,8 +87,7 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
return;
|
||||
}
|
||||
|
||||
RimWellPathGeometryDef* geomDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted( geomDef );
|
||||
auto geomDef = target->firstAncestorOrThisOfTypeAsserted<RimWellPathGeometryDef>();
|
||||
|
||||
for ( auto field : target->fieldsFor3dManipulator() )
|
||||
{
|
||||
@@ -119,9 +118,7 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
m_manipulator->setHandleSize( handleSize );
|
||||
|
||||
{
|
||||
RimWellPath* wellPath = nullptr;
|
||||
target->firstAncestorOrThisOfType( wellPath );
|
||||
|
||||
auto wellPath = target->firstAncestorOrThisOfType<RimWellPath>();
|
||||
if ( wellPath && !wellPath->isTopLevelWellPath() && geomDef->firstActiveTarget() == target )
|
||||
{
|
||||
if ( auto parentWellPath = wellPath->wellPathTieIn()->parentWell() )
|
||||
@@ -168,12 +165,10 @@ void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Ve
|
||||
return;
|
||||
}
|
||||
|
||||
RimWellPathGeometryDef* geomDef;
|
||||
manipulatedTarget->firstAncestorOrThisOfTypeAsserted( geomDef );
|
||||
auto geomDef = manipulatedTarget->firstAncestorOrThisOfTypeAsserted<RimWellPathGeometryDef>();
|
||||
if ( !geomDef ) return;
|
||||
|
||||
RimModeledWellPath* modeledWellPath = nullptr;
|
||||
geomDef->firstAncestorOfType( modeledWellPath );
|
||||
auto modeledWellPath = geomDef->firstAncestorOfType<RimModeledWellPath>();
|
||||
|
||||
cvf::Vec3d domainCoordXYZ; // domain coordinate of the new location
|
||||
cvf::Vec3d deltaManipulatorMovement; // delta change relative current location of target
|
||||
|
||||
+4
-12
@@ -26,6 +26,7 @@
|
||||
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QClipboard>
|
||||
@@ -37,13 +38,8 @@ CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAppendPointsToPolygonFilterFeature::isCommandEnabled()
|
||||
{
|
||||
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( !selectedObject ) return false;
|
||||
|
||||
RimPolygonFilter* polygonFilter = nullptr;
|
||||
selectedObject->firstAncestorOrThisOfType( polygonFilter );
|
||||
|
||||
return ( polygonFilter != nullptr );
|
||||
auto obj = caf::firstAncestorOfTypeFromSelectedObject<RimPolygonFilter>();
|
||||
return obj != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -51,11 +47,7 @@ bool RicAppendPointsToPolygonFilterFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( !selectedObject ) return;
|
||||
|
||||
RimPolygonFilter* polygonFilter = nullptr;
|
||||
selectedObject->firstAncestorOrThisOfType( polygonFilter );
|
||||
auto polygonFilter = caf::firstAncestorOfTypeFromSelectedObject<RimPolygonFilter>();
|
||||
if ( !polygonFilter ) return;
|
||||
|
||||
QStringList listOfThreeDoubles;
|
||||
|
||||
@@ -53,8 +53,7 @@ void RicDeletePolylineTargetFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
if ( !targets.empty() )
|
||||
{
|
||||
RimPolylinePickerInterface* polylineDef = nullptr;
|
||||
targets[0]->firstAncestorOrThisOfTypeAsserted( polylineDef );
|
||||
RimPolylinePickerInterface* polylineDef = targets[0]->firstAncestorOrThisOfTypeAsserted<RimPolylinePickerInterface>();
|
||||
|
||||
for ( auto target : targets )
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked )
|
||||
RimWellPathAttributeCollection* wellPathAttributeCollection = nullptr;
|
||||
if ( attributes.size() > 0 )
|
||||
{
|
||||
attributes[0]->firstAncestorOrThisOfTypeAsserted( wellPathAttributeCollection );
|
||||
wellPathAttributeCollection = attributes[0]->firstAncestorOrThisOfTypeAsserted<RimWellPathAttributeCollection>();
|
||||
for ( RimWellPathAttribute* attributeToDelete : attributes )
|
||||
{
|
||||
wellPathAttributeCollection->deleteAttribute( attributeToDelete );
|
||||
@@ -82,14 +82,12 @@ void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
if ( wellPathAttributeCollection->attributes().empty() )
|
||||
{
|
||||
RimWellPath* wellPath = nullptr;
|
||||
wellPathAttributeCollection->firstAncestorOrThisOfTypeAsserted( wellPath );
|
||||
auto wellPath = wellPathAttributeCollection->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
|
||||
wellPath->updateConnectedEditors();
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( wellPath );
|
||||
}
|
||||
|
||||
RimProject* proj = nullptr;
|
||||
wellPathAttributeCollection->firstAncestorOrThisOfType( proj );
|
||||
RimProject* proj = RimProject::current();
|
||||
if ( proj )
|
||||
{
|
||||
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
|
||||
@@ -51,8 +51,7 @@ void RicDeleteWellPathTargetFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
if ( targets.size() > 0 )
|
||||
{
|
||||
RimWellPathGeometryDef* wellGeomDef = nullptr;
|
||||
targets[0]->firstAncestorOrThisOfTypeAsserted( wellGeomDef );
|
||||
RimWellPathGeometryDef* wellGeomDef = targets[0]->firstAncestorOrThisOfTypeAsserted<RimWellPathGeometryDef>();
|
||||
|
||||
for ( auto target : targets )
|
||||
{
|
||||
|
||||
@@ -68,8 +68,7 @@ void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked )
|
||||
RimGridView* activeView = RiaApplication::instance()->activeGridView();
|
||||
if ( activeView )
|
||||
{
|
||||
std::vector<RimWellMeasurementInViewCollection*> measurementsInView;
|
||||
activeView->descendantsOfType( measurementsInView );
|
||||
auto measurementsInView = activeView->descendantsOfType<RimWellMeasurementInViewCollection>();
|
||||
if ( !measurementsInView.empty() ) measurementsInView.front()->setCheckState( true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ bool RicIntersectionPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& e
|
||||
{
|
||||
RimExtrudedCurveIntersection* intersection = selection[0];
|
||||
|
||||
RimGridView* gridView = nullptr;
|
||||
intersection->firstAncestorOrThisOfTypeAsserted( gridView );
|
||||
RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted<RimGridView>();
|
||||
|
||||
if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView )
|
||||
{
|
||||
|
||||
@@ -17,19 +17,23 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicNewEditableWellPathFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewEditableWellPathFeature, "RicNewEditableWellPathFeature" );
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewEditableWellPathFeature, "RicNewEditableWellPathFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -65,8 +69,7 @@ void RicNewEditableWellPathFeature::onActionTriggered( bool isChecked )
|
||||
RimProject* project = RimProject::current();
|
||||
if ( project && RimProject::current()->activeOilField() )
|
||||
{
|
||||
RimWellPathCollection* wellPathCollection = RimProject::current()->activeOilField()->wellPathCollection();
|
||||
|
||||
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
|
||||
if ( wellPathCollection )
|
||||
{
|
||||
std::vector<RimWellPath*> newWellPaths;
|
||||
|
||||
@@ -65,9 +65,8 @@ void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked )
|
||||
caf::SelectionManager::instance()->objectsByType( &selectedTargets, caf::SelectionManager::FIRST_LEVEL );
|
||||
if ( !selectedTargets.empty() )
|
||||
{
|
||||
auto firstTarget = selectedTargets.front();
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef = nullptr;
|
||||
firstTarget->firstAncestorOrThisOfTypeAsserted( polylineDef );
|
||||
auto firstTarget = selectedTargets.front();
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef = firstTarget->firstAncestorOrThisOfTypeAsserted<RimUserDefinedPolylinesAnnotation>();
|
||||
|
||||
auto afterBeforePair = polylineDef->findActiveTargetsAroundInsertionPoint( firstTarget );
|
||||
|
||||
|
||||
@@ -66,13 +66,11 @@ void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked )
|
||||
RimWellPathAttribute* attribute = nullptr;
|
||||
if ( attributes.size() == 1u )
|
||||
{
|
||||
RimWellPathAttributeCollection* attributeCollection = nullptr;
|
||||
attributes[0]->firstAncestorOrThisOfTypeAsserted( attributeCollection );
|
||||
auto attributeCollection = attributes[0]->firstAncestorOrThisOfTypeAsserted<RimWellPathAttributeCollection>();
|
||||
|
||||
attribute = new RimWellPathAttribute;
|
||||
RimWellPath* wellPath = nullptr;
|
||||
attributeCollection->firstAncestorOrThisOfTypeAsserted( wellPath );
|
||||
attribute = new RimWellPathAttribute;
|
||||
|
||||
auto wellPath = attributeCollection->firstAncestorOrThisOfType<RimWellPath>();
|
||||
attribute->setDepthsFromWellPath( wellPath );
|
||||
attributeCollection->insertAttribute( attributes[0], attribute );
|
||||
|
||||
@@ -83,8 +81,8 @@ void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked )
|
||||
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
|
||||
if ( wellPath )
|
||||
{
|
||||
std::vector<RimWellPathAttributeCollection*> attributeCollections;
|
||||
wellPath->descendantsIncludingThisOfType( attributeCollections );
|
||||
std::vector<RimWellPathAttributeCollection*> attributeCollections =
|
||||
wellPath->descendantsIncludingThisOfType<RimWellPathAttributeCollection>();
|
||||
if ( !attributeCollections.empty() )
|
||||
{
|
||||
attribute = new RimWellPathAttribute;
|
||||
@@ -101,8 +99,7 @@ void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
if ( attribute )
|
||||
{
|
||||
RimProject* project = nullptr;
|
||||
attribute->firstAncestorOrThisOfTypeAsserted( project );
|
||||
RimProject* project = RimProject::current();
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked )
|
||||
if ( selectedTargets.size() > 0 )
|
||||
{
|
||||
RimWellPathTarget* firstTarget = selectedTargets.front();
|
||||
RimWellPathGeometryDef* wellGeomDef = nullptr;
|
||||
firstTarget->firstAncestorOrThisOfTypeAsserted( wellGeomDef );
|
||||
RimWellPathGeometryDef* wellGeomDef = firstTarget->firstAncestorOrThisOfTypeAsserted<RimWellPathGeometryDef>();
|
||||
|
||||
auto afterBeforePair = wellGeomDef->findActiveTargetsAroundInsertionPoint( firstTarget );
|
||||
|
||||
@@ -183,8 +182,7 @@ void RicNewWellPathListTargetFeature::setupActionLook( QAction* actionToSetup )
|
||||
if ( selectedTargets.size() > 0 )
|
||||
{
|
||||
auto firstTarget = selectedTargets.front();
|
||||
RimWellPathGeometryDef* wellGeomDef = nullptr;
|
||||
firstTarget->firstAncestorOrThisOfTypeAsserted( wellGeomDef );
|
||||
RimWellPathGeometryDef* wellGeomDef = firstTarget->firstAncestorOrThisOfTypeAsserted<RimWellPathGeometryDef>();
|
||||
|
||||
auto afterBeforePair = wellGeomDef->findActiveTargetsAroundInsertionPoint( firstTarget );
|
||||
|
||||
|
||||
@@ -67,8 +67,7 @@ void RicPasteModeledWellPathFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
if ( proj && proj->activeOilField() )
|
||||
{
|
||||
RimWellPathCollection* wellPathCollection = proj->activeOilField()->wellPathCollection();
|
||||
|
||||
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
|
||||
if ( wellPathCollection )
|
||||
{
|
||||
RimModeledWellPath* wellPathToSelect = nullptr;
|
||||
@@ -160,8 +159,7 @@ RimModeledWellPath* RicPasteModeledWellPathFeature::duplicateAndInitializeWellPa
|
||||
// Resolve references, will connect to the fracture template
|
||||
destinationWellPath->resolveReferencesRecursively();
|
||||
|
||||
std::vector<RimWellPathFracture*> wellPathFractures;
|
||||
destinationWellPath->descendantsIncludingThisOfType( wellPathFractures );
|
||||
std::vector<RimWellPathFracture*> wellPathFractures = destinationWellPath->descendantsIncludingThisOfType<RimWellPathFracture>();
|
||||
destinationWellPath->createWellPathGeometry();
|
||||
|
||||
for ( auto fracture : wellPathFractures )
|
||||
|
||||
@@ -90,8 +90,7 @@ bool RicWellPathPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& event
|
||||
auto wellPathSourceCandidate = dynamic_cast<const RivWellPathSourceInfo*>( secondPickedPart->sourceInfo() );
|
||||
if ( wellPathSourceCandidate )
|
||||
{
|
||||
RimWellPath* perforationWellPath = nullptr;
|
||||
objectToSelect->firstAncestorOrThisOfType( perforationWellPath );
|
||||
auto perforationWellPath = objectToSelect->firstAncestorOrThisOfType<RimWellPath>();
|
||||
if ( perforationWellPath == wellPathSourceCandidate->wellPath() )
|
||||
{
|
||||
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( secondPickedPart->sourceInfo() );
|
||||
@@ -103,9 +102,8 @@ bool RicWellPathPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& event
|
||||
}
|
||||
else if ( dynamic_cast<RimWellPathValve*>( sourceInfo->object() ) )
|
||||
{
|
||||
objectToSelect = sourceInfo->object();
|
||||
RimWellPath* wellPath = nullptr;
|
||||
objectToSelect->firstAncestorOrThisOfType( wellPath );
|
||||
objectToSelect = sourceInfo->object();
|
||||
auto wellPath = objectToSelect->firstAncestorOrThisOfType<RimWellPath>();
|
||||
|
||||
RimWellPathValve* valve = static_cast<RimWellPathValve*>( sourceInfo->object() );
|
||||
|
||||
@@ -119,12 +117,11 @@ bool RicWellPathPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& event
|
||||
}
|
||||
else if ( dynamic_cast<RimWellPathAttribute*>( sourceInfo->object() ) )
|
||||
{
|
||||
RimWellPath* wellPath = nullptr;
|
||||
RimWellPathAttribute* attribute = static_cast<RimWellPathAttribute*>( sourceInfo->object() );
|
||||
RimWellPathAttributeCollection* collection =
|
||||
attribute->firstAncestorOrThisOfTypeAsserted<RimWellPathAttributeCollection>();
|
||||
|
||||
RimWellPathAttribute* attribute = static_cast<RimWellPathAttribute*>( sourceInfo->object() );
|
||||
RimWellPathAttributeCollection* collection = nullptr;
|
||||
attribute->firstAncestorOrThisOfTypeAsserted( collection );
|
||||
collection->firstAncestorOrThisOfTypeAsserted( wellPath );
|
||||
RimWellPath* wellPath = collection->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
|
||||
|
||||
QString attrText =
|
||||
QString( "Well Path: %1\nCasing Design Attribute: %2" ).arg( wellPath->name() ).arg( attribute->componentLabel() );
|
||||
@@ -134,9 +131,7 @@ bool RicWellPathPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& event
|
||||
}
|
||||
else if ( dynamic_cast<RimWellMeasurement*>( sourceInfo->object() ) )
|
||||
{
|
||||
RimWellMeasurement* measurement = dynamic_cast<RimWellMeasurement*>( sourceInfo->object() );
|
||||
RimWellMeasurementCollection* collection = nullptr;
|
||||
measurement->firstAncestorOrThisOfTypeAsserted( collection );
|
||||
RimWellMeasurement* measurement = dynamic_cast<RimWellMeasurement*>( sourceInfo->object() );
|
||||
|
||||
QString measurementText = QString( "Well path name: %1\n" ).arg( measurement->wellName() );
|
||||
measurementText += QString( "Measured Depth: %1\n" ).arg( measurement->MD() );
|
||||
@@ -164,8 +159,7 @@ bool RicWellPathPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& event
|
||||
if ( rimView )
|
||||
{
|
||||
// Find the RimWellMeasurementInView which matches the selection
|
||||
std::vector<RimWellMeasurementInViewCollection*> wellMeasurementInViewCollections;
|
||||
rimView->descendantsIncludingThisOfType( wellMeasurementInViewCollections );
|
||||
auto wellMeasurementInViewCollections = rimView->descendantsIncludingThisOfType<RimWellMeasurementInViewCollection>();
|
||||
if ( !wellMeasurementInViewCollections.empty() )
|
||||
{
|
||||
RimWellMeasurementInView* wellMeasurementInView =
|
||||
|
||||
Reference in new issue
Block a user