diff src/Modules/Output/Graphics/GraphicsView.cc @ 508:d609725e568a

Re-add support for plotting strobes (untested).
author tomwalters@google.com
date Fri, 22 Jun 2012 12:17:24 +0000
parents e35740ed81f3
children
line wrap: on
line diff
--- a/src/Modules/Output/Graphics/GraphicsView.cc	Wed May 30 20:54:57 2012 +0000
+++ b/src/Modules/Output/Graphics/GraphicsView.cc	Fri Jun 22 12:17:24 2012 +0000
@@ -58,6 +58,7 @@
   m_fMarginTop = parameters_->DefaultFloat(_S("graph.margin.top"), 0.005);
   m_fMarginBottom = parameters_->DefaultFloat(_S("graph.margin.bottom"), 0.05);
   m_bPlotLabels = parameters_->DefaultBool(_S("graph.plotlabels"), true);
+  plotting_strobes_ = parameters_->DefaultBool(_S("graph.plot_strobes"), false);
 
   const char *sGraphType = parameters_->DefaultString(_S("graph.type"), "line");
   if (strcmp(sGraphType, _S("line"))==0)
@@ -136,6 +137,7 @@
   float height = 1.0 / bank.channel_count();
   float heightMinMargin = height * (1.0f - m_fMarginBottom - m_fMarginTop);
   float xScaling = 1.0f;
+  float diameter = height / 5.0;
 
   m_pDev->gGrab();
   PlotAxes(bank);
@@ -155,6 +157,10 @@
     yOffs = yOffs * (1.0f - height) + height / 2.0;
     yOffs = yOffs * (1.0f - m_fMarginTop - m_fMarginBottom) + m_fMarginBottom;
     PlotData(bank[i], bank.sample_rate(), yOffs, heightMinMargin, xScaling);
+    if (plotting_strobes_) {
+      PlotStrobes(bank[i], bank.get_strobes(i), bank.sample_rate(),
+                  yOffs, heightMinMargin ,xScaling, diameter);
+    }
   }
   m_pDev->gRelease();
   
@@ -235,6 +241,35 @@
   PlotDataPointDirect(x, y, val, height);
 }
 
+void GraphicsView::PlotStrobe(float x, float y, float val,
+                              float height,
+                              float diameter) {
+  switch(m_iGraphType) {
+  case GraphTypeLine:
+    m_pDev->gBeginQuadStrip();
+    m_pDev->gVertex2f(x + diameter, y + val * height + diameter);
+    m_pDev->gVertex2f(x + diameter, y + val * height - diameter);
+    m_pDev->gVertex2f(x - diameter, y + val * height - diameter);
+    m_pDev->gVertex2f(x - diameter, y + val * height + diameter);
+    m_pDev->gEnd();
+    break;
+  case GraphTypeColormap:
+    m_pDev->gBeginQuadStrip();
+    m_pDev->gVertex2f(x + diameter, y + diameter);
+    m_pDev->gVertex2f(x + diameter, y - diameter);
+    m_pDev->gVertex2f(x - diameter, y - diameter);
+    m_pDev->gVertex2f(x - diameter, y + diameter);
+    m_pDev->gEnd();
+    break;
+  case GraphTypeNone:
+    // Nothing: just for testing computation overhead of graphing
+    break;
+  default:
+    // Shouldn't happen
+    AIM_ASSERT(0);
+  } 
+}
+
 void GraphicsView::PlotDataPointDirect(float x,
                                        float y,
                                        float val,