From c4994eee7b7da9feef1c6c2daddc44df3602d13c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 11 Apr 2020 13:00:38 +0100 Subject: [PATCH] Fix a pair of bugs in the new highlight net logic. Fixes https://gitlab.com/kicad/code/kicad/issues/4180 --- eeschema/sch_component.cpp | 28 ++++++++++++--------------- eeschema/tools/ee_selection_tool.cpp | 1 + eeschema/tools/sch_editor_control.cpp | 2 +- include/core/typeinfo.h | 9 +++++++-- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 9c69d5383c..3744d38099 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1241,13 +1241,9 @@ EDA_RECT SCH_COMPONENT::GetBodyBoundingBox() const EDA_RECT bBox; if( m_part ) - { bBox = m_part->GetBodyBoundingBox( m_unit, m_convert ); - } else - { bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert ); - } int x0 = bBox.GetX(); int xm = bBox.GetRight(); @@ -1279,8 +1275,8 @@ const EDA_RECT SCH_COMPONENT::GetBoundingBox() const { EDA_RECT bbox = GetBodyBoundingBox(); - for( size_t i = 0; i < m_Fields.size(); i++ ) - bbox.Merge( m_Fields[i].GetBoundingBox() ); + for( const SCH_FIELD& field : m_Fields ) + bbox.Merge( field.GetBoundingBox() ); return bbox; } @@ -1462,7 +1458,7 @@ bool SCH_COMPONENT::UpdateDanglingState( std::vector& aItemLi { bool changed = false; - for( auto& pin : m_pins ) + for( std::unique_ptr& pin : m_pins ) { bool previousState = pin->IsDangling(); pin->SetIsDangling( true ); @@ -1519,12 +1515,12 @@ wxPoint SCH_COMPONENT::GetPinPhysicalPosition( const LIB_PIN* Pin ) const void SCH_COMPONENT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { - for( const auto& pin : m_pins ) + for( const std::unique_ptr& pin : m_pins ) { // Collect only pins attached to the current unit and convert. // others are not associated to this component instance - int pin_unit = pin.get()->GetLibPin()->GetUnit(); - int pin_convert = pin.get()->GetLibPin()->GetConvert(); + int pin_unit = pin->GetLibPin()->GetUnit(); + int pin_convert = pin->GetLibPin()->GetConvert(); if( pin_unit > 0 && pin_unit != GetUnit() ) continue; @@ -1568,8 +1564,9 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR aInspector, void* aTestData, for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p ) { - // If caller wants to inspect component type or and component children types. - if( stype == SCH_LOCATE_ANY_T || stype == Type() ) + if( stype == SCH_LOCATE_ANY_T + || ( stype == SCH_COMPONENT_T ) + || ( stype == SCH_COMPONENT_LOCATE_POWER_T && m_part && m_part->IsPower() ) ) { if( SEARCH_RESULT::QUIT == aInspector( this, aTestData ) ) return SEARCH_RESULT::QUIT; @@ -1577,7 +1574,6 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR aInspector, void* aTestData, if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T ) { - // Test the bounding boxes of fields if they are visible and not empty. for( SCH_FIELD& field : m_Fields ) { if( SEARCH_RESULT::QUIT == aInspector( &field, (void*) this ) ) @@ -1611,12 +1607,12 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR aInspector, void* aTestData, if( stype == SCH_LOCATE_ANY_T || stype == SCH_PIN_T ) { - for( auto& pin : m_pins ) + for( const std::unique_ptr& pin : m_pins ) { // Collect only pins attached to the current unit and convert. // others are not associated to this component instance - int pin_unit = pin.get()->GetLibPin()->GetUnit(); - int pin_convert = pin.get()->GetLibPin()->GetConvert(); + int pin_unit = pin->GetLibPin()->GetUnit(); + int pin_convert = pin->GetLibPin()->GetConvert(); if( pin_unit > 0 && pin_unit != GetUnit() ) continue; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 319e7a1796..c895aed31f 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -788,6 +788,7 @@ bool EE_SELECTION_TOOL::selectMultiple() static KICAD_T nodeTypes[] = { + SCH_COMPONENT_LOCATE_POWER_T, SCH_PIN_T, SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 449208933a..1ee8efe82c 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -790,7 +790,7 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent ) itemConnectionName = connection->Name(); } - if( itemConnectionName == selectedNetName ) + if( !selectedNetName.IsEmpty() && itemConnectionName == selectedNetName ) item->SetBrightened(); else item->ClearBrightened(); diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 99952aeea4..754c2c1c27 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -124,8 +124,7 @@ enum KICAD_T SCH_PIN_T, // Be prudent with these types: - // they should be used only to locate a specific field type - // among SCH_FIELD_T items types + // they should be used only to locate a specific field type among SCH_FIELD_Ts // N.B. If you add a type here, be sure to add it below to the BaseType() SCH_FIELD_LOCATE_REFERENCE_T, SCH_FIELD_LOCATE_VALUE_T, @@ -141,6 +140,9 @@ enum KICAD_T SCH_LABEL_LOCATE_WIRE_T, SCH_LABEL_LOCATE_BUS_T, + // Same for picking components which are power symbols + SCH_COMPONENT_LOCATE_POWER_T, + // matches any type SCH_LOCATE_ANY_T, @@ -230,6 +232,9 @@ constexpr KICAD_T BaseType( const KICAD_T aType ) case SCH_LABEL_LOCATE_BUS_T: return SCH_LABEL_T; + case SCH_COMPONENT_LOCATE_POWER_T: + return SCH_COMPONENT_T; + default: return aType; }