From: Michal MalĂ˝ Date: Fri, 10 Oct 2014 19:43:59 +0000 (+0200) Subject: - Use rounding in subticks counter X-Git-Tag: 0.4a~22 X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=b92df1f2b2c15d2ede5c99f66d99b16a0d8357ed;p=anyanka.git - Use rounding in subticks counter - Fix first tick calculation for negative numbers --- diff --git a/helpers.cpp b/helpers.cpp index 046e4dd..157bcd5 100644 --- a/helpers.cpp +++ b/helpers.cpp @@ -26,13 +26,15 @@ const double Helpers::EPSILON = 2e-14; double Helpers::firstTick(const double from, const double step) { - const double mod = fabs(fmod(from, step)); double ret; + double mod = fmod(from, step); + if (mod < 0.0) + mod = step + mod; if (fabs(mod - 0.0) < EPSILON) ret = from; else - ret = from + (step - fmod(from, step)); + ret = from + (step - mod); return ret; } diff --git a/signalcontroller.cpp b/signalcontroller.cpp index 452189c..d63db55 100644 --- a/signalcontroller.cpp +++ b/signalcontroller.cpp @@ -193,12 +193,12 @@ RulerDrawData SignalController::getRulerDrawData(const double from, const double diffAbs = toAbs - fromAbs; step = 1 / pow(10, floor(log10(1 / (diffAbs))) + 1); // Magic - you want to love it but you better not touch! relStep = (diffRel * step) / (diffAbs); - //qDebug() << __QFUNC__ << "Step" << step << "RelStep" << relStep << "relDiff" << diffRel << fromAbs; + //Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString(" fA %1 tA %2 fR %3 tR %4").arg(fromAbs).arg(toAbs).arg(from).arg(to)); /* Calculate position of the first major tick */ firstTickAbs = Helpers::firstTick(fromAbs, step); firstTickRel = Helpers::firstTick(from, relStep); - //qDebug() << __QFUNC__ << "First tick Abs:" << firstTickAbs << "Rel:" << firstTickRel; + //Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString(" ftA %1 ftR %2").arg(firstTickAbs).arg(firstTickRel)); return RulerDrawData(firstTickAbs, firstTickRel, step, relStep); } diff --git a/signaldrawer.cpp b/signaldrawer.cpp index a07b478..b175ae7 100644 --- a/signaldrawer.cpp +++ b/signaldrawer.cpp @@ -237,6 +237,7 @@ void SignalDrawer::drawLeadingSubticks(const RulerDrawData& rd, std::functiondrawText(1, yPix + (br.height() / 2), m_locale.toString(value, 'f', 2)); + p->drawText(1, yPix, m_locale.toString(value, 'f', 2)); } void SignalDrawer::renderTimeScaleTick(QPainter* const p, const double rel, const double time, const TickType tt)