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;
}
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);
}
const double subRelMin = Helpers::firstTick(relMin, subRelStep);
const double subAbsMin = (rd.firstTickRel - subRelMin) * (subStep(rd.step)) / subRelStep;
+ //Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + " from leading");
drawScaleBySubticks(rd, drawFunc, subRelMin, subAbsMin, rd.firstTickRel);
}
double subRel = fromSubRel;
double absVal = fromAbsVal;
- int ctr = 10 - ((toSubRel - fromSubRel) / subRelStep);
+ int ctr = 10 - floor(((toSubRel - fromSubRel) / subRelStep) + 0.5);
+ //Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString("ctr %1, tsr %2, fsr %3 srs %4").arg(ctr).arg(fromSubRel).arg(toSubRel).arg(subRelStep));
while (subRel < toSubRel) {
drawFunc(subRel, absVal, (ctr++ == 5) ? TickType::TICK : TickType::SUBTICK);
if (maxCueWidth < br.width())
maxCueWidth = br.width();
- p->drawText(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)