Category legend improvements

* Show text after value in category legend
* Use integer slider for category results
* Do not allow min larger than max and max lower than min
This commit is contained in:
Magne Sjaastad 2023-05-22 15:41:48 +02:00 committed by GitHub
parent b83fe73395
commit ee724633b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 90 additions and 15 deletions

View File

@ -41,6 +41,7 @@
#include "RiuMainWindow.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiSliderEditor.h"
#include "cafPdmUiTreeAttributes.h"
#include "cvfAssert.h"
@ -75,6 +76,16 @@ RimEclipsePropertyFilter::RimEclipsePropertyFilter()
CAF_PDM_InitField( &m_upperBound, "UpperBound", 0.0, "Max" );
m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_integerLowerBound, "IntegerLowerBound", "Min" );
m_integerLowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
m_integerLowerBound.registerGetMethod( this, &RimEclipsePropertyFilter::lowerBound );
m_integerLowerBound.registerSetMethod( this, &RimEclipsePropertyFilter::setLowerBound );
CAF_PDM_InitFieldNoDefault( &m_integerUpperBound, "IntegerUpperBound", "Max" );
m_integerUpperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
m_integerUpperBound.registerGetMethod( this, &RimEclipsePropertyFilter::upperBound );
m_integerUpperBound.registerSetMethod( this, &RimEclipsePropertyFilter::setUpperBound );
CAF_PDM_InitField( &m_useCategorySelection, "CategorySelection", false, "Category Selection" );
m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
@ -142,8 +153,19 @@ void RimEclipsePropertyFilter::setIsDuplicatedFromLinkedView( bool isDuplicated
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( &m_lowerBound == changedField || &m_integerLowerBound == changedField )
{
if ( m_lowerBound > m_upperBound ) m_upperBound = m_lowerBound;
}
if ( &m_upperBound == changedField || &m_integerUpperBound == changedField )
{
if ( m_upperBound < m_lowerBound ) m_lowerBound = m_upperBound;
}
if ( &m_lowerBound == changedField || &m_upperBound == changedField || &m_isActive == changedField || &m_filterMode == changedField ||
&m_selectedCategoryValues == changedField || &m_useCategorySelection == changedField )
&m_selectedCategoryValues == changedField || &m_useCategorySelection == changedField || &m_integerUpperBound == changedField ||
&m_integerLowerBound == changedField )
{
m_isDuplicatedFromLinkedView = false;
@ -211,8 +233,16 @@ void RimEclipsePropertyFilter::defineUiOrdering( QString uiConfigName, caf::PdmU
}
else
{
group2.add( &m_lowerBound );
group2.add( &m_upperBound );
if ( m_resultDefinition->hasCategoryResult() )
{
group2.add( &m_integerLowerBound );
group2.add( &m_integerUpperBound );
}
else
{
group2.add( &m_lowerBound );
group2.add( &m_upperBound );
}
}
uiOrdering.skipRemainingFields( true );
@ -330,14 +360,20 @@ void RimEclipsePropertyFilter::defineEditorAttribute( const caf::PdmFieldHandle*
if ( field == &m_lowerBound || field == &m_upperBound )
{
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( !myAttr )
if ( auto doubleAttributes = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
return;
doubleAttributes->m_minimum = m_minimumResultValue;
doubleAttributes->m_maximum = m_maximumResultValue;
}
}
myAttr->m_minimum = m_minimumResultValue;
myAttr->m_maximum = m_maximumResultValue;
if ( field == &m_integerLowerBound || field == &m_integerUpperBound )
{
if ( auto integerAttributes = dynamic_cast<caf::PdmUiSliderEditorAttribute*>( attribute ) )
{
integerAttributes->m_minimum = m_minimumResultValue;
integerAttributes->m_maximum = m_maximumResultValue;
}
}
}
@ -365,6 +401,38 @@ void RimEclipsePropertyFilter::defineObjectEditorAttribute( QString uiConfigName
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimEclipsePropertyFilter::upperBound() const
{
return m_upperBound;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::setUpperBound( const int& upperBound )
{
m_upperBound = upperBound;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimEclipsePropertyFilter::lowerBound() const
{
return m_lowerBound;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::setLowerBound( const int& lowerBound )
{
m_lowerBound = lowerBound;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -59,12 +59,14 @@ public:
private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
private:
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
int upperBound() const;
void setUpperBound( const int& upperBound );
int lowerBound() const;
void setLowerBound( const int& lowerBound );
private:
friend class RimEclipsePropertyFilterCollection;
friend class RicEclipsePropertyFilterFeatureImpl;
@ -80,9 +82,14 @@ private:
private:
caf::PdmChildField<RimEclipseResultDefinition*> m_resultDefinition;
caf::PdmField<QString> m_rangeLabelText;
caf::PdmField<double> m_lowerBound;
caf::PdmField<double> m_upperBound;
caf::PdmField<bool> m_isDuplicatedFromLinkedView;
caf::PdmField<double> m_lowerBound;
caf::PdmField<double> m_upperBound;
caf::PdmProxyValueField<int> m_integerLowerBound;
caf::PdmProxyValueField<int> m_integerUpperBound;
caf::PdmField<bool> m_isDuplicatedFromLinkedView;
caf::PdmField<bool> m_useCategorySelection;

View File

@ -682,7 +682,7 @@ void RimEclipseResultDefinitionTools::updateCellResultLegend( const RimEclipseRe
[value]( const RimColorLegendItem* const item ) { return item->categoryValue() == value; } );
if ( it != items.end() && !( *it )->categoryName().isEmpty() )
{
valueTxt = QString( "%1 (%2)" ).arg( ( *it )->categoryName() ).arg( value );
valueTxt = QString( "%1 %2" ).arg( value ).arg( ( *it )->categoryName() );
}
else
{