Symbol Editor do not display bounding box of invisible pins and fields

This commit is contained in:
jean-pierre charras 2024-03-13 17:42:05 +01:00
parent 6ebccdecc6
commit 3d04d78f76
2 changed files with 32 additions and 23 deletions

View File

@ -229,20 +229,8 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
#endif
if( m_schSettings.GetDrawBoundingBoxes() )
{
BOX2I box = aItem->GetBoundingBox();
if( aItem->Type() == SCH_SYMBOL_T )
box = static_cast<const SCH_SYMBOL*>( aItem )->GetBodyBoundingBox();
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( aItem->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 )
: COLOR4D( 0.2, 0.2, 0.2, 1 ) );
m_gal->SetLineWidth( schIUScale.MilsToIU( 3 ) );
m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
}
// Enable draw bounding box on request. Some bboxes are handled locally.
bool drawBoundingBox = m_schSettings.GetDrawBoundingBoxes();
switch( aItem->Type() )
{
@ -253,9 +241,11 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
draw( static_cast<const LIB_SHAPE*>( aItem ), aLayer, aDimmed );
break;
case LIB_PIN_T:
drawBoundingBox = false;
draw( static_cast<const LIB_PIN*>( aItem ), aLayer, aDimmed );
break;
case LIB_FIELD_T:
drawBoundingBox = false;
draw( static_cast<const LIB_FIELD*>( aItem ), aLayer, aDimmed );
break;
case LIB_TEXT_T:
@ -321,6 +311,25 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
default: return;
}
if( drawBoundingBox )
drawItemBoundingBox( aItem );
}
void SCH_PAINTER::drawItemBoundingBox( const EDA_ITEM* aItem )
{
BOX2I box = aItem->GetBoundingBox();
if( aItem->Type() == SCH_SYMBOL_T )
box = static_cast<const SCH_SYMBOL*>( aItem )->GetBodyBoundingBox();
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( aItem->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 )
: COLOR4D( 0.2, 0.2, 0.2, 1 ) );
m_gal->SetLineWidth( schIUScale.MilsToIU( 3 ) );
m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
}
@ -1111,6 +1120,9 @@ void SCH_PAINTER::draw( const LIB_FIELD* aField, int aLayer, bool aDimmed )
m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
m_gal->DrawLine( bbox.Centre(), VECTOR2I( 0, 0 ) );
}
if( m_schSettings.GetDrawBoundingBoxes() )
drawItemBoundingBox( aField );
}
@ -1401,6 +1413,9 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
return;
}
if( m_schSettings.GetDrawBoundingBoxes() )
drawItemBoundingBox( aPin );
VECTOR2I p0;
VECTOR2I dir;
int len = aPin->GetLength();
@ -2666,14 +2681,7 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed )
}
if( m_schSettings.GetDrawBoundingBoxes() )
{
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( aField->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 )
: COLOR4D( 0.2, 0.2, 0.2, 1 ) );
m_gal->SetLineWidth( schIUScale.MilsToIU( 3 ) );
m_gal->DrawRectangle( bbox.GetOrigin(), bbox.GetEnd() );
}
drawItemBoundingBox( aField );
m_gal->SetStrokeColor( color );
m_gal->SetFillColor( color );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019-2020 CERN
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
@ -146,6 +146,7 @@ public:
void SetSchematic( SCHEMATIC* aSchematic ) { m_schematic = aSchematic; }
private:
void drawItemBoundingBox( const EDA_ITEM* aItem );
void draw( const EDA_ITEM*, int, bool aDimmed );
void draw( const LIB_PIN* aPin, int aLayer, bool aDimmed );
void draw( const LIB_SHAPE* aCircle, int aLayer, bool aDimmed );