[Thplot-cvs] CVS: thplot/src/Draw Axis.cpp,1.4,1.5
Status: Pre-Alpha
Brought to you by:
apeden
From: Tony P. <ap...@us...> - 2002-07-03 14:56:04
|
Update of /cvsroot/thplot/thplot/src/Draw In directory usw-pr-cvs1:/tmp/cvs-serv28368/src/Draw Modified Files: Axis.cpp Log Message: Improved formatting of numeric tick labels. Index: Axis.cpp =================================================================== RCS file: /cvsroot/thplot/thplot/src/Draw/Axis.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Axis.cpp 3 Jul 2002 13:23:40 -0000 1.4 --- Axis.cpp 3 Jul 2002 14:56:01 -0000 1.5 *************** *** 130,142 **** if(labelson) { char tmp[80]; double value; if(!vertical){ value = min; for(i=0;i<=length;i+=20) { ! snprintf(tmp,80,"%g",value); tickFont->setHorizontalJustification(OGLFT::Face::CENTER); tickFont->setVerticalJustification(OGLFT::Face::TOP); tickFont->draw( parent->getX()+i, ! parent->getY()-hashLength-2, tmp ); value += 2*delta; --- 130,155 ---- if(labelson) { char tmp[80]; + char fmt[10]; + int mag = int( log10(fabs(delta)) ); + if( mag < 0 ) { + if( mag > -6 ) { + mag = abs(mag); + snprintf(fmt,10,"%%%d.%df",mag+3,mag); + } else { + snprintf(fmt,10,"%%3.1E"); + } + } else { + snprintf(fmt,10,"%%g"); + } + cout << fmt << endl; double value; if(!vertical){ value = min; for(i=0;i<=length;i+=20) { ! snprintf(tmp,80,fmt,value); tickFont->setHorizontalJustification(OGLFT::Face::CENTER); tickFont->setVerticalJustification(OGLFT::Face::TOP); tickFont->draw( parent->getX()+i, ! parent->getY()-hashLength-1, tmp ); value += 2*delta; *************** *** 145,152 **** value = min; for(i=0;i<=length;i+=20) { ! snprintf(tmp,80,"%g",value); tickFont->setVerticalJustification(OGLFT::Face::MIDDLE); tickFont->setHorizontalJustification(OGLFT::Face::RIGHT); ! tickFont->draw( parent->getX()-hashLength-5, parent->getY()+i, tmp ); --- 158,165 ---- value = min; for(i=0;i<=length;i+=20) { ! snprintf(tmp,80,fmt,value); tickFont->setVerticalJustification(OGLFT::Face::MIDDLE); tickFont->setHorizontalJustification(OGLFT::Face::RIGHT); ! tickFont->draw( parent->getX()-hashLength-1, parent->getY()+i, tmp ); |