Mirroring for intersheet references.

This commit is contained in:
Jeff Young 2020-11-18 23:34:03 +00:00
parent c61c7b62aa
commit 7c344e9be6
4 changed files with 40 additions and 21 deletions

View File

@ -238,6 +238,15 @@ void SCH_TEXT::Rotate90( bool aClockwise )
}
void SCH_TEXT::MirrorSpinStyle( bool aLeftRight )
{
if( aLeftRight )
SetLabelSpinStyle( GetLabelSpinStyle().MirrorY() );
else
SetLabelSpinStyle( GetLabelSpinStyle().MirrorX() );
}
void SCH_TEXT::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle )
{
m_spin_style = aSpinStyle;
@ -1009,6 +1018,31 @@ void SCH_GLOBALLABEL::Rotate90( bool aClockwise )
}
void SCH_GLOBALLABEL::MirrorSpinStyle( bool aLeftRight )
{
SCH_TEXT::MirrorSpinStyle( aLeftRight );
if( ( aLeftRight && m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_HORIZ )
|| ( !aLeftRight && m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_VERT ) )
{
if( m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
else
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
}
wxPoint pos = m_intersheetRefsField.GetTextPos();
wxPoint delta = GetPosition() - pos;
if( aLeftRight )
pos.x = GetPosition().x + delta.x;
else
pos.y = GetPosition().y + delta.y;
m_intersheetRefsField.SetTextPos( pos );
}
void SCH_GLOBALLABEL::UpdateIntersheetRefProps()
{
m_intersheetRefsField.SetTextSize( GetTextSize() );

View File

@ -281,6 +281,7 @@ public:
void Rotate( wxPoint aPosition ) override;
virtual void Rotate90( bool aClockwise );
virtual void MirrorSpinStyle( bool aLeftRight );
bool Matches( wxFindReplaceData& aSearchData, void* aAuxData ) override
{
@ -402,6 +403,7 @@ public:
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
void Rotate90( bool aClockwise ) override;
void MirrorSpinStyle( bool aLeftRight ) override;
void SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) override;

View File

@ -438,8 +438,8 @@ int LIB_CONTROL::AddSymbolToSchematic( const TOOL_EVENT& aEvent )
wxCHECK( part->GetLibId().IsValid(), 0 );
SCH_COMPONENT* comp =
new SCH_COMPONENT( *part, libId, &schframe->GetCurrentSheet(), unit, convert );
SCH_COMPONENT* comp = new SCH_COMPONENT( *part, libId, &schframe->GetCurrentSheet(), unit,
convert );
comp->SetParent( schframe->GetCurrentSheet().LastScreen() );

View File

@ -453,12 +453,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
case SCH_HIER_LABEL_T:
{
SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
textItem->Rotate90( clockwise );
if( textItem->GetFieldsAutoplaced() == FIELDS_AUTOPLACED_AUTO )
textItem->AutoplaceFields( m_frame->GetScreen(), false );
break;
}
@ -469,9 +464,8 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
SCH_SHEET* sheet = pin->GetParent();
for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
{
pin->Rotate( sheet->GetBoundingBox().GetCenter() );
}
break;
}
@ -636,18 +630,7 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
case SCH_HIER_LABEL_T:
{
SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
if( xAxis )
textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().MirrorX() );
else
textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().MirrorY() );
if( item->Type() == SCH_GLOBAL_LABEL_T )
{
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( item );
label->UpdateIntersheetRefProps();
}
textItem->MirrorSpinStyle( !xAxis );
break;
}