mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-20 11:48:35 -06:00
#5659 Well Disks: Use decimal number format for small numbers
This commit is contained in:
parent
08f560a058
commit
3c2d456996
@ -193,8 +193,6 @@ void RivWellDiskPartMgr::buildWellDiskParts( size_t frameIndex, const caf::Displ
|
||||
|
||||
std::vector<std::pair<cvf::String, cvf::Vec3f>> labelsWithPosition;
|
||||
|
||||
int numberPrecision = 2;
|
||||
|
||||
double accumulatedPropertyValue = 0.0;
|
||||
const double valueThresholdForLabel = 1e-6;
|
||||
|
||||
@ -216,7 +214,7 @@ void RivWellDiskPartMgr::buildWellDiskParts( size_t frameIndex, const caf::Displ
|
||||
if ( diskData.singlePropertyValue() > valueThresholdForLabel )
|
||||
{
|
||||
const double singleProperty = diskData.singlePropertyValueSigned();
|
||||
labelText += QString( "\n%2" ).arg( singleProperty, 0, 'g', numberPrecision );
|
||||
labelText += QString( "\n%2" ).arg( RivWellDiskPartMgr::formatNumber( singleProperty ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,11 +237,8 @@ void RivWellDiskPartMgr::buildWellDiskParts( size_t frameIndex, const caf::Displ
|
||||
|
||||
if ( oilFraction > valueThresholdForLabel )
|
||||
{
|
||||
auto p = createTextAndLocation( oilFraction / 2.0,
|
||||
diskPosition,
|
||||
ijScaleFactor,
|
||||
diskData.oilSigned(),
|
||||
numberPrecision );
|
||||
auto p = createTextAndLocation( oilFraction / 2.0, diskPosition, ijScaleFactor, diskData.oilSigned() );
|
||||
|
||||
labelsWithPosition.push_back( p );
|
||||
aggregatedFraction += oilFraction;
|
||||
}
|
||||
@ -253,8 +248,7 @@ void RivWellDiskPartMgr::buildWellDiskParts( size_t frameIndex, const caf::Displ
|
||||
auto p = createTextAndLocation( aggregatedFraction + gasFraction / 2.0,
|
||||
diskPosition,
|
||||
ijScaleFactor,
|
||||
diskData.gasSigned(),
|
||||
numberPrecision );
|
||||
diskData.gasSigned() );
|
||||
labelsWithPosition.push_back( p );
|
||||
aggregatedFraction += gasFraction;
|
||||
}
|
||||
@ -264,8 +258,7 @@ void RivWellDiskPartMgr::buildWellDiskParts( size_t frameIndex, const caf::Displ
|
||||
auto p = createTextAndLocation( aggregatedFraction + waterFraction / 2.0,
|
||||
diskPosition,
|
||||
ijScaleFactor,
|
||||
diskData.waterSigned(),
|
||||
numberPrecision );
|
||||
diskData.waterSigned() );
|
||||
|
||||
labelsWithPosition.push_back( p );
|
||||
aggregatedFraction += waterFraction;
|
||||
@ -409,14 +402,21 @@ void RivWellDiskPartMgr::buildWellDiskParts( size_t frameIndex, const caf::Displ
|
||||
}
|
||||
}
|
||||
|
||||
QString RivWellDiskPartMgr::formatNumber( double num )
|
||||
{
|
||||
if ( std::abs( num ) < 1e4 )
|
||||
return QString::number( num, 'f', 1 );
|
||||
else
|
||||
return QString::number( num, 'g', 2 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<cvf::String, cvf::Vec3f> RivWellDiskPartMgr::createTextAndLocation( const double aggregatedFraction,
|
||||
cvf::Vec3d diskPosition,
|
||||
double ijScaleFactor,
|
||||
const double fraction,
|
||||
int precision )
|
||||
const double fraction )
|
||||
{
|
||||
double sinA = cvf::Math::sin( aggregatedFraction * 2.0 * cvf::PI_F );
|
||||
double cosA = cvf::Math::cos( aggregatedFraction * 2.0 * cvf::PI_F );
|
||||
@ -430,7 +430,7 @@ std::pair<cvf::String, cvf::Vec3f> RivWellDiskPartMgr::createTextAndLocation( co
|
||||
v.x() = v.x() + static_cast<float>( -sinA * radius );
|
||||
v.y() = v.y() + static_cast<float>( cosA * radius );
|
||||
|
||||
auto s = QString::number( fraction, 'g', precision );
|
||||
auto s = RivWellDiskPartMgr::formatNumber( fraction );
|
||||
cvf::String text = cvf::String( s.toStdString() );
|
||||
|
||||
auto p = std::make_pair( text, v );
|
||||
|
@ -59,14 +59,14 @@ private:
|
||||
std::pair<cvf::String, cvf::Vec3f> createTextAndLocation( const double aggregatedFraction,
|
||||
cvf::Vec3d diskPosition,
|
||||
double ijScaleFactor,
|
||||
const double fraction,
|
||||
int precision );
|
||||
const double fraction );
|
||||
|
||||
void clearAllGeometry();
|
||||
Rim3dView* viewWithSettings();
|
||||
RimSimWellInViewCollection* simWellInViewCollection();
|
||||
|
||||
static cvf::Color4f getWellInjectionColor( RigWellResultFrame::WellProductionType productionType );
|
||||
static QString formatNumber( double num );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimSimWellInView> m_rimWell;
|
||||
|
Loading…
Reference in New Issue
Block a user