vis_strip.cc
Go to the documentation of this file.
1 /* Strip plot visualizer
2  * Richard Vaughan 30 March 2009
3  */
4 
5 #include "stage.hh"
6 #include "canvas.hh"
7 using namespace Stg;
8 
9 StripPlotVis::StripPlotVis( float x, float y, float w, float h,
10  size_t len,
11  Color fgcolor, Color bgcolor,
12  const char* name, const char* wfname )
13  : Visualizer( name, wfname ),
14  data( new float[len] ),
15  len(len),
16  count(0),
17  x(x),
18  y(y),
19  w(w),
20  h(h),
21  min(1e32),
22  max(-1e32),
23  fgcolor(fgcolor),
24  bgcolor(bgcolor)
25 {
26  // zero the data
27  memset( data, 0, len * sizeof(float ) );
28 }
29 
31 {
32  if( data )
33  free( data );
34 }
35 
37 {
38  Canvas* canvas = dynamic_cast<WorldGui*>(mod->GetWorld())->GetCanvas();
39 
40  if( ! canvas->selected( mod ) ) // == canvas->SelectedVisualizeAll() )
41  return;
42 
43  canvas->EnterScreenCS();
44 
45  mod->PushColor( bgcolor );
46  glRectf( x,y,w,h );
47  mod->PopColor();
48 
49  mod->PushColor( fgcolor );
51  mod->PopColor();
52 
53  canvas->LeaveScreenCS();
54 }
55 
56 void StripPlotVis::AppendValue( float value )
57 {
58  data[count%len] = value;
59  count++;
60 
61  min = std::min( value, min );
62  max = std::max( value, max );
63 }
virtual void PushColor(Color col)
Definition: stage.hh:2189
Model class
Definition: stage.hh:1742
StripPlotVis(float x, float y, float w, float h, size_t len, Color fgcolor, Color bgcolor, const char *name, const char *wfname)
Definition: vis_strip.cc:9
The Stage library uses its own namespace.
Definition: canvas.hh:8
void EnterScreenCS()
Definition: canvas.cc:1087
float * data
Definition: stage.hh:1610
virtual void PopColor()
Definition: stage.hh:2191
World * GetWorld() const
Definition: stage.hh:2302
void draw_array(float x, float y, float w, float h, float *data, size_t len, size_t offset, float min, float max)
Definition: gl.cc:24
virtual ~StripPlotVis()
Definition: vis_strip.cc:30
void LeaveScreenCS()
Definition: canvas.cc:1101
void AppendValue(float value)
Definition: vis_strip.cc:56
virtual void Visualize(Model *mod, Camera *cam)
Definition: vis_strip.cc:36
bool selected(Model *mod)
Definition: canvas.cc:296


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Mon Jun 10 2019 15:06:10