Revision: 7568
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7568&view=rev
Author:   rtv
Date:     2009-03-31 22:46:27 +0000 (Tue, 31 Mar 2009)

Log Message:
-----------
added missing file

Added Paths:
-----------
    code/stage/trunk/libstage/vis_strip.cc

Added: code/stage/trunk/libstage/vis_strip.cc
===================================================================
--- code/stage/trunk/libstage/vis_strip.cc                              (rev 0)
+++ code/stage/trunk/libstage/vis_strip.cc      2009-03-31 22:46:27 UTC (rev 
7568)
@@ -0,0 +1,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, 
+                                                                        
stg_color_t fgcolor, stg_color_t 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 = MIN( value, min );
+  max = MAX( value, max );
+}


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

Reply via email to