mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7055 Contour Map: Label format it should match the legend format
This commit is contained in:
@@ -417,9 +417,8 @@ std::vector<cvf::ref<cvf::Drawable>>
|
||||
{
|
||||
if ( m_contourLinePolygons[i][j].vertices.empty() ) continue;
|
||||
|
||||
// cvf::String::number does not allow precision on 'g' formats, so use Qt.
|
||||
QString qLabelText = QString::number( m_contourLinePolygons[i][j].value, 'g', 2 );
|
||||
cvf::String labelText = cvfqt::Utils::toString( qLabelText );
|
||||
QString qLabelText = m_contourMapProjection->legendConfig()->valueToText( m_contourLinePolygons[i][j].value );
|
||||
cvf::String labelText = cvfqt::Utils::toString( qLabelText );
|
||||
|
||||
size_t nVertices = m_contourLinePolygons[i][j].vertices.size();
|
||||
size_t nLabels = nVertices;
|
||||
|
||||
@@ -1150,6 +1150,37 @@ void RimRegularLegendConfig::updateFonts()
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimRegularLegendConfig::valueToText( double value, NumberFormatType numberFormat, int precision )
|
||||
{
|
||||
QString valueString;
|
||||
|
||||
switch ( numberFormat )
|
||||
{
|
||||
case RimRegularLegendConfig::NumberFormatType::FIXED:
|
||||
valueString = QString::number( value, 'f', precision );
|
||||
break;
|
||||
case RimRegularLegendConfig::NumberFormatType::SCIENTIFIC:
|
||||
valueString = QString::number( value, 'e', precision );
|
||||
break;
|
||||
default:
|
||||
valueString = QString::number( value );
|
||||
break;
|
||||
}
|
||||
|
||||
return valueString;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimRegularLegendConfig::valueToText( double value ) const
|
||||
{
|
||||
return RimRegularLegendConfig::valueToText( value, m_tickNumberFormat(), m_precision() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -165,6 +165,9 @@ public:
|
||||
|
||||
void updateFonts() override;
|
||||
|
||||
QString valueToText( double value ) const;
|
||||
static QString valueToText( double value, NumberFormatType numberFormat, int precision );
|
||||
|
||||
private:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void initAfterRead() override;
|
||||
|
||||
@@ -123,21 +123,8 @@ void RiuScalarMapperLegendFrame::layoutInfo( LayoutInfo* layout ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuScalarMapperLegendFrame::label( int index ) const
|
||||
{
|
||||
double tickValue = m_tickValues[index];
|
||||
QString valueString;
|
||||
switch ( m_numberFormat )
|
||||
{
|
||||
case RimRegularLegendConfig::NumberFormatType::FIXED:
|
||||
valueString = QString::number( tickValue, 'f', m_tickNumberPrecision );
|
||||
break;
|
||||
case RimRegularLegendConfig::NumberFormatType::SCIENTIFIC:
|
||||
valueString = QString::number( tickValue, 'e', m_tickNumberPrecision );
|
||||
break;
|
||||
default:
|
||||
valueString = QString::number( tickValue );
|
||||
break;
|
||||
}
|
||||
return valueString;
|
||||
double tickValue = m_tickValues[index];
|
||||
return RimRegularLegendConfig::valueToText( tickValue, m_numberFormat, m_tickNumberPrecision );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user