Skip to content

Commit 630301b

Browse files
committed
Implement untented vias for kicad
Also fix tracks sometimes overlapping via holes Issue #416
1 parent a05f4ac commit 630301b

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

InteractiveHtmlBom/ecad/kicad.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ def parse_footprints(self):
573573
return footprints
574574

575575
def parse_tracks(self, tracks):
576+
tent_vias = self.board.GetTentVias()
576577
result = {pcbnew.F_Cu: [], pcbnew.B_Cu: []}
577578
for track in tracks:
578579
if track.GetClass() in ["VIA", "PCB_VIA"]:
@@ -582,6 +583,8 @@ def parse_tracks(self, tracks):
582583
"width": track.GetWidth() * 1e-6,
583584
"net": track.GetNetname(),
584585
}
586+
if not tent_vias:
587+
track_dict["drillsize"] = track.GetDrillValue() * 1e-6
585588
for layer in [pcbnew.F_Cu, pcbnew.B_Cu]:
586589
if track.IsOnLayer(layer):
587590
result[layer].append(track_dict)

InteractiveHtmlBom/ecad/schema/genericjsonpcbdata_v1.schema

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@
519519
"start": { "$ref": "#/definitions/Coordinates" },
520520
"end": { "$ref": "#/definitions/Coordinates" },
521521
"width": { "type": "number" },
522+
"drillsize": { "type": "number" },
522523
"net": { "type": "string" }
523524
},
524525
"required": [

InteractiveHtmlBom/web/render.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -417,21 +417,16 @@ function drawBgLayer(layername, canvas, layer, scalefactor, edgeColor, polygonCo
417417
function drawTracks(canvas, layer, defaultColor, highlight) {
418418
ctx = canvas.getContext("2d");
419419
ctx.lineCap = "round";
420+
421+
var hasHole = (track) => (
422+
'drillsize' in track &&
423+
track.start[0] == track.end[0] &&
424+
track.start[1] == track.end[1]);
425+
426+
// First draw tracks and tented vias
420427
for (var track of pcbdata.tracks[layer]) {
421428
if (highlight && highlightedNet != track.net) continue;
422-
if ('drillsize' in track && track.start[0] == track.end[0] && track.start[1] == track.end[1]) {
423-
var style = getComputedStyle(topmostdiv);
424-
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
425-
ctx.lineWidth = track.width;
426-
ctx.beginPath();
427-
ctx.moveTo(...track.start);
428-
ctx.lineTo(...track.end);
429-
ctx.stroke();
430-
ctx.strokeStyle = style.getPropertyValue('--pad-hole-color');
431-
ctx.lineWidth = track.drillsize;
432-
ctx.lineTo(...track.end);
433-
ctx.stroke();
434-
} else {
429+
if (!hasHole(track)) {
435430
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
436431
ctx.lineWidth = track.width;
437432
ctx.beginPath();
@@ -448,6 +443,25 @@ function drawTracks(canvas, layer, defaultColor, highlight) {
448443
ctx.stroke();
449444
}
450445
}
446+
// Second pass to draw untented vias
447+
var style = getComputedStyle(topmostdiv);
448+
var holeColor = style.getPropertyValue('--pad-hole-color')
449+
450+
for (var track of pcbdata.tracks[layer]) {
451+
if (highlight && highlightedNet != track.net) continue;
452+
if (hasHole(track)) {
453+
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
454+
ctx.lineWidth = track.width;
455+
ctx.beginPath();
456+
ctx.moveTo(...track.start);
457+
ctx.lineTo(...track.end);
458+
ctx.stroke();
459+
ctx.strokeStyle = holeColor;
460+
ctx.lineWidth = track.drillsize;
461+
ctx.lineTo(...track.end);
462+
ctx.stroke();
463+
}
464+
}
451465
}
452466

453467
function drawZones(canvas, layer, defaultColor, highlight) {

0 commit comments

Comments
 (0)