Merge branch 'frankleonrose-60-invert-bottom'

This commit is contained in:
Salvador E. Tropea 2021-04-25 12:23:13 -03:00
commit af18022c2d
4 changed files with 30 additions and 6 deletions

View File

@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Options to better control the rotation filter (#60 and #67):
- invert_bottom: bottom angles are inverted.
- skip_top: top components aren't rotated.
- skip_bottom: bottom components aren't rotated.
## [0.11.0] - 2021-04-25
### Added

View File

@ -342,10 +342,14 @@ Currently the only type available is `generic`.
- `comment`: [string=''] A comment for documentation purposes.
- `extend`: [boolean=true] Extends the internal list of rotations with the one provided.
Otherwise just use the provided list.
- `invert_bottom`: [boolean=false] Rotation for bottom components is negated, resulting in either: `(- component rot - angle)`
or when combined with `negative_bottom`, `(angle - component rot)`.
- `name`: [string=''] Used to identify this particular filter definition.
- `negative_bottom`: [boolean=true] Rotation for bottom components is computed substracting.
- `negative_bottom`: [boolean=true] Rotation for bottom components is computed via subtraction as `(component rot - angle)`.
- `rotations`: [list(list(string))] A list of pairs regular expression/rotation.
Components matching the regular expression will be rotated the indicated angle.
- `skip_bottom`: [boolean=false] Do not rotate components on the bottom.
- `skip_top`: [boolean=false] Do not rotate components on the top.
- subparts: Subparts
This filter implements the KiCost subparts mechanism.
* Valid keys:
@ -2205,8 +2209,9 @@ Using it, instead of the internal filter named `_rot_footprint`, is the same her
The filter supports the following options:
- `extend`: [boolean=true] Extends the internal list of rotations with the one provided. Otherwise just use the provided list.
- `negative_bottom`: [boolean=true] Rotation for bottom components is computed substracting. Note that this should be coherent with the `bottom_negative_x` of the position output.
- `rotations`: [list(list(string))] A list of pairs regular expression/rotation. Components matching the regular expression will be rotated the indicated angle.
- `negative_bottom`: [boolean=true] Rotation for bottom components is computed via subtraction as `(component rot - angle)`. Note that this should be coherent with the `bottom_negative_x` of the position output.
- `invert_bottom`: [boolean=false] Rotation for bottom components is negated, resulting in either: `(- component rot - angle)` or when combined with `negative_bottom`, `(angle - component rot)`.
- `rotations`: [list(list(string))] A list of pairs regular expression/rotation. Components matching the regular expression will be rotated the indicated angle. Special names `_top` and `_bottom` will match all components on that side of the board.
In order to add a new rotation or just change an existing one you just need to use the `rotations` option.
As an example: the internal list of rotations rotates QFN packages by 270 degrees, no suppose you want to rotate them just 90 degrees.

View File

@ -1175,8 +1175,9 @@ Using it, instead of the internal filter named `_rot_footprint`, is the same her
The filter supports the following options:
- `extend`: [boolean=true] Extends the internal list of rotations with the one provided. Otherwise just use the provided list.
- `negative_bottom`: [boolean=true] Rotation for bottom components is computed substracting. Note that this should be coherent with the `bottom_negative_x` of the position output.
- `rotations`: [list(list(string))] A list of pairs regular expression/rotation. Components matching the regular expression will be rotated the indicated angle.
- `negative_bottom`: [boolean=true] Rotation for bottom components is computed via subtraction as `(component rot - angle)`. Note that this should be coherent with the `bottom_negative_x` of the position output.
- `invert_bottom`: [boolean=false] Rotation for bottom components is negated, resulting in either: `(- component rot - angle)` or when combined with `negative_bottom`, `(angle - component rot)`.
- `rotations`: [list(list(string))] A list of pairs regular expression/rotation. Components matching the regular expression will be rotated the indicated angle. Special names `_top` and `_bottom` will match all components on that side of the board.
In order to add a new rotation or just change an existing one you just need to use the `rotations` option.
As an example: the internal list of rotations rotates QFN packages by 270 degrees, no suppose you want to rotate them just 90 degrees.

View File

@ -61,10 +61,17 @@ class Rot_Footprint(BaseFilter): # noqa: F821
""" Extends the internal list of rotations with the one provided.
Otherwise just use the provided list """
self.negative_bottom = True
""" Rotation for bottom components is computed substracting """
""" Rotation for bottom components is computed via subtraction as `(component rot - angle)` """
self.invert_bottom = False
""" Rotation for bottom components is negated, resulting in either: `(- component rot - angle)`
or when combined with `negative_bottom`, `(angle - component rot)` """
self.rotations = Optionable
""" [list(list(string))] A list of pairs regular expression/rotation.
Components matching the regular expression will be rotated the indicated angle """
self.skip_bottom = False
""" Do not rotate components on the bottom """
self.skip_top = False
""" Do not rotate components on the top """
def config(self, parent):
super().config(parent)
@ -89,6 +96,9 @@ class Rot_Footprint(BaseFilter): # noqa: F821
def filter(self, comp):
""" Apply the rotation """
if (self.skip_top and not comp.bottom) or (self.skip_bottom and comp.bottom):
# Component should be excluded
return
for regex, angle in self._rot:
if regex.search(comp.footprint):
old_angle = comp.footprint_rot
@ -96,6 +106,8 @@ class Rot_Footprint(BaseFilter): # noqa: F821
comp.footprint_rot -= angle
else:
comp.footprint_rot += angle
if self.invert_bottom and comp.bottom:
comp.footprint_rot = -comp.footprint_rot
comp.footprint_rot = comp.footprint_rot % 360
if GS.debug_level > 2:
logger.debug('Rotating ref: {} {}: {} -> {}'.