Revision: 6766 http://playerstage.svn.sourceforge.net/playerstage/?rev=6766&view=rev Author: alexcb Date: 2008-07-04 16:33:05 -0700 (Fri, 04 Jul 2008)
Log Message: ----------- modified clock string to indicate follow mode Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-04 22:58:26 UTC (rev 6765) +++ code/stage/trunk/libstage/canvas.cc 2008-07-04 23:33:05 UTC (rev 6766) @@ -696,15 +696,18 @@ glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - colorstack.Push( 0.8,0.8,1.0 ); // pale blue - glRectf( -w()/2, -h()/2, -w()/2 +120, -h()/2+20 ); - colorstack.Pop(); + std::string clockstr = world->ClockString(); + if( showFollow == true && last_selection ) + clockstr.append( " --FOLLOW MODE--" ); - char clockstr[50]; - world->ClockString( clockstr, 50 ); - + int width = clockstr.length() * 7; + + colorstack.Push( 0.8,0.8,1.0 ); // pale blue + glRectf( -w()/2, -h()/2, -w()/2 + width, -h()/2+20 ); + colorstack.Pop(); + colorstack.Push( 0,0,0 ); // black - gl_draw_string( -w()/2+4, -h()/2+4, 5, clockstr ); + gl_draw_string( -w()/2+4, -h()/2+4, 5, clockstr.c_str() ); colorstack.Pop(); glEnable( GL_DEPTH_TEST ); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-04 22:58:26 UTC (rev 6765) +++ code/stage/trunk/libstage/stage.hh 2008-07-04 23:33:05 UTC (rev 6766) @@ -2048,7 +2048,7 @@ /** Get human readable string that describes the current simulation time. */ - void ClockString( char* str, size_t maxlen ); + std::string ClockString( void ); /** Set the minimum real time interval between world updates, in microeconds. */ Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-07-04 22:58:26 UTC (rev 6765) +++ code/stage/trunk/libstage/worldgui.cc 2008-07-04 23:33:05 UTC (rev 6766) @@ -108,6 +108,8 @@ #include <FL/Fl_File_Chooser.H> #include <set> +#include <sstream> +#include <iomanip> // this should be set by CMake #ifndef PACKAGE_STRING @@ -271,7 +273,7 @@ } -void StgWorldGui::ClockString( char* str, size_t maxlen ) +std::string StgWorldGui::ClockString() { const uint32_t usec_per_hour = 360000000; const uint32_t usec_per_minute = 60000000; @@ -290,32 +292,27 @@ average_real_interval /= INTERVAL_LOG_LEN; double localratio = (double)interval_sim / (double)average_real_interval; + + std::ostringstream status_stream; + status_stream.fill( '0' ); + if( hours > 0 ) + status_stream << hours << "h"; -#ifdef DEBUG - if( hours > 0 ) - snprintf( str, maxlen, "Time: %uh%02um%02u.%03us\t[%.6f]\tsubs: %d %s", - hours, minutes, seconds, msec, - localratio, - total_subs, - paused ? "--PAUSED--" : "" ); - else - snprintf( str, maxlen, "Time: %02um%02u.%03us\t[%.6f]\tsubs: %d %s", - minutes, seconds, msec, - localratio, - total_subs, - paused ? "--PAUSED--" : "" ); -#else - if( hours > 0 ) - snprintf( str, maxlen, "%uh%02um%02u.%03us\t[%.2f] %s", - hours, minutes, seconds, msec, - localratio, - paused ? "--PAUSED--" : "" ); - else - snprintf( str, maxlen, "%02um%02u.%03us\t[%.2f] %s", - minutes, seconds, msec, - localratio, - paused ? "--PAUSED--" : "" ); -#endif + localratio = 1; + + status_stream << std::setw( 2 ) << minutes << "m" + << std::setw( 2 ) << seconds << "." << std::setprecision( 3 ) << std::setw( 3 ) << msec << "s "; + + char str[ 80 ]; + snprintf( str, 80, "[%.2f]", localratio ); + status_stream << str; + + + if( paused == true ) + status_stream << " --PAUSED--"; + + + return status_stream.str(); } void StgWorldGui::DrawTree( bool drawall ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit