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:
parent
ad9c767a36
commit
6efceea597
@ -42,6 +42,7 @@
|
||||
#include "RimWellMeasurement.h"
|
||||
#include "RimWellMeasurementCollection.h"
|
||||
#include "RimWellMeasurementFilter.h"
|
||||
#include "RimWellMeasurementInView.h"
|
||||
#include "RimWellMeasurementInViewCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathAttribute.h"
|
||||
@ -301,54 +302,61 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList*
|
||||
|
||||
if ( !gridView->measurementCollection()->isChecked() ) return;
|
||||
|
||||
std::vector<QString> measurementKinds = gridView->measurementCollection()->measurementKinds();
|
||||
|
||||
RivPipeGeometryGenerator geoGenerator;
|
||||
std::vector<RimWellMeasurement*> wellMeasurements =
|
||||
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
|
||||
*wellPathCollection,
|
||||
*m_rimWellPath,
|
||||
measurementKinds );
|
||||
|
||||
for ( RimWellMeasurement* wellMeasurement : wellMeasurements )
|
||||
for ( RimWellMeasurementInView* wellMeasurementInView : gridView->measurementCollection()->measurements() )
|
||||
{
|
||||
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 )
|
||||
if ( wellMeasurementInView->isChecked() )
|
||||
{
|
||||
color = cvf::Color3f( gridView->measurementCollection()->legendConfig()->scalarMapper()->mapToColor(
|
||||
wellMeasurement->value() ) );
|
||||
}
|
||||
std::vector<QString> measurementKinds;
|
||||
measurementKinds.push_back( wellMeasurementInView->measurementKind() );
|
||||
|
||||
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color );
|
||||
for ( auto part : parts )
|
||||
{
|
||||
part->setSourceInfo( objectSourceInfo.p() );
|
||||
model->addPart( part.p() );
|
||||
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() );
|
||||
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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.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}/RimWellMeasurementFilter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInView.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -76,6 +76,7 @@
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewNameConfig.h"
|
||||
#include "RimVirtualPerforationResults.h"
|
||||
#include "RimWellMeasurementInView.h"
|
||||
#include "RimWellMeasurementInViewCollection.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
@ -1308,10 +1309,15 @@ void RimEclipseView::onUpdateLegends()
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
|
||||
if ( m_wellMeasurementCollection->isChecked() && m_wellMeasurementCollection->legendConfig()->showLegend() )
|
||||
if ( m_wellMeasurementCollection->isChecked() )
|
||||
{
|
||||
m_wellMeasurementCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(),
|
||||
isUsingOverrideViewer() );
|
||||
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
|
||||
{
|
||||
if ( wellMeasurement->legendConfig()->showLegend() )
|
||||
{
|
||||
wellMeasurement->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1859,7 +1865,10 @@ void RimEclipseView::onResetLegendsInViewer()
|
||||
sepInterResDef->ternaryLegendConfig()->recreateLegend();
|
||||
}
|
||||
|
||||
m_wellMeasurementCollection->legendConfig()->recreateLegend();
|
||||
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
|
||||
{
|
||||
wellMeasurement->legendConfig()->recreateLegend();
|
||||
}
|
||||
|
||||
nativeOrOverrideViewer()->removeAllColorLegends();
|
||||
}
|
||||
@ -2019,7 +2028,10 @@ std::vector<RimLegendConfig*> RimEclipseView::legendConfigs() const
|
||||
absLegends.push_back( sepInterResDef->ternaryLegendConfig() );
|
||||
}
|
||||
|
||||
absLegends.push_back( m_wellMeasurementCollection->legendConfig() );
|
||||
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
|
||||
{
|
||||
absLegends.push_back( wellMeasurement->legendConfig() );
|
||||
}
|
||||
|
||||
return absLegends;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewNameConfig.h"
|
||||
#include "RimWellMeasurementInView.h"
|
||||
#include "RimWellMeasurementInViewCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
@ -428,7 +429,10 @@ void RimGeoMechView::onResetLegendsInViewer()
|
||||
sepInterResDef->ternaryLegendConfig()->recreateLegend();
|
||||
}
|
||||
|
||||
m_wellMeasurementCollection->legendConfig()->recreateLegend();
|
||||
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
|
||||
{
|
||||
wellMeasurement->legendConfig()->recreateLegend();
|
||||
}
|
||||
|
||||
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(),
|
||||
isUsingOverrideViewer() );
|
||||
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
|
||||
{
|
||||
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( m_wellMeasurementCollection->legendConfig() );
|
||||
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
|
||||
{
|
||||
absLegendConfigs.push_back( wellMeasurement->legendConfig() );
|
||||
}
|
||||
|
||||
return absLegendConfigs;
|
||||
}
|
||||
|
201
ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp
Normal file
201
ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp
Normal 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;
|
||||
}
|
62
ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h
Normal file
62
ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h
Normal 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;
|
||||
};
|
@ -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;
|
||||
}
|
||||
|
@ -20,16 +20,10 @@
|
||||
#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;
|
||||
|
||||
class RimWellMeasurementInViewCollection : public RimCheckableNamedObject
|
||||
{
|
||||
@ -39,22 +33,15 @@ public:
|
||||
RimWellMeasurementInViewCollection();
|
||||
~RimWellMeasurementInViewCollection() override;
|
||||
|
||||
RimRegularLegendConfig* legendConfig();
|
||||
std::vector<QString> measurementKinds() const;
|
||||
|
||||
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
|
||||
std::vector<RimWellMeasurementInView*> measurements() const;
|
||||
|
||||
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();
|
||||
void initAfterRead();
|
||||
|
||||
private:
|
||||
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
|
||||
caf::PdmField<std::vector<QString>> m_measurementKinds;
|
||||
caf::PdmChildArrayField<RimWellMeasurementInView*> m_measurementsInView;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user