pixelStep = pixelLength / numSteps + 1;
//Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString("pixelStep %1, step %2, pixelLength %3, numSteps %4").arg(pixelStep).arg(step).arg(pixelLength).arg(numSteps));
if (pixelStep < minPixelStep) {
- const double upscaleFactor = ceil(minPixelStep / pixelStep);
- step *= upscaleFactor;
+ const double upscaleFactor = minPixelStep / pixelStep;
+ step *= ceil(upscaleFactor / 2.0) * 2.0;
//Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString("Corrected step %1, upscaleFactor %2").arg(step).arg(upscaleFactor));
- } else if (pixelStep > maxPixelStep) {
- const double downscaleFactor = ceil(pixelStep / maxPixelStep);
- step /= downscaleFactor;
+ }
+ else if (pixelStep > maxPixelStep) {
+ const double downscaleFactor = pixelStep / maxPixelStep;
+ step /= ceil(downscaleFactor / 2.0) * 2.0;
//Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + QString("Corrected step %1, downscaleFactor %2").arg(step).arg(downscaleFactor));
}
relStep = (diffRel * step) / (diffAbs);
const int SignalDrawer::AXIS_LABEL_BORDER_OFFSET(2);
const int SignalDrawer::AXIS_LABEL_SCALE_OFFSET(3);
-const int SignalDrawer::MAXIMAL_AXIS_BIGTICK_STEP(75);
+const int SignalDrawer::MAXIMAL_AXIS_BIGTICK_STEP(150);
const int SignalDrawer::MINIMAL_AXIS_BIGTICK_STEP(25);
const int SignalDrawer::SCALE_MARGIN_TIME(16);
const int SignalDrawer::SCALE_MARGIN_VALUE(12);
void SignalDrawer::drawTimeScale(QPainter* const p)
{
+ int maxBigTickStep = calculateMaximalTickStep(m_gWidth);
+
std::function<void (const double, const double, const TickType)> textDrawFunc;
std::function<void (const double, const double, const TickType)> tickDrawFunc;
textDrawFunc = std::bind(&SignalDrawer::renderTimeScaleText, this, p, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
- tickDrawFunc = std::bind(&SignalDrawer::renderTimeScaleTick, this, p, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
+ tickDrawFunc = std::bind(&SignalDrawer::renderTimeScaleTick, this, p, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
- RulerDrawData rd = m_controller->getRulerDrawData(m_relXMin, m_relXMax, SignalController::Axis::TIME, m_gWidth, MINIMAL_AXIS_BIGTICK_STEP, MAXIMAL_AXIS_BIGTICK_STEP);
+ RulerDrawData rd = m_controller->getRulerDrawData(m_relXMin, m_relXMax, SignalController::Axis::TIME, m_gWidth,
+ MINIMAL_AXIS_BIGTICK_STEP, maxBigTickStep);
if (!rd.valid)
return;
std::function<void (const double, const double, const TickType)> textDrawFunc;
std::function<void (const double, const double, const TickType)> tickDrawFunc;
int maxCueWidth = 0;
+ int maxBigTickStep = calculateMaximalTickStep(m_gHeight);
textDrawFunc = std::bind(&SignalDrawer::renderValueScaleText, this, p, std::ref(maxCueWidth), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
tickDrawFunc = std::bind(&SignalDrawer::renderValueScaleTick, this, p, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
- RulerDrawData rd = m_controller->getRulerDrawData(m_relYMin, m_relYMax, SignalController::Axis::VALUE, m_gHeight, MINIMAL_AXIS_BIGTICK_STEP, MAXIMAL_AXIS_BIGTICK_STEP);
+ RulerDrawData rd = m_controller->getRulerDrawData(m_relYMin, m_relYMax, SignalController::Axis::VALUE, m_gHeight,
+ MINIMAL_AXIS_BIGTICK_STEP, maxBigTickStep);
if (!rd.valid)
return;
/** Private functions **/
+int SignalDrawer::calculateMaximalTickStep(const int dimension)
+{
+ if (dimension < MAXIMAL_AXIS_BIGTICK_STEP) {
+ /* The viewport is just too small for the ticks to fit in */
+ if (dimension < MINIMAL_AXIS_BIGTICK_STEP) {
+ return MINIMAL_AXIS_BIGTICK_STEP + 1;
+ } else {
+ return ((dimension - MINIMAL_AXIS_BIGTICK_STEP) / 2) + MINIMAL_AXIS_BIGTICK_STEP + 1;
+ }
+ }
+ return MAXIMAL_AXIS_BIGTICK_STEP;
+}
+
double SignalDrawer::linesIntersection(const double k1, const double q1, const double k2, const double q2)
{
double ret = (q1 - q2) / (k2 - k1);