another version of tracing across buses

This commit is contained in:
2020-08-17 00:32:59 +03:00
parent efb5cbe484
commit c49454bb03
3 changed files with 55 additions and 57 deletions

View File

@@ -1264,14 +1264,17 @@ void BlockView::trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem
double signx = (p1.x() >= p0.x() ? 1. : -1.), signy = (p1.y() >= p0.y() ? 1. : -1.);
int steps(0);
if ((dx + dy) < grid_step) continue;
BlockViewWavetrace::CellState cs = BlockViewWavetrace::Blocked;
if (dx >= dy) { // by x
sx = grid_step;
sy = sx * dy / dx;
steps = qRound(dx / grid_step);
cs = BlockViewWavetrace::HorizontalBus;
} else {
sy = grid_step;
sx = sy * dx / dy;
steps = qRound(dy / grid_step);
cs = BlockViewWavetrace::VerticalBus;
}
sx *= signx;
sy *= signy;
@@ -1279,7 +1282,7 @@ void BlockView::trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem
for (int j = 0; j < steps; ++j) {
QPoint tp = quantize(cp, grid_step).toPoint() / grid_step + dp;
if (tp != qpt)
wavetrace.fill(tp, BlockViewWavetrace::Jump);
wavetrace.fill(tp, cs);
//qDebug() << " set" << cp;
cp += QPointF(sx, sy);
}