diff --git a/doc/panelization.md b/doc/panelization.md index 42eb49f6..ea8d04f3 100644 --- a/doc/panelization.md +++ b/doc/panelization.md @@ -320,6 +320,18 @@ debugRenderPartitionLines(self) Render partition line to the panel to be easily able to inspect them via Pcbnew. +#### `getAuxiliaryOrigin` +``` +getAuxiliaryOrigin(self) +``` +None + +#### `getGridOrigin` +``` +getGridOrigin(self) +``` +None + #### `getPrlFilepath` ``` getPrlFilepath(self, path=None) @@ -347,6 +359,12 @@ inheritDesignSettings(self, board) Inherit design settings from the given board specified by a filename or a board +#### `inheritPageSize` +``` +inheritPageSize(self, board) +``` +Inherit page size from a board specified by a filename or a board + #### `inheritProperties` ``` inheritProperties(self, board) @@ -496,6 +514,12 @@ setGridOrigin(self, point) ``` Set grid origin +#### `setPageSize` +``` +setPageSize(self, size) +``` +Set page size - either a string name (e.g., A4) or size in KiCAD units + #### `setProperties` ``` setProperties(self, properties) @@ -520,6 +544,14 @@ setVCutLayer(self, layer) ``` Set layer on which the V-Cuts will be rendered +#### `translate` +``` +translate(self, vec) +``` +Translates the whole panel by vec. Such a feature can be useful to +specify the panel placement in the sheet. When we translate panel as the +last operation, none of the operations have to be placement-aware. + ## Substrate class This class represents a pice of substrate (with no components). Basically it is @@ -529,6 +561,12 @@ a partition line for the substrate. Read more about partition lines in +#### `backToSource` +``` +backToSource(self, point) +``` +Return a point in the source form (if a reverse transformation was set) + #### `boundary` ``` boundary(self) @@ -608,6 +646,12 @@ a tuple (None, None). Returns a pair tab and cut outline. Add the tab it via union - batch adding of geometry is more efficient. +#### `translate` +``` +translate(self, vec) +``` +Translate substrate by vec + #### `union` ``` union(self, other) diff --git a/doc/resources/conn.png b/doc/resources/conn.png index 8fae868d..bb399333 100644 Binary files a/doc/resources/conn.png and b/doc/resources/conn.png differ diff --git a/doc/resources/examplePanel1.png b/doc/resources/examplePanel1.png index 2e26ad8d..172ed9d4 100644 Binary files a/doc/resources/examplePanel1.png and b/doc/resources/examplePanel1.png differ diff --git a/doc/resources/examplePanel10.png b/doc/resources/examplePanel10.png index 9ac7acff..0908c91d 100644 Binary files a/doc/resources/examplePanel10.png and b/doc/resources/examplePanel10.png differ diff --git a/doc/resources/examplePanel11.png b/doc/resources/examplePanel11.png index eb2dadcd..712417e7 100644 Binary files a/doc/resources/examplePanel11.png and b/doc/resources/examplePanel11.png differ diff --git a/doc/resources/examplePanel12.png b/doc/resources/examplePanel12.png index d843bb97..c2ffb0e6 100644 Binary files a/doc/resources/examplePanel12.png and b/doc/resources/examplePanel12.png differ diff --git a/doc/resources/examplePanel13.png b/doc/resources/examplePanel13.png index a812f5f4..a753c3a0 100644 Binary files a/doc/resources/examplePanel13.png and b/doc/resources/examplePanel13.png differ diff --git a/doc/resources/examplePanel14.png b/doc/resources/examplePanel14.png index 8635a71a..3180c5f9 100644 Binary files a/doc/resources/examplePanel14.png and b/doc/resources/examplePanel14.png differ diff --git a/doc/resources/examplePanel15.png b/doc/resources/examplePanel15.png index aad156f1..d1d2d49f 100644 Binary files a/doc/resources/examplePanel15.png and b/doc/resources/examplePanel15.png differ diff --git a/doc/resources/examplePanel16.png b/doc/resources/examplePanel16.png index 35498cde..a8abd8db 100644 Binary files a/doc/resources/examplePanel16.png and b/doc/resources/examplePanel16.png differ diff --git a/doc/resources/examplePanel17.png b/doc/resources/examplePanel17.png index 974ab641..ee8aa321 100644 Binary files a/doc/resources/examplePanel17.png and b/doc/resources/examplePanel17.png differ diff --git a/doc/resources/examplePanel18.png b/doc/resources/examplePanel18.png index ad292051..01a457d6 100644 Binary files a/doc/resources/examplePanel18.png and b/doc/resources/examplePanel18.png differ diff --git a/doc/resources/examplePanel19.png b/doc/resources/examplePanel19.png index 12460ff7..3e07d031 100644 Binary files a/doc/resources/examplePanel19.png and b/doc/resources/examplePanel19.png differ diff --git a/doc/resources/examplePanel2.png b/doc/resources/examplePanel2.png index 6a96e03c..8c34a30b 100644 Binary files a/doc/resources/examplePanel2.png and b/doc/resources/examplePanel2.png differ diff --git a/doc/resources/examplePanel20.png b/doc/resources/examplePanel20.png index 16cf8b20..b16426f2 100644 Binary files a/doc/resources/examplePanel20.png and b/doc/resources/examplePanel20.png differ diff --git a/doc/resources/examplePanel21.png b/doc/resources/examplePanel21.png index 741d14c9..cd32c0f7 100644 Binary files a/doc/resources/examplePanel21.png and b/doc/resources/examplePanel21.png differ diff --git a/doc/resources/examplePanel22.png b/doc/resources/examplePanel22.png index 15dc50fc..1f08565a 100644 Binary files a/doc/resources/examplePanel22.png and b/doc/resources/examplePanel22.png differ diff --git a/doc/resources/examplePanel3.png b/doc/resources/examplePanel3.png index 298331fe..87a595f3 100644 Binary files a/doc/resources/examplePanel3.png and b/doc/resources/examplePanel3.png differ diff --git a/doc/resources/examplePanel4.png b/doc/resources/examplePanel4.png index c0fd7421..53e7a613 100644 Binary files a/doc/resources/examplePanel4.png and b/doc/resources/examplePanel4.png differ diff --git a/doc/resources/examplePanel5.png b/doc/resources/examplePanel5.png index 4d853e62..4284beb3 100644 Binary files a/doc/resources/examplePanel5.png and b/doc/resources/examplePanel5.png differ diff --git a/doc/resources/examplePanel6.png b/doc/resources/examplePanel6.png index 9b2f825a..c3e3ef07 100644 Binary files a/doc/resources/examplePanel6.png and b/doc/resources/examplePanel6.png differ diff --git a/doc/resources/examplePanel7.png b/doc/resources/examplePanel7.png index e1feb7e3..346ece34 100644 Binary files a/doc/resources/examplePanel7.png and b/doc/resources/examplePanel7.png differ diff --git a/doc/resources/examplePanel8.png b/doc/resources/examplePanel8.png index 39517733..165dec85 100644 Binary files a/doc/resources/examplePanel8.png and b/doc/resources/examplePanel8.png differ diff --git a/doc/resources/examplePanel9.png b/doc/resources/examplePanel9.png index 1516e599..6960a661 100644 Binary files a/doc/resources/examplePanel9.png and b/doc/resources/examplePanel9.png differ diff --git a/kikit/common.py b/kikit/common.py index daf8d519..3c9d1dfa 100644 --- a/kikit/common.py +++ b/kikit/common.py @@ -12,7 +12,7 @@ PKG_BASE = os.path.dirname(__file__) KIKIT_LIB = os.path.join(PKG_BASE, "resources/kikit.pretty") SHP_EPSILON = pcbnew.FromMM(0.001) # Common factor of enlarging substrates to - # cover up numerical imprecisions of Shapely + # cover up numerical imprecisions of Shapely def fromDegrees(angle): return angle * 10 @@ -37,13 +37,14 @@ def fitsIn(what, where): def combineBoundingBoxes(a, b): """ Retrun wxRect as a combination of source bounding boxes """ - x = min(a.GetX(), b.GetX()) - y = min(a.GetY(), b.GetY()) - topLeft = wxPoint(x, y) - x = max(a.GetX() + a.GetWidth(), b.GetX() + b.GetWidth()) - y = max(a.GetY() + a.GetHeight(), b.GetY() + b.GetHeight()) - bottomRight = wxPoint(x, y) - return wxRect(topLeft, bottomRight) + x1 = min(a.GetX(), b.GetX()) + y1 = min(a.GetY(), b.GetY()) + x2 = max(a.GetX() + a.GetWidth(), b.GetX() + b.GetWidth()) + y2 = max(a.GetY() + a.GetHeight(), b.GetY() + b.GetHeight()) + # Beware that we cannot use the following code! It will add 1 to width and + # height. See https://github.com/wxWidgets/wxWidgets/blob/e43895e5317a1e82e295788264553d9839190337/src/common/gdicmn.cpp#L94-L114 + # return wxRect(topLeft, bottomRight) + return wxRect(x1, y1, x2 - x1, y2 - y1) def collectEdges(board, layerName, sourceArea=None): """ Collect edges in sourceArea on given layer including footprints """ diff --git a/kikit/panelize.py b/kikit/panelize.py index c50a15cc..0ff7be30 100644 --- a/kikit/panelize.py +++ b/kikit/panelize.py @@ -717,11 +717,10 @@ def f(point): revertTransformation = makeRevertTransformation(rotationAngle, originPoint, translation) try: - o = Substrate(edges, -bufferOutline, + s = Substrate(edges, 0, revertTransformation=revertTransformation) - s = Substrate(edges, bufferOutline) self.boardSubstrate.union(s) - self.substrates.append(o) + self.substrates.append(s) self.substrates[-1].annotations = annotations except substrate.PositionError as e: point = undoTransformation(e.point, rotationAngle, originPoint, translation) @@ -898,9 +897,8 @@ def makeFrame(self, width, hspace, vspace): boards substrates and the frame. Return a tuple of vertical and horizontal cuts. """ - frameInnerRect = expandRect(shpBoxToRect(self.boardsBBox()), - hspace - SHP_EPSILON, vspace + SHP_EPSILON) - frameOuterRect = expandRect(frameInnerRect, width + SHP_EPSILON) + frameInnerRect = expandRect(shpBoxToRect(self.boardsBBox()), hspace, vspace) + frameOuterRect = expandRect(frameInnerRect, width) outerRing = rectToRing(frameOuterRect) innerRing = rectToRing(frameInnerRect) polygon = Polygon(outerRing, [innerRing]) @@ -930,9 +928,8 @@ def makeRailsTb(self, thickness): Adds a rail to top and bottom. """ minx, miny, maxx, maxy = self.panelBBox() - thickness -= SHP_EPSILON - topRail = box(minx, maxy - SHP_EPSILON, maxx, maxy + thickness) - bottomRail = box(minx, miny + SHP_EPSILON, maxx, miny - thickness) + topRail = box(minx, maxy, maxx, maxy + thickness) + bottomRail = box(minx, miny, maxx, miny - thickness) self.appendSubstrate(topRail) self.appendSubstrate(bottomRail) @@ -941,9 +938,8 @@ def makeRailsLr(self, thickness): Adds a rail to left and right. """ minx, miny, maxx, maxy = self.panelBBox() - thickness -= SHP_EPSILON - leftRail = box(minx - thickness + SHP_EPSILON, miny, minx, maxy) - rightRail = box(maxx - SHP_EPSILON, miny, maxx + thickness, maxy) + leftRail = box(minx - thickness, miny, minx, maxy) + rightRail = box(maxx, miny, maxx + thickness, maxy) self.appendSubstrate(leftRail) self.appendSubstrate(rightRail) @@ -1225,8 +1221,8 @@ def buildFullTabs(self, framingOffsets): outerBounds = self.substrates[0].partitionLine.bounds for s in islice(self.substrates, 1, None): outerBounds = shpBBoxMerge(outerBounds, s.partitionLine.bounds) - fill = box(*outerBounds).difference(bBoxes.buffer(SHP_EPSILON)) - self.appendSubstrate(fill.buffer(SHP_EPSILON)) + fill = box(*outerBounds).difference(bBoxes) + self.appendSubstrate(fill) # Make the cuts from the bounding boxes of the PCB substrateBoundaries = [linestringToSegments(rectToShpBox(s.boundingBox()).exterior) @@ -1510,12 +1506,11 @@ def renderBackbone(self, vthickness, hthickness, vcut, hcut): (x[0] - c * vthickness // 2, x[1]), (x[0] + c * vthickness // 2, x[1])]) cuts.append(cut) - backbones = list([b.buffer(SHP_EPSILON, join_style=2) for b in pieces]) - self.appendSubstrate(backbones) + self.appendSubstrate(pieces) return cuts def addCornerFillets(self, radius): - corners = self.panelCorners(-SHP_EPSILON, -SHP_EPSILON) + corners = self.panelCorners() filletOrigins = self.panelCorners(radius, radius) for corner, opposite in zip(corners, filletOrigins): square = shapely.geometry.box( @@ -1524,15 +1519,15 @@ def addCornerFillets(self, radius): max(corner[0], opposite[0]), max(corner[1], opposite[1]) ) - filletCircle = Point(opposite).buffer(radius + SHP_EPSILON, resolution=16) + filletCircle = Point(opposite).buffer(radius, resolution=16) cutShape = square.difference(filletCircle) self.boardSubstrate.cut(cutShape) def addCornerChamfers(self, size): - corners = self.panelCorners(-SHP_EPSILON, -SHP_EPSILON) - verticalStops = self.panelCorners(-SHP_EPSILON, size) - horizontalStops = self.panelCorners(size, -SHP_EPSILON) + corners = self.panelCorners() + verticalStops = self.panelCorners(0, size) + horizontalStops = self.panelCorners(size, 0) for t, v, h in zip(corners, verticalStops, horizontalStops): cutPoly = Polygon([t, v, h, t]) self.boardSubstrate.cut(cutPoly) diff --git a/kikit/substrate.py b/kikit/substrate.py index 2eaf758a..d5af367b 100644 --- a/kikit/substrate.py +++ b/kikit/substrate.py @@ -615,11 +615,11 @@ def millFillets(self, millRadius): Add fillets to inner conernes which will be produced a by mill with given radius. """ - if millRadius < SHP_EPSILON: + EPS = fromMm(0.01) + RES = 32 + if millRadius < EPS: return self.orient() - RES = 64 - EPS = fromMm(0.01) self.substrates = self.substrates.buffer(millRadius - EPS, resolution=RES) \ .buffer(-millRadius, resolution=RES) \ .buffer(EPS, resolution=RES)