[PcbDraw][Fixed] Reverted upstream patch

Breaks the bottom for KiCad 5/6
This commit is contained in:
Salvador E. Tropea 2024-02-08 10:16:24 -03:00
parent b2cf6f03e3
commit e0ebf0dd1d
3 changed files with 54 additions and 24 deletions

View File

@ -613,4 +613,44 @@ index c9653ac5..a72a944c 100644
return
```
## 2024-02-08 Revert changes, because impact on v5
- The isV8() is not strictly needed, there to allow doing diffs between old and new generated SVGs
- The upstream approach fails to compute the mirror for KiCad 5/6, but I'm not sure if also for other cases
```diff
diff --git a/kibot/PcbDraw/plot.py b/kibot/PcbDraw/plot.py
index a72a944c..dd86b03d 100644
--- a/kibot/PcbDraw/plot.py
+++ b/kibot/PcbDraw/plot.py
@@ -384,7 +384,7 @@ def strip_style_svg(root: etree.Element, keys: List[str], forbidden_colors: List
for key, val in styles.items():
if key not in keys or val == 'none':
new_styles[key] = val
- else:
+ elif isV8():
new_styles[key] = new_val
el.attrib["style"] = ";" \
.join([f"{key}: {val}" for key, val in new_styles.items()]) \
@@ -1319,19 +1319,7 @@ class PcbPlotter():
from lxml.etree import tostring as serializeXml # type: ignore
from . import svgpathtools # type: ignore
- tree = xmlParse(serializeXml(svg))
-
- # As we cannot interpret mask cropping, we cannot simply take all paths
- # from source document (as e.g., silkscreen outside PCB) would enlarge
- # the canvas. Instead, we take bounding box of the substrate and
- # components separately
- paths = []
- components = tree.find(".//*[@id='componentContainer']")
- if components is not None:
- paths += svgpathtools.document.flattened_paths(components)
- substrate = tree.find(".//*[@id='cut-off']")
- if substrate is not None:
- paths += svgpathtools.document.flattened_paths(substrate)
+ paths = svgpathtools.document.flattened_paths(xmlParse(serializeXml(svg)))
if len(paths) == 0:
return
```

View File

@ -192,16 +192,18 @@ if not isV7(KICAD_VERSION) and not isV8(KICAD_VERSION):
for x in dir(pcbnew):
patchRotate(getattr(pcbnew, x))
originalCalcArcAngles = pcbnew.EDA_SHAPE.CalcArcAngles
if not getattr(originalCalcArcAngles, "patched", False):
def newCalcArcAngles(self, start, end):
start.value = self.GetArcAngleStart() / 10
if self.GetShape() == pcbnew.SHAPE_T_CIRCLE:
end.value = start.value + 360
else:
end.value = start.value + self.GetArcAngle() / 10
setattr(newCalcArcAngles, "patched", True)
pcbnew.EDA_SHAPE.CalcArcAngles = newCalcArcAngles
# This is for v6 only, v5 fails
if isV6(KICAD_VERSION):
originalCalcArcAngles = pcbnew.EDA_SHAPE.CalcArcAngles
if not getattr(originalCalcArcAngles, "patched", False):
def newCalcArcAngles(self, start, end):
start.value = self.GetArcAngleStart() / 10
if self.GetShape() == pcbnew.SHAPE_T_CIRCLE:
end.value = start.value + 360
else:
end.value = start.value + self.GetArcAngle() / 10
setattr(newCalcArcAngles, "patched", True)
pcbnew.EDA_SHAPE.CalcArcAngles = newCalcArcAngles
# GetSelectMenuText
for x in dir(pcbnew):

View File

@ -384,7 +384,7 @@ def strip_style_svg(root: etree.Element, keys: List[str], forbidden_colors: List
for key, val in styles.items():
if key not in keys or val == 'none':
new_styles[key] = val
else:
elif isV8():
new_styles[key] = new_val
el.attrib["style"] = ";" \
.join([f"{key}: {val}" for key, val in new_styles.items()]) \
@ -1319,19 +1319,7 @@ class PcbPlotter():
from lxml.etree import tostring as serializeXml # type: ignore
from . import svgpathtools # type: ignore
tree = xmlParse(serializeXml(svg))
# As we cannot interpret mask cropping, we cannot simply take all paths
# from source document (as e.g., silkscreen outside PCB) would enlarge
# the canvas. Instead, we take bounding box of the substrate and
# components separately
paths = []
components = tree.find(".//*[@id='componentContainer']")
if components is not None:
paths += svgpathtools.document.flattened_paths(components)
substrate = tree.find(".//*[@id='cut-off']")
if substrate is not None:
paths += svgpathtools.document.flattened_paths(substrate)
paths = svgpathtools.document.flattened_paths(xmlParse(serializeXml(svg)))
if len(paths) == 0:
return