From 4fb0542946bba9648a70858563a968287d242a06 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 4 Dec 2019 10:41:44 +0100 Subject: [PATCH] #5125 Well measurements : Select all wells by default --- .../RimWellMeasurementInView.cpp | 30 +++++++++++++++++-- .../RimWellMeasurementInView.h | 4 ++- .../RimWellMeasurementInViewCollection.cpp | 4 +++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp b/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp index 05bfb13463..010a51b949 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp @@ -15,6 +15,7 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// + #include "RimWellMeasurementInView.h" #include "Rim3dView.h" @@ -205,13 +206,13 @@ QList // Find wells with a given measurement. std::set wellsWithMeasurementKind; - for ( auto well : wellPathCollection->wellPaths ) + for ( const auto& well : wellPathCollection->wellPaths ) { if ( hasMeasurementKindForWell( well, wellPathCollection, measurements, m_measurementKind ) ) wellsWithMeasurementKind.insert( well->name() ); } - for ( auto wellName : wellsWithMeasurementKind ) + for ( const auto& wellName : wellsWithMeasurementKind ) { options.push_back( caf::PdmOptionItemInfo( wellName, wellName ) ); } @@ -252,3 +253,28 @@ bool RimWellMeasurementInView::isWellChecked( const QString& wellName ) const { return std::find( m_wells.v().begin(), m_wells.v().end(), wellName ) != m_wells.v().end(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellMeasurementInView::setAllWellsSelected() +{ + RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); + if ( wellPathCollection ) + { + std::vector measurements = wellPathCollection->measurementCollection()->measurements(); + + // Find wells with a given measurement. + std::set wellsWithMeasurementKind; + for ( const auto& well : wellPathCollection->wellPaths ) + { + if ( hasMeasurementKindForWell( well, wellPathCollection, measurements, m_measurementKind ) ) + wellsWithMeasurementKind.insert( well->name() ); + } + + for ( const auto& wellName : wellsWithMeasurementKind ) + { + m_wells.v().push_back( wellName ); + } + } +} diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h b/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h index 06fcc4cd8f..7eb4e3e8ac 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h @@ -45,6 +45,7 @@ public: QString measurementKind() const; void setMeasurementKind( const QString& measurementKind ); bool isWellChecked( const QString& wellName ) const; + void setAllWellsSelected(); void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer ); @@ -55,8 +56,9 @@ protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ); + bool* useOptionsOnly ) override; bool updateLegendData(); static bool hasMeasurementKindForWell( const RimWellPath* wellPath, diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp index 57c7d3cfae..252e82d0b8 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp @@ -48,6 +48,8 @@ RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection() CAF_PDM_InitFieldNoDefault( &m_measurementsInView, "MeasurementKinds", "Measurement Kinds", "", "", "" ); m_measurementsInView.uiCapability()->setUiHidden( true ); + m_isChecked = false; + this->setName( "Well Measurements" ); } @@ -132,6 +134,8 @@ void RimWellMeasurementInViewCollection::syncWithChangesInWellMeasurementCollect RimWellMeasurementInView* measurementInView = new RimWellMeasurementInView; measurementInView->setName( kind ); measurementInView->setMeasurementKind( kind ); + measurementInView->setAllWellsSelected(); + m_measurementsInView.push_back( measurementInView ); }