Go to the documentation of this file.00001
00002
00003
00004
00005 #include "stage.hh"
00006 #include "canvas.hh"
00007 using namespace Stg;
00008
00009 StripPlotVis::StripPlotVis( float x, float y, float w, float h,
00010 size_t len,
00011 Color fgcolor, Color bgcolor,
00012 const char* name, const char* wfname )
00013 : Visualizer( name, wfname ),
00014 data( new float[len] ),
00015 len(len),
00016 count(0),
00017 x(x),
00018 y(y),
00019 w(w),
00020 h(h),
00021 min(1e32),
00022 max(-1e32),
00023 fgcolor(fgcolor),
00024 bgcolor(bgcolor)
00025 {
00026
00027 memset( data, 0, len * sizeof(float ) );
00028 }
00029
00030 StripPlotVis::~StripPlotVis()
00031 {
00032 if( data )
00033 free( data );
00034 }
00035
00036 void StripPlotVis::Visualize( Model* mod, Camera* cam )
00037 {
00038 Canvas* canvas = dynamic_cast<WorldGui*>(mod->GetWorld())->GetCanvas();
00039
00040 if( ! canvas->selected( mod ) )
00041 return;
00042
00043 canvas->EnterScreenCS();
00044
00045 mod->PushColor( bgcolor );
00046 glRectf( x,y,w,h );
00047 mod->PopColor();
00048
00049 mod->PushColor( fgcolor );
00050 Gl::draw_array( x,y,w,h,data,len,count%len,min,max );
00051 mod->PopColor();
00052
00053 canvas->LeaveScreenCS();
00054 }
00055
00056 void StripPlotVis::AppendValue( float value )
00057 {
00058 data[count%len] = value;
00059 count++;
00060
00061 min = std::min( value, min );
00062 max = std::max( value, max );
00063 }