mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5001 Improve filtering of measurement collection.
This commit is contained in:
@@ -294,11 +294,16 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList*
|
||||
RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection();
|
||||
if ( !wellMeasurementCollection ) return;
|
||||
|
||||
if ( !wellMeasurementCollection->isChecked() ) return;
|
||||
|
||||
std::vector<QString> measurementKinds = wellMeasurementCollection->measurementKinds();
|
||||
|
||||
RivPipeGeometryGenerator geoGenerator;
|
||||
std::vector<RimWellMeasurement*> wellMeasurements =
|
||||
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
|
||||
*wellPathCollection,
|
||||
*m_rimWellPath );
|
||||
*m_rimWellPath,
|
||||
measurementKinds );
|
||||
|
||||
for ( RimWellMeasurement* wellMeasurement : wellMeasurements )
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimWellMeasurementCollection, "WellMeasurements" );
|
||||
|
||||
@@ -38,6 +39,13 @@ RimWellMeasurementCollection::RimWellMeasurementCollection()
|
||||
m_measurements.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
|
||||
m_measurements.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
|
||||
m_measurements.uiCapability()->setCustomContextMenuEnabled( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_measurementKinds, "MeasurementKinds", "Measurent Kinds", "", "", "" );
|
||||
m_measurementKinds.uiCapability()->setAutoAddingOptionFromValue( false );
|
||||
m_measurementKinds.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
m_measurementKinds.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
m_measurementKinds.xmlCapability()->disableIO();
|
||||
|
||||
this->setName( "Well Measurements" );
|
||||
}
|
||||
|
||||
@@ -177,7 +185,7 @@ void RimWellMeasurementCollection::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_isChecked )
|
||||
if ( changedField == &m_isChecked || changedField == &m_measurementKinds )
|
||||
{
|
||||
RimProject* proj;
|
||||
this->firstAncestorOrThisOfTypeAsserted( proj );
|
||||
@@ -185,3 +193,33 @@ void RimWellMeasurementCollection::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
this->updateAllReferringTracks();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RimWellMeasurementCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
if ( fieldNeedingOptions == &m_measurementKinds )
|
||||
{
|
||||
std::set<QString> measurementKindsInData;
|
||||
for ( auto measurement : measurements() )
|
||||
{
|
||||
measurementKindsInData.insert( measurement->kind() );
|
||||
}
|
||||
|
||||
for ( auto measurementKind : measurementKindsInData )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( measurementKind, measurementKind ) );
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
std::vector<QString> RimWellMeasurementCollection::measurementKinds() const
|
||||
{
|
||||
return m_measurementKinds;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
|
||||
class RimWellMeasurement;
|
||||
|
||||
@@ -34,6 +35,7 @@ public:
|
||||
~RimWellMeasurementCollection() override;
|
||||
|
||||
std::vector<RimWellMeasurement*> measurements() const;
|
||||
std::vector<QString> measurementKinds() const;
|
||||
|
||||
void updateAllReferringTracks();
|
||||
void insertMeasurement( RimWellMeasurement* insertBefore, RimWellMeasurement* measurement );
|
||||
@@ -53,7 +55,10 @@ protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly );
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimWellMeasurement*> m_measurements;
|
||||
caf::PdmField<std::vector<QString>> m_measurementKinds;
|
||||
};
|
||||
|
||||
@@ -87,10 +87,13 @@ void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot )
|
||||
{
|
||||
const RimWellMeasurementCollection* measurementCollection = wellPathCollection->measurementCollection();
|
||||
|
||||
std::vector<QString> measurementKinds = measurementCollection->measurementKinds();
|
||||
|
||||
std::vector<RimWellMeasurement*> measurements =
|
||||
RimWellMeasurementFilter::filterMeasurements( measurementCollection->measurements(),
|
||||
*wellPathCollection,
|
||||
*m_wellPath );
|
||||
*m_wellPath,
|
||||
measurementKinds );
|
||||
|
||||
// Extract the values for this measurement kind
|
||||
std::vector<double> values;
|
||||
|
||||
@@ -28,16 +28,20 @@
|
||||
std::vector<RimWellMeasurement*>
|
||||
RimWellMeasurementFilter::filterMeasurements( const std::vector<RimWellMeasurement*>& measurements,
|
||||
const RimWellPathCollection& wellPathCollection,
|
||||
const RimWellPath& wellPath )
|
||||
const RimWellPath& wellPath,
|
||||
const std::vector<QString>& measurementKinds )
|
||||
{
|
||||
std::vector<RimWellMeasurement*> filteredMeasurements;
|
||||
|
||||
for ( auto& measurement : measurements )
|
||||
{
|
||||
RimWellPath* matchedWellPath = wellPathCollection.tryFindMatchingWellPath( measurement->wellName() );
|
||||
if ( matchedWellPath && matchedWellPath == &wellPath )
|
||||
if ( std::find( measurementKinds.begin(), measurementKinds.end(), measurement->kind() ) != measurementKinds.end() )
|
||||
{
|
||||
filteredMeasurements.push_back( measurement );
|
||||
RimWellPath* matchedWellPath = wellPathCollection.tryFindMatchingWellPath( measurement->wellName() );
|
||||
if ( matchedWellPath && matchedWellPath == &wellPath )
|
||||
{
|
||||
filteredMeasurements.push_back( measurement );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,15 @@ class RimWellPath;
|
||||
class RimWellMeasurement;
|
||||
class RimWellPathCollection;
|
||||
|
||||
class QString;
|
||||
|
||||
class RimWellMeasurementFilter
|
||||
{
|
||||
public:
|
||||
static std::vector<RimWellMeasurement*> filterMeasurements( const std::vector<RimWellMeasurement*>& measurements,
|
||||
const RimWellPathCollection& wellPathCollection,
|
||||
const RimWellPath& rimWellPath );
|
||||
const RimWellPath& rimWellPath,
|
||||
const std::vector<QString>& measurementKinds );
|
||||
|
||||
private:
|
||||
RimWellMeasurementFilter();
|
||||
|
||||
Reference in New Issue
Block a user