Make legend config changed signal more fine grained for Contour Maps

This commit is contained in:
Gaute Lindkvist 2020-12-07 09:30:09 +01:00
parent 02298d81b1
commit 72e170ac2b
18 changed files with 190 additions and 39 deletions

View File

@ -2,6 +2,7 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimCaseCollection.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

View File

@ -138,7 +138,7 @@ void RimContourMapProjection::generateResultsIfNecessary( int timeStep )
generateVertexResults();
}
progress.setProgress( 100 );
m_currentResultTimestep = timeStep;
updateAfterResultGeneration( timeStep );
}
//--------------------------------------------------------------------------------------------------

View File

@ -200,8 +200,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

View File

@ -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 );
}
//--------------------------------------------------------------------------------------------------

View File

@ -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<RimLegendConfigChangeType> 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<RimRegularLegendConfig*> m_legendConfigData;
caf::PdmPtrField<RimRegularLegendConfig*> m_legendConfigPtrField;

View File

@ -512,6 +512,17 @@ RimEclipseContourMapView* RimEclipseContourMapProjection::view() const
return view;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseContourMapProjection::updateAfterResultGeneration( int timeStep )
{
m_currentResultTimestep = timeStep;
RimEclipseCellColors* cellColors = view()->cellResult();
m_currentResultName = cellColors->resultVariable();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -86,6 +86,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;

View File

@ -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();
}
}

View File

@ -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<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;

View File

@ -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 );
}

View File

@ -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<RimLegendConfigChangeType> legendConfigChanged;
public:
RimGeoMechCellColors( void );
~RimGeoMechCellColors( void ) override;
@ -45,4 +49,5 @@ public:
protected:
void updateLegendCategorySettings() override;
void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType );
};

View File

@ -365,8 +365,10 @@ std::vector<double> RimGeoMechContourMapProjection::generateResultsFromAddress(
resultAddress.resultPosType = RIG_ELEMENT_NODAL; // formation indices are stored per element node result.
}
std::vector<float> resultValuesF = resultCollection->resultValues( resultAddress, 0, timeStep );
std::vector<double> resultValues = gridCellValues( resultAddress, resultValuesF );
std::vector<float> resultValuesF = resultCollection->resultValues( resultAddress, 0, timeStep );
if ( resultValuesF.empty() ) return aggregatedResults;
std::vector<double> resultValues = gridCellValues( resultAddress, resultValuesF );
if ( wasInvalid )
{
@ -402,13 +404,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 );
}
//--------------------------------------------------------------------------------------------------
@ -579,6 +575,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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -86,6 +86,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;

View File

@ -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();
}
}

View File

@ -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<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
caf::PdmChildField<RimGeoMechContourMapProjection*> m_contourMapProjection;

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
enum class RimLegendConfigChangeType
{
VISIBILITY,
COLORS,
LEVELS,
NUMBER_FORMAT,
COLOR_MODE,
RANGE,
ALL
};

View File

@ -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<int>::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();
}

View File

@ -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 <tuple>
@ -62,7 +64,7 @@ class RimRegularLegendConfig : public RimLegendConfig
CAF_PDM_HEADER_INIT;
public:
caf::Signal<> changed;
caf::Signal<RimLegendConfigChangeType> 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,