-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement percentage for panel position
- Loading branch information
Showing
9 changed files
with
126 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Tuple | ||
from .common import KiLength | ||
from .units import mm | ||
from .sexpr import SExpr, findNode | ||
from .defs import PAPER_DIMENSIONS | ||
|
||
def getPageDimensionsFromAst(ast: SExpr) -> Tuple[KiLength, KiLength]: | ||
paperNode = findNode(ast, "paper") | ||
if paperNode is None: | ||
# KiCAD 5 board use "page" instead of "paper" | ||
paperNode = findNode(ast, "page") | ||
if paperNode is None: | ||
raise RuntimeError("Source document doesn't contain paper size information") | ||
value = paperNode.items[1].value | ||
if value == "User": | ||
size = (paperNode[2].value, paperNode[3].value) | ||
return tuple(int(float(x) * mm) for x in size) | ||
try: | ||
size = PAPER_DIMENSIONS[value] | ||
if len(paperNode.items) >= 3 and paperNode.items[2] == "portrait": | ||
size = (size[1], size[0]) | ||
return tuple(int(x) for x in size) | ||
except KeyError: | ||
raise RuntimeError(f"Uknown paper size {value}") from None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters