Revision: 7567
http://playerstage.svn.sourceforge.net/playerstage/?rev=7567&view=rev
Author: rtv
Date: 2009-03-31 17:07:29 +0000 (Tue, 31 Mar 2009)
Log Message:
-----------
adding strip plot vis
Modified Paths:
--------------
code/stage/trunk/libstage/CMakeLists.txt
code/stage/trunk/libstage/canvas.cc
code/stage/trunk/libstage/canvas.hh
code/stage/trunk/libstage/gl.cc
code/stage/trunk/libstage/model.cc
code/stage/trunk/libstage/model_fiducial.cc
code/stage/trunk/libstage/powerpack.cc
code/stage/trunk/libstage/stage.hh
Modified: code/stage/trunk/libstage/CMakeLists.txt
===================================================================
--- code/stage/trunk/libstage/CMakeLists.txt 2009-03-31 07:31:00 UTC (rev
7566)
+++ code/stage/trunk/libstage/CMakeLists.txt 2009-03-31 17:07:29 UTC (rev
7567)
@@ -3,7 +3,9 @@
# for config.h
include_directories(${PROJECT_BINARY_DIR})
-set( stageSrcs ancestor.cc
+set( stageSrcs
+ vis_strip.cc
+ ancestor.cc
block.cc
blockgroup.cc
camera.cc
Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2009-03-31 07:31:00 UTC (rev 7566)
+++ code/stage/trunk/libstage/canvas.cc 2009-03-31 17:07:29 UTC (rev 7567)
@@ -125,8 +125,7 @@
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
// install a font
- //gl_font( FL_HELVETICA, 12 );
- gl_font( FL_COURIER, 12 );
+ gl_font( FL_HELVETICA, 12 );
blur = false;
@@ -177,7 +176,7 @@
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- fl_font( FL_HELVETICA, 12 );
+ // fl_font( FL_HELVETICA, 16 );
init_done = true;
}
@@ -983,7 +982,7 @@
colorstack.Push( 0.8,1.0,0.8,0.85 ); // pale green
glRectf( 0, height, width, 90 );
colorstack.Push( 0,0,0 ); // black
- Gl::draw_string_multiline( margin, height + margin,
txtWidth, 50,
+ Gl::draw_string_multiline( margin, height + margin,
width, 50,
world->EnergyString().c_str(),
(Fl_Align)( FL_ALIGN_LEFT | FL_ALIGN_BOTTOM) );
colorstack.Pop();
@@ -1006,6 +1005,30 @@
}
+void Canvas::EnterScreenCS()
+{
+ //use orthogonal projeciton without any zoom
+ glMatrixMode (GL_PROJECTION);
+ glPushMatrix(); //save old projection
+ glLoadIdentity ();
+ glOrtho( 0, w(), 0, h(), -100, 100 );
+ glMatrixMode (GL_MODELVIEW);
+
+ glPushMatrix();
+ glLoadIdentity();
+ glDisable( GL_DEPTH_TEST );
+}
+
+void Canvas::LeaveScreenCS()
+{
+ glEnable( GL_DEPTH_TEST );
+ glPopMatrix();
+ glMatrixMode (GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode (GL_MODELVIEW);
+}
+
+
void Canvas::Screenshot()
{
Modified: code/stage/trunk/libstage/canvas.hh
===================================================================
--- code/stage/trunk/libstage/canvas.hh 2009-03-31 07:31:00 UTC (rev 7566)
+++ code/stage/trunk/libstage/canvas.hh 2009-03-31 17:07:29 UTC (rev 7567)
@@ -130,10 +130,15 @@
void PopColor(){ colorstack.Pop(); }
void InvertView( uint32_t invertflags );
+
+ bool VisualizeAll(){ return ! visualizeAll; }
static void TimerCallback( Canvas* canvas );
static void perspectiveCb( Fl_Widget* w, void* p );
+ void EnterScreenCS();
+ void LeaveScreenCS();
+
void Load( Worldfile* wf, int section );
void Save( Worldfile* wf, int section );
};
Modified: code/stage/trunk/libstage/gl.cc
===================================================================
--- code/stage/trunk/libstage/gl.cc 2009-03-31 07:31:00 UTC (rev 7566)
+++ code/stage/trunk/libstage/gl.cc 2009-03-31 17:07:29 UTC (rev 7567)
@@ -21,7 +21,48 @@
coord_shift( -pose.x, -pose.y, -pose.z, 0 );
}
+void Stg::Gl::draw_array( float x, float y, float w, float h,
+ float* data,
size_t len, size_t offset,
+ float min,
float max )
+{
+ float sample_spacing = w / (float)len;
+ float yscale = h / (max-min);
+
+ //printf( "min %.2f max %.2f\n", min, max );
+ glBegin( GL_LINE_STRIP );
+
+ for( unsigned int i=0; i<len; i++ )
+ glVertex3f( x + (float)i*sample_spacing,
y+(data[(i+offset)%len]-min)*yscale, 0.01 );
+
+ glEnd();
+
+
+ glColor3f( 0,0,0 );
+ char buf[64];
+ snprintf( buf, 63, "%.2f", min );
+ Gl::draw_string( x,y,0,buf );
+ snprintf( buf, 63, "%.2f", max );
+ Gl::draw_string( x,y+h-fl_height(),0,buf );
+
+}
+
+void Stg::Gl::draw_array( float x, float y, float w, float h,
+ float* data,
size_t len, size_t offset )
+{
+ // wild initial bounds
+ float smallest = 1e16;
+ float largest = -1e16;
+
+ for( size_t i=0; i<len; i++ )
+ {
+ smallest = MIN( smallest, data[i] );
+ largest = MAX( largest, data[i] );
+ }
+
+ draw_array( x,y,w,h,data,len,offset,smallest,largest );
+}
+
void Stg::Gl::draw_string( float x, float y, float z, const char *str )
{
glRasterPos3f( x, y, z );
Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc 2009-03-31 07:31:00 UTC (rev 7566)
+++ code/stage/trunk/libstage/model.cc 2009-03-31 17:07:29 UTC (rev 7567)
@@ -356,8 +356,6 @@
if( flag_list == NULL )
return NULL;
- printf( "pop flag" );
-
Flag* flag = (Flag*)flag_list->data;
flag_list = g_list_remove( flag_list, flag );
@@ -366,7 +364,6 @@
return flag;
}
-
void Model::ClearBlocks( void )
{
UnMap();
Modified: code/stage/trunk/libstage/model_fiducial.cc
===================================================================
--- code/stage/trunk/libstage/model_fiducial.cc 2009-03-31 07:31:00 UTC (rev
7566)
+++ code/stage/trunk/libstage/model_fiducial.cc 2009-03-31 17:07:29 UTC (rev
7567)
@@ -28,7 +28,7 @@
const stg_watts_t DEFAULT_FIDUCIAL_WATTS = 10.0;
//TODO make instance attempt to register an option (as customvisualizations do)
-Option ModelFiducial::showFiducialData( "Show Fiducial", "show_fiducial", "",
true, NULL );
+Option ModelFiducial::showFiducialData( "Show Fiducial", "show_fiducial", "",
false, NULL );
/**
@ingroup model
Modified: code/stage/trunk/libstage/powerpack.cc
===================================================================
--- code/stage/trunk/libstage/powerpack.cc 2009-03-31 07:31:00 UTC (rev
7566)
+++ code/stage/trunk/libstage/powerpack.cc 2009-03-31 17:07:29 UTC (rev
7567)
@@ -21,6 +21,8 @@
PowerPack::PowerPack( Model* mod ) :
event_vis( 32,32,1.0 ),
+ output_vis( 0,100,200,40, 1200, stg_color_pack(1,0,0,0),
stg_color_pack(0,0,0,0.5), "energy output", "energy_input" ),
+ stored_vis( 0,142,200,40, 1200, stg_color_pack(0,1,0,0),
stg_color_pack(0,0,0,0.5), "energy stored", "energy_stored" ),
mod( mod),
stored( 0.0 ),
capacity( 0.0 ),
@@ -28,13 +30,18 @@
{
// tell the world about this new pp
mod->world->AddPowerPack( this );
+
mod->AddVisualizer( &event_vis, false );
-};
+ mod->AddVisualizer( &output_vis, true );
+ mod->AddVisualizer( &stored_vis, true );
+}
PowerPack::~PowerPack()
{
mod->world->RemovePowerPack( this );
mod->RemoveVisualizer( &event_vis );
+ mod->RemoveVisualizer( &output_vis );
+ mod->RemoveVisualizer( &stored_vis );
}
@@ -222,6 +229,8 @@
dissipated += amount;
global_dissipated += amount;
+ output_vis.AppendValue( amount );
+ stored_vis.AppendValue( stored );
//stg_watts_t w = j / (interval / 1e6);
}
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2009-03-31 07:31:00 UTC (rev 7566)
+++ code/stage/trunk/libstage/stage.hh 2009-03-31 17:07:29 UTC (rev 7567)
@@ -475,6 +475,11 @@
void draw_octagon( float x, float y, float w, float h, float m );
void draw_vector( double x, double y, double z );
void draw_origin( double len );
+ void draw_array( float x, float y, float w, float h,
+ float* data, size_t
len, size_t offset,
+ float min, float max );
+ void draw_array( float x, float y, float w, float h,
+ float* data, size_t
len, size_t offset );
/** Draws a rectangle with center at x,y, with sides of length dx,dy */
void draw_centered_rect( float x, float y, float dx, float dy );
}
@@ -1380,6 +1385,7 @@
virtual void AddModel( Model* mod );
+
protected:
virtual void PushColor( stg_color_t col );
virtual void PushColor( double r, double g, double b, double a );
@@ -1388,8 +1394,6 @@
void DrawTree( bool leaves );
void DrawFloor();
- Canvas* GetCanvas( void ) { return canvas; }
-
public:
WorldGui(int W,int H,const char*L=0);
@@ -1411,6 +1415,8 @@
void TogglePause(){ paused = !paused; };
bool Paused(){ return( paused ); };
+ Canvas* GetCanvas( void ) { return canvas; }
+
/** show the window - need to call this if you don't Load(). */
void Show();
@@ -1429,6 +1435,29 @@
virtual void RemoveChild( Model* mod );
};
+
+ class StripPlotVis : public Visualizer
+ {
+ private:
+
+ Model* mod;
+ float* data;
+ size_t len;
+ size_t count;
+ unsigned int index;
+ float x,y,w,h,min,max;
+ stg_color_t fgcolor, bgcolor;
+
+ public:
+ StripPlotVis( float x, float y, float w, float h,
+ size_t len,
+ stg_color_t fgcolor,
stg_color_t bgcolor,
+ const char* name, const char*
wfname );
+ virtual ~StripPlotVis();
+ virtual void Visualize( Model* mod, Camera* cam );
+ void AppendValue( float value );
+ };
+
/** energy data packet */
class PowerPack
{
@@ -1460,6 +1489,8 @@
};
DissipationVis event_vis;
+ StripPlotVis output_vis;
+ StripPlotVis stored_vis;
/** The model that owns this object */
Model* mod;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit