Flip labels to match orientation

When changing from local to hierarchical or global, the label style is
typically flipped so that global/hierarchical labels hang off the line
while local labels are set on top.  To make this more intuitive we flip
the initial orientation when changing

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17739
This commit is contained in:
Seth Hillbrand 2024-04-19 16:07:44 -07:00
parent 5da3dd1788
commit 4e6a3a50fc
1 changed files with 39 additions and 0 deletions

View File

@ -2218,6 +2218,19 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
new_label->SetAttributes( *sourceText, false );
new_label->SetSpinStyle( spinStyle );
new_label->SetHyperlink( href );
if( item->Type() == SCH_GLOBAL_LABEL_T || item->Type() == SCH_HIER_LABEL_T )
{
if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::UP )
new_label->MirrorVertically( position.y );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::BOTTOM )
new_label->MirrorVertically( position.y );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::LEFT )
new_label->MirrorHorizontally( position.x );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::RIGHT )
new_label->MirrorHorizontally( position.x );
}
newtext = new_label;
break;
}
@ -2230,6 +2243,19 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
new_label->SetAttributes( *sourceText, false );
new_label->SetSpinStyle( spinStyle );
new_label->SetHyperlink( href );
if( item->Type() == SCH_LABEL_T )
{
if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::UP )
new_label->MirrorVertically( position.y );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::BOTTOM )
new_label->MirrorVertically( position.y );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::LEFT )
new_label->MirrorHorizontally( position.x );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::RIGHT )
new_label->MirrorHorizontally( position.x );
}
newtext = new_label;
break;
}
@ -2242,6 +2268,19 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
new_label->SetAttributes( *sourceText, false );
new_label->SetSpinStyle( spinStyle );
new_label->SetHyperlink( href );
if( item->Type() == SCH_LABEL_T )
{
if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::UP )
new_label->MirrorVertically( position.y );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::BOTTOM )
new_label->MirrorVertically( position.y );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::LEFT )
new_label->MirrorHorizontally( position.x );
else if( static_cast<SCH_LABEL_BASE*>( item )->GetSpinStyle() == SPIN_STYLE::SPIN::RIGHT )
new_label->MirrorHorizontally( position.x );
}
newtext = new_label;
break;
}