Exclude invisible items from view bounding box for zoom-to-fit
Fixes: lp:1116457
* https://bugs.launchpad.net/kicad/+bug/1116457
(cherry picked from commit ede2575018
)
This commit is contained in:
parent
b5c80fe689
commit
549b76739e
|
@ -222,12 +222,18 @@ int COMMON_TOOLS::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
||||||
EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
|
EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
|
||||||
|
|
||||||
BOX2I bBox = frame->GetDocumentExtents();
|
BOX2I bBox = frame->GetDocumentExtents();
|
||||||
|
BOX2I defaultBox = galCanvas->GetDefaultViewBBox();
|
||||||
VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
|
VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
|
||||||
VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
|
VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
|
||||||
|
|
||||||
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
|
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
|
||||||
{
|
{
|
||||||
bBox = galCanvas->GetDefaultViewBBox();
|
bBox = defaultBox;
|
||||||
|
}
|
||||||
|
else if( defaultBox.GetWidth() > 0 && defaultBox.GetHeight() > 0 )
|
||||||
|
{
|
||||||
|
// Ensure worksheet is included in bounding box
|
||||||
|
bBox.Merge( defaultBox );
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTOR2D vsize = bBox.GetSize();
|
VECTOR2D vsize = bBox.GetSize();
|
||||||
|
|
|
@ -211,7 +211,7 @@ void GERBVIEW_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
|
||||||
|
|
||||||
BOX2I GERBVIEW_DRAW_PANEL_GAL::GetDefaultViewBBox() const
|
BOX2I GERBVIEW_DRAW_PANEL_GAL::GetDefaultViewBBox() const
|
||||||
{
|
{
|
||||||
if( m_worksheet )
|
if( m_worksheet && m_view->IsLayerVisible( LAYER_WORKSHEET ) )
|
||||||
return m_worksheet->ViewBBox();
|
return m_worksheet->ViewBBox();
|
||||||
|
|
||||||
return BOX2I();
|
return BOX2I();
|
||||||
|
|
|
@ -1104,6 +1104,7 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
|
||||||
{
|
{
|
||||||
bool hasItems = false;
|
bool hasItems = false;
|
||||||
EDA_RECT area;
|
EDA_RECT area;
|
||||||
|
LSET visible = GetVisibleLayers();
|
||||||
|
|
||||||
// Check segments, dimensions, texts, and fiducials
|
// Check segments, dimensions, texts, and fiducials
|
||||||
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
||||||
|
@ -1111,6 +1112,9 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
|
||||||
if( aBoardEdgesOnly && (item->Type() != PCB_LINE_T || item->GetLayer() != Edge_Cuts ) )
|
if( aBoardEdgesOnly && (item->Type() != PCB_LINE_T || item->GetLayer() != Edge_Cuts ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if( !( item->GetLayerSet() & visible ).any() )
|
||||||
|
continue;
|
||||||
|
|
||||||
if( !hasItems )
|
if( !hasItems )
|
||||||
area = item->GetBoundingBox();
|
area = item->GetBoundingBox();
|
||||||
else
|
else
|
||||||
|
@ -1124,6 +1128,9 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
|
||||||
// Check modules
|
// Check modules
|
||||||
for( MODULE* module = m_Modules; module; module = module->Next() )
|
for( MODULE* module = m_Modules; module; module = module->Next() )
|
||||||
{
|
{
|
||||||
|
if( !( module->GetLayerSet() & visible ).any() )
|
||||||
|
continue;
|
||||||
|
|
||||||
if( !hasItems )
|
if( !hasItems )
|
||||||
area = module->GetBoundingBox();
|
area = module->GetBoundingBox();
|
||||||
else
|
else
|
||||||
|
@ -1135,6 +1142,9 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
|
||||||
// Check tracks
|
// Check tracks
|
||||||
for( TRACK* track = m_Track; track; track = track->Next() )
|
for( TRACK* track = m_Track; track; track = track->Next() )
|
||||||
{
|
{
|
||||||
|
if( !( track->GetLayerSet() & visible ).any() )
|
||||||
|
continue;
|
||||||
|
|
||||||
if( !hasItems )
|
if( !hasItems )
|
||||||
area = track->GetBoundingBox();
|
area = track->GetBoundingBox();
|
||||||
else
|
else
|
||||||
|
@ -1146,6 +1156,9 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
|
||||||
// Check zones
|
// Check zones
|
||||||
for( auto aZone : m_ZoneDescriptorList )
|
for( auto aZone : m_ZoneDescriptorList )
|
||||||
{
|
{
|
||||||
|
if( !( aZone->GetLayerSet() & visible ).any() )
|
||||||
|
continue;
|
||||||
|
|
||||||
if( !hasItems )
|
if( !hasItems )
|
||||||
area = aZone->GetBoundingBox();
|
area = aZone->GetBoundingBox();
|
||||||
else
|
else
|
||||||
|
|
|
@ -432,7 +432,7 @@ void PCB_DRAW_PANEL_GAL::RedrawRatsnest()
|
||||||
|
|
||||||
BOX2I PCB_DRAW_PANEL_GAL::GetDefaultViewBBox() const
|
BOX2I PCB_DRAW_PANEL_GAL::GetDefaultViewBBox() const
|
||||||
{
|
{
|
||||||
if( m_worksheet )
|
if( m_worksheet && m_view->IsLayerVisible( LAYER_WORKSHEET ) )
|
||||||
return m_worksheet->ViewBBox();
|
return m_worksheet->ViewBBox();
|
||||||
|
|
||||||
return BOX2I();
|
return BOX2I();
|
||||||
|
|
Loading…
Reference in New Issue