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:
Magne Sjaastad
2023-05-12 21:41:34 +02:00
committed by GitHub
parent 37e29a0f68
commit 0c90f67dcc
510 changed files with 1651 additions and 3111 deletions

View File

@@ -26,6 +26,7 @@
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
@@ -36,19 +37,8 @@ CAF_CMD_SOURCE_INIT( RicNewCorrelationPlotFeature, "RicNewCorrelationPlotFeature
//--------------------------------------------------------------------------------------------------
bool RicNewCorrelationPlotFeature::isCommandEnabled()
{
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
RimSummaryPlot* summaryPlot = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
selObj->firstAncestorOrThisOfType( summaryPlot );
}
if ( correlationPlotColl ) return true;
if ( summaryPlot ) return true;
if ( caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>() ) return true;
if ( caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>() ) return true;
return false;
}
@@ -58,13 +48,7 @@ bool RicNewCorrelationPlotFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked )
{
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
}
RimCorrelationPlotCollection* correlationPlotColl = caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>();
RimCorrelationPlot* newPlot = nullptr;
if ( !correlationPlotColl )
@@ -72,8 +56,7 @@ void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked )
QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
{
std::vector<RimCorrelationPlotCollection*> correlationPlotCollections;
RimProject::current()->descendantsOfType( correlationPlotCollections );
auto correlationPlotCollections = RimProject::current()->descendantsOfType<RimCorrelationPlotCollection>();
CAF_ASSERT( !correlationPlotCollections.empty() );
correlationPlotColl = correlationPlotCollections.front();