mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5001 Add RimWellMeasurementInViewCollection and legends.
This commit is contained in:
@@ -37,10 +37,12 @@
|
||||
#include "RimFishbonesMultipleSubs.h"
|
||||
#include "RimPerforationCollection.h"
|
||||
#include "RimPerforationInterval.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimWellMeasurement.h"
|
||||
#include "RimWellMeasurementCollection.h"
|
||||
#include "RimWellMeasurementFilter.h"
|
||||
#include "RimWellMeasurementInViewCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathAttribute.h"
|
||||
#include "RimWellPathAttributeCollection.h"
|
||||
@@ -288,15 +290,18 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList*
|
||||
{
|
||||
if ( !m_rimWellPath ) return;
|
||||
|
||||
RimGridView* gridView = dynamic_cast<RimGridView*>( m_rimView.p() );
|
||||
if ( !gridView ) return;
|
||||
|
||||
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
|
||||
if ( !wellPathCollection ) return;
|
||||
|
||||
RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection();
|
||||
if ( !wellMeasurementCollection ) return;
|
||||
|
||||
if ( !wellMeasurementCollection->isChecked() ) return;
|
||||
if ( !gridView->measurementCollection()->isChecked() ) return;
|
||||
|
||||
std::vector<QString> measurementKinds = wellMeasurementCollection->measurementKinds();
|
||||
std::vector<QString> measurementKinds = gridView->measurementCollection()->measurementKinds();
|
||||
|
||||
RivPipeGeometryGenerator geoGenerator;
|
||||
std::vector<RimWellMeasurement*> wellMeasurements =
|
||||
@@ -331,6 +336,14 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList*
|
||||
|
||||
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(
|
||||
wellMeasurement->value() ) );
|
||||
}
|
||||
|
||||
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color );
|
||||
for ( auto part : parts )
|
||||
{
|
||||
|
||||
@@ -145,6 +145,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimObservedFmuRftData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.h
|
||||
)
|
||||
|
||||
|
||||
@@ -294,6 +295,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimObservedFmuRftData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewNameConfig.h"
|
||||
#include "RimVirtualPerforationResults.h"
|
||||
#include "RimWellMeasurementInViewCollection.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "Riu3dSelectionManager.h"
|
||||
@@ -1311,6 +1312,12 @@ void RimEclipseView::onUpdateLegends()
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( virtLegend->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
|
||||
if ( m_wellMeasurementCollection->isChecked() && m_wellMeasurementCollection->legendConfig()->showLegend() )
|
||||
{
|
||||
m_wellMeasurementCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1719,6 +1726,7 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
|
||||
uiTreeOrdering.add( faultResultSettings() );
|
||||
uiTreeOrdering.add( &m_intersectionResultDefCollection );
|
||||
uiTreeOrdering.add( wellCollection() );
|
||||
uiTreeOrdering.add( &m_wellMeasurementCollection );
|
||||
|
||||
{
|
||||
bool showFractureColors = false;
|
||||
@@ -1856,6 +1864,8 @@ void RimEclipseView::onResetLegendsInViewer()
|
||||
sepInterResDef->ternaryLegendConfig()->recreateLegend();
|
||||
}
|
||||
|
||||
m_wellMeasurementCollection->legendConfig()->recreateLegend();
|
||||
|
||||
nativeOrOverrideViewer()->removeAllColorLegends();
|
||||
}
|
||||
|
||||
@@ -2014,6 +2024,8 @@ std::vector<RimLegendConfig*> RimEclipseView::legendConfigs() const
|
||||
absLegends.push_back( sepInterResDef->ternaryLegendConfig() );
|
||||
}
|
||||
|
||||
absLegends.push_back( m_wellMeasurementCollection->legendConfig() );
|
||||
|
||||
return absLegends;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewNameConfig.h"
|
||||
#include "RimWellMeasurementInViewCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "Riu3dSelectionManager.h"
|
||||
@@ -433,6 +434,8 @@ void RimGeoMechView::onResetLegendsInViewer()
|
||||
sepInterResDef->ternaryLegendConfig()->recreateLegend();
|
||||
}
|
||||
|
||||
m_wellMeasurementCollection->legendConfig()->recreateLegend();
|
||||
|
||||
nativeOrOverrideViewer()->removeAllColorLegends();
|
||||
}
|
||||
|
||||
@@ -483,6 +486,12 @@ void RimGeoMechView::onUpdateLegends()
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_wellMeasurementCollection->isChecked() && m_wellMeasurementCollection->legendConfig()->showLegend() )
|
||||
{
|
||||
m_wellMeasurementCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -907,6 +916,7 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
|
||||
uiTreeOrdering.add( cellResult() );
|
||||
uiTreeOrdering.add( m_tensorResults() );
|
||||
uiTreeOrdering.add( &m_intersectionResultDefCollection );
|
||||
uiTreeOrdering.add( &m_wellMeasurementCollection );
|
||||
|
||||
uiTreeOrdering.add( m_intersectionCollection() );
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewLinkerCollection.h"
|
||||
#include "RimViewNameConfig.h"
|
||||
#include "RimWellMeasurementInViewCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuMainWindow.h"
|
||||
@@ -85,6 +86,10 @@ RimGridView::RimGridView()
|
||||
m_overlayInfoConfig = new Rim3dOverlayInfoConfig();
|
||||
m_overlayInfoConfig->setReservoirView( this );
|
||||
m_overlayInfoConfig.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_wellMeasurementCollection, "WellMeasurements", "Well Measurements", "", "", "" );
|
||||
m_wellMeasurementCollection = new RimWellMeasurementInViewCollection;
|
||||
m_wellMeasurementCollection.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -117,6 +122,7 @@ RimGridView::~RimGridView( void )
|
||||
|
||||
delete this->m_overlayInfoConfig();
|
||||
|
||||
delete m_wellMeasurementCollection;
|
||||
delete m_rangeFilterCollection;
|
||||
delete m_overrideRangeFilterCollection;
|
||||
delete m_intersectionCollection;
|
||||
@@ -161,6 +167,14 @@ RimIntersectionCollection* RimGridView::intersectionCollection() const
|
||||
return m_intersectionCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellMeasurementInViewCollection* RimGridView::measurementCollection() const
|
||||
{
|
||||
return m_wellMeasurementCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -30,6 +30,7 @@ class RimIntersectionResultsDefinitionCollection;
|
||||
class RimPropertyFilterCollection;
|
||||
class RimGridCollection;
|
||||
class RimCellRangeFilterCollection;
|
||||
class RimWellMeasurementInViewCollection;
|
||||
|
||||
class RimGridView : public Rim3dView
|
||||
{
|
||||
@@ -48,6 +49,7 @@ public:
|
||||
RimIntersectionCollection* intersectionCollection() const;
|
||||
RimIntersectionResultsDefinitionCollection* separateIntersectionResultsCollection() const;
|
||||
RimAnnotationInViewCollection* annotationCollection() const;
|
||||
RimWellMeasurementInViewCollection* measurementCollection() const;
|
||||
|
||||
virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0;
|
||||
void rangeFiltersUpdated();
|
||||
@@ -87,11 +89,12 @@ protected: // Fields
|
||||
|
||||
caf::PdmChildField<RimIntersectionResultsDefinitionCollection*> m_intersectionResultDefCollection;
|
||||
|
||||
caf::PdmChildField<Rim3dOverlayInfoConfig*> m_overlayInfoConfig;
|
||||
caf::PdmChildField<RimCellRangeFilterCollection*> m_rangeFilterCollection;
|
||||
caf::PdmChildField<RimCellRangeFilterCollection*> m_overrideRangeFilterCollection;
|
||||
caf::PdmChildField<RimGridCollection*> m_gridCollection;
|
||||
caf::PdmChildField<RimAnnotationInViewCollection*> m_annotationCollection;
|
||||
caf::PdmChildField<Rim3dOverlayInfoConfig*> m_overlayInfoConfig;
|
||||
caf::PdmChildField<RimCellRangeFilterCollection*> m_rangeFilterCollection;
|
||||
caf::PdmChildField<RimCellRangeFilterCollection*> m_overrideRangeFilterCollection;
|
||||
caf::PdmChildField<RimGridCollection*> m_gridCollection;
|
||||
caf::PdmChildField<RimAnnotationInViewCollection*> m_annotationCollection;
|
||||
caf::PdmChildField<RimWellMeasurementInViewCollection*> m_wellMeasurementCollection;
|
||||
|
||||
private:
|
||||
cvf::ref<cvf::UByteArray> m_currentReservoirCellVisibility;
|
||||
|
||||
@@ -38,13 +38,7 @@ RimWellMeasurementCollection::RimWellMeasurementCollection()
|
||||
CAF_PDM_InitFieldNoDefault( &m_measurements, "Measurements", "Well Measurements", "", "", "" );
|
||||
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();
|
||||
m_measurements.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
this->setName( "Well Measurements" );
|
||||
}
|
||||
@@ -126,22 +120,6 @@ void RimWellMeasurementCollection::deleteAllMeasurements()
|
||||
this->updateAllReferringTracks();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementCollection::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu,
|
||||
QMenu* menu,
|
||||
QWidget* fieldEditorWidget )
|
||||
{
|
||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||
|
||||
// menuBuilder << "RicNewWellMeasurementFeature";
|
||||
// menuBuilder << "Separator";
|
||||
// menuBuilder << "RicDeleteWellMeasurementFeature";
|
||||
|
||||
menuBuilder.appendToMenu( menu );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -185,7 +163,7 @@ void RimWellMeasurementCollection::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_isChecked || changedField == &m_measurementKinds )
|
||||
if ( changedField == &m_isChecked )
|
||||
{
|
||||
RimProject* proj;
|
||||
this->firstAncestorOrThisOfTypeAsserted( proj );
|
||||
@@ -193,33 +171,3 @@ 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;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ public:
|
||||
~RimWellMeasurementCollection() override;
|
||||
|
||||
std::vector<RimWellMeasurement*> measurements() const;
|
||||
std::vector<QString> measurementKinds() const;
|
||||
|
||||
void updateAllReferringTracks();
|
||||
void insertMeasurement( RimWellMeasurement* insertBefore, RimWellMeasurement* measurement );
|
||||
@@ -44,9 +43,6 @@ public:
|
||||
void deleteAllMeasurements();
|
||||
|
||||
protected:
|
||||
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu,
|
||||
QMenu* menu,
|
||||
QWidget* fieldEditorWidget ) override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
@@ -55,10 +51,7 @@ 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,7 +87,8 @@ void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot )
|
||||
{
|
||||
const RimWellMeasurementCollection* measurementCollection = wellPathCollection->measurementCollection();
|
||||
|
||||
std::vector<QString> measurementKinds = measurementCollection->measurementKinds();
|
||||
std::vector<QString> measurementKinds;
|
||||
measurementKinds.push_back( measurementKind() );
|
||||
|
||||
std::vector<RimWellMeasurement*> measurements =
|
||||
RimWellMeasurementFilter::filterMeasurements( measurementCollection->measurements(),
|
||||
|
||||
@@ -47,3 +47,20 @@ std::vector<RimWellMeasurement*>
|
||||
|
||||
return filteredMeasurements;
|
||||
}
|
||||
|
||||
std::vector<RimWellMeasurement*>
|
||||
RimWellMeasurementFilter::filterMeasurements( const std::vector<RimWellMeasurement*>& measurements,
|
||||
const std::vector<QString>& measurementKinds )
|
||||
{
|
||||
std::vector<RimWellMeasurement*> filteredMeasurements;
|
||||
|
||||
for ( auto& measurement : measurements )
|
||||
{
|
||||
if ( std::find( measurementKinds.begin(), measurementKinds.end(), measurement->kind() ) != measurementKinds.end() )
|
||||
{
|
||||
filteredMeasurements.push_back( measurement );
|
||||
}
|
||||
}
|
||||
|
||||
return filteredMeasurements;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ public:
|
||||
const RimWellPathCollection& wellPathCollection,
|
||||
const RimWellPath& rimWellPath,
|
||||
const std::vector<QString>& measurementKinds );
|
||||
static std::vector<RimWellMeasurement*> filterMeasurements( const std::vector<RimWellMeasurement*>& measurements,
|
||||
const std::vector<QString>& measurementKinds );
|
||||
|
||||
private:
|
||||
RimWellMeasurementFilter();
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RimWellMeasurementInViewCollection.h"
|
||||
|
||||
#include "Rim3dView.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( RimWellMeasurementInViewCollection, "WellMeasurementsInView" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection()
|
||||
{
|
||||
CAF_PDM_InitObject( "Well Measurement", "", "", "" );
|
||||
|
||||
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();
|
||||
|
||||
this->setName( "Well Measurements" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellMeasurementInViewCollection::~RimWellMeasurementInViewCollection()
|
||||
{
|
||||
delete m_legendConfig;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
|
||||
QString uiConfigName /*= ""*/ )
|
||||
{
|
||||
uiTreeOrdering.add( &m_legendConfig );
|
||||
uiTreeOrdering.skipRemainingChildren( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_isChecked || changedField == &m_measurementKinds || changedField == &m_legendConfig )
|
||||
{
|
||||
updateLegendData();
|
||||
RimProject* proj;
|
||||
this->firstAncestorOrThisOfTypeAsserted( proj );
|
||||
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRegularLegendConfig* RimWellMeasurementInViewCollection::legendConfig()
|
||||
{
|
||||
return m_legendConfig;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellMeasurementInViewCollection::updateLegendData()
|
||||
{
|
||||
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 )
|
||||
{
|
||||
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 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;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 RimWellMeasurementInViewCollection : public RimCheckableNamedObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellMeasurementInViewCollection();
|
||||
~RimWellMeasurementInViewCollection() override;
|
||||
|
||||
RimRegularLegendConfig* legendConfig();
|
||||
std::vector<QString> measurementKinds() const;
|
||||
|
||||
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<std::vector<QString>> m_measurementKinds;
|
||||
};
|
||||
Reference in New Issue
Block a user