[PcbDraw][Fixed] Reverted upstream patch
Breaks the bottom for KiCad 5/6
This commit is contained in:
parent
b2cf6f03e3
commit
e0ebf0dd1d
|
|
@ -613,4 +613,44 @@ index c9653ac5..a72a944c 100644
|
||||||
return
|
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
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,8 @@ if not isV7(KICAD_VERSION) and not isV8(KICAD_VERSION):
|
||||||
for x in dir(pcbnew):
|
for x in dir(pcbnew):
|
||||||
patchRotate(getattr(pcbnew, x))
|
patchRotate(getattr(pcbnew, x))
|
||||||
|
|
||||||
|
# This is for v6 only, v5 fails
|
||||||
|
if isV6(KICAD_VERSION):
|
||||||
originalCalcArcAngles = pcbnew.EDA_SHAPE.CalcArcAngles
|
originalCalcArcAngles = pcbnew.EDA_SHAPE.CalcArcAngles
|
||||||
if not getattr(originalCalcArcAngles, "patched", False):
|
if not getattr(originalCalcArcAngles, "patched", False):
|
||||||
def newCalcArcAngles(self, start, end):
|
def newCalcArcAngles(self, start, end):
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ def strip_style_svg(root: etree.Element, keys: List[str], forbidden_colors: List
|
||||||
for key, val in styles.items():
|
for key, val in styles.items():
|
||||||
if key not in keys or val == 'none':
|
if key not in keys or val == 'none':
|
||||||
new_styles[key] = val
|
new_styles[key] = val
|
||||||
else:
|
elif isV8():
|
||||||
new_styles[key] = new_val
|
new_styles[key] = new_val
|
||||||
el.attrib["style"] = ";" \
|
el.attrib["style"] = ";" \
|
||||||
.join([f"{key}: {val}" for key, val in new_styles.items()]) \
|
.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 lxml.etree import tostring as serializeXml # type: ignore
|
||||||
from . import svgpathtools # type: ignore
|
from . import svgpathtools # type: ignore
|
||||||
tree = xmlParse(serializeXml(svg))
|
paths = svgpathtools.document.flattened_paths(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)
|
|
||||||
|
|
||||||
if len(paths) == 0:
|
if len(paths) == 0:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue