7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 09:01:42 +00:00

Eeschema: Import sheet pins: sort pin names intelligently

This commit is contained in:
Damjan 2025-01-29 04:16:35 +00:00 committed by Jon Evans
parent c6e049df2a
commit 46ada43166
2 changed files with 19 additions and 1 deletions

View File

@ -38,6 +38,8 @@
#include <sch_screen.h>
#include <wx/bookctrl.h>
#include <eda_item.h>
#include <wx/string.h>
#include <string_utils.h>
// sch_label.cpp
extern wxString getElectricalTypeLabel( LABEL_FLAG_SHAPE aType );
@ -112,6 +114,12 @@ void PANEL_SYNC_SHEET_PINS::UpdateForms()
}
}
std::sort( dedup_labels_ori.begin(), dedup_labels_ori.end(),
[]( const SCH_HIERLABEL* label1, const SCH_HIERLABEL* label2 )
{
return StrNumCmp( label1->GetText(), label2->GetText(), true ) < 0;
} );
auto check_matched = [&]( SCH_HIERLABEL* label )
{
for( size_t i = 0; i < pins_ori.size(); i++ )

View File

@ -3345,11 +3345,21 @@ SCH_HIERLABEL* SCH_DRAWING_TOOLS::importHierLabel( SCH_SHEET* aSheet )
if( !aSheet->GetScreen() )
return nullptr;
std::vector<SCH_HIERLABEL*> labels;
for( EDA_ITEM* item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
{
SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
labels.push_back( label );
}
/* A global label has been found: check if there a corresponding sheet label. */
std::sort( labels.begin(), labels.end(),
[]( const SCH_HIERLABEL* label1, const SCH_HIERLABEL* label2 )
{
return StrNumCmp( label1->GetText(), label2->GetText(), true ) < 0;
} );
for( SCH_HIERLABEL* label : labels )
{
if( !aSheet->HasPin( label->GetText() ) )
return label;
}