Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 3:7af44e8578c8
* Add "curve" plot style to TimeValueLayer
* Update copyrights to 2006
author | Chris Cannam |
---|---|
date | Thu, 12 Jan 2006 13:42:30 +0000 |
parents | 2a4f26e85b4c |
children | 02aaea1ffaf7 |
comparison
equal
deleted
inserted
replaced
2:77dad696d740 | 3:7af44e8578c8 |
---|---|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ | 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ |
2 | 2 |
3 /* | 3 /* |
4 A waveform viewer and audio annotation editor. | 4 A waveform viewer and audio annotation editor. |
5 Chris Cannam, Queen Mary University of London, 2005 | 5 Chris Cannam, Queen Mary University of London, 2005-2006 |
6 | 6 |
7 This is experimental software. Not for distribution. | 7 This is experimental software. Not for distribution. |
8 */ | 8 */ |
9 | 9 |
10 #include "TimeValueLayer.h" | 10 #include "TimeValueLayer.h" |
84 else if (m_colour == QColor(255, 150, 50)) deft = 5; | 84 else if (m_colour == QColor(255, 150, 50)) deft = 5; |
85 | 85 |
86 } else if (name == tr("Plot Type")) { | 86 } else if (name == tr("Plot Type")) { |
87 | 87 |
88 *min = 0; | 88 *min = 0; |
89 *max = 2; | 89 *max = 3; |
90 | 90 |
91 deft = int(m_plotStyle); | 91 deft = int(m_plotStyle); |
92 | 92 |
93 } else { | 93 } else { |
94 | 94 |
116 switch (value) { | 116 switch (value) { |
117 default: | 117 default: |
118 case 0: return tr("Points"); | 118 case 0: return tr("Points"); |
119 case 1: return tr("Stems"); | 119 case 1: return tr("Stems"); |
120 case 2: return tr("Lines"); | 120 case 2: return tr("Lines"); |
121 case 3: return tr("Curve"); | |
121 } | 122 } |
122 } | 123 } |
123 return tr("<unknown>"); | 124 return tr("<unknown>"); |
124 } | 125 } |
125 | 126 |
315 (max - min))); | 316 (max - min))); |
316 int w = m_model->getResolution() / zoomLevel; | 317 int w = m_model->getResolution() / zoomLevel; |
317 | 318 |
318 if (w < 1) w = 1; | 319 if (w < 1) w = 1; |
319 | 320 |
320 paint.setPen(m_colour); | 321 if (m_plotStyle == PlotCurve) { |
322 paint.setPen(QPen(QBrush(m_colour), 2)); | |
323 } else { | |
324 paint.setPen(m_colour); | |
325 } | |
321 paint.setBrush(brushColour); | 326 paint.setBrush(brushColour); |
322 | 327 |
323 if (m_plotStyle == PlotStems) { | 328 if (m_plotStyle == PlotStems) { |
324 paint.setPen(brushColour); | 329 paint.setPen(brushColour); |
325 if (y < origin - 1) { | 330 if (y < origin - 1) { |
336 //the end perhaps | 341 //the end perhaps |
337 paint.setPen(Qt::black);//!!! | 342 paint.setPen(Qt::black);//!!! |
338 paint.setBrush(Qt::black);//!!! | 343 paint.setBrush(Qt::black);//!!! |
339 } | 344 } |
340 | 345 |
341 paint.drawRect(x, y - 1, w, 2); | 346 if (m_plotStyle != PlotCurve) { |
342 | 347 paint.drawRect(x, y - 1, w, 2); |
343 // if (w > 1) { | 348 } |
344 // paint.setPen(brushColour); | 349 |
345 // paint.drawRect(x, y - 1, w - 1, 2); | 350 if (m_plotStyle == PlotLines || m_plotStyle == PlotCurve) { |
346 // paint.setPen(m_colour); | 351 |
347 // } | |
348 // paint.drawLine(x, 0, x, m_view->height()); | |
349 | |
350 if (m_plotStyle == PlotLines) { | |
351 | |
352 paint.setPen(brushColour); | |
353 SparseTimeValueModel::PointList::const_iterator j = i; | 352 SparseTimeValueModel::PointList::const_iterator j = i; |
354 ++j; | 353 ++j; |
354 | |
355 if (j != points.end()) { | 355 if (j != points.end()) { |
356 | |
356 const SparseTimeValueModel::Point &q(*j); | 357 const SparseTimeValueModel::Point &q(*j); |
357 int nx = (q.frame - startFrame) / zoomLevel; | 358 int nx = (q.frame - startFrame) / zoomLevel; |
358 int ny = int(nearbyint(m_view->height() - | 359 int ny = int(nearbyint(m_view->height() - |
359 ((q.value - min) * m_view->height()) / | 360 ((q.value - min) * m_view->height()) / |
360 (max - min))); | 361 (max - min))); |
361 paint.drawLine(x + w, y, nx, ny); | 362 |
363 if (m_plotStyle == PlotLines) { | |
364 paint.setPen(brushColour); | |
365 paint.drawLine(x + w, y, nx, ny); | |
366 } else { | |
367 paint.drawLine(x, y, nx, ny); | |
368 } | |
362 } | 369 } |
363 } | 370 } |
364 | 371 |
365 | 372 |
366 /// if (p.label != "") { | 373 /// if (p.label != "") { |