|
KiCad PCB EDA Suite
|
Test that pin names and numbers don't overlap between adjacent pins at any rotation. More...
#include <qa_utils/wx_utils/unit_test_utils.h>#include <sch_pin.h>#include <lib_symbol.h>#include <pin_layout_cache.h>#include <transform.h>#include <sch_io/sch_io_mgr.h>#include <wx/log.h>#include <boost/test/unit_test.hpp>Go to the source code of this file.
Functions | |
| static std::unique_ptr< LIB_SYMBOL > | createAdjacentPinsSymbol () |
| Create a test symbol with adjacent pins for testing overlap. | |
| static BOX2I | getTextBoundingBox (const PIN_LAYOUT_CACHE::TEXT_INFO &textInfo) |
| Get the bounding box of pin text (name or number) for a given pin. | |
| static int | getPerpendicularDistance (const SCH_PIN *pin, const VECTOR2I &textPos, const TRANSFORM &transform) |
| Calculate perpendicular distance from pin line to text center. | |
| BOOST_AUTO_TEST_CASE (AdjacentPinTextNoOverlap) | |
| Test that pin names and numbers don't overlap with adjacent pins at 0° and 90°. | |
| BOOST_AUTO_TEST_CASE (PerpendicularDistanceConsistentAcrossRotations) | |
| Test that perpendicular distances from pin to text are preserved across rotations. | |
| BOOST_AUTO_TEST_CASE (NameAndNumberOnOppositeSides) | |
| Test that name is positioned on opposite side from number (when both are outside). | |
Test that pin names and numbers don't overlap between adjacent pins at any rotation.
This is a regression test for issue 21980.
Definition in file test_pin_text_overlap.cpp.
| BOOST_AUTO_TEST_CASE | ( | AdjacentPinTextNoOverlap | ) |
Test that pin names and numbers don't overlap with adjacent pins at 0° and 90°.
This is the core test for issue 21980. At 0° the pins are horizontal and names/numbers are positioned above/below. At 90° the pins become vertical and names/numbers should be positioned left/right with the same clearance.
Definition at line 140 of file test_pin_text_overlap.cpp.
References BOOST_REQUIRE(), createAdjacentPinsSymbol(), DefaultTransform, PIN_LAYOUT_CACHE::GetPinNameInfo(), PIN_LAYOUT_CACHE::GetPinNumberInfo(), getTextBoundingBox(), pin, and SCH_PIN_T.
| BOOST_AUTO_TEST_CASE | ( | NameAndNumberOnOppositeSides | ) |
Test that name is positioned on opposite side from number (when both are outside).
When pin_name_offset is 0 (names outside), the name should be on one side of the pin and the number on the other side to avoid overlap.
Definition at line 384 of file test_pin_text_overlap.cpp.
References BOOST_REQUIRE(), createAdjacentPinsSymbol(), DefaultTransform, PIN_LAYOUT_CACHE::GetPinNameInfo(), PIN_LAYOUT_CACHE::GetPinNumberInfo(), SCH_PIN::GetPosition(), PIN_LEFT, PIN_RIGHT, SCH_PIN::PinDrawOrient(), SCH_PIN_T, VECTOR2< T >::x, and VECTOR2< T >::y.
| BOOST_AUTO_TEST_CASE | ( | PerpendicularDistanceConsistentAcrossRotations | ) |
Test that perpendicular distances from pin to text are preserved across rotations.
The Y distance at 0° (horizontal pins) should equal the X distance at 90° (vertical pins). This ensures consistent visual appearance regardless of symbol rotation.
Definition at line 291 of file test_pin_text_overlap.cpp.
References std::abs(), BOOST_REQUIRE(), createAdjacentPinsSymbol(), DefaultTransform, getPerpendicularDistance(), PIN_LAYOUT_CACHE::GetPinNameInfo(), PIN_LAYOUT_CACHE::GetPinNumberInfo(), SCH_PIN_T, and schIUScale.
|
static |
Create a test symbol with adjacent pins for testing overlap.
This simulates the symbol structure from issue 21980 where pins are closely spaced and have names displayed outside (offset 0).
Definition at line 48 of file test_pin_text_overlap.cpp.
References createAdjacentPinsSymbol(), name, pin, PIN_LEFT, PT_BIDI, and schIUScale.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and createAdjacentPinsSymbol().
|
static |
Calculate perpendicular distance from pin line to text center.
For horizontal pins (PIN_LEFT/PIN_RIGHT), this is the Y distance. For vertical pins (PIN_UP/PIN_DOWN), this is the X distance.
Definition at line 114 of file test_pin_text_overlap.cpp.
References std::abs(), pin, PIN_LEFT, PIN_RIGHT, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE().
|
static |
Get the bounding box of pin text (name or number) for a given pin.
Definition at line 90 of file test_pin_text_overlap.cpp.
References ANGLE_VERTICAL, PIN_LAYOUT_CACHE::TEXT_INFO::m_Angle, PIN_LAYOUT_CACHE::TEXT_INFO::m_Text, PIN_LAYOUT_CACHE::TEXT_INFO::m_TextPosition, PIN_LAYOUT_CACHE::TEXT_INFO::m_TextSize, BOX2< Vec >::SetOrigin(), BOX2< Vec >::SetSize(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE().