User Tools

Site Tools


snapping_in_pcb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
snapping_in_pcb [2017/11/05 16:09]
cparker
snapping_in_pcb [2018/06/02 12:26]
cparker [Proposed System]
Line 16: Line 16:
  
 ===== Proposed System ===== ===== Proposed System =====
 +Presently implemented in the home/​cparker/​snapping_overhaul branch.
 +====Overview====
 +The snapping code is presently located in two places: snap.[c,h] and crosshair.c. snap.[c,h] defines several general types that are used to do the snapping. crosshair.c is where the snapping actually occurs and is where all of the snapping functions are implemented.
  
 +There are three new types in snap.[c,​h]: ​
 +  * SnapSpecType:​ This type is an index type for things that can be snapped to. 
 +  * SnapListType:​ A list of SnapSpecType objects
 +  * SnapType: The result of a snapping test
 +
 +Snapping occurs by iterating through SnapSpecType objects in a SnapListType. Each SnapSpecType object has a "​search"​ function pointer that calls a function to look for the the object type associated with that particular SnapSpecType. These functions are presently defined in crosshair.c. So, for example, there is a SnapSpecType object associated with pins and pads called pin_pad_snap. It has a function associated with it called snap_to_pins_pads that calls SearchObjectByLocation to look for and pins or pads under the cursor, and decide if there is a valid snapping target. If there is, it passes that back to the calling function (as an object, not a pointer).
 +
 +The crosshair structure has two related fields:
 +  * (SnapType*) (*snap)(SnapListType*,​ Coord, Coord): a function pointer to a function that does the snapping
 +  * (SnapListType*) snaps: a pointer to a list of things to try snapping to.
 +
 +Presently, snapping occurs whenever the crosshair is repositioned using MoveCrosshairAbsolute (crosshair.c). This function calls Crosshair.snap(Crosshair.snaps,​ X, Y). If this returns non-null, we found something to snap to, and we reposition the crosshair to those coordinates.
 +
 +Both of the crosshair items are implemented as pointers so that they can be changed dynamically. You could, for example, change the snap list when you go into line drawing mode so that you don't snap to elements or other lines, or do so in a different order.
 +
 +
 +====Details====
 ===== Related Pages ===== ===== Related Pages =====
-  * [[Crosshair|Crosshair]]+  * [[PCB Crosshair|PCB Crosshair]]
  
snapping_in_pcb.txt ยท Last modified: 2019/03/21 12:50 by cparker