Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 743:a352fb986e7b tony_integration
Merge from branch tonioni
author | Chris Cannam |
---|---|
date | Tue, 11 Mar 2014 17:33:19 +0000 |
parents | 56ba2b03508e |
children | b6dc57688c72 |
comparison
equal
deleted
inserted
replaced
718:e5f4385615ac | 743:a352fb986e7b |
---|---|
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 } |
1161 } | 1168 } |
1162 | 1169 |
1163 paint.drawRect(x, -1, nx - x, v->height() + 1); | 1170 paint.drawRect(x, -1, nx - x, v->height() + 1); |
1164 } | 1171 } |
1165 | 1172 |
1166 QString label = p.label; | 1173 if (v->shouldShowFeatureLabels()) { |
1167 bool italic = false; | 1174 |
1168 | 1175 QString label = p.label; |
1169 if (label == "" && | 1176 bool italic = false; |
1170 (m_plotStyle == PlotPoints || | 1177 |
1171 m_plotStyle == PlotSegmentation || | 1178 if (label == "" && |
1172 m_plotStyle == PlotConnectedPoints)) { | 1179 (m_plotStyle == PlotPoints || |
1173 char lc[20]; | 1180 m_plotStyle == PlotSegmentation || |
1174 snprintf(lc, 20, "%.3g", p.value); | 1181 m_plotStyle == PlotConnectedPoints)) { |
1175 label = lc; | 1182 char lc[20]; |
1176 italic = true; | 1183 snprintf(lc, 20, "%.3g", p.value); |
1177 } | 1184 label = lc; |
1178 | 1185 italic = true; |
1179 if (label != "") { | 1186 } |
1180 bool haveRoom = nx > x + 6 + paint.fontMetrics().width(label); | 1187 |
1181 if (haveRoom || | 1188 if (label != "") { |
1182 (!haveNext && | 1189 // Quick test for 20px before we do the slower test using metrics |
1183 (pointCount == 0 || !italic))) { | 1190 bool haveRoom = (nx > x + 20); |
1184 v->drawVisibleText(paint, x + 5, textY, label, | 1191 haveRoom = (haveRoom && |
1185 italic ? | 1192 (nx > x + 6 + paint.fontMetrics().width(label))); |
1186 View::OutlinedItalicText : | 1193 if (haveRoom || |
1187 View::OutlinedText); | 1194 (!haveNext && |
1188 } | 1195 (pointCount == 0 || !italic))) { |
1189 } | 1196 v->drawVisibleText(paint, x + 5, textY, label, |
1197 italic ? | |
1198 View::OutlinedItalicText : | |
1199 View::OutlinedText); | |
1200 } | |
1201 } | |
1202 } | |
1190 | 1203 |
1191 prevFrame = p.frame; | 1204 prevFrame = p.frame; |
1192 ++pointCount; | 1205 ++pointCount; |
1193 } | 1206 } |
1194 | 1207 |