@@ -11,8 +11,10 @@ def node(parent, tag, **attrs):
|
||||
|
||||
def svg_document(doc: Document, annotations=None, id_prefix="") -> bytes:
|
||||
b = doc.sheet.bounds
|
||||
pcb = doc.document_type == 'pcb'
|
||||
layer_visibility = {layer.id: layer.visible for layer in doc.layers}
|
||||
root = Element('svg', {'xmlns': 'http://www.w3.org/2000/svg', 'viewBox': f'{b.x} {b.y} {b.width} {b.height}',
|
||||
'preserveAspectRatio': 'xMidYMid meet', 'role': 'img', 'aria-label': 'Schematic'})
|
||||
'preserveAspectRatio': 'xMidYMid meet', 'role': 'img', 'aria-label': 'PCB' if pcb else 'Schematic'})
|
||||
node(root, 'rect', x=b.x, y=b.y, width=b.width, height=b.height, fill=doc.sheet.background)
|
||||
defs = node(root, 'defs')
|
||||
for i, p in enumerate(doc.primitives):
|
||||
@@ -20,6 +22,12 @@ def svg_document(doc: Document, annotations=None, id_prefix="") -> bytes:
|
||||
if annotations is not None:
|
||||
annotation = annotations.get(p.component_id or p.object_id)
|
||||
target = node(root, 'g', data_object_id=p.component_id or p.object_id, data_change_id=annotation['id'] if annotation else '')
|
||||
if pcb:
|
||||
span = getattr(p, "layer_ids", [])
|
||||
visible = layer_visibility.get(p.layer_id, True) and (p.role != "drill" or not span or any(layer_visibility.get(lid, False) for lid in span))
|
||||
target = node(target, 'g', data_layer_id=p.layer_id or '',
|
||||
data_layer_span=' '.join(getattr(p, 'layer_ids', [])), data_role=p.role,
|
||||
display='inline' if visible else 'none')
|
||||
if p.clip:
|
||||
clip = node(defs, 'clipPath', id=f'{id_prefix}clip-{i}', clipPathUnits='userSpaceOnUse')
|
||||
c = p.clip
|
||||
|
||||
مرجع در شماره جدید
مسدود کردن کاربر