From e6f4c5c508fda26a88fe34bebc90f64db6f5fd1c Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Tue, 26 Jan 2010 16:24:20 +0000 Subject: [PATCH] Increase precision of DbU::getValueString() to 3 decimals for micrometer. Uses SmartTruncate when displaying rulers. --- hurricane/src/hurricane/DbU.cpp | 6 +++--- hurricane/src/hviewer/CellWidget.cpp | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hurricane/src/hurricane/DbU.cpp b/hurricane/src/hurricane/DbU.cpp index fa3c5c93..cb2da7b9 100644 --- a/hurricane/src/hurricane/DbU.cpp +++ b/hurricane/src/hurricane/DbU.cpp @@ -260,10 +260,10 @@ namespace Hurricane { if ( _stringMode == Grid ) { unitSymbol = 'g'; - snprintf ( buffer, 1024, "%.1f", getGrid(u) ); + snprintf ( buffer, 1024, "%.3f", getGrid(u) ); } else if ( _stringMode == Symbolic ) { unitSymbol = 'l'; - snprintf ( buffer, 1024, "%.1f", getLambda(u) ); + snprintf ( buffer, 1024, "%.3f", getLambda(u) ); } else if ( _stringMode == Physical ) { switch ( _stringModeUnitPower ) { case Pico: unitSymbol = 'p'; break; @@ -274,7 +274,7 @@ namespace Hurricane { case Kilo: unitSymbol = 'k'; break; default: unitSymbol = '?'; break; } - snprintf ( buffer, 1024, "%.1f", getPhysical(u,_stringModeUnitPower) ); + snprintf ( buffer, 1024, "%.3f", getPhysical(u,_stringModeUnitPower) ); } else { if ( _stringMode != Db ) cerr << "[ERROR] Unknown Unit representation mode: " << _stringMode << endl; diff --git a/hurricane/src/hviewer/CellWidget.cpp b/hurricane/src/hviewer/CellWidget.cpp index 8222ec41..e20f8dd4 100644 --- a/hurricane/src/hviewer/CellWidget.cpp +++ b/hurricane/src/hviewer/CellWidget.cpp @@ -1904,7 +1904,8 @@ namespace Hurricane { // if ( !tick ) continue; - textGrad = DbU::getValueString( gradStep*tick, (symbolicMode()) ? DbU::Symbolic : DbU::Grid ); + textGrad = DbU::getValueString( gradStep*tick + , DbU::SmartTruncate|((symbolicMode())?DbU::Symbolic:DbU::Grid) ); textGrad.resize ( textGrad.size()-1 ); drawDisplayText ( QPoint ( pxGrad - 1, pxOrigin.y() + tickLength ) @@ -1920,7 +1921,7 @@ namespace Hurricane { , pxAngle.x(), pxAngle.y()+tickLength ); textGrad = DbU::getValueString ( angle.getX() - origin.getX() - , (symbolicMode()) ? DbU::Symbolic : DbU::Grid ); + , DbU::SmartTruncate|((symbolicMode())?DbU::Symbolic:DbU::Grid) ); textGrad.resize ( textGrad.size()-1 ); drawDisplayText ( QPoint ( pxAngle.x() - 1,pxAngle.y() + tickLength ) @@ -1963,7 +1964,8 @@ namespace Hurricane { // if ( !tick ) continue; - textGrad = DbU::getValueString( gradStep*tick, (symbolicMode()) ? DbU::Symbolic : DbU::Grid ); + textGrad = DbU::getValueString( gradStep*tick + , DbU::SmartTruncate|((symbolicMode())?DbU::Symbolic:DbU::Grid) ); textGrad.resize ( textGrad.size()-1 ); drawDisplayText ( QPoint(pxOrigin.x() - tickLength,pyGrad + 1) @@ -1979,7 +1981,7 @@ namespace Hurricane { , pxOrigin.x()-tickLength, pxAngle.y() ); textGrad = DbU::getValueString( angle.getY() - origin.getY() - , (symbolicMode()) ? DbU::Symbolic : DbU::Grid ); + , DbU::SmartTruncate|((symbolicMode())?DbU::Symbolic:DbU::Grid) ); textGrad.resize ( textGrad.size()-1 ); drawDisplayText ( QPoint(pxOrigin.x() - tickLength,pxAngle.y() + 1)