diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index 76db30e523..f58c0c0369 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -151,6 +151,8 @@ static const wxChar SmallDrillMarkSize[] = wxT( "SmallDrillMarkSize" ); static const wxChar HotkeysDumper[] = wxT( "HotkeysDumper" ); +static const wxChar DrawBoundingBoxes[] = wxT( "DrawBoundingBoxes" ); + } // namespace KEYS @@ -252,6 +254,7 @@ ADVANCED_CFG::ADVANCED_CFG() m_SkipBoundingBoxOnFpLoad = false; m_SmallDrillMarkSize = 0.35; m_HotkeysDumper = false; + m_DrawBoundingBoxes = false; loadFromConfigFile(); } @@ -342,6 +345,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::HotkeysDumper, &m_HotkeysDumper, false ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::DrawBoundingBoxes, + &m_DrawBoundingBoxes, false ) ); + wxConfigLoadSetups( &aCfg, configParams ); for( PARAM_CFG* param : configParams ) diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 5f3f4b109d..e1f6563a22 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -193,6 +193,21 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) #endif + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + { + BOX2I box = item->GetBoundingBox(); + + if( item->Type() == SCH_COMPONENT_T ) + box = static_cast( item )->GetBodyBoundingBox(); + + m_gal->SetIsFill( false ); + m_gal->SetIsStroke( true ); + m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) : + COLOR4D( 0.2, 0.2, 0.2, 1 ) ); + m_gal->SetLineWidth( Mils2iu( 3 ) ); + m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() ); + } + switch( item->Type() ) { HANDLE_ITEM( LIB_PART_T, LIB_PART ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 2e9ec4a466..e3ac7fa6a6 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -792,9 +792,8 @@ bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const const EDA_RECT SCH_LABEL::GetBoundingBox() const { EDA_RECT rect = GetTextBox(); - int margin = GetTextOffset(); - rect.Inflate( margin ); + rect.Offset( 0, -GetTextOffset() ); if( GetTextAngle() != 0.0 ) { @@ -1291,10 +1290,10 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const int y = GetTextPos().y; int penWidth = GetEffectiveTextPenWidth(); int margin = GetTextOffset(); - int height = ( (GetTextHeight() * 15) / 10 ) + penWidth + 2 * margin; + int height = ( ( GetTextHeight() * 15 ) / 10 ) + penWidth + margin; int length = LenSize( GetShownText(), penWidth ) + height // add height for triangular shapes - + 2 * margin; + - margin; // margin added to height not needed here int dx, dy; @@ -1304,7 +1303,6 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const case LABEL_SPIN_STYLE::LEFT: dx = -length; dy = height; - x += margin; y -= height / 2; break; @@ -1312,13 +1310,11 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const dx = height; dy = -length; x -= height / 2; - y += margin; break; case LABEL_SPIN_STYLE::RIGHT: dx = length; dy = height; - x -= margin; y -= height / 2; break; @@ -1326,7 +1322,6 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const dx = height; dy = length; x -= height / 2; - y -= margin; break; } @@ -1457,10 +1452,9 @@ const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const int x = GetTextPos().x; int y = GetTextPos().y; - int height = GetTextHeight() + penWidth + 2 * margin; + int height = GetTextHeight() + penWidth + margin; int length = LenSize( GetShownText(), penWidth ) - + height // add height for triangular shapes - + 2 * margin; + + height; // add height for triangular shapes int dx, dy; diff --git a/include/advanced_config.h b/include/advanced_config.h index a022f57251..a19a3c03dd 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -160,6 +160,11 @@ public: */ bool m_HotkeysDumper; + /** + * Draw GAL bounding boxes in painters + */ + bool m_DrawBoundingBoxes; + private: ADVANCED_CFG();