diff --git a/ApplicationCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp b/ApplicationCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp index 73083fea2e..7e4967f86c 100644 --- a/ApplicationCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp @@ -25,10 +25,12 @@ #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfRay.h" #include "cvfScalarMapper.h" +#include "cvfqtUtils.h" #include #include +#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -267,7 +269,9 @@ std::vector>> { if ( m_contourLinePolygons[i][j].vertices.empty() ) continue; - cvf::String labelText( m_contourLinePolygons[i][j].value ); + // 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 ); size_t nVertices = m_contourLinePolygons[i][j].vertices.size(); @@ -402,7 +406,9 @@ std::vector> { if ( m_contourLinePolygons[i][j].vertices.empty() ) continue; - cvf::String labelText( m_contourLinePolygons[i][j].value ); + // 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 ); size_t nVertices = m_contourLinePolygons[i][j].vertices.size(); size_t nLabels = nVertices; diff --git a/ApplicationCode/ProjectDataModel/RimContourMapProjection.cpp b/ApplicationCode/ProjectDataModel/RimContourMapProjection.cpp index 2938eec0b3..7a53c83ed0 100644 --- a/ApplicationCode/ProjectDataModel/RimContourMapProjection.cpp +++ b/ApplicationCode/ProjectDataModel/RimContourMapProjection.cpp @@ -976,11 +976,11 @@ void RimContourMapProjection::generateTrianglesWithVertexValues() std::vector clippedTriangle; if ( v == clippedPolygon.size() - 1 ) { - clippedTriangle = { clippedPolygon[v], clippedPolygon[0], baryCenter }; + clippedTriangle = {clippedPolygon[v], clippedPolygon[0], baryCenter}; } else { - clippedTriangle = { clippedPolygon[v], clippedPolygon[v + 1], baryCenter }; + clippedTriangle = {clippedPolygon[v], clippedPolygon[v + 1], baryCenter}; } polygonTriangles.push_back( clippedTriangle ); } @@ -1103,18 +1103,14 @@ void RimContourMapProjection::generateContourPolygons() { if ( nContourLevels > 2 ) { - if ( legendConfig()->mappingMode() == RimRegularLegendConfig::MappingType::LINEAR_DISCRETE || - legendConfig()->mappingMode() == RimRegularLegendConfig::MappingType::LINEAR_CONTINUOUS ) - { - const int fudgeFactor = 0.01; - // Adjust contour levels slightly to avoid weird visual artifacts due to numerical error. - contourLevels.front() -= fudgeFactor * ( contourLevels.back() - contourLevels.front() ); - contourLevels.back() += fudgeFactor * ( contourLevels.back() - contourLevels.front() ); - } - else - { - contourLevels.front() *= 0.5; - } + const size_t N = contourLevels.size(); + // Adjust contour levels slightly to avoid weird visual artifacts due to numerical error. + double fudgeFactor = 1.0e-3; + double fudgeAmountMin = fudgeFactor * ( contourLevels[1] - contourLevels[0] ); + double fudgeAmountMax = fudgeFactor * ( contourLevels[N - 1u] - contourLevels[N - 2u] ); + + contourLevels.front() += fudgeAmountMin; + contourLevels.back() -= fudgeAmountMax; double simplifyEpsilon = m_smoothContourLines() ? 5.0e-2 * sampleSpacing() : 1.0e-3 * sampleSpacing();