Revision: 6713
http://playerstage.svn.sourceforge.net/playerstage/?rev=6713&view=rev
Author: rtv
Date: 2008-06-30 00:59:07 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
added quick screenshot option. screenshots have a bug - they only work right
when the image width is a multiple of 8
Modified Paths:
--------------
code/stage/trunk/libstage/canvas.cc
code/stage/trunk/libstage/stage.hh
code/stage/trunk/libstage/worldgui.cc
code/stage/trunk/worlds/fasr.world
Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2008-06-29 11:40:30 UTC (rev 6712)
+++ code/stage/trunk/libstage/canvas.cc 2008-06-30 07:59:07 UTC (rev 6713)
@@ -1,8 +1,8 @@
/** canvas.cc
- Implement the main world viewing area in FLTK and OpenGL.
-Author: Richard Vaughan ([EMAIL PROTECTED])
-$Id: canvas.cc,v 1.12 2008-03-03 07:01:12 rtv Exp $
- */
+ Implement the main world viewing area in FLTK and OpenGL.
+ Author: Richard Vaughan ([EMAIL PROTECTED])
+ $Id: canvas.cc,v 1.12 2008-03-03 07:01:12 rtv Exp $
+*/
#include "stage_internal.hh"
#include "texture_manager.hh"
@@ -26,8 +26,8 @@
c->redraw();
Fl::repeat_timeout(((double)c->interval/1000),
-
(Fl_Timeout_Handler)StgCanvas::TimerCallback,
- c);
+ (Fl_Timeout_Handler)StgCanvas::TimerCallback,
+ c);
}
@@ -46,34 +46,35 @@
showTrailRise( "Trails/Rising blocks", "show_trailrise", "#r", false ),
showTrails( "Trails/Fast", "show_trailfast", "t", false ),
showTree( "Debug/Tree", "show_tree", "#T", false ),
- showOccupancy( "Debug/Occupancy", "show_occupancy", "#O", false )
+ showOccupancy( "Debug/Occupancy", "show_occupancy", "#O", false ),
+ showScreenshots( "Save screenshots", "screenshots", "", false )
{
- end();
+ end();
- //show(); // must do this so that the GL context is created before
configuring GL
- // but that line causes a segfault in Linux/X11! TODO: test in OS X
+ //show(); // must do this so that the GL context is created before
configuring GL
+ // but that line causes a segfault in Linux/X11! TODO: test in OS X
- this->world = world;
- selected_models = NULL;
- last_selection = NULL;
+ this->world = world;
+ selected_models = NULL;
+ last_selection = NULL;
- use_perspective_camera = false;
- perspective_camera.setPose( -3.0, 0.0, 1.0 );
- perspective_camera.setPitch( 70.0 ); //look down
+ use_perspective_camera = false;
+ perspective_camera.setPose( -3.0, 0.0, 1.0 );
+ perspective_camera.setPitch( 70.0 ); //look down
- startx = starty = 0;
- //panx = pany = stheta = sphi = 0.0;
- //scale = 15.0;
- interval = 50; //msec between redraws
+ startx = starty = 0;
+ //panx = pany = stheta = sphi = 0.0;
+ //scale = 15.0;
+ interval = 50; //msec between redraws
- graphics = true;
- dragging = false;
- rotating = false;
+ graphics = true;
+ dragging = false;
+ rotating = false;
- // // start the timer that causes regular redraws
- Fl::add_timeout( ((double)interval/1000),
- (Fl_Timeout_Handler)StgCanvas::TimerCallback,
- this);
+ // // start the timer that causes regular redraws
+ Fl::add_timeout( ((double)interval/1000),
+ (Fl_Timeout_Handler)StgCanvas::TimerCallback,
+ this);
}
StgCanvas::~StgCanvas()
@@ -610,27 +611,35 @@
glMatrixMode (GL_MODELVIEW);
}
-
- if( 0 )
+
+ if( showScreenshots )
Screenshot();
}
void StgCanvas::Screenshot()
{
- GLint viewport[4];
- glGetIntegerv(GL_VIEWPORT,viewport);
-
- int width = viewport[2] - viewport[0];
- int height = viewport[3] - viewport[1];
+ int viewport[4];
+ glGetIntegerv(GL_VIEWPORT, viewport);
+ int width = viewport[2];//w();
+ int height = viewport[3];//;;h();
int depth = 3; // RGB
-
- uint8_t* pixels= new uint8_t[ width * height * depth ];
+
+ // printf( "VP: %d %d %d %d WIN %d %d\n",
+// viewport[0],
+// viewport[1],
+// viewport[2],
+// viewport[3],
+// w(),
+// h() );
+
+ uint8_t* pixels = new uint8_t[ width * height * depth ];
glFlush(); // make sure the drawing is done
// read the pixels from the screen
- glReadPixels( viewport[0], viewport[1], width, height, GL_RGB,
GL_UNSIGNED_BYTE, pixels );
+ //glReadPixels( viewport[0], viewport[1], width, height, GL_RGB,
GL_UNSIGNED_BYTE, pixels );
+ glReadPixels( 0,0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels );
static uint32_t count = 0;
char filename[64];
@@ -644,23 +653,29 @@
// write png header information
png_structp pp = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+ assert(pp);
png_infop info = png_create_info_struct(pp);
+ assert(info);
+
png_init_io(pp, fp);
- png_set_compression_level(pp, Z_DEFAULT_COMPRESSION);
+
+ png_bytep rowpointers[height];
+ for( int i=0; i<height; i++ )
+ rowpointers[i] = &pixels[ (height-1-i) * width * depth ];
+
+ png_set_rows( pp, info, rowpointers );
+
+ //png_set_compression_level(pp, Z_DEFAULT_COMPRESSION);
png_set_IHDR( pp, info,
width, height, 8,
PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
- png_write_info(pp, info);
+
+ png_write_png( pp, info, PNG_TRANSFORM_IDENTITY, NULL );
+ png_destroy_write_struct(&pp, &info);
- // write pixels in reverse row order
- for( int y=height-1; y >= 0; y-- )
- png_write_row( pp, pixels + 3*y*width );
-
- png_write_end(pp, info);
- png_destroy_write_struct(&pp, 0);
fclose(fp);
printf( "Saved %s\n", filename );
@@ -684,6 +699,7 @@
showTrails.CreateMenuItem( menu, path );
showTrailRise.CreateMenuItem( menu, path );
showTree.CreateMenuItem( menu, path );
+ showScreenshots.CreateMenuItem( menu, path );
}
@@ -711,6 +727,7 @@
showTrailRise.Load( wf, sec );
showTrails.Load( wf, sec );
showTree.Load( wf, sec );
+ showScreenshots.Load( wf, sec );
invalidate(); // we probably changed something
}
@@ -741,6 +758,7 @@
showTrailRise.Save( wf, sec );
showTrails.Save( wf, sec );
showTree.Save( wf, sec );
+ showScreenshots.Save( wf, sec );
}
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2008-06-29 11:40:30 UTC (rev 6712)
+++ code/stage/trunk/libstage/stage.hh 2008-06-30 07:59:07 UTC (rev 6713)
@@ -1938,19 +1938,20 @@
void DrawGlobalGrid();
Option
- showBlinken,
- showBlocks,
- showClock,
- showData,
- showFlags,
- showFollow,
- showFootprints,
- showGrid,
- showOccupancy,
- showTrailArrows,
- showTrailRise,
- showTrails,
- showTree;
+ showBlinken,
+ showBlocks,
+ showClock,
+ showData,
+ showFlags,
+ showFollow,
+ showFootprints,
+ showGrid,
+ showOccupancy,
+ showScreenshots,
+ showTrailArrows,
+ showTrailRise,
+ showTrails,
+ showTree;
public:
Modified: code/stage/trunk/libstage/worldgui.cc
===================================================================
--- code/stage/trunk/libstage/worldgui.cc 2008-06-29 11:40:30 UTC (rev
6712)
+++ code/stage/trunk/libstage/worldgui.cc 2008-06-30 07:59:07 UTC (rev
6713)
@@ -1,99 +1,99 @@
/** @defgroup worldgui World with Graphical User Interface
- The Stage window consists of a menu bar, a view of the simulated
- world, and a status bar.
+ The Stage window consists of a menu bar, a view of the simulated
+ world, and a status bar.
- The world view shows part of the simulated world. You can zoom the
- view in and out, and scroll it to see more of the world. Simulated
- robot devices, obstacles, etc., are rendered as colored polygons. The
- world view can also show visualizations of the data and configuration
- of various sensor and actuator models. The View menu has options to
- control which data and configurations are rendered.
+ The world view shows part of the simulated world. You can zoom the
+ view in and out, and scroll it to see more of the world. Simulated
+ robot devices, obstacles, etc., are rendered as colored polygons. The
+ world view can also show visualizations of the data and configuration
+ of various sensor and actuator models. The View menu has options to
+ control which data and configurations are rendered.
-API: Stg::StgWorldGui
+ API: Stg::StgWorldGui
-<h2>Worldfile Properties</h2>
+ <h2>Worldfile Properties</h2>
[EMAIL PROTECTED] Summary and default values
+ @par Summary and default values
[EMAIL PROTECTED]
-window
-(
-# gui properties
-center [0 0]
-size [700 740]
-scale 1.0
+ @verbatim
+ window
+ (
+ # gui properties
+ center [0 0]
+ size [700 740]
+ scale 1.0
-# model properties do not apply to the gui window
-)
[EMAIL PROTECTED]
+ # model properties do not apply to the gui window
+ )
+ @endverbatim
[EMAIL PROTECTED] Details
-- title [string]
-- the string displayed in the window title bar. Defaults to the worldfile file
name.
-- size [width:int width:int]
-- size of the window in pixels
-- center [x:float y:float]
-- location of the center of the window in world coordinates (meters)
-- scale [?:double]
-- ratio of world to pixel coordinates (window zoom)
+ @par Details
+ - title [string]
+ - the string displayed in the window title bar. Defaults to the worldfile
file name.
+ - size [width:int width:int]
+ - size of the window in pixels
+ - center [x:float y:float]
+ - location of the center of the window in world coordinates (meters)
+ - scale [?:double]
+ - ratio of world to pixel coordinates (window zoom)
-<h2>Using the Stage window</h2>
+ <h2>Using the Stage window</h2>
-<h3>Scrolling the view</h3>
+ <h3>Scrolling the view</h3>
-<p>Left-click and drag on the background to move your view of the world.
+ <p>Left-click and drag on the background to move your view of the world.
-<h3>Zooming the view</h3>
+ <h3>Zooming the view</h3>
-<p>Right-click and drag on the background to zoom your view of the
-world. When you press the right mouse button, a circle appears. Moving
-the mouse adjusts the size of the circle; the current view is scaled
-with the circle.
+ <p>Right-click and drag on the background to zoom your view of the
+ world. When you press the right mouse button, a circle appears. Moving
+ the mouse adjusts the size of the circle; the current view is scaled
+ with the circle.
-<h3>Saving the world</h3>
+ <h3>Saving the world</h3>
-<P>You can save the current pose of everything in the world, using the
-File/Save menu item. <b>Warning: the saved poses overwrite the current
-world file.</b> Make a copy of your world file before saving if you
-want to keep the old poses.
+ <P>You can save the current pose of everything in the world, using the
+ File/Save menu item. <b>Warning: the saved poses overwrite the current
+ world file.</b> Make a copy of your world file before saving if you
+ want to keep the old poses.
-<h3>Saving a screenshot</h3>
+ <h3>Saving a screenshot</h3>
-<p> The File/Export menu allows you to export a screenshot of the
-current world view in JPEG or PNG format. The frame is saved in the
-current directory with filename in the format "stage-(frame
-number).(jpg/png)".
+ <p> The File/Export menu allows you to export a screenshot of the
+ current world view in JPEG or PNG format. The frame is saved in the
+ current directory with filename in the format "stage-(frame
+ number).(jpg/png)".
-You can also save sequences of screen shots. To start saving a
-sequence, select the desired time interval from the same menu, then
-select File/Export/Sequence of frames. The frames are saved in the
-current directory with filenames in the format "stage-(sequence
-number)-(frame number).(jpg/png)".
+ You can also save sequences of screen shots. To start saving a
+ sequence, select the desired time interval from the same menu, then
+ select File/Export/Sequence of frames. The frames are saved in the
+ current directory with filenames in the format "stage-(sequence
+ number)-(frame number).(jpg/png)".
-The frame and sequence numbers are reset to zero every time you run
-Stage, so be careful to rename important frames before they are
-overwritten.
+ The frame and sequence numbers are reset to zero every time you run
+ Stage, so be careful to rename important frames before they are
+ overwritten.
-<h3>Pausing and resuming the clock</h3>
+ <h3>Pausing and resuming the clock</h3>
-<p>The Clock/Pause menu item allows you to stop the simulation clock,
- freezing the world. Selecting this item again re-starts the clock.
+ <p>The Clock/Pause menu item allows you to stop the simulation clock,
+ freezing the world. Selecting this item again re-starts the clock.
- <h3>View options</h3>
+ <h3>View options</h3>
- <p>The View menu allows you to toggle rendering of a 1m grid, to help
- you line up objects (View/Grid). You can control whether polygons are
- filled (View/Fill polygons); turning this off slightly improves
- graphics performance. The rest of the view menu contains options for
- rendering of data and configuration for each type of model, and a
- debug menu that enables visualization of some of the innards of Stage.
+ <p>The View menu allows you to toggle rendering of a 1m grid, to help
+ you line up objects (View/Grid). You can control whether polygons are
+ filled (View/Fill polygons); turning this off slightly improves
+ graphics performance. The rest of the view menu contains options for
+ rendering of data and configuration for each type of model, and a
+ debug menu that enables visualization of some of the innards of Stage.
- */
+*/
#include "stage_internal.hh"
#include "region.hh"
@@ -114,129 +114,129 @@
#define PACKAGE_STRING "Stage-3.dev"
#endif
- StgWorldGui::StgWorldGui(int W,int H,const char* L) :
- Fl_Window(W,H,L),
- ShowAll( "Visualize all models", "show_vis", "", true )
+StgWorldGui::StgWorldGui(int W,int H,const char* L) :
+ Fl_Window(W,H,L),
+ ShowAll( "Visualize all models", "show_vis", "", true )
{
- //size_range( 100,100 ); // set minimum window size
- oDlg = NULL;
- graphics = true;
- paused = false;
+ //size_range( 100,100 ); // set minimum window size
+ oDlg = NULL;
+ graphics = true;
+ paused = false;
- interval_real = (stg_usec_t)thousand * DEFAULT_INTERVAL_REAL;
+ interval_real = (stg_usec_t)thousand * DEFAULT_INTERVAL_REAL;
- for( unsigned int i=0; i<INTERVAL_LOG_LEN; i++ )
- this->interval_log[i] = this->interval_real;
+ for( unsigned int i=0; i<INTERVAL_LOG_LEN; i++ )
+ this->interval_log[i] = this->interval_real;
- // build the menus
- mbar = new Fl_Menu_Bar(0,0, W, 30);// 640, 30);
- mbar->textsize(12);
+ // build the menus
+ mbar = new Fl_Menu_Bar(0,0, W, 30);// 640, 30);
+ mbar->textsize(12);
- canvas = new StgCanvas( this,0,30,W,H-30 );
- resizable(canvas);
- end();
+ canvas = new StgCanvas( this,0,30,W,H-30 );
+ resizable(canvas);
+ end();
- mbar->add( "&File", 0, 0, 0, FL_SUBMENU );
- mbar->add( "File/&Load World...", FL_CTRL + 'l',
StgWorldGui::fileLoadCb, this, FL_MENU_DIVIDER );
- mbar->add( "File/&Save World", FL_CTRL + 's', StgWorldGui::fileSaveCb,
this );
- mbar->add( "File/Save World &As...", FL_CTRL + FL_SHIFT + 's',
StgWorldGui::fileSaveAsCb, this, FL_MENU_DIVIDER );
+ mbar->add( "&File", 0, 0, 0, FL_SUBMENU );
+ mbar->add( "File/&Load World...", FL_CTRL + 'l', fileLoadCb, this,
FL_MENU_DIVIDER );
+ mbar->add( "File/&Save World", FL_CTRL + 's', fileSaveCb, this );
+ mbar->add( "File/Save World &As...", FL_CTRL + FL_SHIFT + 's',
StgWorldGui::fileSaveAsCb, this, FL_MENU_DIVIDER );
- mbar->add( "File/Screenshots", 0,0,0, FL_SUBMENU );
- //mbar->add( "File/Screenshots/
+ //mbar->add( "File/Screenshots", 0,0,0, FL_SUBMENU );
+ //mbar->add( "File/Screenshots/Save Frames, fileScreenshotSaveCb,
this,FL_MENU_TOGGLE );
- mbar->add( "File/E&xit", FL_CTRL+'q', StgWorldGui::fileExitCb, this );
+ mbar->add( "File/E&xit", FL_CTRL+'q', StgWorldGui::fileExitCb, this );
- mbar->add( "&View", 0, 0, 0, FL_SUBMENU );
- mbar->add( "View/Filter data...", FL_SHIFT + 'd',
StgWorldGui::viewOptionsCb, this );
- canvas->CreateMenuItems( mbar, "View" );
+ mbar->add( "&View", 0, 0, 0, FL_SUBMENU );
+ mbar->add( "View/Filter data...", FL_SHIFT + 'd',
StgWorldGui::viewOptionsCb, this );
+ canvas->CreateMenuItems( mbar, "View" );
- mbar->add( "&Help", 0, 0, 0, FL_SUBMENU );
- mbar->add( "Help/&About Stage...", 0, StgWorldGui::helpAboutCb, this );
- //mbar->add( "Help/HTML Documentation", FL_CTRL + 'g', (Fl_Callback
*)dummy_cb );
+ mbar->add( "&Help", 0, 0, 0, FL_SUBMENU );
+ mbar->add( "Help/&About Stage...", 0, StgWorldGui::helpAboutCb, this );
+ //mbar->add( "Help/HTML Documentation", FL_CTRL + 'g', (Fl_Callback
*)dummy_cb );
- callback( StgWorldGui::windowCb, this );
+ callback( StgWorldGui::windowCb, this );
- show();
+ show();
}
StgWorldGui::~StgWorldGui()
{
- delete mbar;
- if ( oDlg )
- delete oDlg;
- delete canvas;
+ delete mbar;
+ if ( oDlg )
+ delete oDlg;
+ delete canvas;
}
void StgWorldGui::Load( const char* filename )
{
- PRINT_DEBUG1( "%s.Load()", token );
+ PRINT_DEBUG1( "%s.Load()", token );
- fileMan->newWorld( filename );
+ fileMan->newWorld( filename );
- StgWorld::Load( filename );
+ StgWorld::Load( filename );
- int world_section = 0; // use the top-level section for some parms
- // that
traditionally live there
+ int world_section = 0; // use the top-level section for some parms
+ // that traditionally live there
- this->paused =
- wf->ReadInt( world_section, "paused", this->paused );
+ this->paused =
+ wf->ReadInt( world_section, "paused", this->paused );
- this->interval_real = (stg_usec_t)thousand *
- wf->ReadInt( world_section, "interval_real",
(int)(this->interval_real/thousand) );
+ this->interval_real = (stg_usec_t)thousand *
+ wf->ReadInt( world_section, "interval_real",
(int)(this->interval_real/thousand) );
- // use the window section for the rest
- int window_section = wf->LookupEntity( "window" );
+ // use the window section for the rest
+ int window_section = wf->LookupEntity( "window" );
- if( window_section < 1) // no section defined
- return;
+ if( window_section < 1) // no section defined
+ return;
- int width = (int)wf->ReadTupleFloat(window_section, "size", 0, w() );
- int height = (int)wf->ReadTupleFloat(window_section, "size", 1, h() );
- // on OS X this behaves badly - prevents the Window manager resizing
- //larger than this size.
- size( width,height );
+ int width = (int)wf->ReadTupleFloat(window_section, "size", 0, w() );
+ int height = (int)wf->ReadTupleFloat(window_section, "size", 1, h() );
+ // on OS X this behaves badly - prevents the Window manager resizing
+ //larger than this size.
+ size( width,height );
- // configure the canvas
- canvas->Load( wf, window_section );
+ // configure the canvas
+ canvas->Load( wf, window_section );
- updateOptions();
+ updateOptions();
}
void StgWorldGui::UnLoad()
{
- StgWorld::UnLoad();
-// canvas->camera.setPose( 0, 0 );
+ StgWorld::UnLoad();
+ // canvas->camera.setPose( 0, 0 );
}
bool StgWorldGui::Save( const char* filename )
{
- PRINT_DEBUG1( "%s.Save()", token );
+ PRINT_DEBUG1( "%s.Save()", token );
- StgWorld::Save( filename );
+ StgWorld::Save( filename );
- // use the window section for the rest
- int window_section = wf->LookupEntity( "window" );
+ // use the window section for the rest
+ int window_section = wf->LookupEntity( "window" );
- if( window_section > 0 ) // section defined
- {
- wf->WriteTupleFloat( window_section, "size", 0, w() );
- wf->WriteTupleFloat( window_section, "size", 1, h() );
+ if( window_section > 0 ) // section defined
+ {
+ wf->WriteTupleFloat( window_section, "size", 0, w() );
+ wf->WriteTupleFloat( window_section, "size", 1, h() );
- canvas->Save( wf, window_section );
+ canvas->Save( wf, window_section );
- // TODO - per model visualizations save
- }
+ // TODO - per model visualizations save
+ }
- // TODO - error checking
- return true;
+ // TODO - error checking
+ return true;
}
bool StgWorldGui::Update()
{
if( real_time_of_last_update == 0 )
- real_time_of_last_update = RealTimeNow();
+ real_time_of_last_update = RealTimeNow();
bool val = paused ? true : StgWorld::Update();
@@ -244,16 +244,16 @@
stg_usec_t timenow;
do { // we loop over updating the GUI, sleeping if there's any spare
- // time
- Fl::check();
+ // time
+ Fl::check();
- timenow = RealTimeNow();
- interval = timenow - real_time_of_last_update; // guaranteed to be >= 0
+ timenow = RealTimeNow();
+ interval = timenow - real_time_of_last_update; // guaranteed to be >= 0
- double sleeptime = (double)interval_real - (double)interval;
+ double sleeptime = (double)interval_real - (double)interval;
- if( sleeptime > 0 )
- usleep( (stg_usec_t)MIN(sleeptime,100000) ); // check the GUI at
10Hz min
+ if( sleeptime > 0 )
+ usleep( (stg_usec_t)MIN(sleeptime,100000) ); // check the GUI at 10Hz min
} while( interval < interval_real );
@@ -268,351 +268,351 @@
void StgWorldGui::ClockString( char* str, size_t maxlen )
{
- const uint32_t usec_per_hour = 360000000;
- const uint32_t usec_per_minute = 60000000;
- const uint32_t usec_per_second = 1000000;
- const uint32_t usec_per_msec = 1000;
+ const uint32_t usec_per_hour = 360000000;
+ const uint32_t usec_per_minute = 60000000;
+ const uint32_t usec_per_second = 1000000;
+ const uint32_t usec_per_msec = 1000;
- 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;
+ 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;
+ // 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;
+ double localratio = (double)interval_sim / (double)average_real_interval;
#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--" : "" );
+ 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--" : "" );
+ 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
}
void StgWorldGui::DrawTree( bool drawall )
{
- g_hash_table_foreach( superregions, (GHFunc)SuperRegion::Draw_cb, NULL
);
+ g_hash_table_foreach( superregions, (GHFunc)SuperRegion::Draw_cb, NULL );
}
void StgWorldGui::DrawFloor()
{
- PushColor( 1,1,1,1 );
- g_hash_table_foreach( superregions, (GHFunc)SuperRegion::Floor_cb, NULL
);
- PopColor();
+ PushColor( 1,1,1,1 );
+ g_hash_table_foreach( superregions, (GHFunc)SuperRegion::Floor_cb, NULL );
+ PopColor();
}
void StgWorldGui::windowCb( Fl_Widget* w, void* p )
{
- StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
+ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
- switch ( Fl::event() ) {
- case FL_SHORTCUT:
- if ( Fl::event_key() == FL_Escape )
- return;
- case FL_CLOSE: // clicked close button
- bool done = worldGui->closeWindowQuery();
- if ( !done )
- return;
- }
+ switch ( Fl::event() ) {
+ case FL_SHORTCUT:
+ if ( Fl::event_key() == FL_Escape )
+ return;
+ case FL_CLOSE: // clicked close button
+ bool done = worldGui->closeWindowQuery();
+ if ( !done )
+ return;
+ }
- exit(0);
+ exit(0);
}
void StgWorldGui::fileLoadCb( Fl_Widget* w, void* p )
{
- StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
+ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
- const char* filename;
- const char* worldsPath;
- //bool success;
- const char* pattern = "World Files (*.world)";
+ const char* filename;
+ const char* worldsPath;
+ //bool success;
+ const char* pattern = "World Files (*.world)";
- worldsPath = worldGui->fileMan->worldsRoot().c_str();
- Fl_File_Chooser fc( worldsPath, pattern, Fl_File_Chooser::CREATE, "Load
World File..." );
- fc.ok_label( "Load" );
+ worldsPath = worldGui->fileMan->worldsRoot().c_str();
+ Fl_File_Chooser fc( worldsPath, pattern, Fl_File_Chooser::CREATE, "Load
World File..." );
+ fc.ok_label( "Load" );
- fc.show();
- while (fc.shown())
- Fl::wait();
+ fc.show();
+ while (fc.shown())
+ Fl::wait();
- filename = fc.value();
+ filename = fc.value();
- if (filename != NULL) { // chose something
- if ( worldGui->fileMan->readable( filename ) ) {
- // file is readable, clear and load
+ if (filename != NULL) { // chose something
+ if ( worldGui->fileMan->readable( filename ) ) {
+ // file is readable, clear and load
- // if (initialized) {
- worldGui->Stop();
- worldGui->UnLoad();
- // }
+ // if (initialized) {
+ worldGui->Stop();
+ worldGui->UnLoad();
+ // }
- // todo: make sure loading is successful
- worldGui->Load( filename );
- worldGui->Start(); // if (stopped)
- }
- else {
- fl_alert( "Unable to read selected world file." );
- }
+ // todo: make sure loading is successful
+ worldGui->Load( filename );
+ worldGui->Start(); // if (stopped)
+ }
+ else {
+ fl_alert( "Unable to read selected world file." );
+ }
- }
+ }
}
void StgWorldGui::fileSaveCb( Fl_Widget* w, void* p )
{
- StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
+ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
- // save to current file
- bool success = worldGui->Save( NULL );
- if ( !success ) {
- fl_alert( "Error saving world file." );
- }
+ // save to current file
+ bool success = worldGui->Save( NULL );
+ if ( !success ) {
+ fl_alert( "Error saving world file." );
+ }
}
void StgWorldGui::fileSaveAsCb( Fl_Widget* w, void* p )
{
- StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
+ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
- worldGui->saveAsDialog();
+ worldGui->saveAsDialog();
}
void StgWorldGui::fileExitCb( Fl_Widget* w, void* p )
{
- StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
+ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
- bool done = worldGui->closeWindowQuery();
- if (done) {
- exit(0);
- }
+ bool done = worldGui->closeWindowQuery();
+ if (done) {
+ exit(0);
+ }
}
void StgWorldGui::viewOptionsCb( Fl_Widget* w, void* p ) {
- StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
+ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
- if ( !worldGui->oDlg ) {
- int x = worldGui->w()+worldGui->x() + 10;
- int y = worldGui->y();
- OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 );
- oDlg->callback( optionsDlgCb, worldGui );
- oDlg->showAllOpt( &worldGui->ShowAll );
- oDlg->setOptions( worldGui->drawOptions );
- oDlg->show();
+ if ( !worldGui->oDlg ) {
+ int x = worldGui->w()+worldGui->x() + 10;
+ int y = worldGui->y();
+ OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 );
+ oDlg->callback( optionsDlgCb, worldGui );
+ oDlg->showAllOpt( &worldGui->ShowAll );
+ oDlg->setOptions( worldGui->drawOptions );
+ oDlg->show();
- worldGui->oDlg = oDlg;
- }
- else {
- worldGui->oDlg->show(); // bring it to front
- }
+ worldGui->oDlg = oDlg;
+ }
+ else {
+ worldGui->oDlg->show(); // bring it to front
+ }
}
void StgWorldGui::optionsDlgCb( Fl_Widget* w, void* p ) {
- OptionsDlg* oDlg = static_cast<OptionsDlg*>( w );
- StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
+ OptionsDlg* oDlg = static_cast<OptionsDlg*>( w );
+ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
- // get event from dialog
- OptionsDlg::event_t event;
- event = oDlg->event();
+ // get event from dialog
+ OptionsDlg::event_t event;
+ event = oDlg->event();
- // Check FLTK events first
- switch ( Fl::event() ) {
- case FL_SHORTCUT:
- if ( Fl::event_key() != FL_Escape )
- break; //return
- // otherwise, ESC pressed-> do as below
- case FL_CLOSE: // clicked close button
- // override event to close
- event = OptionsDlg::CLOSE;
- break;
- }
+ // Check FLTK events first
+ switch ( Fl::event() ) {
+ case FL_SHORTCUT:
+ if ( Fl::event_key() != FL_Escape )
+ break; //return
+ // otherwise, ESC pressed-> do as below
+ case FL_CLOSE: // clicked close button
+ // override event to close
+ event = OptionsDlg::CLOSE;
+ break;
+ }
- switch ( event ) {
- case OptionsDlg::CHANGE:
- {
- //Option* o = oDlg->changed();
- //printf( "\"%s\" changed to %d!\n", o->name().c_str(),
o->val() );
- break;
- }
- case OptionsDlg::CLOSE:
- // invalidate the oDlg pointer from the WorldGui
- // instance before the dialog is destroyed
- worldGui->oDlg = NULL;
- oDlg->hide();
- //Fl::delete_widget( oDlg );
- return;
- case OptionsDlg::NO_EVENT:
- case OptionsDlg::CHANGE_ALL:
- break;
- }
+ switch ( event ) {
+ case OptionsDlg::CHANGE:
+ {
+ //Option* o = oDlg->changed();
+ //printf( "\"%s\" changed to %d!\n", o->name().c_str(), o->val() );
+ break;
+ }
+ case OptionsDlg::CLOSE:
+ // invalidate the oDlg pointer from the WorldGui
+ // instance before the dialog is destroyed
+ worldGui->oDlg = NULL;
+ oDlg->hide();
+ //Fl::delete_widget( oDlg );
+ return;
+ case OptionsDlg::NO_EVENT:
+ case OptionsDlg::CHANGE_ALL:
+ break;
+ }
}
void aboutOKBtnCb( Fl_Widget* w, void* p ) {
- Fl_Return_Button* btn;
- btn = static_cast<Fl_Return_Button*>( w );
+ Fl_Return_Button* btn;
+ btn = static_cast<Fl_Return_Button*>( w );
- btn->window()->do_callback();
+ btn->window()->do_callback();
}
void aboutCloseCb( Fl_Widget* w, void* p ) {
- Fl_Window* win;
- win = static_cast<Fl_Window*>( w );
- Fl_Text_Display* textDisplay;
- textDisplay = static_cast<Fl_Text_Display*>( p );
+ Fl_Window* win;
+ win = static_cast<Fl_Window*>( w );
+ Fl_Text_Display* textDisplay;
+ textDisplay = static_cast<Fl_Text_Display*>( p );
- Fl_Text_Buffer* tbuf = textDisplay->buffer();
- textDisplay->buffer( NULL );
- delete tbuf;
- Fl::delete_widget( win );
+ Fl_Text_Buffer* tbuf = textDisplay->buffer();
+ textDisplay->buffer( NULL );
+ delete tbuf;
+ Fl::delete_widget( win );
}
void StgWorldGui::helpAboutCb( Fl_Widget* w, void* p )
{
- StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
+ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p );
- fl_register_images();
+ fl_register_images();
- const int Width = 400;
- const int Height = 220;
- const int Spc = 10;
- const int ButtonH = 25;
- const int ButtonW = 60;
- const int pngH = 82;
- //const int pngW = 264;
+ const int Width = 400;
+ const int Height = 220;
+ const int Spc = 10;
+ const int ButtonH = 25;
+ const int ButtonW = 60;
+ const int pngH = 82;
+ //const int pngW = 264;
- Fl_Window* win = new Fl_Window( Width, Height ); // make a window
+ Fl_Window* win = new Fl_Window( Width, Height ); // make a window
- Fl_Box* box = new Fl_Box( Spc, Spc,
- Width-2*Spc, pngH ); // widget that will contain
image
+ Fl_Box* box = new Fl_Box( Spc, Spc,
+ Width-2*Spc, pngH ); // widget that will contain
image
- std::string fullpath;
- fullpath = worldGui->fileMan->fullPath( "stagelogo.png" );
- Fl_PNG_Image* png = new Fl_PNG_Image( fullpath.c_str() ); // load image
into ram
- box->image( png ); // attach image to box
+ std::string fullpath;
+ fullpath = worldGui->fileMan->fullPath( "stagelogo.png" );
+ Fl_PNG_Image* png = new Fl_PNG_Image( fullpath.c_str() ); // load image into
ram
+ box->image( png ); // attach image to box
- Fl_Text_Display* textDisplay;
- textDisplay = new Fl_Text_Display( Spc, pngH+2*Spc,
- Width-2*Spc,
Height-pngH-ButtonH-4*Spc );
- textDisplay->box( FL_NO_BOX );
- textDisplay->color( win->color() );
- win->callback( aboutCloseCb, textDisplay );
+ Fl_Text_Display* textDisplay;
+ textDisplay = new Fl_Text_Display( Spc, pngH+2*Spc,
+ Width-2*Spc, Height-pngH-ButtonH-4*Spc );
+ textDisplay->box( FL_NO_BOX );
+ textDisplay->color( win->color() );
+ win->callback( aboutCloseCb, textDisplay );
- const char* AboutText =
- "\n"
- "Part of the Player Project\n"
- "http://playerstage.sourceforge.net\n"
- "Copyright 2000-2008 Richard Vaughan and contributors";
+ const char* AboutText =
+ "\n"
+ "Part of the Player Project\n"
+ "http://playerstage.sourceforge.net\n"
+ "Copyright 2000-2008 Richard Vaughan and contributors";
- Fl_Text_Buffer* tbuf = new Fl_Text_Buffer;
- tbuf->text( PACKAGE_STRING );
- tbuf->append( AboutText );
- textDisplay->buffer( tbuf );
+ Fl_Text_Buffer* tbuf = new Fl_Text_Buffer;
+ tbuf->text( PACKAGE_STRING );
+ tbuf->append( AboutText );
+ textDisplay->buffer( tbuf );
- Fl_Return_Button* button;
- button = new Fl_Return_Button( (Width - ButtonW)/2, Height-Spc-ButtonH,
- ButtonW, ButtonH,
- "&OK" );
- button->callback( aboutOKBtnCb );
+ Fl_Return_Button* button;
+ button = new Fl_Return_Button( (Width - ButtonW)/2, Height-Spc-ButtonH,
+ ButtonW, ButtonH,
+ "&OK" );
+ button->callback( aboutOKBtnCb );
- win->show();
+ win->show();
}
bool StgWorldGui::saveAsDialog()
{
- const char* newFilename;
- bool success = false;
- const char* pattern = "World Files (*.world)";
+ const char* newFilename;
+ bool success = false;
+ const char* pattern = "World Files (*.world)";
- Fl_File_Chooser fc( wf->filename, pattern, Fl_File_Chooser::CREATE,
"Save File As..." );
- fc.ok_label( "Save" );
+ Fl_File_Chooser fc( wf->filename, pattern, Fl_File_Chooser::CREATE, "Save
File As..." );
+ fc.ok_label( "Save" );
- fc.show();
- while (fc.shown())
- Fl::wait();
+ fc.show();
+ while (fc.shown())
+ Fl::wait();
- newFilename = fc.value();
+ newFilename = fc.value();
- if (newFilename != NULL) {
- // todo: make sure file ends in .world
- success = Save( newFilename );
- if ( !success ) {
- fl_alert( "Error saving world file." );
- }
- }
+ if (newFilename != NULL) {
+ // todo: make sure file ends in .world
+ success = Save( newFilename );
+ if ( !success ) {
+ fl_alert( "Error saving world file." );
+ }
+ }
- return success;
+ return success;
}
bool StgWorldGui::closeWindowQuery()
{
- int choice;
+ int choice;
- if ( wf ) {
- // worldfile loaded, ask to save
- choice = fl_choice("Do you want to save?",
- "&Cancel", // ->0: defaults
to ESC
- "&Yes", // ->1
- "&No" // ->2
- );
+ if ( wf ) {
+ // worldfile loaded, ask to save
+ choice = fl_choice("Do you want to save?",
+ "&Cancel", // ->0: defaults to ESC
+ "&Yes", // ->1
+ "&No" // ->2
+ );
- switch (choice) {
- case 1: // Yes
- if ( saveAsDialog() ) {
- return true;
- }
- else {
- return false;
- }
- case 2: // No
- return true;
- }
+ switch (choice) {
+ case 1: // Yes
+ if ( saveAsDialog() ) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ case 2: // No
+ return true;
+ }
- // Cancel
- return false;
- }
- else {
- // nothing is loaded, just quit
- return true;
- }
+ // Cancel
+ return false;
+ }
+ else {
+ // nothing is loaded, just quit
+ return true;
+ }
}
void StgWorldGui::updateOptions() {
std::set<Option*, Option::optComp> options;
- std::vector<Option*> modOpts;
- for( GList* it=update_list; it; it=it->next ) {
- modOpts = ((StgModel*)it->data)->getOptions();
- options.insert( modOpts.begin(), modOpts.end() );
- }
+ std::vector<Option*> modOpts;
+ for( GList* it=update_list; it; it=it->next ) {
+ modOpts = ((StgModel*)it->data)->getOptions();
+ options.insert( modOpts.begin(), modOpts.end() );
+ }
- drawOptions.assign( options.begin(), options.end() );
+ drawOptions.assign( options.begin(), options.end() );
- if ( oDlg ) {
- oDlg->setOptions( drawOptions );
- }
+ if ( oDlg ) {
+ oDlg->setOptions( drawOptions );
+ }
}
Modified: code/stage/trunk/worlds/fasr.world
===================================================================
--- code/stage/trunk/worlds/fasr.world 2008-06-29 11:40:30 UTC (rev 6712)
+++ code/stage/trunk/worlds/fasr.world 2008-06-30 07:59:07 UTC (rev 6713)
@@ -21,7 +21,7 @@
# configure the GUI window
window
(
- size [ 671.000 413.000 ]
+ size [ 280.000 480.000 ]
center [-0.294 0.114]
rotate [ -52.500 -18.500 ]
scale 27.525
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit