Allow users to control the order of sheets through sheet fields.
Fixes https://gitlab.com/kicad/code/kicad/issues/2394
This commit is contained in:
parent
ed3e366715
commit
da1a89fc7e
|
@ -318,7 +318,11 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow()
|
||||||
m_sheet->SetBackgroundColor( m_backgroundSwatch->GetSwatchColor() );
|
m_sheet->SetBackgroundColor( m_backgroundSwatch->GetSwatchColor() );
|
||||||
|
|
||||||
m_frame->TestDanglingEnds();
|
m_frame->TestDanglingEnds();
|
||||||
m_frame->RefreshItem( m_sheet );
|
|
||||||
|
// Refresh all sheets in case ordering changed.
|
||||||
|
for( SCH_ITEM* item : m_frame->GetScreen()->Items().OfType( SCH_SHEET_T ) )
|
||||||
|
m_frame->RefreshItem( item );
|
||||||
|
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -776,11 +776,37 @@ void SCH_SCREEN::GetSheets( std::vector<SCH_ITEM*>* aItems )
|
||||||
|
|
||||||
std::sort( aItems->begin(), aItems->end(),
|
std::sort( aItems->begin(), aItems->end(),
|
||||||
[]( EDA_ITEM* a, EDA_ITEM* b ) -> bool
|
[]( EDA_ITEM* a, EDA_ITEM* b ) -> bool
|
||||||
|
{
|
||||||
|
long a_order = 0;
|
||||||
|
long b_order = 0;
|
||||||
|
|
||||||
|
for( const SCH_FIELD& field : static_cast<SCH_SHEET*>( a )->GetFields() )
|
||||||
|
{
|
||||||
|
if( field.GetName().CmpNoCase( wxT( "Order" ) ) == 0 )
|
||||||
|
{
|
||||||
|
field.GetText().ToLong( &a_order );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( const SCH_FIELD& field : static_cast<SCH_SHEET*>( b )->GetFields() )
|
||||||
|
{
|
||||||
|
if( field.GetName().CmpNoCase( wxT( "Order" ) ) == 0 )
|
||||||
|
{
|
||||||
|
field.GetText().ToLong( &b_order );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( a_order == b_order )
|
||||||
{
|
{
|
||||||
if( a->GetPosition().x == b->GetPosition().x )
|
if( a->GetPosition().x == b->GetPosition().x )
|
||||||
return a->GetPosition().y < b->GetPosition().y;
|
return a->GetPosition().y < b->GetPosition().y;
|
||||||
else
|
|
||||||
return a->GetPosition().x < b->GetPosition().x;
|
return a->GetPosition().x < b->GetPosition().x;
|
||||||
|
}
|
||||||
|
|
||||||
|
return a_order < b_order;
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue