#6081 Color Results : Update views when color legend content changes

This commit is contained in:
Magne Sjaastad 2020-06-17 13:26:11 +02:00
parent e11557c2be
commit c13f1d752d
16 changed files with 100 additions and 50 deletions

View File

@ -1072,6 +1072,14 @@ void Rim3dView::updateAnnotationItems()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::resetLegends()
{
onResetLegendsInViewer();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -159,6 +159,7 @@ public:
void createMeasurementDisplayModelAndRedraw();
void updateGridBoxData();
void updateAnnotationItems();
void resetLegends();
void setScaleZAndUpdate( double scaleZ );
void updateScaling();

View File

@ -20,6 +20,7 @@
#include "RiaColorTools.h"
#include "Rim3dView.h"
#include "RimColorLegendItem.h"
CAF_PDM_SOURCE_INIT( RimColorLegend, "ColorLegend" );
@ -147,3 +148,27 @@ caf::IconProvider RimColorLegend::paletteIconProvider() const
iconProvider.setBackgroundColorGradient( colorNames );
return iconProvider;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimColorLegend::onColorLegendItemHasChanged()
{
this->updateConnectedEditors();
std::vector<caf::PdmObjectHandle*> referringObjects;
this->objectsWithReferringPtrFields( referringObjects );
for ( auto o : referringObjects )
{
o->uiCapability()->updateConnectedEditors();
Rim3dView* view = nullptr;
o->firstAncestorOrThisOfType( view );
if ( view )
{
view->resetLegends();
view->scheduleCreateDisplayModelAndRedraw();
}
}
}

View File

@ -44,19 +44,18 @@ public:
~RimColorLegend() override;
public:
void setColorLegendName( const QString& colorLegendName );
QString colorLegendName();
void setColorLegendName( const QString& colorLegendName );
void setReadOnly( bool doReadOnly );
void appendColorLegendItem( RimColorLegendItem* colorLegendItem );
void appendColorLegendItem( RimColorLegendItem* colorLegendItem );
std::vector<RimColorLegendItem*> colorLegendItems() const;
cvf::Color3ubArray colorArray() const;
caf::IconProvider paletteIconProvider() const;
caf::IconProvider paletteIconProvider() const;
void onColorLegendItemHasChanged();
public:
caf::PdmFieldHandle* userDescriptionField() override;

View File

@ -104,7 +104,7 @@ void RimColorLegendCollection::createStandardColorLegends()
QColor colorQ( colorArray[i].r(), colorArray[i].g(), colorArray[i].b() );
RimColorLegendItem* colorLegendItem = new RimColorLegendItem;
colorLegendItem->setValues( colorQ.name(), i, color3f );
colorLegendItem->setValues( colorQ.name(), static_cast<int>( i ), color3f );
colorLegend->appendColorLegendItem( colorLegendItem );
colorLegend->setReadOnly( true );

View File

@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimColorLegendItem.h"
#include "RimColorLegend.h"
#include "cvfColor3.h"
@ -113,6 +114,12 @@ void RimColorLegendItem::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
const QVariant& oldValue,
const QVariant& newValue )
{
RimColorLegend* colorLegend = nullptr;
this->firstAncestorOrThisOfType( colorLegend );
if ( colorLegend )
{
colorLegend->onColorLegendItemHasChanged();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -2032,29 +2032,12 @@ void RimEclipseView::setCurrentCellResultData( const std::vector<double>& values
//--------------------------------------------------------------------------------------------------
void RimEclipseView::onResetLegendsInViewer()
{
RimRegularLegendConfig* cellResultNormalLegendConfig = this->cellResult()->legendConfig();
if ( cellResultNormalLegendConfig ) cellResultNormalLegendConfig->recreateLegend();
this->cellResult()->ternaryLegendConfig()->recreateLegend();
this->cellEdgeResult()->legendConfig()->recreateLegend();
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() )
for ( auto legendConfig : legendConfigs() )
{
sepInterResDef->regularLegendConfig()->recreateLegend();
sepInterResDef->ternaryLegendConfig()->recreateLegend();
}
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateSurfaceResultsCollection()->intersectionResultsDefinitions() )
{
sepInterResDef->regularLegendConfig()->recreateLegend();
sepInterResDef->ternaryLegendConfig()->recreateLegend();
}
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
wellMeasurement->legendConfig()->recreateLegend();
if ( legendConfig )
{
legendConfig->recreateLegend();
}
}
nativeOrOverrideViewer()->removeAllColorLegends();
@ -2223,6 +2206,11 @@ std::vector<RimLegendConfig*> RimEclipseView::legendConfigs() const
absLegends.push_back( wellMeasurement->legendConfig() );
}
for ( auto legendConfig : m_surfaceCollection->legendConfigs() )
{
absLegends.push_back( legendConfig );
}
return absLegends;
}

View File

@ -445,25 +445,12 @@ void RimGeoMechView::setGeoMechCase( RimGeoMechCase* gmCase )
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::onResetLegendsInViewer()
{
this->cellResult()->legendConfig->recreateLegend();
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() )
for ( auto legendConfig : legendConfigs() )
{
sepInterResDef->regularLegendConfig()->recreateLegend();
sepInterResDef->ternaryLegendConfig()->recreateLegend();
}
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateSurfaceResultsCollection()->intersectionResultsDefinitions() )
{
sepInterResDef->regularLegendConfig()->recreateLegend();
sepInterResDef->ternaryLegendConfig()->recreateLegend();
}
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
wellMeasurement->legendConfig()->recreateLegend();
if ( legendConfig )
{
legendConfig->recreateLegend();
}
}
nativeOrOverrideViewer()->removeAllColorLegends();

View File

@ -60,3 +60,11 @@ int RimLegendConfig::fontSize() const
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultSceneFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::recreateLegend()
{
onRecreateLegend();
}

View File

@ -52,4 +52,9 @@ public:
virtual caf::TitledOverlayFrame* titledOverlayFrame() = 0;
virtual int fontSize() const override;
void recreateLegend();
protected:
virtual void onRecreateLegend() = 0;
};

View File

@ -634,7 +634,7 @@ void RimRegularLegendConfig::setMappingMode( MappingType mappingType )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimRegularLegendConfig::recreateLegend()
void RimRegularLegendConfig::onRecreateLegend()
{
// Due to possible visualization bug, we need to recreate the legend if the last viewer
// has been removed, (and thus the opengl resources has been deleted) The text in

View File

@ -110,7 +110,7 @@ public:
};
typedef caf::AppEnum<MappingType> MappingEnum;
void recreateLegend();
void onRecreateLegend();
void setColorLegend( RimColorLegend* colorLegend );
RimColorLegend* colorLegend() const;

View File

@ -239,7 +239,7 @@ void RimTernaryLegendConfig::setAutomaticRanges( TernaryArrayIndex ternaryIndex,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTernaryLegendConfig::recreateLegend()
void RimTernaryLegendConfig::onRecreateLegend()
{
// Due to possible visualization bug, we need to recreate the legend if the last viewer
// has been removed, (and thus the opengl resources has been deleted) The text in

View File

@ -57,7 +57,7 @@ public:
void setUiValuesFromLegendConfig( const RimTernaryLegendConfig* otherLegendConfig );
void setAutomaticRanges( TernaryArrayIndex ternaryIndex, double globalMin, double globalMax, double localMin, double localMax );
void recreateLegend();
void onRecreateLegend();
bool showLegend() const;
void setTitle( const QString& title );
const RivTernaryScalarMapper* scalarMapper() const;

View File

@ -25,6 +25,7 @@
#include "RimSurface.h"
#include "RimSurfaceCollection.h"
#include "RimSurfaceInView.h"
#include "RimSurfaceResultDefinition.h"
#include "RivSurfacePartMgr.h"
@ -252,3 +253,21 @@ void RimSurfaceInViewCollection::updateLegendRangesTextAndVisibility( RiuViewer*
surf->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer, isUsingOverrideViewer );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimRegularLegendConfig*> RimSurfaceInViewCollection::legendConfigs()
{
std::vector<RimRegularLegendConfig*> configs;
for ( RimSurfaceInView* surf : m_surfacesInView )
{
if ( surf->surfaceResultDefinition() )
{
configs.push_back( surf->surfaceResultDefinition()->legendConfig() );
}
}
return configs;
}

View File

@ -32,6 +32,7 @@ class ScalarMapper;
class RimSurfaceInView;
class RimSurface;
class RimRegularLegendConfig;
class RiuViewer;
class RimSurfaceInViewCollection : public RimCheckableNamedObject
@ -53,6 +54,8 @@ public:
bool hasAnyActiveSeparateResults();
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
std::vector<RimRegularLegendConfig*> legendConfigs();
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;