7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 14:11:41 +00:00

Remove a few EDA_RECT instances.

This commit is contained in:
Jeff Young 2022-08-31 00:28:18 +01:00
parent c7036ae076
commit 5679b9dbdc
72 changed files with 186 additions and 209 deletions

View File

@ -317,7 +317,7 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
aWarningReporter->Report( wxEmptyString );
}
EDA_RECT bbbox;
BOX2I bbbox;
if( m_board )
{

View File

@ -153,8 +153,7 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
}
else
{
EDA_RECT targetBbox = getBoundingBox();
bBox = BOX2I( targetBbox.GetOrigin(), targetBbox.GetSize() );
bBox = getBoundingBox();
view->SetLayerVisible( LAYER_DRAWINGSHEET, false );
}

View File

@ -701,7 +701,7 @@ void DS_DATA_ITEM_TEXT::SetConstrainedTextSize()
dummy.SetVertJustify( m_Vjustify );
dummy.SetTextAngle( EDA_ANGLE( m_Orient, DEGREES_T ) );
EDA_RECT rect = dummy.GetTextBox();
BOX2I rect = dummy.GetTextBox();
VECTOR2D size;
size.x = rect.GetWidth() / FSCALE;
size.y = rect.GetHeight() / FSCALE;

View File

@ -631,9 +631,9 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
}
const EDA_RECT EDA_SHAPE::getBoundingBox() const
const BOX2I EDA_SHAPE::getBoundingBox() const
{
EDA_RECT bbox;
BOX2I bbox;
switch( m_shape )
{
@ -812,7 +812,7 @@ bool EDA_SHAPE::hitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
arect.Normalize();
arect.Inflate( aAccuracy );
EDA_RECT bb = getBoundingBox();
BOX2I bb = getBoundingBox();
switch( m_shape )
{
@ -1015,7 +1015,7 @@ std::vector<VECTOR2I> EDA_SHAPE::GetRectCorners() const
}
void EDA_SHAPE::computeArcBBox( EDA_RECT& aBBox ) const
void EDA_SHAPE::computeArcBBox( BOX2I& aBBox ) const
{
// Start, end, and each inflection point the arc crosses will enclose the entire arc.
// Only include the center when filled; it's not necessarily inside the BB of an unfilled

View File

@ -497,7 +497,7 @@ int EDA_TEXT::GetInterline() const
}
EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
{
VECTOR2I drawPos = GetDrawPos();
@ -509,7 +509,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
return m_bounding_box_cache;
}
EDA_RECT rect;
BOX2I rect;
wxArrayString strings;
wxString text = GetShownText();
int thickness = GetEffectiveTextPenWidth();
@ -619,7 +619,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
bool EDA_TEXT::TextHitTest( const VECTOR2I& aPoint, int aAccuracy ) const
{
EDA_RECT rect = GetTextBox();
BOX2I rect = GetTextBox();
VECTOR2I location = aPoint;
rect.Inflate( aAccuracy );
@ -942,7 +942,7 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn
VECTOR2I corners[4]; // Buffer of polygon corners
EDA_RECT rect = GetTextBox();
BOX2I rect = GetTextBox();
// TrueType bounding boxes aren't guaranteed to include all descenders, diacriticals, etc.
// Since we use this for zone knockouts and DRC, we need something more accurate.

View File

@ -71,10 +71,10 @@ MARKER_BASE::MARKER_BASE( int aScalingFactor, std::shared_ptr<RC_ITEM> aItem, TY
for( unsigned ii = 1; ii < CORNERS_COUNT; ii++ )
{
++point_shape;
start.x = std::min( start.x, point_shape->x);
start.y = std::min( start.y, point_shape->y);
end.x = std::max( end.x, point_shape->x);
end.y = std::max( end.y, point_shape->y);
start.x = std::min( start.x, point_shape->x );
start.y = std::min( start.y, point_shape->y );
end.x = std::max( end.x, point_shape->x );
end.y = std::max( end.y, point_shape->y );
}
m_shapeBoundingBox.SetOrigin( start);
@ -89,7 +89,7 @@ MARKER_BASE::~MARKER_BASE()
bool MARKER_BASE::HitTestMarker( const VECTOR2I& aHitPosition, int aAccuracy ) const
{
EDA_RECT bbox = GetBoundingBoxMarker();
BOX2I bbox = GetBoundingBoxMarker();
bbox.Inflate( aAccuracy );
// Fast hit test using boundary box. A finer test will be made if requested
@ -120,17 +120,14 @@ void MARKER_BASE::ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon, int aScale ) const
}
EDA_RECT MARKER_BASE::GetBoundingBoxMarker() const
BOX2I MARKER_BASE::GetBoundingBoxMarker() const
{
VECTOR2I size_iu = m_shapeBoundingBox.GetSize();
VECTOR2I position_iu = m_shapeBoundingBox.GetPosition();
size_iu.x *= m_scalingFactor;
size_iu.y *= m_scalingFactor;
position_iu.x *= m_scalingFactor;
position_iu.y *= m_scalingFactor;
position_iu += m_Pos;
BOX2I bbox = m_shapeBoundingBox;
return EDA_RECT( position_iu, size_iu );
VECTOR2I pos = m_Pos;
pos += m_shapeBoundingBox.GetPosition() * m_scalingFactor;
return BOX2I( pos, bbox.GetSize() * m_scalingFactor );
}

View File

@ -26,6 +26,7 @@
#include <algorithm>
#include <eda_item.h>
#include <eda_rect.h>
#include <tool/selection.h>
@ -93,7 +94,7 @@ VECTOR2I SELECTION::GetCenter() const
}
}
EDA_RECT bbox;
BOX2I bbox;
if( hasOnlyText )
{
@ -116,9 +117,9 @@ VECTOR2I SELECTION::GetCenter() const
}
EDA_RECT SELECTION::GetBoundingBox() const
BOX2I SELECTION::GetBoundingBox() const
{
EDA_RECT bbox;
BOX2I bbox;
for( EDA_ITEM* item : m_items )
bbox.Merge( item->GetBoundingBox() );

View File

@ -373,7 +373,7 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const
/* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
* calling GetTextBox() that works using top to bottom Y axis orientation.
*/
EDA_RECT rect = GetTextBox( -1, true );
BOX2I rect = GetTextBox( -1, true );
rect.RevertYAxis();
// We are using now a bottom to top Y axis.

View File

@ -415,7 +415,7 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
const EDA_RECT LIB_SHAPE::GetBoundingBox() const
{
EDA_RECT rect = getBoundingBox();
BOX2I rect = getBoundingBox();
rect.RevertYAxis();

View File

@ -911,10 +911,10 @@ void LIB_SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const
}
const EDA_RECT LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aConvert, bool aIncludePins,
bool aIncludePrivateItems ) const
const BOX2I LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aConvert, bool aIncludePins,
bool aIncludePrivateItems ) const
{
EDA_RECT bbox;
BOX2I bbox;
for( const LIB_ITEM& item : m_drawings )
{

View File

@ -225,8 +225,8 @@ public:
* if aConvert == 0 Convert is non used
* Fields are not taken in account
**/
const EDA_RECT GetBodyBoundingBox( int aUnit, int aConvert, bool aIncludePins,
bool aIncludePrivateItems ) const;
const BOX2I GetBodyBoundingBox( int aUnit, int aConvert, bool aIncludePins,
bool aIncludePrivateItems ) const;
const EDA_RECT GetBoundingBox() const override
{

View File

@ -133,7 +133,7 @@ void LIB_TEXT::MoveTo( const VECTOR2I& newPosition )
void LIB_TEXT::NormalizeJustification( bool inverse )
{
VECTOR2I delta( 0, 0 );
EDA_RECT bbox = GetTextBox();
BOX2I bbox = GetTextBox();
if( GetTextAngle().IsHorizontal() )
{
@ -400,7 +400,7 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const
/* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
* calling GetTextBox() that works using top to bottom Y axis orientation.
*/
EDA_RECT rect = GetTextBox( -1, true );
BOX2I rect = GetTextBox( -1, true );
rect.RevertYAxis();
// We are using now a bottom to top Y axis.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2022 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
@ -68,7 +68,7 @@ public:
rect.Inflate( aAccuracy );
EDA_RECT textBox = GetTextBox();
BOX2I textBox = GetTextBox();
textBox.RevertYAxis();
if( aContained )

View File

@ -1680,18 +1680,14 @@ const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
DS_PROXY_VIEW_ITEM* ds = SCH_BASE_FRAME::GetCanvas()->GetView()->GetDrawingSheet();
EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
// Need an EDA_RECT so the first ".Merge" sees it's uninitialized
EDA_RECT bBoxItems;
// Calc the bounding box of all items on screen except the page border
for( EDA_ITEM* item : GetScreen()->Items() )
{
if( item != dsAsItem ) // Ignore the drawing-sheet itself
bBoxItems.Merge( item->GetBoundingBox() );
bBoxDoc = bBoxItems;
bBoxDoc.Merge( item->GetBoundingBox() );
}
}
return bBoxDoc;
}

View File

@ -402,7 +402,7 @@ EDA_ANGLE SCH_FIELD::GetDrawRotation() const
const EDA_RECT SCH_FIELD::GetBoundingBox() const
{
// Calculate the text bounding box:
EDA_RECT rect = GetTextBox();
BOX2I rect = GetTextBox();
// Calculate the bounding box position relative to the parent:
VECTOR2I origin = GetParentPosition();

View File

@ -639,11 +639,11 @@ int SCH_LABEL_BASE::GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings ) con
}
const EDA_RECT SCH_LABEL_BASE::GetBodyBoundingBox() const
const BOX2I SCH_LABEL_BASE::GetBodyBoundingBox() const
{
// build the bounding box of the label only, without taking into account its fields
EDA_RECT box;
BOX2I box;
std::vector<VECTOR2I> pts;
CreateGraphicShape( nullptr, pts, GetTextPos() );
@ -661,7 +661,7 @@ const EDA_RECT SCH_LABEL_BASE::GetBoundingBox() const
{
// build the bounding box of the entire label, including its fields
EDA_RECT box( GetBodyBoundingBox() );
BOX2I box = GetBodyBoundingBox();
for( const SCH_FIELD& field : m_fields )
{
@ -684,7 +684,7 @@ const EDA_RECT SCH_LABEL_BASE::GetBoundingBox() const
bool SCH_LABEL_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
EDA_RECT bbox = GetBodyBoundingBox();
BOX2I bbox = GetBodyBoundingBox();
bbox.Inflate( aAccuracy );
if( bbox.Contains( aPosition ) )
@ -960,9 +960,9 @@ SCH_LABEL::SCH_LABEL( const VECTOR2I& pos, const wxString& text ) :
}
const EDA_RECT SCH_LABEL::GetBodyBoundingBox() const
const BOX2I SCH_LABEL::GetBodyBoundingBox() const
{
EDA_RECT rect = GetTextBox();
BOX2I rect = GetTextBox();
rect.Offset( 0, -GetTextOffset() );
rect.Inflate( GetEffectiveTextPenWidth() );
@ -1501,7 +1501,7 @@ void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aSettings,
}
const EDA_RECT SCH_HIERLABEL::GetBodyBoundingBox() const
const BOX2I SCH_HIERLABEL::GetBodyBoundingBox() const
{
int penWidth = GetEffectiveTextPenWidth();
int margin = GetTextOffset();
@ -1548,7 +1548,7 @@ const EDA_RECT SCH_HIERLABEL::GetBodyBoundingBox() const
break;
}
EDA_RECT box( VECTOR2I( x, y ), VECTOR2I( dx, dy ) );
BOX2I box( VECTOR2I( x, y ), VECTOR2I( dx, dy ) );
box.Normalize();
return box;
}

View File

@ -147,7 +147,7 @@ public:
/**
* Return the bounding box of the label only, without taking in account its fields.
*/
virtual const EDA_RECT GetBodyBoundingBox() const;
virtual const BOX2I GetBodyBoundingBox() const;
/**
* Return the bounding box of the label including its fields.
@ -225,7 +225,7 @@ public:
return wxT( "SCH_LABEL" );
}
const EDA_RECT GetBodyBoundingBox() const override;
const BOX2I GetBodyBoundingBox() const override;
bool IsConnectable() const override { return true; }
@ -395,7 +395,7 @@ public:
void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
const EDA_RECT GetBodyBoundingBox() const override;
const BOX2I GetBodyBoundingBox() const override;
bool IsConnectable() const override { return true; }

View File

@ -1866,7 +1866,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
// SCH_FIELD text.
if( aText->GetDrawFont()->IsOutline() )
{
EDA_RECT firstLineBBox = aText->GetTextBox( 0 );
BOX2I firstLineBBox = aText->GetTextBox( 0 );
int sizeDiff = firstLineBBox.GetHeight() - aText->GetTextSize().y;
int adjust = KiROUND( sizeDiff * 0.4 );
VECTOR2I adjust_offset( 0, - adjust );

View File

@ -1438,7 +1438,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
for( size_t ii = 0; ii < strings.size(); ++ii )
{
EDA_RECT bbox = libtext->GetTextBox( ii, true );
BOX2I bbox = libtext->GetTextBox( ii, true );
VECTOR2I linePos = { bbox.GetLeft(), -bbox.GetBottom() };
RotatePoint( linePos, libtext->GetTextPos(), -libtext->GetTextAngle() );

View File

@ -617,10 +617,10 @@ void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
}
const EDA_RECT SCH_SHEET::GetBodyBoundingBox() const
const BOX2I SCH_SHEET::GetBodyBoundingBox() const
{
VECTOR2I end;
EDA_RECT box( m_pos, m_size );
BOX2I box( m_pos, m_size );
int lineWidth = GetPenWidth();
int textLength = 0;
@ -640,7 +640,7 @@ const EDA_RECT SCH_SHEET::GetBodyBoundingBox() const
const EDA_RECT SCH_SHEET::GetBoundingBox() const
{
EDA_RECT box = GetBodyBoundingBox();
BOX2I box = GetBodyBoundingBox();
for( const SCH_FIELD& field : m_fields )
box.Merge( field.GetBoundingBox() );
@ -1024,7 +1024,7 @@ BITMAPS SCH_SHEET::GetMenuImage() const
bool SCH_SHEET::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
EDA_RECT rect = GetBodyBoundingBox();
BOX2I rect = GetBodyBoundingBox();
rect.Inflate( aAccuracy );

View File

@ -248,7 +248,7 @@ public:
/**
* Return a bounding box for the sheet body but not the fields.
*/
const EDA_RECT GetBodyBoundingBox() const;
const BOX2I GetBodyBoundingBox() const;
const EDA_RECT GetBoundingBox() const override;

View File

@ -1396,9 +1396,9 @@ void SCH_SYMBOL::Show( int nestLevel, std::ostream& os ) const
#endif
EDA_RECT SCH_SYMBOL::doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const
BOX2I SCH_SYMBOL::doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const
{
EDA_RECT bBox;
BOX2I bBox;
if( m_part )
bBox = m_part->GetBodyBoundingBox( m_unit, m_convert, aIncludePins, false );
@ -1441,7 +1441,7 @@ EDA_RECT SCH_SYMBOL::doGetBoundingBox( bool aIncludePins, bool aIncludeFields )
}
EDA_RECT SCH_SYMBOL::GetBodyBoundingBox() const
BOX2I SCH_SYMBOL::GetBodyBoundingBox() const
{
return doGetBoundingBox( false, false );
}
@ -1883,7 +1883,7 @@ SCH_SYMBOL& SCH_SYMBOL::operator=( const SCH_ITEM& aItem )
bool SCH_SYMBOL::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
EDA_RECT bBox = GetBodyBoundingBox();
BOX2I bBox = GetBodyBoundingBox();
bBox.Inflate( aAccuracy / 2 );
if( bBox.Contains( aPosition ) )

View File

@ -330,7 +330,7 @@ public:
/**
* Return a bounding box for the symbol body but not the pins or fields.
*/
EDA_RECT GetBodyBoundingBox() const;
BOX2I GetBodyBoundingBox() const;
/**
* Return a bounding box for the symbol body and pins but not the fields.
@ -705,7 +705,7 @@ public:
bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override;
private:
EDA_RECT doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;
BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;
bool doIsConnected( const VECTOR2I& aPosition ) const override;

View File

@ -300,7 +300,7 @@ void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
// SCH_FIELD text.
if( GetDrawFont()->IsOutline() )
{
EDA_RECT firstLineBBox = GetTextBox( 0 );
BOX2I firstLineBBox = GetTextBox( 0 );
int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
int adjust = KiROUND( sizeDiff * 0.4 );
VECTOR2I adjust_offset( 0, - adjust );
@ -315,7 +315,7 @@ void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
const EDA_RECT SCH_TEXT::GetBoundingBox() const
{
EDA_RECT rect = GetTextBox();
BOX2I rect = GetTextBox();
if( !GetTextAngle().IsZero() ) // Rotate rect.
{
@ -456,7 +456,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground ) const
// SCH_FIELD text.
if( GetDrawFont()->IsOutline() )
{
EDA_RECT firstLineBBox = GetTextBox( 0 );
BOX2I firstLineBBox = GetTextBox( 0 );
int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
int adjust = KiROUND( sizeDiff * 0.4 );
VECTOR2I adjust_offset( 0, - adjust );

View File

@ -82,9 +82,9 @@ EDA_ITEM* EE_SELECTION::GetTopLeftItem( bool onlyModules ) const
}
EDA_RECT EE_SELECTION::GetBoundingBox() const
BOX2I EE_SELECTION::GetBoundingBox() const
{
EDA_RECT bbox;
BOX2I bbox;
for( EDA_ITEM* item : m_items )
{

Some files were not shown because too many files have changed in this diff Show More