#5125 Make each well measurement a checkable entity.

This commit is contained in:
Kristian Bendiksen
2019-11-29 13:49:43 +01:00
parent ad9c767a36
commit 6efceea597
8 changed files with 389 additions and 178 deletions

View File

@@ -42,6 +42,7 @@
#include "RimWellMeasurement.h" #include "RimWellMeasurement.h"
#include "RimWellMeasurementCollection.h" #include "RimWellMeasurementCollection.h"
#include "RimWellMeasurementFilter.h" #include "RimWellMeasurementFilter.h"
#include "RimWellMeasurementInView.h"
#include "RimWellMeasurementInViewCollection.h" #include "RimWellMeasurementInViewCollection.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathAttribute.h" #include "RimWellPathAttribute.h"
@@ -301,54 +302,61 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList*
if ( !gridView->measurementCollection()->isChecked() ) return; if ( !gridView->measurementCollection()->isChecked() ) return;
std::vector<QString> measurementKinds = gridView->measurementCollection()->measurementKinds(); for ( RimWellMeasurementInView* wellMeasurementInView : gridView->measurementCollection()->measurements() )
RivPipeGeometryGenerator geoGenerator;
std::vector<RimWellMeasurement*> wellMeasurements =
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
*wellPathCollection,
*m_rimWellPath,
measurementKinds );
for ( RimWellMeasurement* wellMeasurement : wellMeasurements )
{ {
double wellPathRadius = this->wellPathRadius( characteristicCellSize, this->wellPathCollection() ); if ( wellMeasurementInView->isChecked() )
double startMD = wellMeasurement->MD() - wellPathRadius * 0.5;
double endMD = wellMeasurement->MD() + wellPathRadius * 0.5;
std::vector<cvf::Vec3d> displayCoords;
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMD ) ) );
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMD ) ) );
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMD ) ) );
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMD ) ) );
std::vector<double> radii;
radii.push_back( wellPathRadius );
radii.push_back( wellPathRadius * 2.5 );
radii.push_back( wellPathRadius * 2.5 );
radii.push_back( wellPathRadius );
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( wellMeasurement );
cvf::Collection<cvf::Part> parts;
cvf::Color3f color = mapWellMeasurementToColor( wellMeasurement->kind(), wellMeasurement->value() );
// Use the view legend config to find color, if only one type of measurement is selected.
if ( measurementKinds.size() == 1 )
{ {
color = cvf::Color3f( gridView->measurementCollection()->legendConfig()->scalarMapper()->mapToColor( std::vector<QString> measurementKinds;
wellMeasurement->value() ) ); measurementKinds.push_back( wellMeasurementInView->measurementKind() );
}
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color ); RivPipeGeometryGenerator geoGenerator;
for ( auto part : parts ) std::vector<RimWellMeasurement*> wellMeasurements =
{ RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
part->setSourceInfo( objectSourceInfo.p() ); *wellPathCollection,
model->addPart( part.p() ); *m_rimWellPath,
measurementKinds );
for ( RimWellMeasurement* wellMeasurement : wellMeasurements )
{
double wellPathRadius = this->wellPathRadius( characteristicCellSize, this->wellPathCollection() );
double startMD = wellMeasurement->MD() - wellPathRadius * 0.5;
double endMD = wellMeasurement->MD() + wellPathRadius * 0.5;
std::vector<cvf::Vec3d> displayCoords;
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMD ) ) );
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMD ) ) );
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMD ) ) );
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMD ) ) );
std::vector<double> radii;
radii.push_back( wellPathRadius );
radii.push_back( wellPathRadius * 2.5 );
radii.push_back( wellPathRadius * 2.5 );
radii.push_back( wellPathRadius );
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( wellMeasurement );
cvf::Collection<cvf::Part> parts;
cvf::Color3f color = mapWellMeasurementToColor( wellMeasurement->kind(), wellMeasurement->value() );
// Use the view legend config to find color, if only one type of measurement is selected.
if ( measurementKinds.size() == 1 )
{
color = cvf::Color3f(
wellMeasurementInView->legendConfig()->scalarMapper()->mapToColor( wellMeasurement->value() ) );
}
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color );
for ( auto part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );
model->addPart( part.p() );
}
}
} }
} }
} }

View File

@@ -146,6 +146,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.h ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.h
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInView.h
) )
@@ -296,6 +297,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInView.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@@ -76,6 +76,7 @@
#include "RimViewLinker.h" #include "RimViewLinker.h"
#include "RimViewNameConfig.h" #include "RimViewNameConfig.h"
#include "RimVirtualPerforationResults.h" #include "RimVirtualPerforationResults.h"
#include "RimWellMeasurementInView.h"
#include "RimWellMeasurementInViewCollection.h" #include "RimWellMeasurementInViewCollection.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
@@ -1308,10 +1309,15 @@ void RimEclipseView::onUpdateLegends()
isUsingOverrideViewer() ); isUsingOverrideViewer() );
} }
if ( m_wellMeasurementCollection->isChecked() && m_wellMeasurementCollection->legendConfig()->showLegend() ) if ( m_wellMeasurementCollection->isChecked() )
{ {
m_wellMeasurementCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
isUsingOverrideViewer() ); {
if ( wellMeasurement->legendConfig()->showLegend() )
{
wellMeasurement->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() );
}
}
} }
} }
@@ -1859,7 +1865,10 @@ void RimEclipseView::onResetLegendsInViewer()
sepInterResDef->ternaryLegendConfig()->recreateLegend(); sepInterResDef->ternaryLegendConfig()->recreateLegend();
} }
m_wellMeasurementCollection->legendConfig()->recreateLegend(); for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
wellMeasurement->legendConfig()->recreateLegend();
}
nativeOrOverrideViewer()->removeAllColorLegends(); nativeOrOverrideViewer()->removeAllColorLegends();
} }
@@ -2019,7 +2028,10 @@ std::vector<RimLegendConfig*> RimEclipseView::legendConfigs() const
absLegends.push_back( sepInterResDef->ternaryLegendConfig() ); absLegends.push_back( sepInterResDef->ternaryLegendConfig() );
} }
absLegends.push_back( m_wellMeasurementCollection->legendConfig() ); for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
absLegends.push_back( wellMeasurement->legendConfig() );
}
return absLegends; return absLegends;
} }

View File

@@ -46,6 +46,7 @@
#include "RimTernaryLegendConfig.h" #include "RimTernaryLegendConfig.h"
#include "RimViewLinker.h" #include "RimViewLinker.h"
#include "RimViewNameConfig.h" #include "RimViewNameConfig.h"
#include "RimWellMeasurementInView.h"
#include "RimWellMeasurementInViewCollection.h" #include "RimWellMeasurementInViewCollection.h"
#include "Riu3DMainWindowTools.h" #include "Riu3DMainWindowTools.h"
@@ -428,7 +429,10 @@ void RimGeoMechView::onResetLegendsInViewer()
sepInterResDef->ternaryLegendConfig()->recreateLegend(); sepInterResDef->ternaryLegendConfig()->recreateLegend();
} }
m_wellMeasurementCollection->legendConfig()->recreateLegend(); for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
wellMeasurement->legendConfig()->recreateLegend();
}
nativeOrOverrideViewer()->removeAllColorLegends(); nativeOrOverrideViewer()->removeAllColorLegends();
} }
@@ -481,10 +485,16 @@ void RimGeoMechView::onUpdateLegends()
} }
} }
if ( m_wellMeasurementCollection->isChecked() && m_wellMeasurementCollection->legendConfig()->showLegend() ) if ( m_wellMeasurementCollection->isChecked() )
{ {
m_wellMeasurementCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
isUsingOverrideViewer() ); {
if ( wellMeasurement->legendConfig()->showLegend() )
{
wellMeasurement->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(),
isUsingOverrideViewer() );
}
}
} }
} }
} }
@@ -587,7 +597,10 @@ std::vector<RimLegendConfig*> RimGeoMechView::legendConfigs() const
absLegendConfigs.push_back( sepInterResDef->regularLegendConfig() ); absLegendConfigs.push_back( sepInterResDef->regularLegendConfig() );
} }
absLegendConfigs.push_back( m_wellMeasurementCollection->legendConfig() ); for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
absLegendConfigs.push_back( wellMeasurement->legendConfig() );
}
return absLegendConfigs; return absLegendConfigs;
} }

View File

@@ -0,0 +1,201 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellMeasurementInView.h"
#include "Rim3dView.h"
#include "RimGridView.h"
#include "RimProject.h"
#include "RimRegularLegendConfig.h"
#include "RimTools.h"
#include "RimWellLogTrack.h"
#include "RimWellMeasurement.h"
#include "RimWellMeasurementCollection.h"
#include "RimWellMeasurementFilter.h"
#include "RimWellPathCollection.h"
#include "RiuViewer.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include <cmath>
CAF_PDM_SOURCE_INIT( RimWellMeasurementInView, "WellMeasurementInView" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellMeasurementInView::RimWellMeasurementInView()
{
CAF_PDM_InitObject( "Well Measurement", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_measurementKind, "MeasurementKind", "Measurement Kind", "", "", "" );
m_measurementKind.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" );
m_legendConfig = new RimRegularLegendConfig();
m_legendConfig.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells", "", "", "" );
m_wells.uiCapability()->setAutoAddingOptionFromValue( false );
m_wells.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
m_wells.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
m_wells.xmlCapability()->disableIO();
this->setName( "Well Measurement" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellMeasurementInView::~RimWellMeasurementInView()
{
delete m_legendConfig;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellMeasurementInView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
QString uiConfigName /*= ""*/ )
{
uiTreeOrdering.add( &m_legendConfig );
uiTreeOrdering.skipRemainingChildren( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellMeasurementInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
updateLegendData();
RimGridView* rimGridView = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimGridView );
rimGridView->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimWellMeasurementInView::legendConfig()
{
return m_legendConfig;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellMeasurementInView::updateLegendData()
{
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( !wellPathCollection ) return false;
RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection();
if ( !wellMeasurementCollection ) return false;
std::vector<QString> selectedMeasurementKinds;
selectedMeasurementKinds.push_back( m_measurementKind );
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 )
{
minValue = std::min( measurement->value(), minValue );
maxValue = std::max( measurement->value(), maxValue );
}
if ( minValue != HUGE_VAL )
{
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;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellMeasurementInView::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer,
bool isUsingOverrideViewer )
{
bool addToViewer = updateLegendData();
if ( addToViewer )
{
nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( m_legendConfig->titledOverlayFrame(),
isUsingOverrideViewer );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimWellMeasurementInView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_wells )
{
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( wellPathCollection )
{
// std::vector<RimWellMeasurement*> measurements = wellPathCollection->measurementCollection()->measurements();
std::set<QString> wellsWithMeasurementKind;
for ( auto well : wellPathCollection->wellPaths )
{
wellsWithMeasurementKind.insert( well->name() );
}
for ( auto wellName : wellsWithMeasurementKind )
{
options.push_back( caf::PdmOptionItemInfo( wellName, wellName ) );
}
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellMeasurementInView::measurementKind() const
{
return m_measurementKind;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellMeasurementInView::setMeasurementKind( const QString& measurementKind )
{
m_measurementKind = measurementKind;
}

View File

@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimCheckableNamedObject.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include <vector>
class RimWellMeasurement;
class RimRegularLegendConfig;
class RiuViewer;
class RimWellMeasurementInView : public RimCheckableNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimWellMeasurementInView();
~RimWellMeasurementInView() override;
RimRegularLegendConfig* legendConfig();
QString measurementKind() const;
void setMeasurementKind( const QString& measurementKind );
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly );
bool updateLegendData();
private:
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
caf::PdmField<QString> m_measurementKind;
caf::PdmField<std::vector<QString>> m_wells;
};

View File

@@ -26,10 +26,9 @@
#include "RimWellMeasurement.h" #include "RimWellMeasurement.h"
#include "RimWellMeasurementCollection.h" #include "RimWellMeasurementCollection.h"
#include "RimWellMeasurementFilter.h" #include "RimWellMeasurementFilter.h"
#include "RimWellMeasurementInView.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RiuViewer.h"
#include "cafCmdFeatureMenuBuilder.h" #include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiTableViewEditor.h" #include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTreeOrdering.h" #include "cafPdmUiTreeOrdering.h"
@@ -44,17 +43,10 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementInViewCollection, "WellMeasurementsInView
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection() RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection()
{ {
CAF_PDM_InitObject( "Well Measurement", "", "", "" ); CAF_PDM_InitObject( "Well Measurements", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_measurementsInView, "MeasurementKinds", "Measurement Kinds", "", "", "" );
m_legendConfig = new RimRegularLegendConfig(); m_measurementsInView.uiCapability()->setUiHidden( true );
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();
this->setName( "Well Measurements" ); 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, void RimWellMeasurementInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
QString uiConfigName /*= ""*/ ) QString uiConfigName /*= ""*/ )
{ {
uiTreeOrdering.add( &m_legendConfig ); uiTreeOrdering.add( &m_measurementsInView );
uiTreeOrdering.skipRemainingChildren( true ); uiTreeOrdering.skipRemainingChildren( true );
} }
@@ -84,7 +89,6 @@ void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHa
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) const QVariant& newValue )
{ {
updateLegendData();
RimGridView* rimGridView = nullptr; RimGridView* rimGridView = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimGridView ); this->firstAncestorOrThisOfTypeAsserted( rimGridView );
rimGridView->scheduleCreateDisplayModelAndRedraw(); rimGridView->scheduleCreateDisplayModelAndRedraw();
@@ -93,103 +97,25 @@ void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHa
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimWellMeasurementInViewCollection::legendConfig() void RimWellMeasurementInViewCollection::initAfterRead()
{
return m_legendConfig;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellMeasurementInViewCollection::updateLegendData()
{ {
// TODO: Need a better solution for this!!!
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( !wellPathCollection ) return false; if ( wellPathCollection )
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 )
{ {
std::vector<RimWellMeasurement*> wellMeasurements = const RimWellMeasurementCollection* measurementCollection = wellPathCollection->measurementCollection();
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(), std::set<QString> measurementKinds;
selectedMeasurementKinds ); for ( RimWellMeasurement* wellMeasurement : measurementCollection->measurements() )
double minValue = HUGE_VAL;
double maxValue = -HUGE_VAL;
double posClosestToZero = HUGE_VAL;
double negClosestToZero = -HUGE_VAL;
for ( auto& measurement : wellMeasurements )
{ {
minValue = std::min( measurement->value(), minValue ); measurementKinds.insert( wellMeasurement->kind() );
maxValue = std::max( measurement->value(), maxValue );
} }
if ( minValue != HUGE_VAL ) for ( QString kind : measurementKinds )
{ {
m_legendConfig->setTitle( QString( "Well Measurement: \n" ) + selectedMeasurementKinds[0] ); RimWellMeasurementInView* measurementInView = new RimWellMeasurementInView;
m_legendConfig->setAutomaticRanges( minValue, maxValue, minValue, maxValue ); measurementInView->setName( kind );
m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero ); measurementInView->setMeasurementKind( kind );
return true; 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;
} }

View File

@@ -20,16 +20,10 @@
#include "RimCheckableNamedObject.h" #include "RimCheckableNamedObject.h"
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include <vector> #include <vector>
class RimWellMeasurement; class RimWellMeasurementInView;
class RimRegularLegendConfig;
class RiuViewer;
class RimWellMeasurementInViewCollection : public RimCheckableNamedObject class RimWellMeasurementInViewCollection : public RimCheckableNamedObject
{ {
@@ -39,22 +33,15 @@ public:
RimWellMeasurementInViewCollection(); RimWellMeasurementInViewCollection();
~RimWellMeasurementInViewCollection() override; ~RimWellMeasurementInViewCollection() override;
RimRegularLegendConfig* legendConfig(); std::vector<RimWellMeasurementInView*> measurements() const;
std::vector<QString> measurementKinds() const;
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
protected: protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) override; const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, void initAfterRead();
bool* useOptionsOnly );
bool updateLegendData();
private: private:
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig; caf::PdmChildArrayField<RimWellMeasurementInView*> m_measurementsInView;
caf::PdmField<std::vector<QString>> m_measurementKinds;
}; };