From 6e0deccdc177cd648afe93a6a06656d594e59f41 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Mon, 5 Apr 2021 21:52:50 -0400 Subject: [PATCH 1/6] Add invert_bottom parameter --- README.md | 6 ++++-- docs/README.in | 3 ++- kibot/fil_rot_footprint.py | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fd4ed701..a9a34811 100644 --- a/README.md +++ b/README.md @@ -343,7 +343,8 @@ Currently the only type available is `generic`. - `extend`: [boolean=true] Extends the internal list of rotations with the one provided. Otherwise just use the provided list. - `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)`. + - `invert_bottom`: [boolean=false] Rotation for bottom components is negated. - `rotations`: [list(list(string))] A list of pairs regular expression/rotation. Components matching the regular expression will be rotated the indicated angle. - subparts: Subparts @@ -2181,7 +2182,8 @@ 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. +- `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. In order to add a new rotation or just change an existing one you just need to use the `rotations` option. diff --git a/docs/README.in b/docs/README.in index 25ec1d59..6e6ccc97 100644 --- a/docs/README.in +++ b/docs/README.in @@ -1175,7 +1175,8 @@ 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. +- `negative_bottom`: [boolean=true] Rotation for bottom components is computed via substracting. 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. In order to add a new rotation or just change an existing one you just need to use the `rotations` option. diff --git a/kibot/fil_rot_footprint.py b/kibot/fil_rot_footprint.py index 9319d433..c4c54b01 100644 --- a/kibot/fil_rot_footprint.py +++ b/kibot/fil_rot_footprint.py @@ -61,7 +61,9 @@ 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 substracting """ + self.invert_bottom = False + """ Rotation for bottom components is negated """ self.rotations = Optionable """ [list(list(string))] A list of pairs regular expression/rotation. Components matching the regular expression will be rotated the indicated angle """ @@ -96,6 +98,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: {} {}: {} -> {}'. From b946e519fbc67a1ad380132a2681743c7a8c2846 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Mon, 5 Apr 2021 22:15:22 -0400 Subject: [PATCH 2/6] _top & _bottom select all components on a side --- README.md | 4 ++-- docs/README.in | 2 +- kibot/fil_rot_footprint.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a9a34811..91a3c4db 100644 --- a/README.md +++ b/README.md @@ -346,7 +346,7 @@ Currently the only type available is `generic`. - `negative_bottom`: [boolean=true] Rotation for bottom components is computed via subtraction as `(component rot - angle)`. - `invert_bottom`: [boolean=false] Rotation for bottom components is negated. - `rotations`: [list(list(string))] A list of pairs regular expression/rotation. - Components matching the regular expression will be rotated the indicated angle. + 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. - subparts: Subparts This filter implements the KiCost subparts mechanism. * Valid keys: @@ -2184,7 +2184,7 @@ 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 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. +- `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. diff --git a/docs/README.in b/docs/README.in index 6e6ccc97..ec0fdc53 100644 --- a/docs/README.in +++ b/docs/README.in @@ -1177,7 +1177,7 @@ 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 via substracting. 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. +- `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. diff --git a/kibot/fil_rot_footprint.py b/kibot/fil_rot_footprint.py index c4c54b01..18a99d39 100644 --- a/kibot/fil_rot_footprint.py +++ b/kibot/fil_rot_footprint.py @@ -92,7 +92,8 @@ class Rot_Footprint(BaseFilter): # noqa: F821 def filter(self, comp): """ Apply the rotation """ for regex, angle in self._rot: - if regex.search(comp.footprint): + side = "_bottom" if comp.bottom else "_top" + if regex.search(comp.footprint) or regex.search(side): old_angle = comp.footprint_rot if self.negative_bottom and comp.bottom: comp.footprint_rot -= angle From 5c88dec5bcdbbe2d7d8cc344c05847eb15b0e059 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Wed, 7 Apr 2021 08:33:37 -0400 Subject: [PATCH 3/6] Use match_string for more selective power --- kibot/fil_rot_footprint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kibot/fil_rot_footprint.py b/kibot/fil_rot_footprint.py index 18a99d39..601e829c 100644 --- a/kibot/fil_rot_footprint.py +++ b/kibot/fil_rot_footprint.py @@ -93,7 +93,8 @@ class Rot_Footprint(BaseFilter): # noqa: F821 """ Apply the rotation """ for regex, angle in self._rot: side = "_bottom" if comp.bottom else "_top" - if regex.search(comp.footprint) or regex.search(side): + match_string = comp.footprint + side + if regex.search(match_string): old_angle = comp.footprint_rot if self.negative_bottom and comp.bottom: comp.footprint_rot -= angle From 798fdc3e34778da2169e11b44d4331ba0a5b6cd6 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 25 Apr 2021 12:06:43 -0300 Subject: [PATCH 4/6] Updated help strings and reverted side match patch. --- kibot/fil_rot_footprint.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kibot/fil_rot_footprint.py b/kibot/fil_rot_footprint.py index 601e829c..d3be6b0a 100644 --- a/kibot/fil_rot_footprint.py +++ b/kibot/fil_rot_footprint.py @@ -61,9 +61,10 @@ 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 via substracting """ + """ Rotation for bottom components is computed via subtraction as `(component rot - angle)` """ self.invert_bottom = False - """ Rotation for bottom components is negated """ + """ 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 """ @@ -92,9 +93,7 @@ class Rot_Footprint(BaseFilter): # noqa: F821 def filter(self, comp): """ Apply the rotation """ for regex, angle in self._rot: - side = "_bottom" if comp.bottom else "_top" - match_string = comp.footprint + side - if regex.search(match_string): + if regex.search(comp.footprint): old_angle = comp.footprint_rot if self.negative_bottom and comp.bottom: comp.footprint_rot -= angle From 35d25439c181321015cc083b4bb78904f780698b Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 25 Apr 2021 12:12:41 -0300 Subject: [PATCH 5/6] Regenerated the help for rot_footprint and adjusted the README.in --- README.md | 7 ++++--- docs/README.in | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ed27e219..ef73b45e 100644 --- a/README.md +++ b/README.md @@ -342,11 +342,12 @@ 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 via subtraction as `(component rot - angle)`. - - `invert_bottom`: [boolean=false] Rotation for bottom components is negated. - `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. + Components matching the regular expression will be rotated the indicated angle. - subparts: Subparts This filter implements the KiCost subparts mechanism. * Valid keys: @@ -2207,7 +2208,7 @@ 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 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)`. +- `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. diff --git a/docs/README.in b/docs/README.in index b364985b..3e4711a7 100644 --- a/docs/README.in +++ b/docs/README.in @@ -1175,8 +1175,8 @@ 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 via substracting. 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)` +- `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. From a7bf1b080cc2a75f00b2318a6609f42030a82e4f Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 25 Apr 2021 12:20:39 -0300 Subject: [PATCH 6/6] Added skip_top and skip_bottom options to the rot_footprint filter. --- CHANGELOG.md | 6 ++++++ README.md | 2 ++ kibot/fil_rot_footprint.py | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaebc230..226a69ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index ef73b45e..e3ee358f 100644 --- a/README.md +++ b/README.md @@ -348,6 +348,8 @@ Currently the only type available is `generic`. - `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: diff --git a/kibot/fil_rot_footprint.py b/kibot/fil_rot_footprint.py index d3be6b0a..09f0e79b 100644 --- a/kibot/fil_rot_footprint.py +++ b/kibot/fil_rot_footprint.py @@ -68,6 +68,10 @@ class Rot_Footprint(BaseFilter): # noqa: F821 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) @@ -92,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