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);
+ //Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString(" rD %1 aD %2").arg(diffRel).arg(diffAbs));
//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);
- //Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString(" ftA %1 ftR %2").arg(firstTickAbs).arg(firstTickRel));
+ switch (axis) {
+ case Axis::TIME:
+ firstTickRel = timeToRel(firstTickAbs);
+ break;
+ case Axis::VALUE:
+ firstTickRel = valueToRel(firstTickAbs);
+ break;
+ }
+ Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString(" ftA %1 ftR %2 aS %3 rS %4").arg(firstTickAbs).arg(firstTickRel).arg(step).arg(relStep));
return RulerDrawData(firstTickAbs, firstTickRel, step, relStep);
}
const double relMin)
{
const double subRelStep = subStep(rd.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);
+ const double subAbsStep = subStep(rd.step);
+ double subRel = rd.firstTickRel;
+ double subAbs = rd.firstTickAbs;
+ int ctr = 0;
+
+ while (subRel >= relMin) {
+ drawFunc(subRel, subAbs, (ctr++ == 5) ? TickType::TICK : TickType::SUBTICK);
+ subRel -= subRelStep;
+ subAbs -= subAbsStep;
+ }
}
void SignalDrawer::drawScaleBySubticks(const RulerDrawData& rd, std::function<void (const double, const double, const TickType)> drawFunc, const double fromSubRel,
{
double absVal = rd.firstTickAbs;
for (double rel = rd.firstTickRel; rel <= relMax; rel += rd.relStep) {
- drawFunc(rel, absVal, TickType::TICK);
+ Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString(" rel %1 abs %2").arg(rel).arg(absVal));
+ drawFunc(rel, absVal, TickType::BIGTICK);
/* Draw subticks ticks */
if (drawSubTicks)
/* Do not draw labels that would overflow */
QRect br = p->fontMetrics().boundingRect(text);
- if (yPix - (br.height() / 2) < 0)
- return;
+/* if (yPix - (br.height() / 2) < 0)
+ return;*/
if (maxCueWidth < br.width())
maxCueWidth = br.width();
const int xPix = relToXPix(rel);
switch (tt) {
- case TickType::TICK:
- p->drawLine(xPix, m_gHeight + 2, xPix, m_gHeight + 6);
- break;
- case TickType::SUBTICK:
- p->drawLine(xPix, m_gHeight + 2, xPix , m_gHeight + 4);
- break;
+ case TickType::BIGTICK:
+ p->drawLine(xPix, m_gHeight + 2, xPix, m_gHeight + 8);
+ break;
+ case TickType::TICK:
+ p->drawLine(xPix, m_gHeight + 2, xPix, m_gHeight + 6);
+ break;
+ case TickType::SUBTICK:
+ p->drawLine(xPix, m_gHeight + 2, xPix , m_gHeight + 4);
+ break;
}
}
const int yPix = relToYPix(rel);
switch (tt) {
- case TickType::TICK:
- p->drawLine(m_leftGraphOffset - 6, yPix, m_leftGraphOffset - 1, yPix);
- break;
- case TickType::SUBTICK:
- p->drawLine(m_leftGraphOffset - 4, yPix, m_leftGraphOffset - 1, yPix);
- break;
+ case TickType::BIGTICK:
+ p->drawLine(m_leftGraphOffset - 8, yPix, m_leftGraphOffset - 1, yPix);
+ break;
+ case TickType::TICK:
+ p->drawLine(m_leftGraphOffset - 6, yPix, m_leftGraphOffset - 1, yPix);
+ break;
+ case TickType::SUBTICK:
+ p->drawLine(m_leftGraphOffset - 4, yPix, m_leftGraphOffset - 1, yPix);
+ break;
}
}