示例#1
0
	outline_paths = GU.buildCyclePathsForLineSegments(outline_line_list)
elif "COPPER_TOP" in layers:
	t = layers["COPPER_TOP"];
	outline_line_list = []
	for t_l in t.layers:
		if options.search_outline_nonzero:
			outline_line_list += [k for k in t_l.draws if isinstance(k, GD.GerbObj_Line)]
		else:
			outline_line_list += [k for k in t_l.draws if isinstance(k, GD.GerbObj_Line) and k.width == 0]
	outline_paths = GU.buildCyclePathsForLineSegments(outline_line_list)

# Calculate a bounding rectangle using either all visible objects, or only zero-width lines
check_layers = [v for k,v in layers.items() if not k.startswith("DRILL")]
if (options.bounding_from_visible_only):
	check_layers = [v for k,v in layers.items() if k in render_order and not k.startswith("DRILL")]
artwork_bounds = GU.calculateBoundingRectFromPCBLayers(check_layers, options.size0)

# Calculate the board area, for use in setting up the image / image transform
if outline_paths and not options.bounds_artwork:
	srcrect = GU.calculateBoundingRectFromOutlines(outline_paths)

	srcrect_sane = True
	copper_layers = [v for k,v in layers.iteritems() if k.startswith("COPPER")]
	copper_bounds = GU.calculateBoundingRectFromPCBLayers(copper_layers)

	# Check if we have artwork outside the source rectangle
	if  srcrect.getStartPoint().x > copper_bounds.getStartPoint().x or \
		srcrect.getStartPoint().y > copper_bounds.getStartPoint().y or \
		srcrect.getEndPoint().x < copper_bounds.getEndPoint().x or \
		srcrect.getEndPoint().y < copper_bounds.getEndPoint().y:
		srcrect_sane = False 
示例#2
0
	for j in rep.layers:
		if (j.polarity == "LP_C"):
				cr.set_source_rgba(1,0,0, 1)
		else:
				cr.set_source_rgba(0,0,1, 1)

		for k in j.draws:
			GD.emitGerbObjectCairoPath(cr, k)
			
			cr.stroke()		
			
	cr.pop_group_to_source()
	cr.paint_with_alpha(1)

	
srcrect = GU.calculateBoundingRectFromPCBLayers([p], False)

print srcrect

# Calculate the image size and transform
(width, height), transform = GD.prepareCairoTransform(1024, srcrect, pad = 50, trim_to_ratio = True)

# Prepare a surface to render onto
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
cr = cairo.Context(surface)

# Apply the transform to the context
transform(cr)

renderGerberFile(p, cr)
示例#3
0
            ]
        else:
            outline_line_list += [
                k for k in t_l.draws
                if isinstance(k, GD.GerbObj_Line) and k.width == 0
            ]
    outline_paths = GU.buildCyclePathsForLineSegments(outline_line_list)

# Calculate a bounding rectangle using either all visible objects, or only zero-width lines
check_layers = [v for k, v in layers.items() if not k.startswith("DRILL")]
if (options.bounding_from_visible_only):
    check_layers = [
        v for k, v in layers.items()
        if k in render_order and not k.startswith("DRILL")
    ]
artwork_bounds = GU.calculateBoundingRectFromPCBLayers(check_layers,
                                                       options.size0)

# Calculate the board area, for use in setting up the image / image transform
if outline_paths and not options.bounds_artwork:
    srcrect = GU.calculateBoundingRectFromOutlines(outline_paths)

    srcrect_sane = True
    copper_layers = [
        v for k, v in layers.iteritems() if k.startswith("COPPER")
    ]
    copper_bounds = GU.calculateBoundingRectFromPCBLayers(copper_layers)

    # Check if we have artwork outside the source rectangle
    if  srcrect.getStartPoint().x > copper_bounds.getStartPoint().x or \
     srcrect.getStartPoint().y > copper_bounds.getStartPoint().y or \
     srcrect.getEndPoint().x < copper_bounds.getEndPoint().x or \