mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-21 22:13:25 -06:00
Merge remote-tracking branch 'origin/2020.10-patch-01' into dev
This commit is contained in:
commit
6e789afd10
@ -25,6 +25,8 @@
|
||||
|
||||
#include "cafPdmFieldReorderCapability.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimColorLegend, "ColorLegend" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -94,6 +96,7 @@ void RimColorLegend::addReorderCapability()
|
||||
void RimColorLegend::appendColorLegendItem( RimColorLegendItem* colorLegendItem )
|
||||
{
|
||||
m_colorLegendItems.push_back( colorLegendItem );
|
||||
onColorLegendItemHasChanged();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -143,11 +146,18 @@ void RimColorLegend::orderChanged( const caf::SignalEmitter* emitter )
|
||||
cvf::Color3ubArray RimColorLegend::colorArray() const
|
||||
{
|
||||
std::vector<RimColorLegendItem*> legendItems = colorLegendItems();
|
||||
cvf::Color3ubArray colorArray( legendItems.size() );
|
||||
|
||||
// The interpolation algorithm requires minimum two levels
|
||||
size_t colorCount = std::max( size_t( 2 ), legendItems.size() );
|
||||
|
||||
cvf::Color3ubArray colorArray( colorCount );
|
||||
colorArray.setAll( cvf::Color3ub::GRAY );
|
||||
|
||||
for ( size_t i = 0; i < legendItems.size(); i++ )
|
||||
{
|
||||
colorArray.set( i, cvf::Color3ub( legendItems[i]->color() ) );
|
||||
}
|
||||
|
||||
return colorArray;
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,10 @@ void RimEclipseCellColors::changeLegendConfig( QString resultVarNameOfNewLegend
|
||||
|
||||
if ( useLog )
|
||||
{
|
||||
newLegend->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS );
|
||||
newLegend->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_DISCRETE );
|
||||
newLegend->setTickNumberFormat( RimRegularLegendConfig::NumberFormatType::AUTO );
|
||||
newLegend->setRangeMode( RimLegendConfig::RangeModeType::USER_DEFINED );
|
||||
newLegend->resetUserDefinedValues();
|
||||
}
|
||||
|
||||
if ( this->hasCategoryResult() )
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiToolButtonEditor.h"
|
||||
|
||||
#include "cvfMath.h"
|
||||
@ -149,6 +150,7 @@ RimRegularLegendConfig::RimRegularLegendConfig()
|
||||
, m_localAutoPosClosestToZero( 0 )
|
||||
, m_localAutoNegClosestToZero( 0 )
|
||||
, m_isAllTimeStepsRangeDisabled( false )
|
||||
, m_resetUserDefinedValues( false )
|
||||
{
|
||||
CAF_PDM_InitObject( "Color Legend", ":/Legend.png", "", "" );
|
||||
CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Show Legend", "", "", "" );
|
||||
@ -222,6 +224,10 @@ RimRegularLegendConfig::RimRegularLegendConfig()
|
||||
m_scalarMapperLegend = new caf::OverlayScalarMapperLegend( standardFont );
|
||||
m_categoryLegend = new caf::CategoryLegend( standardFont, m_categoryMapper.p() );
|
||||
|
||||
CAF_PDM_InitField( &m_resetUserDefinedValuesButton, "ResetDefaultValues", false, "Reset Default Values", "", "", "" );
|
||||
m_resetUserDefinedValuesButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
m_resetUserDefinedValuesButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
updateFieldVisibility();
|
||||
updateLegend();
|
||||
}
|
||||
@ -300,6 +306,13 @@ void RimRegularLegendConfig::fieldChangedByUi( const caf::PdmFieldHandle* change
|
||||
updateCategoryItems();
|
||||
}
|
||||
|
||||
if ( changedField == &m_resetUserDefinedValuesButton )
|
||||
{
|
||||
resetUserDefinedValues();
|
||||
|
||||
m_resetUserDefinedValuesButton = false;
|
||||
}
|
||||
|
||||
updateLegend();
|
||||
|
||||
RimGridView* view = nullptr;
|
||||
@ -359,6 +372,31 @@ void RimRegularLegendConfig::updateLegend()
|
||||
{
|
||||
m_significantDigitsInData = m_precision;
|
||||
|
||||
if ( m_resetUserDefinedValues && m_globalAutoMax != cvf::UNDEFINED_DOUBLE )
|
||||
{
|
||||
if ( m_mappingMode() == MappingType::LOG10_CONTINUOUS || m_mappingMode() == MappingType::LOG10_DISCRETE )
|
||||
{
|
||||
double exponentMax = computeTenExponentCeil( m_globalAutoMax );
|
||||
double exponentMin = computeTenExponentFloor( m_globalAutoPosClosestToZero );
|
||||
|
||||
m_userDefinedMaxValue = pow( 10, exponentMax );
|
||||
m_userDefinedMinValue = pow( 10, exponentMin );
|
||||
|
||||
int numLevels = exponentMax - exponentMin;
|
||||
if ( numLevels > 0 )
|
||||
{
|
||||
m_numLevels = numLevels;
|
||||
}
|
||||
}
|
||||
else if ( m_mappingMode() == MappingType::LINEAR_CONTINUOUS || m_mappingMode() == MappingType::LINEAR_DISCRETE )
|
||||
{
|
||||
m_userDefinedMaxValue = m_globalAutoMax;
|
||||
m_userDefinedMinValue = m_globalAutoMin;
|
||||
}
|
||||
|
||||
m_resetUserDefinedValues = false;
|
||||
}
|
||||
|
||||
double adjustedMin = cvf::UNDEFINED_DOUBLE;
|
||||
double adjustedMax = cvf::UNDEFINED_DOUBLE;
|
||||
|
||||
@ -540,6 +578,14 @@ void RimRegularLegendConfig::setTickNumberFormat( NumberFormatType numberFormat
|
||||
m_tickNumberFormat = numberFormat;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRegularLegendConfig::resetUserDefinedValues()
|
||||
{
|
||||
m_resetUserDefinedValues = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -612,6 +658,23 @@ caf::PdmFieldHandle* RimRegularLegendConfig::objectToggleField()
|
||||
return &m_showLegend;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRegularLegendConfig::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( &m_resetUserDefinedValuesButton == field )
|
||||
{
|
||||
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
||||
if ( attrib )
|
||||
{
|
||||
attrib->m_buttonText = "Reset User Defined Values";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -954,6 +1017,14 @@ RiuAbstractLegendFrame* RimRegularLegendConfig::makeLegendFrame()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRegularLegendConfig::setRangeMode( RangeModeType rangeMode )
|
||||
{
|
||||
m_rangeMode = rangeMode;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1036,6 +1107,32 @@ RimColorLegend* RimRegularLegendConfig::mapToColorLegend( ColorRangesType colorT
|
||||
return project->colorLegendCollection()->findByName( RimRegularLegendConfig::ColorRangeEnum::uiText( colorType ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimRegularLegendConfig::computeTenExponentCeil( double value )
|
||||
{
|
||||
if ( value < 0.0 ) return 0.0;
|
||||
|
||||
double logDecValueMax = log10( value );
|
||||
logDecValueMax = cvf::Math::ceil( logDecValueMax );
|
||||
|
||||
return logDecValueMax;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimRegularLegendConfig::computeTenExponentFloor( double value )
|
||||
{
|
||||
if ( value < 0.0 ) return 0.0;
|
||||
|
||||
double logDecValueMin = log10( value );
|
||||
logDecValueMin = cvf::Math::floor( logDecValueMin );
|
||||
|
||||
return logDecValueMin;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1087,6 +1184,9 @@ void RimRegularLegendConfig::defineUiOrdering( QString uiConfigName, caf::PdmUiO
|
||||
mappingGr->add( &m_userDefinedMinValue );
|
||||
mappingGr->add( &m_categoryColorMode );
|
||||
}
|
||||
|
||||
uiOrdering.add( &m_resetUserDefinedValuesButton );
|
||||
|
||||
updateFieldVisibility();
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,7 @@ public:
|
||||
void setMappingMode( MappingType mappingType );
|
||||
MappingType mappingMode() { return m_mappingMode(); }
|
||||
void setTickNumberFormat( NumberFormatType numberFormat );
|
||||
void resetUserDefinedValues();
|
||||
|
||||
void disableAllTimeStepsRange( bool doDisable );
|
||||
|
||||
@ -153,16 +154,24 @@ public:
|
||||
caf::TitledOverlayFrame* titledOverlayFrame() override;
|
||||
RiuAbstractLegendFrame* makeLegendFrame();
|
||||
|
||||
RangeModeType rangeMode() const;
|
||||
void setRangeMode( RangeModeType rangeMode );
|
||||
RangeModeType rangeMode() const;
|
||||
|
||||
static cvf::Color3ubArray colorArrayFromColorType( ColorRangesType colorType );
|
||||
static RimColorLegend* mapToColorLegend( ColorRangesType colorType );
|
||||
|
||||
static double computeTenExponentCeil( double value );
|
||||
static double computeTenExponentFloor( double value );
|
||||
|
||||
void updateFonts() override;
|
||||
|
||||
private:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void initAfterRead() override;
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
@ -216,10 +225,13 @@ private:
|
||||
caf::PdmField<caf::AppEnum<ColorRangesType>> m_colorRangeMode_OBSOLETE;
|
||||
caf::PdmField<caf::AppEnum<MappingType>> m_mappingMode;
|
||||
caf::PdmField<caf::AppEnum<CategoryColorModeType>> m_categoryColorMode;
|
||||
caf::PdmField<bool> m_resetUserDefinedValuesButton;
|
||||
|
||||
caf::PdmPtrField<RimColorLegend*> m_colorLegend;
|
||||
caf::PdmField<bool> m_selectColorLegendButton;
|
||||
|
||||
bool m_resetUserDefinedValues;
|
||||
|
||||
QString m_title;
|
||||
int m_significantDigitsInData;
|
||||
};
|
||||
|
@ -1,15 +1,16 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RiaTestDataDirectory.h"
|
||||
#include "RifColorLegendData.h"
|
||||
#include "RigFormationNames.h"
|
||||
|
||||
#include "QDir"
|
||||
#include "RiaTestDataDirectory.h"
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
TEST( RifColorLegendData, ReadLYRFileWithoutColor )
|
||||
{
|
||||
QDir baseFolder( TEST_DATA_DIR );
|
||||
@ -83,3 +84,47 @@ TEST( RifColorLegendData, ReadLYRFileWithColorHTML )
|
||||
EXPECT_EQ( 0.0f, formationColor.g() );
|
||||
EXPECT_EQ( 0.0f, formationColor.b() );
|
||||
}
|
||||
|
||||
TEST( RimRegularLegendConfig, LogTenFunctions )
|
||||
{
|
||||
{
|
||||
// Negative values will return zero
|
||||
double value = -0.0015;
|
||||
|
||||
auto exponentCeil = RimRegularLegendConfig::computeTenExponentCeil( value );
|
||||
EXPECT_EQ( 0.0f, exponentCeil );
|
||||
|
||||
auto exponentFloor = RimRegularLegendConfig::computeTenExponentFloor( value );
|
||||
EXPECT_EQ( 0.0f, exponentFloor );
|
||||
}
|
||||
|
||||
{
|
||||
double value = 0.15;
|
||||
|
||||
auto exponentCeil = RimRegularLegendConfig::computeTenExponentCeil( value );
|
||||
EXPECT_EQ( 0.0f, exponentCeil );
|
||||
|
||||
auto exponentFloor = RimRegularLegendConfig::computeTenExponentFloor( value );
|
||||
EXPECT_EQ( -1.0f, exponentFloor );
|
||||
}
|
||||
|
||||
{
|
||||
double value = 1.5;
|
||||
|
||||
auto exponentCeil = RimRegularLegendConfig::computeTenExponentCeil( value );
|
||||
EXPECT_EQ( 1.0f, exponentCeil );
|
||||
|
||||
auto exponentFloor = RimRegularLegendConfig::computeTenExponentFloor( value );
|
||||
EXPECT_EQ( 0.0f, exponentFloor );
|
||||
}
|
||||
|
||||
{
|
||||
double value = 15;
|
||||
|
||||
auto exponentCeil = RimRegularLegendConfig::computeTenExponentCeil( value );
|
||||
EXPECT_EQ( 2.0f, exponentCeil );
|
||||
|
||||
auto exponentFloor = RimRegularLegendConfig::computeTenExponentFloor( value );
|
||||
EXPECT_EQ( 1.0f, exponentFloor );
|
||||
}
|
||||
}
|
||||
|
@ -429,60 +429,64 @@ void RiuViewer::paintOverlayItems( QPainter* painter )
|
||||
if ( this->isComparisonViewActive() )
|
||||
{
|
||||
Rim3dView* compView = dynamic_cast<Rim3dView*>( m_rimView.p() )->activeComparisonView();
|
||||
columnWidth = 200;
|
||||
|
||||
// int sliderPos = this->width() * this->comparisonViewVisibleNormalizedRect().min().x();
|
||||
int sliderPos = 0.5 * this->width();
|
||||
int compViewItemsXPos = sliderPos + 0.5 * ( this->width() - sliderPos ) - 0.5 * columnWidth;
|
||||
columnPos = 0.5 * sliderPos - 0.5 * columnWidth;
|
||||
|
||||
if ( m_showInfoText )
|
||||
if ( compView )
|
||||
{
|
||||
{
|
||||
Rim3dView* view = dynamic_cast<Rim3dView*>( m_rimView.p() );
|
||||
m_shortInfoLabel->setText( "<center>" + view->ownerCase()->caseUserDescription() + "</center>" );
|
||||
columnWidth = 200;
|
||||
|
||||
QPoint topLeft = QPoint( columnPos, yPos );
|
||||
m_shortInfoLabel->resize( columnWidth, m_shortInfoLabel->sizeHint().height() );
|
||||
m_shortInfoLabel->render( painter, topLeft );
|
||||
// int sliderPos = this->width() * this->comparisonViewVisibleNormalizedRect().min().x();
|
||||
int sliderPos = 0.5 * this->width();
|
||||
int compViewItemsXPos = sliderPos + 0.5 * ( this->width() - sliderPos ) - 0.5 * columnWidth;
|
||||
columnPos = 0.5 * sliderPos - 0.5 * columnWidth;
|
||||
|
||||
if ( m_showInfoText )
|
||||
{
|
||||
{
|
||||
Rim3dView* view = dynamic_cast<Rim3dView*>( m_rimView.p() );
|
||||
m_shortInfoLabel->setText( "<center>" + view->ownerCase()->caseUserDescription() + "</center>" );
|
||||
|
||||
QPoint topLeft = QPoint( columnPos, yPos );
|
||||
m_shortInfoLabel->resize( columnWidth, m_shortInfoLabel->sizeHint().height() );
|
||||
m_shortInfoLabel->render( painter, topLeft );
|
||||
}
|
||||
|
||||
{
|
||||
m_shortInfoLabelCompView->setText( "<center>" + compView->ownerCase()->caseUserDescription() +
|
||||
"</center>" );
|
||||
QPoint topLeft = QPoint( compViewItemsXPos, yPos );
|
||||
m_shortInfoLabelCompView->resize( columnWidth, m_shortInfoLabelCompView->sizeHint().height() );
|
||||
m_shortInfoLabelCompView->render( painter, topLeft );
|
||||
}
|
||||
|
||||
yPos += m_shortInfoLabel->height();
|
||||
}
|
||||
|
||||
int pickAreaHeight = yPos - startYPos;
|
||||
if ( m_showAnimProgress && isAnimationActive( true ) && compView->timeStepCount() > 1 )
|
||||
{
|
||||
m_shortInfoLabelCompView->setText( "<center>" + compView->ownerCase()->caseUserDescription() + "</center>" );
|
||||
QPoint topLeft = QPoint( compViewItemsXPos, yPos );
|
||||
m_shortInfoLabelCompView->resize( columnWidth, m_shortInfoLabelCompView->sizeHint().height() );
|
||||
m_shortInfoLabelCompView->render( painter, topLeft );
|
||||
QString stepName = compView->timeStepName( compView->currentTimeStep() );
|
||||
|
||||
m_animationProgressCompView->setFormat( "Time Step: %v/%m " + stepName );
|
||||
m_animationProgressCompView->setMinimum( 0 );
|
||||
m_animationProgressCompView->setMaximum( static_cast<int>( compView->timeStepCount() ) - 1 );
|
||||
m_animationProgressCompView->setValue( compView->currentTimeStep() );
|
||||
|
||||
m_animationProgressCompView->resize( columnWidth, m_animationProgressCompView->sizeHint().height() );
|
||||
|
||||
m_animationProgressCompView->render( painter, QPoint( compViewItemsXPos, yPos ) );
|
||||
|
||||
pickAreaHeight += m_animationProgressCompView->height();
|
||||
}
|
||||
|
||||
yPos += m_shortInfoLabel->height();
|
||||
m_infoPickArea.setLeft( columnPos );
|
||||
m_infoPickArea.setWidth( columnWidth );
|
||||
m_infoPickArea.setHeight( pickAreaHeight );
|
||||
m_infoPickArea.setTop( startYPos );
|
||||
|
||||
m_infoPickAreaCompView.setLeft( compViewItemsXPos );
|
||||
m_infoPickAreaCompView.setWidth( columnWidth );
|
||||
m_infoPickAreaCompView.setHeight( pickAreaHeight );
|
||||
m_infoPickAreaCompView.setTop( startYPos );
|
||||
}
|
||||
|
||||
int pickAreaHeight = yPos - startYPos;
|
||||
if ( m_showAnimProgress && isAnimationActive( true ) && compView->timeStepCount() > 1 )
|
||||
{
|
||||
QString stepName = compView->timeStepName( compView->currentTimeStep() );
|
||||
|
||||
m_animationProgressCompView->setFormat( "Time Step: %v/%m " + stepName );
|
||||
m_animationProgressCompView->setMinimum( 0 );
|
||||
m_animationProgressCompView->setMaximum( static_cast<int>( compView->timeStepCount() ) - 1 );
|
||||
m_animationProgressCompView->setValue( compView->currentTimeStep() );
|
||||
|
||||
m_animationProgressCompView->resize( columnWidth, m_animationProgressCompView->sizeHint().height() );
|
||||
|
||||
m_animationProgressCompView->render( painter, QPoint( compViewItemsXPos, yPos ) );
|
||||
|
||||
pickAreaHeight += m_animationProgressCompView->height();
|
||||
}
|
||||
|
||||
m_infoPickArea.setLeft( columnPos );
|
||||
m_infoPickArea.setWidth( columnWidth );
|
||||
m_infoPickArea.setHeight( pickAreaHeight );
|
||||
m_infoPickArea.setTop( startYPos );
|
||||
|
||||
m_infoPickAreaCompView.setLeft( compViewItemsXPos );
|
||||
m_infoPickAreaCompView.setWidth( columnWidth );
|
||||
m_infoPickAreaCompView.setHeight( pickAreaHeight );
|
||||
m_infoPickAreaCompView.setTop( startYPos );
|
||||
}
|
||||
|
||||
if ( showAnimBar && m_showAnimProgress )
|
||||
|
Loading…
Reference in New Issue
Block a user