Revision: 7589
http://playerstage.svn.sourceforge.net/playerstage/?rev=7589&view=rev
Author: rtv
Date: 2009-04-09 17:53:34 +0000 (Thu, 09 Apr 2009)
Log Message:
-----------
fixed -g crash bug
Modified Paths:
--------------
code/stage/trunk/libstage/block.cc
code/stage/trunk/libstage/blockgroup.cc
code/stage/trunk/libstage/stage.hh
code/stage/trunk/libstage/world.cc
code/stage/trunk/libstage/worldgui.cc
Modified: code/stage/trunk/libstage/block.cc
===================================================================
--- code/stage/trunk/libstage/block.cc 2009-04-09 17:12:41 UTC (rev 7588)
+++ code/stage/trunk/libstage/block.cc 2009-04-09 17:53:34 UTC (rev 7589)
@@ -68,8 +68,7 @@
pts[p].x += x;
pts[p].y += y;
}
-
- // force redraw
+
mod->blockgroup.BuildDisplayList( mod );
}
@@ -363,7 +362,7 @@
double px = pts[W].x;
double py = pts[W].y;
- unsigned int keep_W = W;
+ //unsigned int keep_W = W;
int xa = floor( (pts[W ].x + offsetx) * scalex );
int ya = floor( (pts[W ].y + offsety) * scaley );
@@ -372,8 +371,8 @@
mod->rastervis.AddPoint( px, py );
- int keep_xa = xa;
- int keep_xb = xb;
+ //int keep_xa = xa;
+ //int keep_xb = xb;
//printf( " line (%d,%d) to (%d,%d)\n", xa,ya,xb,yb );
Modified: code/stage/trunk/libstage/blockgroup.cc
===================================================================
--- code/stage/trunk/libstage/blockgroup.cc 2009-04-09 17:12:41 UTC (rev
7588)
+++ code/stage/trunk/libstage/blockgroup.cc 2009-04-09 17:53:34 UTC (rev
7589)
@@ -149,6 +149,9 @@
void BlockGroup::BuildDisplayList( Model* mod )
{
+ if( ! mod->world->IsGUI() )
+ return;
+
//printf( "display list for model %s\n", mod->token );
if( displaylist == 0 )
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2009-04-09 17:12:41 UTC (rev 7588)
+++ code/stage/trunk/libstage/stage.hh 2009-04-09 17:53:34 UTC (rev 7589)
@@ -892,12 +892,17 @@
Worldfile* wf; ///< If set, points to the worldfile used to create this
world
public:
+
static const int DEFAULT_PPM = 50; // default resolution in pixels per
meter
static const stg_msec_t DEFAULT_INTERVAL_SIM = 100; ///< duration of sim
timestep
/** hint that the world needs to be redrawn if a GUI is attached */
void NeedRedraw(){ dirty = true; };
+ /** Get human readable string that describes the current simulation
+ time. */
+ virtual std::string ClockString( void );
+
Model* CreateModel( Model* parent, const char* typestr );
void LoadModel( Worldfile* wf, int entity, GHashTable* entitytable );
void LoadBlock( Worldfile* wf, int entity, GHashTable* entitytable );
@@ -1393,9 +1398,9 @@
bool closeWindowQuery();
virtual void AddModel( Model* mod );
+
+ protected:
-
- protected:
virtual void PushColor( stg_color_t col );
virtual void PushColor( double r, double g, double b, double a );
virtual void PopColor();
@@ -1408,6 +1413,7 @@
WorldGui(int W,int H,const char*L=0);
~WorldGui();
+ virtual std::string ClockString();
virtual bool Update();
virtual void Load( const char* filename );
virtual void UnLoad();
@@ -1429,10 +1435,6 @@
/** show the window - need to call this if you don't Load(). */
void Show();
- /** Get human readable string that describes the current simulation
- time. */
- std::string ClockString( void );
-
/** Get human readable string that describes the current global energy
state. */
std::string EnergyString( void );
Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc 2009-04-09 17:12:41 UTC (rev 7588)
+++ code/stage/trunk/libstage/world.cc 2009-04-09 17:53:34 UTC (rev 7589)
@@ -425,7 +425,33 @@
return( (quit_time > 0) && (sim_time >= quit_time) );
}
+std::string World::ClockString()
+{
+ const uint32_t usec_per_hour = 3600000000U;
+ const uint32_t usec_per_minute = 60000000U;
+ const uint32_t usec_per_second = 1000000U;
+ const uint32_t usec_per_msec = 1000U;
+
+ uint32_t hours = sim_time / usec_per_hour;
+ uint32_t minutes = (sim_time % usec_per_hour) / usec_per_minute;
+ uint32_t seconds = (sim_time % usec_per_minute) / usec_per_second;
+ uint32_t msec = (sim_time % usec_per_second) / usec_per_msec;
+
+ std::string str;
+ char buf[256];
+ if( hours > 0 )
+ {
+ snprintf( buf, 255, "%uh", hours );
+ str += buf;
+ }
+
+ snprintf( buf, 255, " %um %02us %03umsec", minutes, seconds, msec);
+ str += buf;
+
+ return str;
+}
+
bool World::Update()
{
PRINT_DEBUG( "World::Update()" );
@@ -480,9 +506,16 @@
LISTMETHOD( reentrant_update_list, Model*, CallUpdateCallbacks );
}
+ if( this->updates % 100 == 0 )
+ {
+ printf( "\r[Stage: %s]", ClockString().c_str() );
+ fflush( stdout );
+ }
+
this->sim_time += this->interval_sim;
this->updates++;
+
return false;
}
Modified: code/stage/trunk/libstage/worldgui.cc
===================================================================
--- code/stage/trunk/libstage/worldgui.cc 2009-04-09 17:12:41 UTC (rev
7588)
+++ code/stage/trunk/libstage/worldgui.cc 2009-04-09 17:53:34 UTC (rev
7589)
@@ -355,7 +355,10 @@
usleep( (stg_usec_t)MIN(sleeptime,20000) ); // check
the GUI at 10Hz min
}
} while( interval < interval_real );
-
+
+// if( !IsGUI() )
+// printf( "[Stage: %s\n", ClockString().cstr()
+
//printf( "\r \t\t timenow %lu", timenow );
//printf( "interval_real %.20f\n", interval_real );
@@ -371,6 +374,29 @@
return val;
}
+std::string WorldGui::ClockString()
+{
+ std::string str = World::ClockString();
+
+ // find the average length of the last few realtime intervals;
+ stg_usec_t average_real_interval = 0;
+ for( uint32_t i=0; i<INTERVAL_LOG_LEN; i++ )
+ average_real_interval += interval_log[i];
+ average_real_interval /= INTERVAL_LOG_LEN;
+
+ double localratio = (double)interval_sim / (double)average_real_interval;
+
+ char buf[32];
+ snprintf( buf, 32, " [%.2f]", localratio );
+ str + buf;
+
+ if( paused == true )
+ str += " [ PAUSED ]";
+
+ return str;
+}
+
+
void WorldGui::AddModel( Model* mod )
{
if( mod->parent == NULL )
@@ -387,44 +413,7 @@
World::RemoveChild( mod );
}
-std::string WorldGui::ClockString()
-{
- const uint32_t usec_per_hour = 3600000000U;
- const uint32_t usec_per_minute = 60000000U;
- const uint32_t usec_per_second = 1000000U;
- const uint32_t usec_per_msec = 1000U;
-
- uint32_t hours = sim_time / usec_per_hour;
- uint32_t minutes = (sim_time % usec_per_hour) / usec_per_minute;
- uint32_t seconds = (sim_time % usec_per_minute) / usec_per_second;
- uint32_t msec = (sim_time % usec_per_second) / usec_per_msec;
-
- // find the average length of the last few realtime intervals;
- stg_usec_t average_real_interval = 0;
- for( uint32_t i=0; i<INTERVAL_LOG_LEN; i++ )
- average_real_interval += interval_log[i];
- average_real_interval /= INTERVAL_LOG_LEN;
-
- double localratio = (double)interval_sim / (double)average_real_interval;
-
- std::string str;
- char buf[256];
- if( hours > 0 )
- {
- snprintf( buf, 255, "%uh", hours );
- str += buf;
- }
-
- snprintf( buf, 255, " %um %02us %03umsec [%.2f]", minutes, seconds, msec,
localratio );
- str += buf;
-
- if( paused == true )
- str += " [ PAUSED ]";
-
- return str;
-}
-
std::string WorldGui::EnergyString()
{
char str[512];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit