From 9fd2b326659472b02a6c6d0074bb2fcb2225bd1f Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sun, 21 Apr 2024 10:54:34 -0400 Subject: [PATCH] Do not show click to start wire cursor for hidden pins. Selecting show hidden pins will allow users to connect to hidden pins. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17145 (cherry picked from commit ca18dc8ec892caa3e029f3c0b0ad22d926415a20) --- eeschema/sch_symbol.cpp | 23 +++++++++++++++++++++++ eeschema/sch_symbol.h | 9 +++++++++ eeschema/tools/ee_selection_tool.cpp | 13 +++++++++++++ 3 files changed, 45 insertions(+) diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index ce0e559e8b..b74b7c0a30 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1146,6 +1146,29 @@ SCH_PIN* SCH_SYMBOL::GetPin( const wxString& aNumber ) const } +const SCH_PIN* SCH_SYMBOL::GetPin( const VECTOR2I& aPos ) const +{ + for( const std::unique_ptr& pin : m_pins ) + { + int pin_unit = pin->GetLibPin() ? pin->GetLibPin()->GetUnit() + : GetUnit(); + int pin_bodyStyle = pin->GetLibPin() ? pin->GetLibPin()->GetBodyStyle() + : GetBodyStyle(); + + if( pin_unit > 0 && pin_unit != GetUnit() ) + continue; + + if( pin_bodyStyle > 0 && pin_bodyStyle != GetBodyStyle() ) + continue; + + if( pin->IsPointClickableAnchor( aPos ) ) + return pin.get(); + } + + return nullptr; +} + + void SCH_SYMBOL::GetLibPins( std::vector& aPinsList ) const { if( m_part ) diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 4d09060722..976b782c31 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -635,6 +635,15 @@ public: */ SCH_PIN* GetPin( LIB_PIN* aLibPin ) const; + /** + * Return the #SCH_PIN object found at \a aPosition. + * + * @param aPosition is the position of the pin to fetch. + * + * @return the #SCH_PIN object found at \a aPosition or nullptr. + */ + const SCH_PIN* GetPin( const VECTOR2I& aPosition ) const; + /** * Retrieve a list of the SCH_PINs for the given sheet path. * diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 4d59a84688..436f793966 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -953,6 +953,19 @@ OPT_TOOL_EVENT EE_SELECTION_TOOL::autostartEvent( TOOL_EVENT* aEvent, EE_GRID_HE if( possibleConnection.IsBus() ) newEvt = EE_ACTIONS::drawBus.MakeEvent(); } + else if( aItem->Type() == SCH_SYMBOL_T ) + { + const SCH_SYMBOL* symbol = static_cast( aItem ); + + wxCHECK( symbol, OPT_TOOL_EVENT() ); + + const SCH_PIN* pin = symbol->GetPin( pos ); + + wxCHECK( pin, OPT_TOOL_EVENT() ); + + if( !pin->IsVisible() && !m_frame->eeconfig()->m_Appearance.show_hidden_pins ) + return OPT_TOOL_EVENT(); + } newEvt->SetMousePosition( pos ); newEvt->SetHasPosition( true );