mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5125 Make each well measurement a checkable entity.
This commit is contained in:
@@ -26,10 +26,9 @@
|
||||
#include "RimWellMeasurement.h"
|
||||
#include "RimWellMeasurementCollection.h"
|
||||
#include "RimWellMeasurementFilter.h"
|
||||
#include "RimWellMeasurementInView.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
@@ -44,17 +43,10 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementInViewCollection, "WellMeasurementsInView
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection()
|
||||
{
|
||||
CAF_PDM_InitObject( "Well Measurement", "", "", "" );
|
||||
CAF_PDM_InitObject( "Well Measurements", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" );
|
||||
m_legendConfig = new RimRegularLegendConfig();
|
||||
m_legendConfig.uiCapability()->setUiHidden( 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();
|
||||
CAF_PDM_InitFieldNoDefault( &m_measurementsInView, "MeasurementKinds", "Measurement Kinds", "", "", "" );
|
||||
m_measurementsInView.uiCapability()->setUiHidden( true );
|
||||
|
||||
this->setName( "Well Measurements" );
|
||||
}
|
||||
@@ -62,18 +54,31 @@ RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellMeasurementInViewCollection::~RimWellMeasurementInViewCollection()
|
||||
RimWellMeasurementInViewCollection::~RimWellMeasurementInViewCollection() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellMeasurementInView*> RimWellMeasurementInViewCollection::measurements() const
|
||||
{
|
||||
delete m_legendConfig;
|
||||
std::vector<RimWellMeasurementInView*> attrs;
|
||||
|
||||
for ( auto attr : m_measurementsInView )
|
||||
{
|
||||
attrs.push_back( attr.p() );
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
|
||||
QString uiConfigName /*= ""*/ )
|
||||
{
|
||||
uiTreeOrdering.add( &m_legendConfig );
|
||||
uiTreeOrdering.add( &m_measurementsInView );
|
||||
uiTreeOrdering.skipRemainingChildren( true );
|
||||
}
|
||||
|
||||
@@ -84,7 +89,6 @@ void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHa
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
updateLegendData();
|
||||
RimGridView* rimGridView = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( rimGridView );
|
||||
rimGridView->scheduleCreateDisplayModelAndRedraw();
|
||||
@@ -93,103 +97,25 @@ void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHa
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRegularLegendConfig* RimWellMeasurementInViewCollection::legendConfig()
|
||||
{
|
||||
return m_legendConfig;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellMeasurementInViewCollection::updateLegendData()
|
||||
void RimWellMeasurementInViewCollection::initAfterRead()
|
||||
{
|
||||
// TODO: Need a better solution for this!!!
|
||||
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
|
||||
if ( !wellPathCollection ) return false;
|
||||
|
||||
RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection();
|
||||
if ( !wellMeasurementCollection ) return false;
|
||||
|
||||
std::vector<QString> selectedMeasurementKinds = measurementKinds();
|
||||
|
||||
// Only show legend when only one measurement is selected
|
||||
if ( selectedMeasurementKinds.size() == 1 )
|
||||
if ( wellPathCollection )
|
||||
{
|
||||
std::vector<RimWellMeasurement*> wellMeasurements =
|
||||
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
|
||||
selectedMeasurementKinds );
|
||||
|
||||
double minValue = HUGE_VAL;
|
||||
double maxValue = -HUGE_VAL;
|
||||
double posClosestToZero = HUGE_VAL;
|
||||
double negClosestToZero = -HUGE_VAL;
|
||||
|
||||
for ( auto& measurement : wellMeasurements )
|
||||
const RimWellMeasurementCollection* measurementCollection = wellPathCollection->measurementCollection();
|
||||
std::set<QString> measurementKinds;
|
||||
for ( RimWellMeasurement* wellMeasurement : measurementCollection->measurements() )
|
||||
{
|
||||
minValue = std::min( measurement->value(), minValue );
|
||||
maxValue = std::max( measurement->value(), maxValue );
|
||||
measurementKinds.insert( wellMeasurement->kind() );
|
||||
}
|
||||
|
||||
if ( minValue != HUGE_VAL )
|
||||
for ( QString kind : measurementKinds )
|
||||
{
|
||||
m_legendConfig->setTitle( QString( "Well Measurement: \n" ) + selectedMeasurementKinds[0] );
|
||||
m_legendConfig->setAutomaticRanges( minValue, maxValue, minValue, maxValue );
|
||||
m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero );
|
||||
return true;
|
||||
RimWellMeasurementInView* measurementInView = new RimWellMeasurementInView;
|
||||
measurementInView->setName( kind );
|
||||
measurementInView->setMeasurementKind( kind );
|
||||
m_measurementsInView.push_back( measurementInView );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementInViewCollection::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer,
|
||||
bool isUsingOverrideViewer )
|
||||
{
|
||||
bool addToViewer = updateLegendData();
|
||||
if ( addToViewer )
|
||||
{
|
||||
nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( m_legendConfig->titledOverlayFrame(),
|
||||
isUsingOverrideViewer );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RimWellMeasurementInViewCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
if ( fieldNeedingOptions == &m_measurementKinds )
|
||||
{
|
||||
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
|
||||
if ( wellPathCollection )
|
||||
{
|
||||
std::vector<RimWellMeasurement*> measurements = wellPathCollection->measurementCollection()->measurements();
|
||||
|
||||
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> RimWellMeasurementInViewCollection::measurementKinds() const
|
||||
{
|
||||
return m_measurementKinds;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user