pcb-rnd knowledge pool


Pixel slop

pixel_slop by Tibor 'Igor2' Palinkas on 2017-09-10

Tags: insight, rounding, HID, display, screen, draw, select, click

node source



Abstract: If you want to select an object by a click, you must have the (center of the) crosshair be on the object. In case of a line, this means the crosshair must be within the boundaries of the line width. But the line previse line width (in nanometer) is scaled down to pixels on screen. We have a value called "pixel slop" to compenzate for this roundnig.

  Imported from the mailing list archives.

This is all calculated in core, while rendering happens in various HIDs. To overcome possible different rounding as on "which pixel the line really uses", there's a certain tolerance, specified in pixels, called pcb_pixel_slop .

What you have in your example is a horizontal line that is between two rows of grid in a way that no part of the line overlaps with any grid row.

This means you can not officially select it by trying to click on the line, because you can not place the crosshair on the line because the crosshair will snap to grid rows and will never overlap the line.

The only reason you can still select it sometime using this method is that at certain zoom levels, pcb_pixel_slop says "well, on-screen, it's close enough, let's accept it".

You can test it by zooming in to give the engine more pixels; you won't be able toe select it. Then start zooming out, step by step, and try select click again: at some point it will stop working. That's when your grid points get too far away from the edge of the line for pcb_pixel_slop.

The reason you can select by endpoint is probably because you have snap to off-grid points of line on and it simply snaps at the endpoint even if it is between grid points.

Official solution: if you have objects in between grid poitns, either select it using selection boxes or refine your grid or depend on the object-point-snap settings.