comparison 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
comparison
equal deleted inserted replaced
507:7cc44d4e9b86 508:d609725e568a
56 m_fMarginLeft = parameters_->DefaultFloat(_S("graph.margin.left"), 0.05); 56 m_fMarginLeft = parameters_->DefaultFloat(_S("graph.margin.left"), 0.05);
57 m_fMarginRight = parameters_->DefaultFloat(_S("graph.margin.right"), 0.005); 57 m_fMarginRight = parameters_->DefaultFloat(_S("graph.margin.right"), 0.005);
58 m_fMarginTop = parameters_->DefaultFloat(_S("graph.margin.top"), 0.005); 58 m_fMarginTop = parameters_->DefaultFloat(_S("graph.margin.top"), 0.005);
59 m_fMarginBottom = parameters_->DefaultFloat(_S("graph.margin.bottom"), 0.05); 59 m_fMarginBottom = parameters_->DefaultFloat(_S("graph.margin.bottom"), 0.05);
60 m_bPlotLabels = parameters_->DefaultBool(_S("graph.plotlabels"), true); 60 m_bPlotLabels = parameters_->DefaultBool(_S("graph.plotlabels"), true);
61 plotting_strobes_ = parameters_->DefaultBool(_S("graph.plot_strobes"), false);
61 62
62 const char *sGraphType = parameters_->DefaultString(_S("graph.type"), "line"); 63 const char *sGraphType = parameters_->DefaultString(_S("graph.type"), "line");
63 if (strcmp(sGraphType, _S("line"))==0) 64 if (strcmp(sGraphType, _S("line"))==0)
64 m_iGraphType = GraphTypeLine; 65 m_iGraphType = GraphTypeLine;
65 else if (strcmp(sGraphType, _S("colormap"))==0) 66 else if (strcmp(sGraphType, _S("colormap"))==0)
134 135
135 void GraphicsView::Process(const SignalBank &bank) { 136 void GraphicsView::Process(const SignalBank &bank) {
136 float height = 1.0 / bank.channel_count(); 137 float height = 1.0 / bank.channel_count();
137 float heightMinMargin = height * (1.0f - m_fMarginBottom - m_fMarginTop); 138 float heightMinMargin = height * (1.0f - m_fMarginBottom - m_fMarginTop);
138 float xScaling = 1.0f; 139 float xScaling = 1.0f;
140 float diameter = height / 5.0;
139 141
140 m_pDev->gGrab(); 142 m_pDev->gGrab();
141 PlotAxes(bank); 143 PlotAxes(bank);
142 m_pDev->gColor3f(1.0f, 1.0f, 0.8f); 144 m_pDev->gColor3f(1.0f, 1.0f, 0.8f);
143 for (int i = 0; i < bank.channel_count(); i++) { 145 for (int i = 0; i < bank.channel_count(); i++) {
153 155
154 // Scale to single channel graphing. 156 // Scale to single channel graphing.
155 yOffs = yOffs * (1.0f - height) + height / 2.0; 157 yOffs = yOffs * (1.0f - height) + height / 2.0;
156 yOffs = yOffs * (1.0f - m_fMarginTop - m_fMarginBottom) + m_fMarginBottom; 158 yOffs = yOffs * (1.0f - m_fMarginTop - m_fMarginBottom) + m_fMarginBottom;
157 PlotData(bank[i], bank.sample_rate(), yOffs, heightMinMargin, xScaling); 159 PlotData(bank[i], bank.sample_rate(), yOffs, heightMinMargin, xScaling);
160 if (plotting_strobes_) {
161 PlotStrobes(bank[i], bank.get_strobes(i), bank.sample_rate(),
162 yOffs, heightMinMargin ,xScaling, diameter);
163 }
158 } 164 }
159 m_pDev->gRelease(); 165 m_pDev->gRelease();
160 166
161 frame_rate_ = bank.sample_rate() 167 frame_rate_ = bank.sample_rate()
162 / (bank.start_time() - previous_start_time_); 168 / (bank.start_time() - previous_start_time_);
233 m_bFirstPoint = false; 239 m_bFirstPoint = false;
234 } 240 }
235 PlotDataPointDirect(x, y, val, height); 241 PlotDataPointDirect(x, y, val, height);
236 } 242 }
237 243
244 void GraphicsView::PlotStrobe(float x, float y, float val,
245 float height,
246 float diameter) {
247 switch(m_iGraphType) {
248 case GraphTypeLine:
249 m_pDev->gBeginQuadStrip();
250 m_pDev->gVertex2f(x + diameter, y + val * height + diameter);
251 m_pDev->gVertex2f(x + diameter, y + val * height - diameter);
252 m_pDev->gVertex2f(x - diameter, y + val * height - diameter);
253 m_pDev->gVertex2f(x - diameter, y + val * height + diameter);
254 m_pDev->gEnd();
255 break;
256 case GraphTypeColormap:
257 m_pDev->gBeginQuadStrip();
258 m_pDev->gVertex2f(x + diameter, y + diameter);
259 m_pDev->gVertex2f(x + diameter, y - diameter);
260 m_pDev->gVertex2f(x - diameter, y - diameter);
261 m_pDev->gVertex2f(x - diameter, y + diameter);
262 m_pDev->gEnd();
263 break;
264 case GraphTypeNone:
265 // Nothing: just for testing computation overhead of graphing
266 break;
267 default:
268 // Shouldn't happen
269 AIM_ASSERT(0);
270 }
271 }
272
238 void GraphicsView::PlotDataPointDirect(float x, 273 void GraphicsView::PlotDataPointDirect(float x,
239 float y, 274 float y,
240 float val, 275 float val,
241 float height) { 276 float height) {
242 // Draw it in the right way 277 // Draw it in the right way