Skip to content
This repository
tag: v4.0.1
Fetching contributors…

Cannot retrieve contributors at this time

file 63 lines (52 sloc) 1.23 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
/* Strip plot visualizer
* Richard Vaughan 30 March 2009
*/

#include "stage.hh"
#include "canvas.hh"
using namespace Stg;

StripPlotVis::StripPlotVis( float x, float y, float w, float h,
size_t len,
Color fgcolor, Color bgcolor,
const char* name, const char* wfname )
  : Visualizer( name, wfname ),
data( new float[len] ),
len(len),
count(0),
x(x),
y(y),
w(w),
h(h),
min(1e32),
max(-1e32),
fgcolor(fgcolor),
bgcolor(bgcolor)
{
  // zero the data
  memset( data, 0, len * sizeof(float ) );
}

StripPlotVis::~StripPlotVis()
{
  if( data )
free( data );
}

void StripPlotVis::Visualize( Model* mod, Camera* cam )
{
  Canvas* canvas = dynamic_cast<WorldGui*>(mod->GetWorld())->GetCanvas();

  if( ! canvas->selected( mod ) ) // == canvas->SelectedVisualizeAll() )
return;

  canvas->EnterScreenCS();
  
  mod->PushColor( bgcolor );
  glRectf( x,y,w,h );
  mod->PopColor();
  
  mod->PushColor( fgcolor );
  Gl::draw_array( x,y,w,h,data,len,count%len,min,max );
  mod->PopColor();
  
  canvas->LeaveScreenCS();
}

void StripPlotVis::AppendValue( float value )
{
  data[count%len] = value;
  count++;
  
  min = std::min( value, min );
  max = std::max( value, max );
}
Something went wrong with that request. Please try again.