Skip to content

Commit

Permalink
[Rotation Filter] Keep same results for bennymeg mode
Browse files Browse the repository at this point in the history
For the offsets specified in fields
  • Loading branch information
set-soft committed Mar 27, 2024
1 parent 8c062ad commit 1fa0d85
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/source/configuration/sup_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Supported filters
This option forces the wrong computation for compatibility.
This option also controls the way offset signs are interpreted. When enabled the offsets matches this plugin,
when disabled matches the interpretation used by the matthewlai/JLCKicadTools plugin.
Disabling this option you'll get better algorithms, but loose compatibility with this plugin.
- ``comment`` :index:`: <pair: filter - rot_footprint; comment>` [string=''] A comment for documentation purposes.
- ``extend`` :index:`: <pair: filter - rot_footprint; extend>` [boolean=true] Extends the internal list of rotations with the one provided.
Otherwise just use the provided list.
Expand Down
14 changes: 9 additions & 5 deletions kibot/fil_rot_footprint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2023 Salvador E. Tropea
# Copyright (c) 2020-2023 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2024 Salvador E. Tropea
# Copyright (c) 2020-2024 Instituto Nacional de Tecnología Industrial
# License: AGPL-3.0
# Project: KiBot (formerly KiPlot)
# Description: Implements a filter to rotate footprints.
Expand Down Expand Up @@ -139,7 +139,8 @@ def __init__(self):
The correct computation is `(180 - component rot) + angle` but the plugin does `180 - (component rot + angle)`.
This option forces the wrong computation for compatibility.
This option also controls the way offset signs are interpreted. When enabled the offsets matches this plugin,
when disabled matches the interpretation used by the matthewlai/JLCKicadTools plugin """
when disabled matches the interpretation used by the matthewlai/JLCKicadTools plugin.
Disabling this option you'll get better algorithms, but loose compatibility with this plugin """

def config(self, parent):
super().config(parent)
Expand Down Expand Up @@ -285,8 +286,11 @@ def apply_field_offset(self, comp):
# Signs here matches bennymeg/JLC-Plugin-for-KiCad because the fields usage comes from it
pos_offset_x = -pos_offset_x
pos_offset_y = -pos_offset_y
logger.debugl(2, f'- changing to {pos_offset_x}, {pos_offset_y} mm to match signs')
self.apply_offset_value(comp, comp.footprint_rot, pos_offset_x, pos_offset_y)
angle = comp.offset_footprint_rot
logger.debugl(2, f'- changing to {pos_offset_x}, {pos_offset_y} mm to match signs, using angle {angle}')
else:
angle = comp.footprint_rot
self.apply_offset_value(comp, angle, pos_offset_x, pos_offset_y)
return True
return False

Expand Down
4 changes: 2 additions & 2 deletions tests/test_plot/test_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ def test_position_rot_bottom(test_dir):
# Manually rotated 270
'Q3': (122, 86, 'top', 270),
# Manually moved 1,1
'Q4': (131, 87, 'top', 180),
'Q4': (133, 85, 'top', 180),
'Q5': (122, 77, 'bottom', 0),
# Offset using *offsets*
'Q6': (131, 78, 'bottom', 0),
# Manually rotated 270
'Q7': (122, 86, 'bottom', 90),
# Manually moved 1,1
'Q8': (133, 85, 'bottom', 0)}
'Q8': (131, 87, 'bottom', 0)}
POS_TRS = ('Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8')


Expand Down

0 comments on commit 1fa0d85

Please sign in to comment.