Skip to content

Commit

Permalink
Implement untented vias for kicad
Browse files Browse the repository at this point in the history
Also fix tracks sometimes overlapping via holes

Issue #416
  • Loading branch information
qu1ck committed Sep 26, 2023
1 parent a05f4ac commit 630301b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
3 changes: 3 additions & 0 deletions InteractiveHtmlBom/ecad/kicad.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ def parse_footprints(self):
return footprints

def parse_tracks(self, tracks):
tent_vias = self.board.GetTentVias()
result = {pcbnew.F_Cu: [], pcbnew.B_Cu: []}
for track in tracks:
if track.GetClass() in ["VIA", "PCB_VIA"]:
Expand All @@ -582,6 +583,8 @@ def parse_tracks(self, tracks):
"width": track.GetWidth() * 1e-6,
"net": track.GetNetname(),
}
if not tent_vias:
track_dict["drillsize"] = track.GetDrillValue() * 1e-6
for layer in [pcbnew.F_Cu, pcbnew.B_Cu]:
if track.IsOnLayer(layer):
result[layer].append(track_dict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@
"start": { "$ref": "#/definitions/Coordinates" },
"end": { "$ref": "#/definitions/Coordinates" },
"width": { "type": "number" },
"drillsize": { "type": "number" },
"net": { "type": "string" }
},
"required": [
Expand Down
40 changes: 27 additions & 13 deletions InteractiveHtmlBom/web/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,21 +417,16 @@ function drawBgLayer(layername, canvas, layer, scalefactor, edgeColor, polygonCo
function drawTracks(canvas, layer, defaultColor, highlight) {
ctx = canvas.getContext("2d");
ctx.lineCap = "round";

var hasHole = (track) => (
'drillsize' in track &&
track.start[0] == track.end[0] &&
track.start[1] == track.end[1]);

// First draw tracks and tented vias
for (var track of pcbdata.tracks[layer]) {
if (highlight && highlightedNet != track.net) continue;
if ('drillsize' in track && track.start[0] == track.end[0] && track.start[1] == track.end[1]) {
var style = getComputedStyle(topmostdiv);
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
ctx.lineWidth = track.width;
ctx.beginPath();
ctx.moveTo(...track.start);
ctx.lineTo(...track.end);
ctx.stroke();
ctx.strokeStyle = style.getPropertyValue('--pad-hole-color');
ctx.lineWidth = track.drillsize;
ctx.lineTo(...track.end);
ctx.stroke();
} else {
if (!hasHole(track)) {
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
ctx.lineWidth = track.width;
ctx.beginPath();
Expand All @@ -448,6 +443,25 @@ function drawTracks(canvas, layer, defaultColor, highlight) {
ctx.stroke();
}
}
// Second pass to draw untented vias
var style = getComputedStyle(topmostdiv);
var holeColor = style.getPropertyValue('--pad-hole-color')

for (var track of pcbdata.tracks[layer]) {
if (highlight && highlightedNet != track.net) continue;
if (hasHole(track)) {
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
ctx.lineWidth = track.width;
ctx.beginPath();
ctx.moveTo(...track.start);
ctx.lineTo(...track.end);
ctx.stroke();
ctx.strokeStyle = holeColor;
ctx.lineWidth = track.drillsize;
ctx.lineTo(...track.end);
ctx.stroke();
}
}
}

function drawZones(canvas, layer, defaultColor, highlight) {
Expand Down

0 comments on commit 630301b

Please sign in to comment.