Fix schematic sheet resizing bug.
Calculate the proper minimum height when resizing sheets to prevent resized sheet height from always increasing. Prevent the sheet pins from being drawn in the corners of the sheet when updating the edge constraints on resize. This ensures that the sheet pin is always drawn within the bounds of the sheet. Please note that this fix may not be 100% accurate as is assumes the default grid size of 50 mils. This may not be what the user expected but it guarantees that wires will connect to the pin properly. Fixes lp:1699796 https://bugs.launchpad.net/kicad/+bug/1699796
This commit is contained in:
parent
57619956e8
commit
e176fc181d
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2016 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2017 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -82,8 +82,6 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) :
|
|||
|
||||
SCH_SHEET::~SCH_SHEET()
|
||||
{
|
||||
// wxLogDebug( wxT( "Destroying sheet " ) + m_name );
|
||||
|
||||
// also, look at the associated sheet & its reference count
|
||||
// perhaps it should be deleted also.
|
||||
if( m_screen )
|
||||
|
@ -460,6 +458,7 @@ int SCH_SHEET::GetMinWidth() const
|
|||
|
||||
for( size_t j = 0; j < m_pins.size(); j++ )
|
||||
{
|
||||
// Check for pin directly across from the current pin.
|
||||
if( (i == j) || (m_pins[i].GetPosition().y != m_pins[j].GetPosition().y) )
|
||||
continue;
|
||||
|
||||
|
@ -481,19 +480,35 @@ int SCH_SHEET::GetMinHeight() const
|
|||
|
||||
for( size_t i = 0; i < m_pins.size(); i++ )
|
||||
{
|
||||
int pinY = m_pins[i].GetPosition().y - m_pos.y;
|
||||
int edge = m_pins[i].GetEdge();
|
||||
|
||||
if( pinY > height )
|
||||
height = pinY;
|
||||
// Make sure pin is on top or bottom side of sheet.
|
||||
if( edge < 2 )
|
||||
continue;
|
||||
|
||||
EDA_RECT rect = m_pins[i].GetBoundingBox();
|
||||
|
||||
if( height < rect.GetHeight() )
|
||||
height = rect.GetHeight();
|
||||
|
||||
for( size_t j = 0; j < m_pins.size(); j++ )
|
||||
{
|
||||
// Check for pin directly above or below the current pin.
|
||||
if( (i == j) || (m_pins[i].GetPosition().x != m_pins[j].GetPosition().x) )
|
||||
continue;
|
||||
|
||||
if( height < rect.GetHeight() + m_pins[j].GetBoundingBox().GetHeight() )
|
||||
{
|
||||
height = rect.GetHeight() + m_pins[j].GetBoundingBox().GetHeight();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete sheet labels which do not have corresponding hierarchical label.
|
||||
*/
|
||||
void SCH_SHEET::CleanupSheet()
|
||||
{
|
||||
SCH_SHEET_PINS::iterator i = m_pins.begin();
|
||||
|
@ -636,13 +651,19 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, lineWidth,
|
||||
false, false );
|
||||
|
||||
|
||||
/* Draw text : SheetLabel */
|
||||
for( SCH_SHEET_PIN& sheetPin : m_pins )
|
||||
{
|
||||
if( !sheetPin.IsMoving() )
|
||||
sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// Only for testing purposes, draw the component bounding box
|
||||
EDA_RECT boundingBox = GetBoundingBox();
|
||||
GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -184,29 +184,29 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
|
|||
SetTextY( Pos.y );
|
||||
|
||||
if( GetTextPos().y < sheet->m_pos.y )
|
||||
SetTextY( sheet->m_pos.y );
|
||||
SetTextY( sheet->m_pos.y + 50 );
|
||||
|
||||
if( GetTextPos().y > (sheet->m_pos.y + sheet->m_size.y) )
|
||||
SetTextY( sheet->m_pos.y + sheet->m_size.y );
|
||||
SetTextY( sheet->m_pos.y + sheet->m_size.y - 50 );
|
||||
}
|
||||
else // vertical sheetpin
|
||||
else
|
||||
{
|
||||
if( Pos.y > center.y )
|
||||
{
|
||||
SetEdge( SHEET_BOTTOM_SIDE ); //bottom
|
||||
SetEdge( SHEET_BOTTOM_SIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetEdge( SHEET_TOP_SIDE ); //top
|
||||
SetEdge( SHEET_TOP_SIDE );
|
||||
}
|
||||
|
||||
SetTextX( Pos.x );
|
||||
|
||||
if( GetTextPos().x < sheet->m_pos.x )
|
||||
SetTextX( sheet->m_pos.x );
|
||||
SetTextX( sheet->m_pos.x + 50 );
|
||||
|
||||
if( GetTextPos().x > (sheet->m_pos.x + sheet->m_size.x) )
|
||||
SetTextX( sheet->m_pos.x + sheet->m_size.x );
|
||||
SetTextX( sheet->m_pos.x + sheet->m_size.x - 50 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -277,8 +277,8 @@ static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const
|
|||
|
||||
wxPoint pos = sheet->GetPosition();
|
||||
|
||||
int width = aPanel->GetParent()->GetCrossHairPosition().x - sheet->GetPosition().x;
|
||||
int height = aPanel->GetParent()->GetCrossHairPosition().y - sheet->GetPosition().y;
|
||||
int width = aPanel->GetParent()->GetCrossHairPosition().x - pos.x;
|
||||
int height = aPanel->GetParent()->GetCrossHairPosition().y - pos.y;
|
||||
|
||||
// If the sheet doesn't have any pins, clamp the minimum size to the default values.
|
||||
width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width;
|
||||
|
@ -289,7 +289,7 @@ static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const
|
|||
int gridSizeX = KiROUND( screen->GetGridSize().x );
|
||||
int gridSizeY = KiROUND( screen->GetGridSize().y );
|
||||
|
||||
// If the sheet has pins, use the pin positions to clamp the minimum height.
|
||||
// If the sheet has pins, use the pin positions to clamp the minimum width and height.
|
||||
height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
|
||||
sheet->GetMinHeight() + gridSizeY : height;
|
||||
width = ( width < sheet->GetMinWidth() + gridSizeX ) ?
|
||||
|
|
Loading…
Reference in New Issue