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 [2018/06/03 18:51]
cparker [Details]
snapping_in_pcb [2018/06/10 10:52]
cparker
Line 39: Line 39:
  
 In a nod to the gobject/​glib folks, I've tried to adopt some similar naming conventions for functions. In a nod to the gobject/​glib folks, I've tried to adopt some similar naming conventions for functions.
 +
 +===SnapType===
 +A SnapType contains information about the result of a snapping test. This is basically a messenger type. It's mostly used to convey info from one place to another, and doesn'​t necessarily persist for very long. These are produced by snapping functions to indicate that a snappable object was or wasn't found. They contain a SnapSpecType pointer (that as I write this I realize is never used), an object type indicate, a pointer to a found object, a flag that it was valid for snapping, it's location, and the square of the distance to it.
  
 ===SnapSpecType=== ===SnapSpecType===
Line 74: Line 77:
 One thing to note: there is a feature, I think it's called 'Auto Enforce DRC Clearance'​ in the settings menu. It used to be implemented at the end of the ''​FitCrosshairIntoGrid''​ function that was previously responsible for the snapping. This has been moved into ''​MoveCrosshairAbsolute''​ until a better home can be found for it. I don't think this really belongs as part of the crosshair subsystem. One thing to note: there is a feature, I think it's called 'Auto Enforce DRC Clearance'​ in the settings menu. It used to be implemented at the end of the ''​FitCrosshairIntoGrid''​ function that was previously responsible for the snapping. This has been moved into ''​MoveCrosshairAbsolute''​ until a better home can be found for it. I don't think this really belongs as part of the crosshair subsystem.
  
-===Adding Snaps===+===Discussion=== 
 +One thing I'm on the fence about is if the snapping functions should get a pointer to the SnapSpecType they were called from. Presently, the functions answer the question: "is there something of this type under the cursor that can be snapped to?". To answer that question, the SnapSpecType data isn't required, and so presently it's not provided. However, if this were to become more sophisticated in the future, it might become necessary. 
 + 
 +===TODO List=== 
 +  * Configuration actions 
 +  * snap-to-the-closest-object function 
 +  * snapping preferences saving 
 +  * sub-snaps? (lines, line endpoints, midpoints... ) 
 +  * lesstif config page 
 +  * tests 
 + 
 +====Adding Snaps====
  
 TODO: TEST THIS! TODO: TEST THIS!
Line 80: Line 94:
 Under this configuration,​ it is fairly easy to add snaps or change the snapping behavior using plugins. Let's examine how that could work with an example. Let's change how the element snapping works. Presently, it snaps to the location of the element mark. Let's snap to the center of the bounding box instead. Under this configuration,​ it is fairly easy to add snaps or change the snapping behavior using plugins. Let's examine how that could work with an example. Let's change how the element snapping works. Presently, it snaps to the location of the element mark. Let's snap to the center of the bounding box instead.
  
-First, get the plugin template from [pcb_developer_introduction_2]. In a real plugin, you would probably want to write some actions to enable and disable your features, but, for the sake of this example, we'll skip that. So, delete that stuff. Then, let's grab the existing code for snapping to elements out of crosshair.c,​ and copy it into the plugin file. There are two parts, the snapping function, and the ''​SnapSpecType''​ definition. Here they are (more or less). The snapping function should be fairly easy to read:+First, get the plugin template from [[geda:pcb_developer_introduction_2]]. In a real plugin, you would probably want to write some actions to enable and disable your features, but, for the sake of this example, we'll skip that. So, delete that stuff. Then, let's grab the existing code for snapping to elements out of crosshair.c,​ and copy it into the plugin file. There are two parts, the snapping function, and the ''​SnapSpecType''​ definition. Here they are (more or less). The snapping function should be fairly easy to read:
  
 <code C> <code C>
snapping_in_pcb.txt · Last modified: 2019/03/21 12:50 by cparker