# HG changeset patch # User tomwalters@google.com # Date 1340367444 0 # Node ID d609725e568aa1fb22551594ff46242e8669744c # Parent 7cc44d4e9b867ea158fe27033c7b703d044b8ca0 Re-add support for plotting strobes (untested). diff -r 7cc44d4e9b86 -r d609725e568a src/Modules/Output/Graphics/GraphicsView.cc --- 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, diff -r 7cc44d4e9b86 -r d609725e568a src/Modules/Output/Graphics/GraphicsView.h --- a/src/Modules/Output/Graphics/GraphicsView.h Wed May 30 20:54:57 2012 +0000 +++ b/src/Modules/Output/Graphics/GraphicsView.h Fri Jun 22 12:17:24 2012 +0000 @@ -95,10 +95,24 @@ * \param xScale Scaling in x-direction. 1.0 makes it cover the whole length. 0.5 only the left half. */ virtual void PlotData(const vector &signal, - float sample_rate, + float sample_rate, float yOffset, float height, float xScale) = 0; + + virtual void PlotStrobes(const vector& signal, + const vector& strobes, + float sample_rate, + float y_offset, + float height, + float x_scale, + float diameter) = 0; + + virtual void PlotStrobe(float x, + float y, + float val, + float height, + float diameter); /*! \brief Plot the axes for a signal bank * \param pSig Signal to plot the axes for @@ -167,6 +181,7 @@ int previous_start_time_; bool initialized_; + bool plotting_strobes_; }; } // namespace aimc #endif /* __GRAPHICS_VIEW_H__ */ diff -r 7cc44d4e9b86 -r d609725e568a src/Modules/Output/Graphics/GraphicsViewTime.cc --- a/src/Modules/Output/Graphics/GraphicsViewTime.cc Wed May 30 20:54:57 2012 +0000 +++ b/src/Modules/Output/Graphics/GraphicsViewTime.cc Fri Jun 22 12:17:24 2012 +0000 @@ -93,6 +93,31 @@ m_pDev->gText2f(0.8f, 0.0025f, sTxt, false); } +void GraphicsViewTime::PlotStrobes(const vector& signal, + const vector& strobes, + float sample_rate, + float y_offset, + float height, + float x_scale, + float diameter) { + x_scale *= 1000.0 / sample_rate; + m_pDev->gColor3f(1.0f, 0.0f, 0.0f); + for (vector::const_iterator i = strobes.begin(); + i != strobes.end(); ++i) { + float x = *i * x_scale; + float y = signal[*i]; + x = m_pAxisX->m_pScale->FromLinearScaled(x) + 0.5f; + y = m_pAxisY->m_pScale->FromLinearScaled(y); + + if (x < 0.0) + continue; + + // Now fit it into the drawing area. + x = x * (1.0f - m_fMarginLeft - m_fMarginRight) + m_fMarginLeft; // fit inside x-axis area + PlotStrobe(x, y_offset, y, height, diameter); + } +} + void GraphicsViewTime::PlotData(const vector &signal, float sample_rate, float yOffset, diff -r 7cc44d4e9b86 -r d609725e568a src/Modules/Output/Graphics/GraphicsViewTime.h --- a/src/Modules/Output/Graphics/GraphicsViewTime.h Wed May 30 20:54:57 2012 +0000 +++ b/src/Modules/Output/Graphics/GraphicsViewTime.h Fri Jun 22 12:17:24 2012 +0000 @@ -34,13 +34,19 @@ virtual GraphicsViewTime *Clone(GraphicsOutputDevice *pDev); private: - void PlotData(const vector &signal, - float sample_rate, - float yOffset, - float height, - float xScale = 1.0); - void PlotAxes(const vector &signal); - void PlotAxes(const SignalBank &pBank); + virtual void PlotData(const vector &signal, + float sample_rate, + float yOffset, + float height, + float xScale = 1.0); + virtual void PlotStrobes(const vector& signal, + const vector& strobes, + float sample_rate, + float y_offset, + float height, + float x_scale, + float diameter); + virtual void PlotAxes(const SignalBank &pBank); }; } // namesapce aimc #endif /* __GRAPHICS_VIEW_TIME_H__ */ diff -r 7cc44d4e9b86 -r d609725e568a src/Support/SignalBank.h --- a/src/Support/SignalBank.h Wed May 30 20:54:57 2012 +0000 +++ b/src/Support/SignalBank.h Fri Jun 22 12:17:24 2012 +0000 @@ -64,6 +64,12 @@ inline const vector &get_signal(int channel) const { return signals_[channel]; }; + + inline const vector& get_strobes(int channel) const { + //DCHECK(channel > 0); + //DCHECK(channel < strobes.size()); + return strobes_[channel]; + }; // Return a reference to the signal vector. The reference is not // const, so the vector is directly modifiable. In order to maintain