Mercurial > hg > svgui
diff layer/TimeRulerLayer.cpp @ 1148:c0d841cb8ab9 tony-2.0-integration
Merge latest SV 3.0 branch code
author | Chris Cannam |
---|---|
date | Fri, 19 Aug 2016 15:58:57 +0100 |
parents | ee01a4062747 |
children | a34a2a25907c |
line wrap: on
line diff
--- a/layer/TimeRulerLayer.cpp Tue Oct 20 12:55:09 2015 +0100 +++ b/layer/TimeRulerLayer.cpp Fri Aug 19 15:58:57 2016 +0100 @@ -19,19 +19,20 @@ #include "data/model/Model.h" #include "base/RealTime.h" +#include "view/View.h" + #include "ColourDatabase.h" -#include "view/View.h" +#include "PaintAssistant.h" #include <QPainter> #include <iostream> #include <cmath> +#include <stdexcept> //#define DEBUG_TIME_RULER_LAYER 1 - - TimeRulerLayer::TimeRulerLayer() : SingleColourLayer(), m_model(0), @@ -182,6 +183,8 @@ } else { incms = 1; int ms = rtGap.msec(); +// cerr << "rtGap.msec = " << ms << ", rtGap = " << rtGap << ", count = " << count << endl; +// cerr << "startFrame = " << startFrame << ", endFrame = " << endFrame << " rtStart = " << rtStart << ", rtEnd = " << rtEnd << endl; if (ms > 0) { incms *= 10; ms /= 10; } if (ms > 0) { incms *= 10; ms /= 10; } if (ms > 0) { incms *= 5; ms /= 5; } @@ -241,6 +244,9 @@ // time < 0 which would cut it in half int minlabel = 1; // ms + // used for a sanity check + sv_frame_t prevframe = 0; + while (1) { // frame is used to determine where to draw the lines, so it @@ -253,10 +259,17 @@ frame /= v->getZoomLevel(); frame *= v->getZoomLevel(); // so frame corresponds to an exact pixel + if (frame == prevframe && prevframe != 0) { + cerr << "ERROR: frame == prevframe (== " << frame + << ") in TimeRulerLayer::paint" << endl; + throw std::logic_error("frame == prevframe in TimeRulerLayer::paint"); + } + prevframe = frame; + int x = v->getXForFrame(frame); #ifdef DEBUG_TIME_RULER_LAYER - SVDEBUG << "Considering frame = " << frame << ", x = " << x << endl; + cerr << "Considering frame = " << frame << ", x = " << x << endl; #endif if (x >= rect.x() + rect.width() + 50) { @@ -313,7 +326,7 @@ // backmost layer, don't worry about outlining the text paint.drawText(x+2 - tw/2, y, text); } else { - v->drawVisibleText(paint, x+2 - tw/2, y, text, View::OutlinedText); + PaintAssistant::drawVisibleText(v, paint, x+2 - tw/2, y, text, PaintAssistant::OutlinedText); } } }