From 1fa0d8545bd9f7630e668038aa4afb442c8c3f93 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 27 Mar 2024 07:32:50 -0300 Subject: [PATCH] [Rotation Filter] Keep same results for bennymeg mode For the offsets specified in fields --- docs/source/configuration/sup_filters.rst | 1 + kibot/fil_rot_footprint.py | 14 +++++++++----- tests/test_plot/test_position.py | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/source/configuration/sup_filters.rst b/docs/source/configuration/sup_filters.rst index 270845a88..501b9c800 100644 --- a/docs/source/configuration/sup_filters.rst +++ b/docs/source/configuration/sup_filters.rst @@ -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:`: ` [string=''] A comment for documentation purposes. - ``extend`` :index:`: ` [boolean=true] Extends the internal list of rotations with the one provided. Otherwise just use the provided list. diff --git a/kibot/fil_rot_footprint.py b/kibot/fil_rot_footprint.py index 449248d69..f338872aa 100644 --- a/kibot/fil_rot_footprint.py +++ b/kibot/fil_rot_footprint.py @@ -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. @@ -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) @@ -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 diff --git a/tests/test_plot/test_position.py b/tests/test_plot/test_position.py index 9db32c515..970e76463 100644 --- a/tests/test_plot/test_position.py +++ b/tests/test_plot/test_position.py @@ -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')