Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 721:15b5c679b909 tonioni
Fix for treating zeros as gaps
| author | Chris Cannam |
|---|---|
| date | Thu, 30 Jan 2014 17:33:18 +0000 |
| parents | 137d3ff48f73 |
| children | 1640a7c753cc |
comparison
equal
deleted
inserted
replaced
| 720:5f9c0147d1d6 | 721:15b5c679b909 |
|---|---|
| 970 | 970 |
| 971 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); | 971 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); |
| 972 i != points.end(); ++i) { | 972 i != points.end(); ++i) { |
| 973 | 973 |
| 974 if (m_derivative && i == points.begin()) continue; | 974 if (m_derivative && i == points.begin()) continue; |
| 975 | 975 |
| 976 const SparseTimeValueModel::Point &p(*i); | 976 const SparseTimeValueModel::Point &p(*i); |
| 977 | 977 |
| 978 float value = p.value; | 978 float value = p.value; |
| 979 if (m_derivative) { | 979 if (m_derivative) { |
| 980 SparseTimeValueModel::PointList::const_iterator j = i; | 980 SparseTimeValueModel::PointList::const_iterator j = i; |
| 985 int x = v->getXForFrame(p.frame); | 985 int x = v->getXForFrame(p.frame); |
| 986 int y = getYForValue(v, value); | 986 int y = getYForValue(v, value); |
| 987 | 987 |
| 988 bool gap = false; | 988 bool gap = false; |
| 989 if (m_plotStyle == PlotDiscreteCurves) { | 989 if (m_plotStyle == PlotDiscreteCurves) { |
| 990 if (value == 0.0) { | |
| 991 // Treat zeros as gaps | |
| 992 continue; | |
| 993 } | |
| 990 gap = (p.frame > prevFrame && | 994 gap = (p.frame > prevFrame && |
| 991 (p.frame - prevFrame >= m_model->getResolution() * 2)); | 995 (p.frame - prevFrame >= m_model->getResolution() * 2)); |
| 992 } | 996 } |
| 993 | 997 |
| 994 if (m_plotStyle != PlotSegmentation) { | 998 if (m_plotStyle != PlotSegmentation) { |
| 998 textY = paint.fontMetrics().ascent() + 1; | 1002 textY = paint.fontMetrics().ascent() + 1; |
| 999 } | 1003 } |
| 1000 } | 1004 } |
| 1001 | 1005 |
| 1002 bool haveNext = false; | 1006 bool haveNext = false; |
| 1007 float nvalue = 0.f; | |
| 1003 int nf = v->getModelsEndFrame(); | 1008 int nf = v->getModelsEndFrame(); |
| 1004 int nx = v->getXForFrame(nf); | 1009 int nx = v->getXForFrame(nf); |
| 1005 int ny = y; | 1010 int ny = y; |
| 1006 | 1011 |
| 1007 SparseTimeValueModel::PointList::const_iterator j = i; | 1012 SparseTimeValueModel::PointList::const_iterator j = i; |
| 1008 ++j; | 1013 ++j; |
| 1009 | 1014 |
| 1010 if (j != points.end()) { | 1015 if (j != points.end()) { |
| 1011 const SparseTimeValueModel::Point &q(*j); | 1016 const SparseTimeValueModel::Point &q(*j); |
| 1012 float nvalue = q.value; | 1017 nvalue = q.value; |
| 1013 if (m_derivative) nvalue -= p.value; | 1018 if (m_derivative) nvalue -= p.value; |
| 1014 nf = q.frame; | 1019 nf = q.frame; |
| 1015 nx = v->getXForFrame(nf); | 1020 nx = v->getXForFrame(nf); |
| 1016 ny = getYForValue(v, nvalue); | 1021 ny = getYForValue(v, nvalue); |
| 1017 haveNext = true; | 1022 haveNext = true; |
| 1114 | 1119 |
| 1115 float y0 = y; | 1120 float y0 = y; |
| 1116 float y1 = ny; | 1121 float y1 = ny; |
| 1117 | 1122 |
| 1118 if (m_plotStyle == PlotDiscreteCurves) { | 1123 if (m_plotStyle == PlotDiscreteCurves) { |
| 1119 bool nextGap = nf - p.frame >= m_model->getResolution() * 2; | 1124 bool nextGap = |
| 1125 (nvalue == 0.0) || | |
| 1126 (nf - p.frame >= m_model->getResolution() * 2); | |
| 1120 if (nextGap) { | 1127 if (nextGap) { |
| 1121 x1 = x0; | 1128 x1 = x0; |
| 1122 y1 = y0; | 1129 y1 = y0; |
| 1123 } | 1130 } |
| 1124 } | 1131 } |
