Mercurial > hg > svgui
diff layer/TimeValueLayer.cpp @ 20:1deb5f87a18c
* Add getXForFrame / getFrameForX in preference to using the zoom level everywhere
author | Chris Cannam |
---|---|
date | Mon, 30 Jan 2006 13:19:42 +0000 |
parents | 01849cd277e6 |
children | 3a506d25d95a |
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp Fri Jan 27 18:04:07 2006 +0000 +++ b/layer/TimeValueLayer.cpp Mon Jan 30 13:19:42 2006 +0000 @@ -188,10 +188,7 @@ { if (!m_model) return SparseTimeValueModel::PointList(); - long startFrame = m_view->getStartFrame(); - long endFrame = m_view->getEndFrame(); - int zoomLevel = m_view->getZoomLevel(); - long frame = startFrame + x * zoomLevel; + long frame = getFrameForX(x); SparseTimeValueModel::PointList onPoints = m_model->getPoints(frame); @@ -209,8 +206,8 @@ if (prevPoints.empty()) { usePoints = nextPoints; - } else if (prevPoints.begin()->frame < startFrame && - !(nextPoints.begin()->frame > endFrame)) { + } else if (prevPoints.begin()->frame < m_view->getStartFrame() && + !(nextPoints.begin()->frame > m_view->getEndFrame())) { usePoints = nextPoints; } else if (nextPoints.begin()->frame - frame < frame - prevPoints.begin()->frame) { @@ -310,12 +307,9 @@ // Profiler profiler("TimeValueLayer::paint", true); - long startFrame = m_view->getStartFrame(); - int zoomLevel = m_view->getZoomLevel(); - int x0 = rect.left(), x1 = rect.right(); - long frame0 = startFrame + x0 * zoomLevel; - long frame1 = startFrame + x1 * zoomLevel; + long frame0 = getFrameForX(x0); + long frame1 = getFrameForX(x1); SparseTimeValueModel::PointList points(m_model->getPoints (frame0, frame1)); @@ -346,7 +340,9 @@ if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; } - int w = m_model->getResolution() / zoomLevel; + int w = + getXForFrame(frame0 + m_model->getResolution()) - + getXForFrame(frame0); paint.save(); @@ -362,7 +358,7 @@ const SparseTimeValueModel::Point &p(*i); - int x = (p.frame - startFrame) / zoomLevel; + int x = getXForFrame(p.frame); int y = int(nearbyint(m_view->height() - ((p.value - min) * m_view->height()) / (max - min))); @@ -419,7 +415,7 @@ if (j != points.end()) { const SparseTimeValueModel::Point &q(*j); - int nx = (q.frame - startFrame) / zoomLevel; + int nx = getXForFrame(q.frame); int ny = int(nearbyint(m_view->height() - ((q.value - min) * m_view->height()) / (max - min)));