From 7c344e9be60ce9bf6988f90720706bb7cefa229a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 18 Nov 2020 23:34:03 +0000 Subject: [PATCH] Mirroring for intersheet references. --- eeschema/sch_text.cpp | 34 ++++++++++++++++++++++++++++++++ eeschema/sch_text.h | 2 ++ eeschema/tools/lib_control.cpp | 4 ++-- eeschema/tools/sch_edit_tool.cpp | 21 ++------------------ 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 3905bf1754..7058fdceb6 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -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() ); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index cc21786a5d..ad72862e0a 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -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& aFunction ) override; void Rotate90( bool aClockwise ) override; + void MirrorSpinStyle( bool aLeftRight ) override; void SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) override; diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index e879d58425..8a9ba52741 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -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() ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 40a33a975e..18d71eaea9 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -453,12 +453,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) case SCH_HIER_LABEL_T: { SCH_TEXT* textItem = static_cast( 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( 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( item ); - label->UpdateIntersheetRefProps(); - } - + textItem->MirrorSpinStyle( !xAxis ); break; }