diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 6cc02612e8..499eacb56e 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -813,6 +813,17 @@ void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorConstrainOnEdge( sheetPin->GetPosition() ); + sheetPin->ConstrainOnEdge( sheetPin->GetPosition(), false ); } diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 1db803ce0f..43e6b098c9 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -169,6 +169,8 @@ public: */ bool IsVerticalOrientation() const; + void SetPositionIgnoringPins( const VECTOR2I& aPosition ); + /** * Add aSheetPin to the sheet. * diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index cf13dfb8f6..0d06c78998 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -153,7 +153,7 @@ enum SHEET_SIDE SCH_SHEET_PIN::GetSide() const } -void SCH_SHEET_PIN::ConstrainOnEdge( VECTOR2I Pos ) +void SCH_SHEET_PIN::ConstrainOnEdge( VECTOR2I aPos, bool aAllowEdgeSwitch ) { SCH_SHEET* sheet = GetParent(); @@ -173,20 +173,27 @@ void SCH_SHEET_PIN::ConstrainOnEdge( VECTOR2I Pos ) sheetEdge.Append( leftSide, botSide ); sheetEdge.Append( leftSide, topSide ); - switch( sheetEdge.NearestSegment( Pos ) ) + if( aAllowEdgeSwitch ) { - case 0: SetSide( SHEET_SIDE::TOP ); break; - case 1: SetSide( SHEET_SIDE::RIGHT ); break; - case 2: SetSide( SHEET_SIDE::BOTTOM ); break; - case 3: SetSide( SHEET_SIDE::LEFT ); break; - default: wxASSERT( "Invalid segment number" ); + switch( sheetEdge.NearestSegment( aPos ) ) + { + case 0: SetSide( SHEET_SIDE::TOP ); break; + case 1: SetSide( SHEET_SIDE::RIGHT ); break; + case 2: SetSide( SHEET_SIDE::BOTTOM ); break; + case 3: SetSide( SHEET_SIDE::LEFT ); break; + default: wxASSERT( "Invalid segment number" ); + } + } + else + { + SetSide( GetSide() ); } switch( GetSide() ) { case SHEET_SIDE::RIGHT: case SHEET_SIDE::LEFT: - SetTextY( Pos.y ); + SetTextY( aPos.y ); if( GetTextPos().y < topSide ) SetTextY( topSide ); @@ -198,7 +205,7 @@ void SCH_SHEET_PIN::ConstrainOnEdge( VECTOR2I Pos ) case SHEET_SIDE::BOTTOM: case SHEET_SIDE::TOP: - SetTextX( Pos.x ); + SetTextX( aPos.x ); if( GetTextPos().x < leftSide ) SetTextX( leftSide ); @@ -252,7 +259,7 @@ void SCH_SHEET_PIN::Rotate( const VECTOR2I& aCenter ) RotatePoint( pt, aCenter, ANGLE_90 ); SHEET_SIDE oldSide = GetSide(); - ConstrainOnEdge( pt ); + ConstrainOnEdge( pt, true ); // If the new side is the same as the old side, instead mirror across the center of that side. if( GetSide() == oldSide ) diff --git a/eeschema/sch_sheet_pin.h b/eeschema/sch_sheet_pin.h index 3ae03cf5bd..9b90809c65 100644 --- a/eeschema/sch_sheet_pin.h +++ b/eeschema/sch_sheet_pin.h @@ -141,7 +141,7 @@ public: * Adjust label position to edge based on proximity to vertical or horizontal edge * of the parent sheet. */ - void ConstrainOnEdge( VECTOR2I Pos ); + void ConstrainOnEdge( VECTOR2I aPos, bool aAllowEdgeSwitch ); /** * Get the parent sheet object of this sheet pin. @@ -186,7 +186,10 @@ public: BITMAPS GetMenuImage() const override; - void SetPosition( const VECTOR2I& aPosition ) override { ConstrainOnEdge( aPosition ); } + void SetPosition( const VECTOR2I& aPosition ) override + { + ConstrainOnEdge( aPosition, true ); + } bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override { diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 21df957ef9..b84b62fb35 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -1035,32 +1035,10 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const } if( sheet->GetPosition() != sheetNewPos ) - { - //Keep pins in the place they were before resizing - for( SCH_SHEET_PIN* pin : sheet->GetPins() ) - { - switch( pin->GetSide() ) - { - case SHEET_SIDE::LEFT: - case SHEET_SIDE::RIGHT: - pin->Move( VECTOR2I( 0, sheet->GetPosition().y - sheetNewPos.y ) ); - break; - case SHEET_SIDE::TOP: - case SHEET_SIDE::BOTTOM: - pin->Move( VECTOR2I( sheet->GetPosition().x - sheetNewPos.x, 0 ) ); - break; - case SHEET_SIDE::UNDEFINED: - break; - } - } - - sheet->SetPosition( sheetNewPos ); - } + sheet->SetPositionIgnoringPins( sheetNewPos ); if( sheet->GetSize() != sheetNewSize ) - { sheet->Resize( sheetNewSize ); - } break; } diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index fa2a5ed8ee..a0d3201f05 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -1555,7 +1555,7 @@ void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta ) SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) aItem; pin->SetStoredPos( pin->GetStoredPos() + aDelta ); - pin->ConstrainOnEdge( pin->GetStoredPos() ); + pin->ConstrainOnEdge( pin->GetStoredPos(), true ); break; }