mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5217 Add filtering for well measurement.
This commit is contained in:
parent
492ec395c0
commit
2a0ba626d7
@ -283,13 +283,18 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList*
|
||||
std::vector<QString> measurementKinds;
|
||||
measurementKinds.push_back( wellMeasurementInView->measurementKind() );
|
||||
|
||||
RivPipeGeometryGenerator geoGenerator;
|
||||
double lowerBound = 0.0;
|
||||
double upperBound = 0.0;
|
||||
wellMeasurementInView->rangeValues( &lowerBound, &upperBound );
|
||||
std::vector<RimWellMeasurement*> wellMeasurements =
|
||||
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
|
||||
*wellPathCollection,
|
||||
*m_rimWellPath,
|
||||
measurementKinds );
|
||||
measurementKinds,
|
||||
lowerBound,
|
||||
upperBound );
|
||||
|
||||
RivPipeGeometryGenerator geoGenerator;
|
||||
for ( RimWellMeasurement* wellMeasurement : wellMeasurements )
|
||||
{
|
||||
double wellPathRadius = this->wellPathRadius( characteristicCellSize, this->wellPathCollection() );
|
||||
|
@ -17,6 +17,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RimWellMeasurementFilter.h"
|
||||
|
||||
#include "cvfMath.h"
|
||||
|
||||
#include "RimWellMeasurement.h"
|
||||
#include "RimWellMeasurementCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
@ -31,11 +33,10 @@ std::vector<RimWellMeasurement*>
|
||||
const RimWellPath& wellPath,
|
||||
const std::vector<QString>& measurementKinds )
|
||||
{
|
||||
std::vector<RimWellMeasurement*> filteredMeasurements;
|
||||
std::vector<RimWellMeasurement*> filteredMeasurementsByKinds = filterMeasurements( measurements, measurementKinds );
|
||||
|
||||
for ( auto& measurement : measurements )
|
||||
{
|
||||
if ( std::find( measurementKinds.begin(), measurementKinds.end(), measurement->kind() ) != measurementKinds.end() )
|
||||
std::vector<RimWellMeasurement*> filteredMeasurements;
|
||||
for ( auto& measurement : filteredMeasurementsByKinds )
|
||||
{
|
||||
RimWellPath* matchedWellPath = wellPathCollection.tryFindMatchingWellPath( measurement->wellName() );
|
||||
if ( matchedWellPath && matchedWellPath == &wellPath )
|
||||
@ -43,11 +44,41 @@ std::vector<RimWellMeasurement*>
|
||||
filteredMeasurements.push_back( measurement );
|
||||
}
|
||||
}
|
||||
|
||||
return filteredMeasurements;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellMeasurement*>
|
||||
RimWellMeasurementFilter::filterMeasurements( const std::vector<RimWellMeasurement*>& measurements,
|
||||
const RimWellPathCollection& wellPathCollection,
|
||||
const RimWellPath& wellPath,
|
||||
const std::vector<QString>& measurementKinds,
|
||||
double lowerBound,
|
||||
double upperBound )
|
||||
{
|
||||
std::vector<RimWellMeasurement*> filteredMeasurementsByKindsAndWellPath = filterMeasurements( measurements,
|
||||
wellPathCollection,
|
||||
wellPath,
|
||||
measurementKinds );
|
||||
|
||||
std::vector<RimWellMeasurement*> filteredMeasurements;
|
||||
for ( auto& measurement : filteredMeasurementsByKindsAndWellPath )
|
||||
{
|
||||
if ( RimWellMeasurementFilter::isInsideRange( measurement->value(), lowerBound, upperBound ) )
|
||||
{
|
||||
filteredMeasurements.push_back( measurement );
|
||||
}
|
||||
}
|
||||
|
||||
return filteredMeasurements;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellMeasurement*>
|
||||
RimWellMeasurementFilter::filterMeasurements( const std::vector<RimWellMeasurement*>& measurements,
|
||||
const std::vector<QString>& measurementKinds )
|
||||
@ -64,3 +95,22 @@ std::vector<RimWellMeasurement*>
|
||||
|
||||
return filteredMeasurements;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellMeasurementFilter::isInsideRange( double value, double lowerBound, double upperBound )
|
||||
{
|
||||
// Invalid range: everything is inside
|
||||
if ( lowerBound == cvf::UNDEFINED_DOUBLE || cvf::UNDEFINED_DOUBLE == upperBound )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( lowerBound <= value && value <= upperBound )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -32,9 +32,19 @@ public:
|
||||
const RimWellPathCollection& wellPathCollection,
|
||||
const RimWellPath& rimWellPath,
|
||||
const std::vector<QString>& measurementKinds );
|
||||
|
||||
static std::vector<RimWellMeasurement*> filterMeasurements( const std::vector<RimWellMeasurement*>& measurements,
|
||||
const RimWellPathCollection& wellPathCollection,
|
||||
const RimWellPath& rimWellPath,
|
||||
const std::vector<QString>& measurementKinds,
|
||||
double lowerBound,
|
||||
double upperBound );
|
||||
|
||||
static std::vector<RimWellMeasurement*> filterMeasurements( const std::vector<RimWellMeasurement*>& measurements,
|
||||
const std::vector<QString>& measurementKinds );
|
||||
|
||||
private:
|
||||
RimWellMeasurementFilter();
|
||||
|
||||
static bool isInsideRange( double value, double lowerBound, double upperBound );
|
||||
};
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmUiDoubleSliderEditor.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
@ -57,9 +58,17 @@ RimWellMeasurementInView::RimWellMeasurementInView()
|
||||
CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells", "", "", "" );
|
||||
m_wells.uiCapability()->setAutoAddingOptionFromValue( false );
|
||||
m_wells.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
m_wells.xmlCapability()->disableIO();
|
||||
|
||||
CAF_PDM_InitField( &m_lowerBound, "LowerBound", -HUGE_VAL, "Min", "", "", "" );
|
||||
m_lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitField( &m_upperBound, "UpperBound", HUGE_VAL, "Max", "", "", "" );
|
||||
m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
|
||||
|
||||
this->setName( "Well Measurement" );
|
||||
|
||||
m_minimumResultValue = cvf::UNDEFINED_DOUBLE;
|
||||
m_maximumResultValue = cvf::UNDEFINED_DOUBLE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -80,6 +89,49 @@ void RimWellMeasurementInView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiT
|
||||
uiTreeOrdering.skipRemainingChildren( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
RimCheckableNamedObject::defineUiOrdering( uiConfigName, uiOrdering );
|
||||
uiOrdering.add( &m_wells );
|
||||
|
||||
if ( !hasCategoryResult() )
|
||||
{
|
||||
caf::PdmUiGroup& filterGroup = *( uiOrdering.addNewGroup( "Value Filter Settings" ) );
|
||||
filterGroup.add( &m_lowerBound );
|
||||
filterGroup.add( &m_upperBound );
|
||||
}
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementInView::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( field == &m_lowerBound || field == &m_upperBound )
|
||||
{
|
||||
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
|
||||
if ( !myAttr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myAttr->m_minimum = m_minimumResultValue;
|
||||
myAttr->m_maximum = m_maximumResultValue;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -93,6 +145,15 @@ void RimWellMeasurementInView::fieldChangedByUi( const caf::PdmFieldHandle* chan
|
||||
rimGridView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementInView::rangeValues( double* lowerBound, double* upperBound ) const
|
||||
{
|
||||
*lowerBound = m_lowerBound;
|
||||
*upperBound = m_upperBound;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -130,21 +191,38 @@ bool RimWellMeasurementInView::updateLegendData()
|
||||
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
|
||||
selectedMeasurementKinds );
|
||||
|
||||
double minValue = HUGE_VAL;
|
||||
double maxValue = -HUGE_VAL;
|
||||
double oldMinimumResultValue = m_minimumResultValue;
|
||||
double oldMaximumResultValue = m_maximumResultValue;
|
||||
|
||||
m_minimumResultValue = HUGE_VAL;
|
||||
m_maximumResultValue = -HUGE_VAL;
|
||||
double posClosestToZero = HUGE_VAL;
|
||||
double negClosestToZero = -HUGE_VAL;
|
||||
|
||||
for ( auto& measurement : wellMeasurements )
|
||||
{
|
||||
minValue = std::min( measurement->value(), minValue );
|
||||
maxValue = std::max( measurement->value(), maxValue );
|
||||
m_minimumResultValue = std::min( measurement->value(), m_minimumResultValue );
|
||||
m_maximumResultValue = std::max( measurement->value(), m_maximumResultValue );
|
||||
}
|
||||
|
||||
if ( minValue != HUGE_VAL )
|
||||
if ( m_minimumResultValue != HUGE_VAL )
|
||||
{
|
||||
// Refresh filter slider if lower or upper boundary was undefined
|
||||
if ( std::isinf( m_lowerBound ) )
|
||||
{
|
||||
m_lowerBound = m_minimumResultValue;
|
||||
}
|
||||
|
||||
if ( std::isinf( m_upperBound ) )
|
||||
{
|
||||
m_upperBound = m_maximumResultValue;
|
||||
}
|
||||
|
||||
m_legendConfig->setTitle( QString( "Well Measurement: \n" ) + selectedMeasurementKinds[0] );
|
||||
m_legendConfig->setAutomaticRanges( minValue, maxValue, minValue, maxValue );
|
||||
m_legendConfig->setAutomaticRanges( m_minimumResultValue,
|
||||
m_maximumResultValue,
|
||||
m_minimumResultValue,
|
||||
m_maximumResultValue );
|
||||
m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero );
|
||||
return true;
|
||||
}
|
||||
|
@ -51,8 +51,15 @@ public:
|
||||
|
||||
bool hasCategoryResult() const;
|
||||
|
||||
void rangeValues( double* lowerBound, double* upperBound ) const;
|
||||
|
||||
protected:
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
@ -70,4 +77,9 @@ private:
|
||||
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
|
||||
caf::PdmField<QString> m_measurementKind;
|
||||
caf::PdmField<std::vector<QString>> m_wells;
|
||||
caf::PdmField<double> m_lowerBound;
|
||||
caf::PdmField<double> m_upperBound;
|
||||
|
||||
double m_minimumResultValue;
|
||||
double m_maximumResultValue;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user