From 5176e4e635a839d2a3548eb33ba0f1e9ac9623e7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 Dec 2020 15:51:23 +0100 Subject: [PATCH] Make legend config changed signal more fine grained for Contour Maps --- .../ProjectDataModel/CMakeLists_files.cmake | 1 + .../RimContourMapProjection.cpp | 2 +- .../RimContourMapProjection.h | 5 +- .../ProjectDataModel/RimEclipseCellColors.cpp | 4 +- .../ProjectDataModel/RimEclipseCellColors.h | 7 +- .../RimEclipseContourMapProjection.cpp | 11 ++++ .../RimEclipseContourMapProjection.h | 2 + .../RimEclipseContourMapView.cpp | 17 +++-- .../RimEclipseContourMapView.h | 4 +- .../ProjectDataModel/RimGeoMechCellColors.cpp | 10 +++ .../ProjectDataModel/RimGeoMechCellColors.h | 5 ++ .../RimGeoMechContourMapProjection.cpp | 26 +++++--- .../RimGeoMechContourMapProjection.h | 2 + .../RimGeoMechContourMapView.cpp | 28 +++++++- .../RimGeoMechContourMapView.h | 5 ++ .../RimLegendConfigChangeType.h | 29 ++++++++ .../RimRegularLegendConfig.cpp | 66 +++++++++++++++---- .../ProjectDataModel/RimRegularLegendConfig.h | 5 +- 18 files changed, 190 insertions(+), 39 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimLegendConfigChangeType.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index c694218bac..a6de4e4aac 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -8,6 +8,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.h ${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimLegendConfigChangeType.h ${CMAKE_CURRENT_LIST_DIR}/RimRegularLegendConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimOilField.h ${CMAKE_CURRENT_LIST_DIR}/RimProject.h diff --git a/ApplicationCode/ProjectDataModel/RimContourMapProjection.cpp b/ApplicationCode/ProjectDataModel/RimContourMapProjection.cpp index c51b4000cc..d33ee84d32 100644 --- a/ApplicationCode/ProjectDataModel/RimContourMapProjection.cpp +++ b/ApplicationCode/ProjectDataModel/RimContourMapProjection.cpp @@ -138,7 +138,7 @@ void RimContourMapProjection::generateResultsIfNecessary( int timeStep ) generateVertexResults(); } progress.setProgress( 100 ); - m_currentResultTimestep = timeStep; + updateAfterResultGeneration( timeStep ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimContourMapProjection.h b/ApplicationCode/ProjectDataModel/RimContourMapProjection.h index 5bfac7d219..8ba509fd98 100644 --- a/ApplicationCode/ProjectDataModel/RimContourMapProjection.h +++ b/ApplicationCode/ProjectDataModel/RimContourMapProjection.h @@ -199,8 +199,9 @@ protected: cvf::Vec2d cellCenterPosition( uint i, uint j ) const; cvf::Vec2d origin2d() const; - cvf::Vec2ui calculateMapSize() const; - double gridEdgeOffset() const; + cvf::Vec2ui calculateMapSize() const; + double gridEdgeOffset() const; + virtual void updateAfterResultGeneration( int timeStep ) = 0; protected: // Framework overrides diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index d9226b6b67..48717fa9c0 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -196,9 +196,9 @@ void RimEclipseCellColors::changeLegendConfig( QString resultVarNameOfNewLegend //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseCellColors::onLegendConfigChanged( const caf::SignalEmitter* emitter ) +void RimEclipseCellColors::onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType ) { - legendConfigChanged.send(); + legendConfigChanged.send( changeType ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h index 44d004f8e6..87b474dee2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h @@ -21,14 +21,15 @@ #pragma once #include "RimEclipseResultDefinition.h" +#include "RimLegendConfigChangeType.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmPtrField.h" class RimEclipseCase; -class RimTernaryLegendConfig; class RimRegularLegendConfig; +class RimTernaryLegendConfig; //================================================================================================== /// @@ -39,7 +40,7 @@ class RimEclipseCellColors : public RimEclipseResultDefinition CAF_PDM_HEADER_INIT; public: - caf::Signal<> legendConfigChanged; + caf::Signal legendConfigChanged; public: RimEclipseCellColors(); @@ -72,7 +73,7 @@ protected: private: void changeLegendConfig( QString resultVarNameOfNewLegend ); - void onLegendConfigChanged( const caf::SignalEmitter* emitter ); + void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType ); caf::PdmChildArrayField m_legendConfigData; caf::PdmPtrField m_legendConfigPtrField; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseContourMapProjection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseContourMapProjection.cpp index 5013d4ab07..b73c343784 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseContourMapProjection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseContourMapProjection.cpp @@ -502,6 +502,17 @@ RimEclipseContourMapView* RimEclipseContourMapProjection::view() const return view; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseContourMapProjection::updateAfterResultGeneration( int timeStep ) +{ + m_currentResultTimestep = timeStep; + + RimEclipseCellColors* cellColors = view()->cellResult(); + m_currentResultName = cellColors->resultVariable(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseContourMapProjection.h b/ApplicationCode/ProjectDataModel/RimEclipseContourMapProjection.h index 7c708d3fc8..c2a5345ef9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseContourMapProjection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseContourMapProjection.h @@ -84,6 +84,8 @@ protected: RimEclipseCase* eclipseCase() const; RimEclipseContourMapView* view() const; + void updateAfterResultGeneration( int timeStep ) override; + protected: // Framework overrides void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseContourMapView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseContourMapView.cpp index 18ddc2504b..4c16dac04f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseContourMapView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseContourMapView.cpp @@ -33,6 +33,7 @@ #include "RimEclipsePropertyFilterCollection.h" #include "RimFaultInViewCollection.h" #include "RimGridCollection.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInViewCollection.h" #include "RimViewNameConfig.h" @@ -251,7 +252,6 @@ void RimEclipseContourMapView::updateGeometry() } onUpdateLegends(); // To make sure the scalar mappers are set up correctly - appendWellsAndFracturesToModel(); { // Step 2: generate geometry. Takes about 60% of the time. createContourMapGeometry(); @@ -264,6 +264,9 @@ void RimEclipseContourMapView::updateGeometry() appendPickPointVisToModel(); progress.setProgress( 100 ); } + + appendWellsAndFracturesToModel(); + m_overlayInfoConfig()->update3DInfo(); } @@ -528,17 +531,23 @@ bool RimEclipseContourMapView::zoomChangeAboveTreshold( const cvf::Vec3d& curren //-------------------------------------------------------------------------------------------------- void RimEclipseContourMapView::scheduleGeometryRegen( RivCellSetEnum geometryType ) { - RimEclipseView::scheduleGeometryRegen( geometryType ); if ( geometryType != VISIBLE_WELL_CELLS ) { m_contourMapProjection->clearGeometry(); } + RimEclipseView::scheduleGeometryRegen( geometryType ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseContourMapView::onLegendConfigChanged( const caf::SignalEmitter* emitter ) +void RimEclipseContourMapView::onLegendConfigChanged( const caf::SignalEmitter* emitter, + RimLegendConfigChangeType changeType ) { - m_contourMapProjection->clearGeometry(); + using ChangeType = RimLegendConfigChangeType; + if ( changeType == ChangeType::LEVELS || changeType == ChangeType::COLOR_MODE || changeType == ChangeType::RANGE || + changeType == ChangeType::ALL ) + { + m_contourMapProjection->clearGeometry(); + } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseContourMapView.h b/ApplicationCode/ProjectDataModel/RimEclipseContourMapView.h index f371f073ea..bd0cf508ba 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseContourMapView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseContourMapView.h @@ -21,7 +21,9 @@ #include "RimEclipseView.h" #include "RimNameConfig.h" +enum class RimLegendConfigChangeType; class RimEclipseContourMapProjection; +class RimRegularLegendConfig; class RimViewNameConfig; class RimScaleLegendConfig; class RivContourMapProjectionPartMgr; @@ -67,7 +69,7 @@ protected: bool zoomChangeAboveTreshold( const cvf::Vec3d& currentCameraPosition ) const; void scheduleGeometryRegen( RivCellSetEnum geometryType ) override; - void onLegendConfigChanged( const caf::SignalEmitter* emitter ); + void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType ); private: cvf::ref m_contourMapProjectionPartMgr; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp index 0dcf05bdec..ce06e602c4 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp @@ -30,10 +30,12 @@ CAF_PDM_SOURCE_INIT( RimGeoMechCellColors, "GeoMechResultSlot" ); /// //-------------------------------------------------------------------------------------------------- RimGeoMechCellColors::RimGeoMechCellColors( void ) + : legendConfigChanged( this ) { CAF_PDM_InitFieldNoDefault( &legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); this->legendConfig = new RimRegularLegendConfig(); legendConfig.uiCapability()->setUiHidden( true ); + legendConfig->changed.connect( this, &RimGeoMechCellColors::onLegendConfigChanged ); } //-------------------------------------------------------------------------------------------------- @@ -104,3 +106,11 @@ void RimGeoMechCellColors::updateLegendCategorySettings() } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCellColors::onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType ) +{ + legendConfigChanged.send( changeType ); +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h index 989182a0b8..1f268246e1 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h @@ -20,6 +20,7 @@ #pragma once #include "RimGeoMechResultDefinition.h" +#include "RimLegendConfigChangeType.h" #include "cafPdmChildField.h" #include "cafPdmField.h" @@ -34,6 +35,9 @@ class RimGeoMechCellColors : public RimGeoMechResultDefinition { CAF_PDM_HEADER_INIT; +public: + caf::Signal legendConfigChanged; + public: RimGeoMechCellColors( void ); ~RimGeoMechCellColors( void ) override; @@ -45,4 +49,5 @@ public: protected: void updateLegendCategorySettings() override; + void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType ); }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechContourMapProjection.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechContourMapProjection.cpp index 744c3599b8..b1a07d2fd5 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechContourMapProjection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechContourMapProjection.cpp @@ -363,8 +363,10 @@ std::vector RimGeoMechContourMapProjection::generateResultsFromAddress( resultAddress.resultPosType = RIG_ELEMENT_NODAL; // formation indices are stored per element node result. } - std::vector resultValuesF = resultCollection->resultValues( resultAddress, 0, timeStep ); - std::vector resultValues = gridCellValues( resultAddress, resultValuesF ); + std::vector resultValuesF = resultCollection->resultValues( resultAddress, 0, timeStep ); + if ( resultValuesF.empty() ) return aggregatedResults; + + std::vector resultValues = gridCellValues( resultAddress, resultValuesF ); if ( wasInvalid ) { @@ -400,13 +402,7 @@ bool RimGeoMechContourMapProjection::resultVariableChanged() const RimGeoMechCellColors* cellColors = view()->cellResult(); RigFemResultAddress resAddr = cellColors->resultAddress(); - if ( resAddr.fieldName == "PP" ) - { - resAddr.fieldName = "POR-Bar"; // More likely to be in memory than POR - } - if ( resAddr.fieldName == "POR-Bar" ) resAddr.resultPosType = RIG_ELEMENT_NODAL; - - return !( m_currentResultAddr == resAddr ); + return !m_currentResultAddr.isValid() || !( m_currentResultAddr == resAddr ); } //-------------------------------------------------------------------------------------------------- @@ -569,6 +565,18 @@ RimGeoMechContourMapView* RimGeoMechContourMapProjection::view() const return view; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechContourMapProjection::updateAfterResultGeneration( int timeStep ) +{ + m_currentResultTimestep = timeStep; + + RimGeoMechCellColors* cellColors = view()->cellResult(); + RigFemResultAddress resAddr = cellColors->resultAddress(); + m_currentResultAddr = resAddr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechContourMapProjection.h b/ApplicationCode/ProjectDataModel/RimGeoMechContourMapProjection.h index 444943ae4b..8ce2e636f6 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechContourMapProjection.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechContourMapProjection.h @@ -85,6 +85,8 @@ protected: RimGeoMechCase* geoMechCase() const; RimGeoMechContourMapView* view() const; + void updateAfterResultGeneration( int timeStep ) override; + protected: // Framework overrides void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.cpp index cc91afa21f..adea8a3a4e 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.cpp @@ -28,6 +28,7 @@ #include "RimGeoMechContourMapProjection.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGridCollection.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInViewCollection.h" #include "RimViewNameConfig.h" @@ -70,6 +71,8 @@ RimGeoMechContourMapView::RimGeoMechContourMapView() m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr( contourMapProjection(), this ); ( (RiuViewerToViewInterface*)this )->setCameraPosition( sm_defaultViewMatrix ); + + cellResult()->legendConfigChanged.connect( this, &RimGeoMechContourMapView::onLegendConfigChanged ); } //-------------------------------------------------------------------------------------------------- @@ -236,8 +239,6 @@ void RimGeoMechContourMapView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiT //-------------------------------------------------------------------------------------------------- void RimGeoMechContourMapView::onUpdateDisplayModelForCurrentTimeStep() { - m_contourMapProjection->clearGeometry(); - updateGeometry(); } @@ -501,3 +502,26 @@ bool RimGeoMechContourMapView::zoomChangeAboveTreshold( const cvf::Vec3d& curren const double threshold = 0.05 * distance; return std::fabs( m_cameraPositionLastUpdate.z() - currentCameraPosition.z() ) > threshold; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechContourMapView::scheduleGeometryRegen( RivCellSetEnum geometryType ) +{ + m_contourMapProjection->clearGeometry(); + RimGeoMechView::scheduleGeometryRegen( geometryType ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechContourMapView::onLegendConfigChanged( const caf::SignalEmitter* emitter, + RimLegendConfigChangeType changeType ) +{ + using ChangeType = RimLegendConfigChangeType; + if ( changeType == ChangeType::LEVELS || changeType == ChangeType::COLOR_MODE || changeType == ChangeType::RANGE || + changeType == ChangeType::ALL ) + { + m_contourMapProjection->clearGeometry(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.h b/ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.h index 788bdfcb14..5ca966edce 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.h @@ -21,7 +21,9 @@ #include "RimGeoMechView.h" #include "RimNameConfig.h" +enum class RimLegendConfigChangeType; class RimGeoMechContourMapProjection; +class RimRegularLegendConfig; class RimViewNameConfig; class RimScaleLegendConfig; class RivContourMapProjectionPartMgr; @@ -66,6 +68,9 @@ protected: bool zoomChangeAboveTreshold( const cvf::Vec3d& currentCameraPosition ) const; + void scheduleGeometryRegen( RivCellSetEnum geometryType ) override; + void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType ); + private: cvf::ref m_contourMapProjectionPartMgr; caf::PdmChildField m_contourMapProjection; diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfigChangeType.h b/ApplicationCode/ProjectDataModel/RimLegendConfigChangeType.h new file mode 100644 index 0000000000..f44efda521 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimLegendConfigChangeType.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +enum class RimLegendConfigChangeType +{ + VISIBILITY, + COLORS, + LEVELS, + NUMBER_FORMAT, + COLOR_MODE, + RANGE, + ALL +}; diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index c76844e38b..f622925b31 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -269,16 +269,7 @@ void RimRegularLegendConfig::fieldChangedByUi( const caf::PdmFieldHandle* change const QVariant& oldValue, const QVariant& newValue ) { - if ( changedField == &m_selectColorLegendButton ) - { - m_selectColorLegendButton = false; - if ( m_colorLegend != nullptr ) - { - Riu3DMainWindowTools::selectAsCurrentItem( m_colorLegend() ); - } - return; - } - + sendChangedSignal( changedField ); if ( changedField == &m_numLevels ) { int upperLimit = std::numeric_limits::max(); @@ -297,9 +288,17 @@ void RimRegularLegendConfig::fieldChangedByUi( const caf::PdmFieldHandle* change m_userDefinedMinValue = roundToNumSignificantDigits( m_globalAutoMin, m_precision ); } } - updateFieldVisibility(); } + else if ( changedField == &m_selectColorLegendButton ) + { + m_selectColorLegendButton = false; + if ( m_colorLegend != nullptr ) + { + Riu3DMainWindowTools::selectAsCurrentItem( m_colorLegend() ); + } + return; + } if ( ( changedField == &m_colorLegend || changedField == &m_mappingMode ) && m_mappingMode() == MappingType::CATEGORY_INTEGER ) @@ -314,7 +313,6 @@ void RimRegularLegendConfig::fieldChangedByUi( const caf::PdmFieldHandle* change m_resetUserDefinedValuesButton = false; } - changed.send(); updateLegend(); RimGridView* view = nullptr; @@ -371,6 +369,47 @@ void RimRegularLegendConfig::fieldChangedByUi( const caf::PdmFieldHandle* change this->updateUiIconFromToggleField(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::sendChangedSignal( const caf::PdmFieldHandle* changedField ) +{ + using ChangeType = RimLegendConfigChangeType; + + if ( changedField == &m_showLegend ) + { + changed.send( ChangeType::VISIBILITY ); + } + else if ( changedField == &m_numLevels ) + { + changed.send( ChangeType::LEVELS ); + } + else if ( changedField == &m_precision || changedField == &m_tickNumberFormat ) + { + changed.send( ChangeType::NUMBER_FORMAT ); + } + else if ( changedField == &m_userDefinedMinValue || changedField == &m_userDefinedMaxValue ) + { + changed.send( ChangeType::RANGE ); + } + else if ( changedField == &m_rangeMode || changedField == &m_mappingMode ) + { + changed.send( ChangeType::COLOR_MODE ); + } + else if ( changedField == &m_categoryColorMode ) + { + changed.send( ChangeType::COLOR_MODE ); + } + else if ( changedField == &m_colorLegend ) + { + changed.send( ChangeType::COLORS ); + } + else if ( changedField == &m_resetUserDefinedValuesButton ) + { + changed.send( ChangeType::ALL ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1220,10 +1259,9 @@ void RimRegularLegendConfig::defineUiOrdering( QString uiConfigName, caf::PdmUiO mappingGr->add( &m_userDefinedMaxValue ); mappingGr->add( &m_userDefinedMinValue ); mappingGr->add( &m_categoryColorMode ); + uiOrdering.add( &m_resetUserDefinedValuesButton ); } - uiOrdering.add( &m_resetUserDefinedValuesButton ); - updateFieldVisibility(); } diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index 69b906df63..c77a943a09 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -21,11 +21,13 @@ #pragma once #include "RimLegendConfig.h" +#include "RimLegendConfigChangeType.h" #include "cvfArray.h" #include "cvfObject.h" #include "cafPdmPtrField.h" +#include "cafSignal.h" #include @@ -62,7 +64,7 @@ class RimRegularLegendConfig : public RimLegendConfig CAF_PDM_HEADER_INIT; public: - caf::Signal<> changed; + caf::Signal changed; public: RimRegularLegendConfig(); @@ -173,6 +175,7 @@ public: private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void sendChangedSignal( const caf::PdmFieldHandle* changedField ); void initAfterRead() override; caf::PdmFieldHandle* objectToggleField() override; void defineEditorAttribute( const caf::PdmFieldHandle* field,