Commits

saar drimer committed cc7bfa8

copper shapes can now be defined as rings

Comments (0)

Files changed (3)

 
     print
 
+
     drills = cfg['board'].get('drills')
     if drills is not None:
         print "-- processing drills:",
-        for drill in drills:
-            component_refdef = drill
-            fp_drill_count = place_component(drills[drill])
-            # add the count to the total
-            drill_count = utils.add_dict_values(drill_count,
-                                                fp_drill_count)
+        for pcb_layer in utils.get_surface_layers(cfg):
+            for drill_refdef in drills[pcb_layer]:
+                component_refdef = drill_refdef
+                fp_drill_count = place_component(drills[pcb_layer][drill_refdef])
+                # add the count to the total
+                drill_count = utils.add_dict_values(drill_count,
+                                                    fp_drill_count)
 
     print
 

utils/footprint.py

                     shape_rotate = shape.get('rotate') or 0
                     gerber_lp = shape.get('gerber_lp')
                     shape_soldermask_buffer = shape.get('soldermask_buffer') or soldermask_buffer
+                    shape_style = None
 
                     translate = (str(round((location.x + shape_offset.x)*part_scale_factor, sig_dig)) + ' ' +
                                  str(round((-location.y - shape_offset.y)*part_scale_factor, sig_dig)))
                     elif shape_type.lower() == 'circle':
                         diameter = shape.get('diameter')
                         shape_path = svg.circle_diameter_to_path(diameter)
+
+                    elif shape_type.lower() == 'ring':
+                        shape_path = svg.ring_diameters_to_path(shape.get('diameter_outer'),
+                                                                shape.get('diameter_inner'))
+                        gerber_lp = 'dc'
+                        shape_style = 'fill-rule:evenodd;'
      
                     else:
                         print "ERROR: unrecognised shape type %s" % shape_type
                     if gerber_lp is not None:
                         shape_element.set('gerber_lp', gerber_lp)
 
+                    if shape_style is not None:
+                        shape_element.set('style', shape_style)
+
                     # first check if the pad has a distance setting, then check for global
                     # setting, and if not, default to 0.5
                     # TODO: set the default setting in the board config, not hard coded
                             shape_soldermask_scale_factor = float(soldermask.get('scale_factor') or soldermask_scale_factor)
 
                             if soldermask_type in ['shape', 'same_as_shape']:
-                                soldermask_path = shape_path
+
+                                # for a ring, this increases the size of the outer ring and decreases
+                                # the size of the inner ring
+                                if shape_type == 'ring':
+                                    outer_diameter = shape.get('diameter_outer')*shape_soldermask_scale_factor
+                                    inner_diameter = shape.get('diameter_inner')-(outer_diameter-shape.get('diameter_outer'))
+                                    soldermask_path = svg.ring_diameters_to_path(outer_diameter,
+                                                                                 inner_diameter)
+                                    shape_soldermask_scale_factor = 1
+                                else:
+                                    soldermask_path = shape_path
                             
                             elif soldermask_type in ['rect', 'rectangle']:
                                 width = float(soldermask['width'])
                                                             pad_scale_factor *
                                                             shape_soldermask_scale_factor)
 
+
+
                         w, h, shape_soldermask_path = svg.transform_path(soldermask_path, 
                                                                          False, 
                                                                          soldermask_combined_scale_factor, 
                         if gerber_lp is not None:
                             soldermask_pad.set('gerber_lp', gerber_lp)
 
+                        if shape_style is not None:
+                            soldermask_pad.set('style', shape_style)
 
 
             pad_drills = part['pads'][pad_name].get('drills') or None
 
 
 
+def ring_diameters_to_path(d1, d2):
+    """
+    Returns a path for a ring based on two diameters; the
+    function automatically determines which diameter is the
+    inner and which is the outer diameter
+    """
+
+    path = None
+
+    if d1 == d2:
+        path = circle_diameter_to_path(d1)
+    else:
+        if d1 > d2:
+            outer = d1
+            inner = d2
+        else:
+            outer = d2
+            inner = d1
+        path = circle_diameter_to_path(outer)
+        path += circle_diameter_to_path(inner, Point(0, outer/2))
+    
+    return path
+
+
+
+
 
-def circle_diameter_to_path(d):
+def circle_diameter_to_path(d, offset=Point()):
     """
     Returns an SVG path of a circle of diameter 'diameter'
     """
     # by Aleksas Riskus
     k = 0.5522847498
 
-    return "m %s,%s c %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s z" % (0,r, k*r,0, r,-r*(1-k), r,-r, 0,-r*k, -r*(1-k),-r, -r,-r, -r*k,0, -r,r*(1-k), -r,r, 0,r*k, r*(1-k),r, r,r)
+    return "m %s,%s c %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s %s,%s z" % (0,r-offset.y, k*r,0, r,-r*(1-k), r,-r, 0,-r*k, -r*(1-k),-r, -r,-r, -r*k,0, -r,r*(1-k), -r,r, 0,r*k, r*(1-k),r, r,r)
 
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.