More EDA_RECE yeetage.

This commit is contained in:
Jeff Young 2022-08-31 17:17:14 +01:00
parent ebe9617e77
commit b4492e0bd2
50 changed files with 151 additions and 173 deletions

View File

@ -23,7 +23,6 @@
*/
#include <bitmap_base.h>
#include <eda_rect.h> // for EDA_RECT
#include <gr_basic.h>
#include <math/util.h> // for KiROUND
#include <memory> // for make_unique, unique_ptr

View File

@ -247,7 +247,7 @@ bool DIALOG_SHIM::Show( bool show )
#endif
ret = wxDialog::Show( show );
// classname is key, returns a zeroed out default EDA_RECT if none existed before.
// classname is key, returns a zeroed-out default wxRect if none existed before.
wxRect savedDialogRect = class_map[ hash_key ];
if( savedDialogRect.GetSize().x != 0 && savedDialogRect.GetSize().y != 0 )

View File

@ -26,7 +26,6 @@
#include <bitmaps.h>
#include <eda_item.h>
#include <eda_rect.h>
#include <trace_helpers.h>
#include <trigo.h>
#include <i18n_utility.h>

View File

@ -35,7 +35,6 @@
#include <eda_item.h>
#include <base_units.h>
#include <callback_gal.h>
#include <eda_rect.h>
#include <eda_text.h> // for EDA_TEXT, TEXT_EFFECTS, GR_TEXT_VJUSTIF...
#include <gal/color4d.h> // for COLOR4D, COLOR4D::BLACK
#include <gr_text.h>
@ -509,7 +508,7 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
return m_bounding_box_cache;
}
BOX2I rect;
BOX2I bbox;
wxArrayString strings;
wxString text = GetShownText();
int thickness = GetEffectiveTextPenWidth();
@ -549,7 +548,7 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
if( aInvertY )
pos.y = -pos.y;
rect.SetOrigin( pos );
bbox.SetOrigin( pos );
// for multiline texts and aLine < 0, merge all rectangles (aLine == -1 signals all lines)
if( IsMultilineAllowed() && aLine < 0 && strings.GetCount() )
@ -566,7 +565,7 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) );
}
rect.SetSize( textsize );
bbox.SetSize( textsize );
/*
* At this point the rectangle origin is the text origin (m_Pos). This is correct only for
@ -578,16 +577,16 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
{
case GR_TEXT_H_ALIGN_LEFT:
if( IsMirrored() )
rect.SetX( rect.GetX() - ( rect.GetWidth() - italicOffset ) );
bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) );
break;
case GR_TEXT_H_ALIGN_CENTER:
rect.SetX( rect.GetX() - ( rect.GetWidth() - italicOffset ) / 2 );
bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) / 2 );
break;
case GR_TEXT_H_ALIGN_RIGHT:
if( !IsMirrored() )
rect.SetX( rect.GetX() - ( rect.GetWidth() - italicOffset ) );
bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) );
break;
}
@ -597,23 +596,23 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
break;
case GR_TEXT_V_ALIGN_CENTER:
rect.SetY( rect.GetY() - ( rect.GetHeight() + overbarOffset ) / 2 );
bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) / 2 );
break;
case GR_TEXT_V_ALIGN_BOTTOM:
rect.SetY( rect.GetY() - ( rect.GetHeight() + overbarOffset ) );
bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) );
break;
}
rect.Normalize(); // Make h and v sizes always >= 0
bbox.Normalize(); // Make h and v sizes always >= 0
m_bounding_box_cache_valid = true;
m_bounding_box_cache_pos = drawPos;
m_bounding_box_cache_line = aLine;
m_bounding_box_cache_inverted = aInvertY;
m_bounding_box_cache = rect;
m_bounding_box_cache = bbox;
return rect;
return bbox;
}

View File

@ -104,7 +104,7 @@ void ORIGIN_VIEWITEM::ViewDraw( int, VIEW* aView ) const
VECTOR2D start( m_position );
VECTOR2D end( m_end );
EDA_RECT clip( VECTOR2I( start ), VECTOR2I( end.x - start.x, end.y - start.y ) );
BOX2I clip( VECTOR2I( start ), VECTOR2I( end.x - start.x, end.y - start.y ) );
clip.Normalize();
double theta = atan2( end.y - start.y, end.x - start.x );

View File

@ -20,7 +20,6 @@
#include <base_units.h>
#include <charconv>
#include <string_utils.h>
#include <eda_rect.h>
#include <render_settings.h>
#include <geometry/shape.h>
#include <geometry/shape_segment.h>
@ -94,8 +93,7 @@ void STROKE_PARAMS::Stroke( const SHAPE* aShape, PLOT_DASH_TYPE aLineStyle, int
VECTOR2D start = line->GetSeg().A;
VECTOR2D end = line->GetSeg().B;
EDA_RECT clip( (VECTOR2I) start, wxSize( end.x - start.x, end.y - start.y ) );
BOX2I clip( start, VECTOR2I( end.x - start.x, end.y - start.y ) );
clip.Normalize();
double theta = atan2( end.y - start.y, end.x - start.x );

View File

@ -26,9 +26,8 @@
#include <trigo.h>
#include <transform.h>
#include <common.h>
#include <eda_rect.h>
#include <math/util.h> // for KiROUND
#include <math/box2.h>
bool TRANSFORM::operator==( const TRANSFORM& aTransform ) const
{
@ -45,9 +44,9 @@ VECTOR2I TRANSFORM::TransformCoordinate( const VECTOR2I& aPoint ) const
}
EDA_RECT TRANSFORM::TransformCoordinate( const EDA_RECT& aRect ) const
BOX2I TRANSFORM::TransformCoordinate( const BOX2I& aRect ) const
{
EDA_RECT rect;
BOX2I rect;
rect.SetOrigin( TransformCoordinate( aRect.GetOrigin() ) );
rect.SetEnd( TransformCoordinate( aRect.GetEnd() ) );
return rect;

View File

@ -27,7 +27,6 @@
#ifndef CLASS_PIN_H
#define CLASS_PIN_H
#include <eda_rect.h>
#include <lib_item.h>
#include <pin_type.h>
#include <lib_symbol.h>

View File

@ -26,7 +26,6 @@
#define EESCHEMA_SCH_RTREE_H_
#include <core/typeinfo.h>
#include <eda_rect.h>
#include <sch_item.h>
#include <set>
#include <vector>

View File

@ -25,10 +25,9 @@
#ifndef BITMAP_BASE_H
#define BITMAP_BASE_H
#include <eda_rect.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <math/box2.h>
namespace KIGFX
{

View File

@ -25,22 +25,18 @@
*/
/**
* @file board_printout.h
* @brief Board print handler definition file.
*/
#ifndef BOARD_PRINTOUT_H
#define BOARD_PRINTOUT_H
#include <wx/print.h>
#include <layer_ids.h>
#include <eda_rect.h>
#include <printout.h>
#include <math/box2.h>
#include <memory>
namespace KIGFX {
namespace KIGFX
{
class GAL;
class VIEW;
class PAINTER;

View File

@ -242,7 +242,7 @@ public:
/**
* Test if \a aRect intersects this item.
*
* @param aRect A reference to a #EDA_RECT object containing the rectangle to test.
* @param aRect A reference to a #BOX2I object containing the rectangle to test.
* @param aContained Set to true to test for containment instead of an intersection.
* @param aAccuracy Increase \a aRect by this amount.
* @return True if \a aRect contains or intersects the item bounding box.

View File

@ -29,7 +29,6 @@
#include <vector>
#include <outline_mode.h>
#include <eda_rect.h>
#include <eda_search_data.h>
#include <font/glyph.h>
#include <font/text_attributes.h>
@ -388,7 +387,7 @@ private:
mutable VECTOR2I m_bounding_box_cache_pos;
mutable int m_bounding_box_cache_line;
mutable bool m_bounding_box_cache_inverted;
mutable EDA_RECT m_bounding_box_cache;
mutable BOX2I m_bounding_box_cache;
TEXT_ATTRIBUTES m_attributes;
VECTOR2I m_pos;

View File

@ -30,7 +30,6 @@
#include <rc_item.h>
#include <gr_basic.h>
#include <eda_rect.h>
class SHAPE_LINE_CHAIN;

View File

@ -32,8 +32,8 @@
#include <wx/gdicmn.h>
#include <geometry/eda_angle.h>
#include <math/box2.h>
class EDA_RECT;
/**
* for transforming drawing coordinates for a wxDC device context.
@ -64,9 +64,8 @@ public:
/**
* Calculate a new coordinate according to the mirror/rotation transform.
* Useful to calculate actual coordinates of a point
* from coordinates relative to a symbol.
* which are given for a non rotated, non mirrored item
* Useful to calculate actual coordinates of a point from coordinates relative to a symbol,
* which are given for a non-rotated,-non mirrored item.
* @param aPoint = The position to transform
* @return The transformed coordinate.
*/
@ -74,19 +73,17 @@ public:
/**
* Calculate a new rect according to the mirror/rotation transform.
* Useful to calculate actual coordinates of a point
* from coordinates relative to a symbol
* which are given for a non rotated, non mirrored item
* Useful to calculate actual coordinates of a point from coordinates relative to a symbol,
* which are given for a non-rotated,-non mirrored item.
* @param aRect = The rectangle to transform
* @return The transformed rectangle.
*/
EDA_RECT TransformCoordinate( const EDA_RECT& aRect ) const;
BOX2I TransformCoordinate( const BOX2I& aRect ) const;
/**
* Calculate the Inverse mirror/rotation transform.
* Useful to calculate coordinates relative to a symbol.
* which must be for a non rotated, non mirrored item
* from the actual coordinate.
* Useful to calculate coordinates relative to a symbol, which must be for a non-rotated,
* non-mirrored item from the actual coordinate.
* @return The inverse transform.
*/
TRANSFORM InverseTransform( ) const;

View File

@ -32,7 +32,7 @@
#include <math.h> // for copysign
#include <stdlib.h> // for abs
#include <math/vector2d.h>
#include <math/box2.h>
#include <geometry/eda_angle.h>
class EDA_RECT;
@ -187,7 +187,7 @@ VECTOR2<ret_type> GetClampedCoords( const VECTOR2<in_type>& aCoords, pad_type aP
*
* @return - False if any part of the line lies within the rectangle.
*/
bool ClipLine( const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2 );
bool ClipLine( const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2 );
#endif // #ifndef GEOMETRY_UTILS_H

View File

@ -114,7 +114,7 @@ int GetCircleToPolyCorrection( int aMaxError )
* Utility for the line clipping code, returns the boundary code of
* a point. Bit allocation is arbitrary
*/
inline int clipOutCode( const EDA_RECT *aClipBox, int x, int y )
inline int clipOutCode( const BOX2I *aClipBox, int x, int y )
{
int code;
@ -134,7 +134,7 @@ inline int clipOutCode( const EDA_RECT *aClipBox, int x, int y )
}
bool ClipLine( const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2 )
bool ClipLine( const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2 )
{
// Stock Cohen-Sutherland algorithm; check *any* CG book for details
int outcode1 = clipOutCode( aClipBox, x1, y1 );
@ -194,6 +194,7 @@ bool ClipLine( const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2 )
outcode2 = clipOutCode( aClipBox, x2, y2 );
}
}
return false;
}

View File

@ -1,11 +1,8 @@
/**
* @file pl_editor_layout.cpp
* @brief PL_EDITOR_LAYOUT class functions.
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
* This program is free software; you can redistribute it and/or
@ -26,12 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <algorithm>
#include <climits>
#include <eda_draw_frame.h>
#include <eda_item.h>
#include <eda_rect.h>
#include "pl_editor_layout.h"
PL_EDITOR_LAYOUT::PL_EDITOR_LAYOUT()
@ -46,9 +38,9 @@ PL_EDITOR_LAYOUT::~PL_EDITOR_LAYOUT()
}
EDA_RECT PL_EDITOR_LAYOUT::ComputeBoundingBox()
BOX2I PL_EDITOR_LAYOUT::ComputeBoundingBox()
{
EDA_RECT bbox;
BOX2I bbox;
SetBoundingBox( bbox );
return bbox;

View File

@ -1,6 +1,3 @@
/**
* @file pl_editor_layout.h
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -64,26 +61,26 @@ public:
*
* @return the full item list bounding box.
*/
EDA_RECT ComputeBoundingBox();
BOX2I ComputeBoundingBox();
/**
* Called soon after ComputeBoundingBox() to return the same EDA_RECT,
* as long as the CLASS_PL_EDITOR_LAYOUT has not changed.
* Called soon after ComputeBoundingBox() to return the same BOX2I, as long as the
* CLASS_PL_EDITOR_LAYOUT has not changed.
*/
const BOX2I GetBoundingBox() const { return m_boundingBox; }
void SetBoundingBox( const EDA_RECT& aBox ) { m_boundingBox = aBox; }
void SetBoundingBox( const BOX2I& aBox ) { m_boundingBox = aBox; }
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const;
#endif
private:
EDA_RECT m_boundingBox;
PAGE_INFO m_paper;
TITLE_BLOCK m_titles;
BOX2I m_boundingBox;
PAGE_INFO m_paper;
TITLE_BLOCK m_titles;
DS_DRAW_ITEM_LIST m_drawItemList;
DS_DRAW_ITEM_LIST m_drawItemList;
};
#endif // #ifndef CLASS_PL_EDITOR_LAYOUT_H

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 CERN
* Copyright (C) 2019 KiCad Developers, see AUTHORS.TXT for contributors.
* Copyright (C) 2019-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
@ -23,8 +23,7 @@
*/
#include <eda_item.h>
#include <eda_rect.h>
#include "tools/pl_selection.h"
#include <tools/pl_selection.h>
EDA_ITEM* PL_SELECTION::GetTopLeftItem( bool onlyModules ) const

View File

@ -396,8 +396,8 @@ bool PL_SELECTION_TOOL::selectMultiple()
bool anyAdded = false;
bool anySubtracted = false;
// Construct an EDA_RECT to determine EDA_ITEM selection
EDA_RECT selectionRect( (wxPoint)area.GetOrigin(), wxSize( width, height ) );
// Construct a BOX2I to determine EDA_ITEM selection
BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
selectionRect.Normalize();

View File

@ -1790,7 +1790,7 @@ FOOTPRINT* BOARD::GetFootprint( const VECTOR2I& aPosition, PCB_LAYER_ID aActiveL
// Filter non visible footprints if requested
if( !aVisibleOnly || IsFootprintLayerVisible( layer ) )
{
EDA_RECT bb = candidate->GetBoundingBox( false, false );
BOX2I bb = candidate->GetBoundingBox( false, false );
int offx = bb.GetX() + bb.GetWidth() / 2;
int offy = bb.GetY() + bb.GetHeight() / 2;

View File

@ -1296,7 +1296,7 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
{
for( const std::shared_ptr<PCB_SHAPE>& shape : m_dummyPad->GetPrimitives() )
{
EDA_RECT shapeBBox = shape->GetBoundingBox();
BOX2I shapeBBox = shape->GetBoundingBox();
if( absMargin > shapeBBox.GetWidth() || absMargin > shapeBBox.GetHeight() )
{

View File

@ -280,13 +280,14 @@ public:
* It checks all items in the bbox overlap to find the minimal actual distance and
* position.
*/
bool QueryColliding( EDA_RECT aBox, SHAPE* aRefShape, PCB_LAYER_ID aLayer, int aClearance,
bool QueryColliding( const BOX2I& aBox, SHAPE* aRefShape, PCB_LAYER_ID aLayer, int aClearance,
int* aActual, VECTOR2I* aPos ) const
{
aBox.Inflate( aClearance );
BOX2I bbox = aBox;
bbox.Inflate( aClearance );
int min[2] = { aBox.GetX(), aBox.GetY() };
int max[2] = { aBox.GetRight(), aBox.GetBottom() };
int min[2] = { bbox.GetX(), bbox.GetY() };
int max[2] = { bbox.GetRight(), bbox.GetBottom() };
bool collision = false;
int actual = INT_MAX;
@ -335,7 +336,7 @@ public:
/**
* Quicker version of above that just reports a raw yes/no.
*/
bool QueryColliding( EDA_RECT aBox, SHAPE* aRefShape, PCB_LAYER_ID aLayer ) const
bool QueryColliding( const BOX2I& aBox, SHAPE* aRefShape, PCB_LAYER_ID aLayer ) const
{
SHAPE_POLY_SET* poly = dynamic_cast<SHAPE_POLY_SET*>( aRefShape );
@ -531,7 +532,7 @@ public:
m_rect = { { INT_MIN, INT_MIN }, { INT_MAX, INT_MAX } };
};
DRC_LAYER( drc_rtree* aTree, const EDA_RECT aRect ) : layer_tree( aTree )
DRC_LAYER( drc_rtree* aTree, const BOX2I& aRect ) : layer_tree( aTree )
{
m_rect = { { aRect.GetX(), aRect.GetY() },
{ aRect.GetRight(), aRect.GetBottom() } };
@ -558,12 +559,12 @@ public:
DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const VECTOR2I& aPoint, int aAccuracy = 0 ) const
{
EDA_RECT rect( aPoint, VECTOR2I( 0, 0 ) );
BOX2I rect( aPoint, VECTOR2I( 0, 0 ) );
rect.Inflate( aAccuracy );
return DRC_LAYER( m_tree[int( aLayer )], rect );
}
DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const EDA_RECT& aRect ) const
DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const BOX2I& aRect ) const
{
return DRC_LAYER( m_tree[int( aLayer )], aRect );
}

View File

@ -114,11 +114,11 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
if( m_drcEngine->IsCancelled() )
return 0;
ZONE* ruleArea = areaZonePair.first;
ZONE* copperZone = areaZonePair.second;
EDA_RECT areaBBox = ruleArea->GetCachedBoundingBox();
EDA_RECT copperBBox = copperZone->GetCachedBoundingBox();
bool isInside = false;
ZONE* ruleArea = areaZonePair.first;
ZONE* copperZone = areaZonePair.second;
BOX2I areaBBox = ruleArea->GetCachedBoundingBox();
BOX2I copperBBox = copperZone->GetCachedBoundingBox();
bool isInside = false;
if( copperZone->IsFilled() && areaBBox.Intersects( copperBBox ) )
{

View File

@ -79,9 +79,9 @@ private:
void testSilkToMaskClearance();
void testMaskBridges();
void testItemAgainstItems( BOARD_ITEM* aItem, const EDA_RECT& aItemBBox,
void testItemAgainstItems( BOARD_ITEM* aItem, const BOX2I& aItemBBox,
PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer );
void testMaskItemAgainstZones( BOARD_ITEM* item, const EDA_RECT& itemBBox,
void testMaskItemAgainstZones( BOARD_ITEM* item, const BOX2I& itemBBox,
PCB_LAYER_ID refLayer, PCB_LAYER_ID targetLayer );
bool checkMaskAperture( BOARD_ITEM* aMaskItem, BOARD_ITEM* aTestItem, PCB_LAYER_ID aTestLayer,
@ -400,8 +400,7 @@ bool DRC_TEST_PROVIDER_SOLDER_MASK::checkItemMask( BOARD_ITEM* aMaskItem, int aT
}
void DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems( BOARD_ITEM* aItem,
const EDA_RECT& aItemBBox,
void DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems( BOARD_ITEM* aItem, const BOX2I& aItemBBox,
PCB_LAYER_ID aRefLayer,
PCB_LAYER_ID aTargetLayer )
{
@ -558,7 +557,7 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems( BOARD_ITEM* aItem,
void DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones( BOARD_ITEM* aItem,
const EDA_RECT& aItemBBox,
const BOX2I& aItemBBox,
PCB_LAYER_ID aMaskLayer,
PCB_LAYER_ID aTargetLayer )
{
@ -577,8 +576,8 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones( BOARD_ITEM* aItem,
continue;
}
EDA_RECT inflatedBBox( aItemBBox );
int clearance = m_board->GetDesignSettings().m_SolderMaskToCopperClearance;
BOX2I inflatedBBox( aItemBBox );
int clearance = m_board->GetDesignSettings().m_SolderMaskToCopperClearance;
if( aItem->Type() == PCB_PAD_T )
clearance += static_cast<PAD*>( aItem )->GetSolderMaskExpansion();

View File

@ -664,7 +664,7 @@ void FOOTPRINT::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode )
double FOOTPRINT::GetArea( int aPadding ) const
{
EDA_RECT bbox = GetBoundingBox( false, false );
BOX2I bbox = GetBoundingBox( false, false );
double w = std::abs( static_cast<double>( bbox.GetWidth() ) ) + aPadding;
double h = std::abs( static_cast<double>( bbox.GetHeight() ) ) + aPadding;
@ -759,7 +759,7 @@ const BOX2I FOOTPRINT::GetBoundingBox() const
}
const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const
const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const
{
const BOARD* board = GetBoard();
bool isFPEdit = board && board->IsFootprintHolder();
@ -1059,7 +1059,7 @@ bool FOOTPRINT::IsOnLayer( PCB_LAYER_ID aLayer ) const
bool FOOTPRINT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
EDA_RECT rect = GetBoundingBox( false, false );
BOX2I rect = GetBoundingBox( false, false );
return rect.Inflate( aAccuracy ).Contains( aPosition );
}
@ -1494,7 +1494,7 @@ double FOOTPRINT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
const BOX2I FOOTPRINT::ViewBBox() const
{
EDA_RECT area = GetBoundingBox( true, true );
BOX2I area = GetBoundingBox( true, true );
// Add the Clearance shape size: (shape around the pads when the clearance is shown. Not
// optimized, but the draw cost is small (perhaps smaller than optimization).

View File

@ -170,7 +170,7 @@ public:
// Virtual function
const BOX2I GetBoundingBox() const override;
const EDA_RECT GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const;
const BOX2I GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const;
PADS& Pads() { return m_pads; }
const PADS& Pads() const { return m_pads; }
@ -797,11 +797,11 @@ private:
// that any edit that could affect the bounding boxes (including edits to the footprint
// children) marked the bounding boxes dirty. It would definitely be faster -- but also more
// fragile.
mutable EDA_RECT m_cachedBoundingBox;
mutable BOX2I m_cachedBoundingBox;
mutable int m_boundingBoxCacheTimeStamp;
mutable EDA_RECT m_cachedVisibleBBox;
mutable BOX2I m_cachedVisibleBBox;
mutable int m_visibleBBoxCacheTimeStamp;
mutable EDA_RECT m_cachedTextExcludedBBox;
mutable BOX2I m_cachedTextExcludedBBox;
mutable int m_textExcludedBBoxCacheTimeStamp;
mutable SHAPE_POLY_SET m_cachedHull;
mutable int m_hullCacheTimeStamp;

View File

@ -29,7 +29,6 @@
#include <board_item.h>
class LINE_READER;
class EDA_RECT;
class FOOTPRINT;
class MSG_PANEL_ITEM;
class PCB_BASE_FRAME;

View File

@ -231,7 +231,7 @@ VECTOR2I FP_TEXTBOX::GetDrawPos() const
bool FP_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
EDA_RECT rect = GetBoundingBox();
BOX2I rect = GetBoundingBox();
rect.Inflate( aAccuracy );

View File

@ -28,7 +28,6 @@
#include <fp_shape.h>
class LINE_READER;
class EDA_RECT;
class FOOTPRINT;
class MSG_PANEL_ITEM;
class PCB_BASE_FRAME;

View File

@ -100,8 +100,8 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater, bool* aR
std::vector<FOOTPRINT*> newFootprints = aUpdater.GetAddedFootprints();
// Spread new footprints.
wxPoint areaPosition = (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition();
EDA_RECT bbox = board->GetBoundingBox();
VECTOR2I areaPosition = GetCanvas()->GetViewControls()->GetCursorPosition();
BOX2I bbox = board->GetBoundingBox();
GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );

View File

@ -1428,9 +1428,9 @@ const BOX2I PAD::ViewBBox() const
{
// Bounding box includes soldermask too. Remember mask and/or paste
// margins can be < 0
int solderMaskMargin = std::max( GetSolderMaskExpansion(), 0 );
int solderMaskMargin = std::max( GetSolderMaskExpansion(), 0 );
VECTOR2I solderPasteMargin = VECTOR2D( GetSolderPasteMargin() );
EDA_RECT bbox = GetBoundingBox();
BOX2I bbox = GetBoundingBox();
// get the biggest possible clearance
int clearance = 0;

View File

@ -132,9 +132,9 @@ const BOX2I PCB_BITMAP::GetBoundingBox() const
std::shared_ptr<SHAPE> PCB_BITMAP::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
{
EDA_RECT box = GetBoundingBox();
return std::shared_ptr<SHAPE_RECT>(
new SHAPE_RECT( box.GetCenter(), box.GetWidth(), box.GetHeight() ) );
BOX2I box = GetBoundingBox();
return std::shared_ptr<SHAPE_RECT>( new SHAPE_RECT( box.GetCenter(), box.GetWidth(),
box.GetHeight() ) );
}
@ -178,7 +178,7 @@ void PCB_BITMAP::Show( int nestLevel, std::ostream& os ) const
bool PCB_BITMAP::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
EDA_RECT rect = GetBoundingBox();
BOX2I rect = GetBoundingBox();
rect.Inflate( aAccuracy );

View File

@ -1264,7 +1264,7 @@ const BOX2I PCB_DIM_CENTER::GetBoundingBox() const
{
int halfWidth = VECTOR2I( m_end - m_start ).x + ( m_lineThickness / 2.0 );
EDA_RECT bBox;
BOX2I bBox;
bBox.SetX( m_start.x - halfWidth );
bBox.SetY( m_start.y - halfWidth );

View File

@ -406,7 +406,7 @@ static void intersectsBackCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
bool collidesWithArea( BOARD_ITEM* aItem, PCB_EXPR_CONTEXT* aCtx, ZONE* aArea )
{
BOARD* board = aArea->GetBoard();
EDA_RECT areaBBox = aArea->GetCachedBoundingBox();
BOX2I areaBBox = aArea->GetCachedBoundingBox();
std::shared_ptr<SHAPE> shape;
// Collisions include touching, so we need to deflate outline by enough to exclude it.

View File

@ -307,8 +307,7 @@ const BOX2I PCB_MARKER::GetBoundingBox() const
const BOX2I PCB_MARKER::ViewBBox() const
{
EDA_RECT bbox = GetBoundingBox();
return BOX2I( bbox.GetOrigin(), VECTOR2I( bbox.GetWidth(), bbox.GetHeight() ) );
return GetBoundingBox();
}

View File

@ -629,9 +629,10 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
viewport.SetOrigin( VECTOR2D( matrix * VECTOR2D( 0, 0 ) ) );
viewport.SetEnd( VECTOR2D( matrix * screenSize ) );
viewport.Normalize();
EDA_RECT clipBox( viewport.Normalize() );
SEG visibleSeg( start, end );
BOX2I clipBox( viewport.GetOrigin(), viewport.GetSize() );
SEG visibleSeg( start, end );
ClipLine( &clipBox, visibleSeg.A.x, visibleSeg.A.y, visibleSeg.B.x, visibleSeg.B.y );
@ -2088,7 +2089,7 @@ void PCB_PAINTER::draw( const FOOTPRINT* aFootprint, int aLayer )
const SHAPE_POLY_SET& poly = aFootprint->GetBoundingHull();
m_gal->DrawPolygon( poly );
#else
EDA_RECT bbox = aFootprint->GetBoundingBox( false, false );
BOX2I bbox = aFootprint->GetBoundingBox( false, false );
VECTOR2I topLeft = bbox.GetPosition();
VECTOR2I botRight = bbox.GetPosition() + bbox.GetSize();

View File

@ -103,7 +103,7 @@ void PCB_TARGET::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
const BOX2I PCB_TARGET::GetBoundingBox() const
{
EDA_RECT bBox;
BOX2I bBox;
bBox.SetX( m_pos.x - m_size / 2 );
bBox.SetY( m_pos.y - m_size / 2 );
bBox.SetWidth( m_size );

View File

@ -28,7 +28,6 @@
#include <board_item.h>
class EDA_RECT;
class LINE_READER;

View File

@ -102,8 +102,8 @@ public:
return TextHitTest( aPosition, aAccuracy );
}
/** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
* bool aContained = true, int aAccuracy ) const
/**
* @copydoc BOARD_ITEM::HitTest(const BOX2I& aRect, bool aContained, int aAccuracy ) const
*/
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
{

View File

@ -379,7 +379,7 @@ void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
bool PCB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
EDA_RECT rect = GetBoundingBox();
BOX2I rect = GetBoundingBox();
rect.Inflate( aAccuracy );

View File

@ -627,7 +627,8 @@ double PCB_TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
// When drawing netnames, clip the track to the viewport
VECTOR2I start( GetStart() );
VECTOR2I end( GetEnd() );
EDA_RECT clipBox( aView->GetViewport() );
BOX2D viewport = aView->GetViewport();
BOX2I clipBox( viewport.GetOrigin(), viewport.GetSize() );
ClipLine( &clipBox, start.x, start.y, end.x, end.y );
@ -1009,7 +1010,7 @@ bool PCB_ARC::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) cons
bool PCB_VIA::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT arect = aRect;
BOX2I arect = aRect;
arect.Inflate( aAccuracy );
BOX2I box( GetStart() );

View File

@ -1812,7 +1812,7 @@ void ALTIUM_PCB::ParsePolygons6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbF
if( elem.hatchstyle == ALTIUM_POLYGON_HATCHSTYLE::NONE )
{
// use a small hack to get us only an outline (hopefully)
const EDA_RECT& bbox = zone->GetBoundingBox();
const BOX2I& bbox = zone->GetBoundingBox();
zone->SetHatchGap( std::max( bbox.GetHeight(), bbox.GetWidth() ) );
}
else

View File

@ -576,7 +576,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, PAD* aPad )
// this string _must_ be unique for a given physical shape, so try to make it unique
MD5_HASH hash = pad_shape.GetHash();
EDA_RECT rect = aPad->GetBoundingBox();
BOX2I rect = aPad->GetBoundingBox();
snprintf( name, sizeof( name ), "Cust%sPad_%.6gx%.6g_%.6gx_%.6g_%d_um_%s",
uniqifier.c_str(), IU2um( aPad->GetSize().x ), IU2um( aPad->GetSize().y ),
IU2um( rect.GetWidth() ), IU2um( rect.GetHeight() ), (int) polygonal_shape.size(),

View File

@ -139,12 +139,12 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE_ON_MOVE::testCourtyardClearances()
frontBBox.Inflate( m_largestCourtyardClearance );
backBBox.Inflate( m_largestCourtyardClearance );
EDA_RECT fpABBox = fpA->GetBoundingBox();
BOX2I fpABBox = fpA->GetBoundingBox();
for( FOOTPRINT* fpB : m_FpInMove )
{
fpB->BuildCourtyardCaches();
EDA_RECT fpBBBox = fpB->GetBoundingBox();
BOX2I fpBBBox = fpB->GetBoundingBox();
const SHAPE_POLY_SET& frontB = fpB->GetCourtyard( F_CrtYd );
const SHAPE_POLY_SET& backB = fpB->GetCourtyard( B_CrtYd );
DRC_CONSTRAINT constraint;

View File

@ -885,8 +885,8 @@ bool PCB_SELECTION_TOOL::selectMultiple()
int height = area.GetEnd().y - area.GetOrigin().y;
// Construct an EDA_RECT to determine BOARD_ITEM selection
EDA_RECT selectionRect( (wxPoint) area.GetOrigin(), wxSize( width, height ) );
// Construct a BOX2I to determine BOARD_ITEM selection
BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
selectionRect.Normalize();
@ -2582,7 +2582,7 @@ int PCB_SELECTION_TOOL::hitTestDistance( const wxPoint& aWhere, BOARD_ITEM* aIte
case PCB_FOOTPRINT_T:
{
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aItem );
EDA_RECT bbox = footprint->GetBoundingBox( false, false );
BOX2I bbox = footprint->GetBoundingBox( false, false );
try
{

View File

@ -131,7 +131,7 @@ public:
/**
* ONLY TO BE USED BY CLIENTS WHICH SET UP THE CACHE!
*/
const EDA_RECT GetCachedBoundingBox() const { return m_bboxCache; }
const BOX2I GetCachedBoundingBox() const { return m_bboxCache; }
void CacheBoundingBox() { m_bboxCache = GetBoundingBox(); }
/**
@ -425,8 +425,7 @@ public:
SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
/**
* @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
* bool aContained = true, int aAccuracy) const
* @copydoc BOARD_ITEM::HitTest(const BOX2I& aRect, bool aContained, int aAccuracy) const
*/
bool HitTest( const BOX2I& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
@ -876,7 +875,7 @@ protected:
std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> m_FilledPolysList;
/// Temp variables used while filling
EDA_RECT m_bboxCache;
BOX2I m_bboxCache;
std::map<PCB_LAYER_ID, bool> m_fillFlags;
/// A hash value used in zone filling calculations to see if the filled areas are up to date

View File

@ -203,7 +203,7 @@ bool ZONE_FILLER::Fill( std::vector<ZONE*>& aZones, bool aCheck, wxWindow* aPare
// A higher priority zone is found: if we intersect and it's not filled yet
// then we have to wait.
EDA_RECT inflatedBBox = aZone->GetCachedBoundingBox();
BOX2I inflatedBBox = aZone->GetCachedBoundingBox();
inflatedBBox.Inflate( m_worstClearance );
return inflatedBBox.Intersects( aOtherZone->GetCachedBoundingBox() );
@ -572,7 +572,7 @@ void ZONE_FILLER::knockoutThermalReliefs( const ZONE* aZone, PCB_LAYER_ID aLayer
{
for( PAD* pad : footprint->Pads() )
{
EDA_RECT padBBox = pad->GetBoundingBox();
BOX2I padBBox = pad->GetBoundingBox();
padBBox.Inflate( m_worstClearance );
if( !padBBox.Intersects( aZone->GetCachedBoundingBox() ) )
@ -672,8 +672,8 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE* aZone, PCB_LAYER_ID aLa
// A small extra clearance to be sure actual track clearances are not smaller than
// requested clearance due to many approximations in calculations, like arc to segment
// approx, rounding issues, etc.
EDA_RECT zone_boundingbox = aZone->GetCachedBoundingBox();
int extra_margin = Millimeter2iu( ADVANCED_CFG::GetCfg().m_ExtraClearance );
BOX2I zone_boundingbox = aZone->GetCachedBoundingBox();
int extra_margin = Millimeter2iu( ADVANCED_CFG::GetCfg().m_ExtraClearance );
// Items outside the zone bounding box are skipped, so it needs to be inflated by the
// largest clearance value found in the netclasses and rules
@ -1179,7 +1179,7 @@ bool ZONE_FILLER::fillCopperZone( const ZONE* aZone, PCB_LAYER_ID aLayer, PCB_LA
for( int ii = aFillPolys.OutlineCount() - 1; ii >= 0; ii-- )
{
std::vector<SHAPE_LINE_CHAIN>& island = aFillPolys.Polygon( ii );
EDA_RECT islandExtents = island.front().BBox();
BOX2I islandExtents = island.front().BBox();
if( islandExtents.GetSizeMax() < half_min_width )
aFillPolys.DeletePolygon( ii );
@ -1239,7 +1239,7 @@ bool ZONE_FILLER::fillNonCopperZone( const ZONE* aZone, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aFillPolys )
{
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
EDA_RECT zone_boundingbox = aZone->GetCachedBoundingBox();
BOX2I zone_boundingbox = aZone->GetCachedBoundingBox();
SHAPE_POLY_SET clearanceHoles;
long ticker = 0;
@ -1357,7 +1357,7 @@ void ZONE_FILLER::buildThermalSpokes( const ZONE* aZone, PCB_LAYER_ID aLayer,
std::deque<SHAPE_LINE_CHAIN>& aSpokesList )
{
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
EDA_RECT zoneBB = aZone->GetCachedBoundingBox();
BOX2I zoneBB = aZone->GetCachedBoundingBox();
DRC_CONSTRAINT constraint;
zoneBB.Inflate( std::max( bds.GetBiggestClearanceValue(), aZone->GetLocalClearance() ) );
@ -1626,7 +1626,7 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer
// one of the holes. Effectively this means their copper outline needs to be expanded
// to be at least as wide as the gap so that it is guaranteed to touch at least one
// edge.
EDA_RECT zone_boundingbox = aZone->GetCachedBoundingBox();
BOX2I zone_boundingbox = aZone->GetCachedBoundingBox();
SHAPE_POLY_SET aprons;
int min_apron_radius = ( aZone->GetHatchGap() * 10 ) / 19;

View File

@ -84,12 +84,13 @@ BOOST_AUTO_TEST_CASE( Default )
BOOST_CHECK_EQUAL( count, 0 );
}
EDA_RECT bbox;
BOX2I bbox;
for( int type = 0; type <= MAX_STRUCT_TYPE_ID; type++ )
{
count = 0;
for( auto item : m_tree.Overlapping( SCH_JUNCTION_T, bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( SCH_JUNCTION_T, bbox ) )
{
ignore_unused( item );
count++;
@ -127,12 +128,13 @@ BOOST_AUTO_TEST_CASE( Junctions )
BOOST_CHECK_EQUAL( count, 0 );
EDA_RECT small_bbox( VECTOR2I( -1, -1 ), VECTOR2I( Mils2iu( 2 ), Mils2iu( 2 ) ) );
EDA_RECT med_bbox( VECTOR2I( 0, 0 ), VECTOR2I( Mils2iu( 100 ), Mils2iu( 100 ) ) );
EDA_RECT big_bbox( VECTOR2I( 0, 0 ), VECTOR2I( Mils2iu( 5000 ), Mils2iu( 5000 ) ) );
BOX2I small_bbox( VECTOR2I( -1, -1 ), VECTOR2I( Mils2iu( 2 ), Mils2iu( 2 ) ) );
BOX2I med_bbox( VECTOR2I( 0, 0 ), VECTOR2I( Mils2iu( 100 ), Mils2iu( 100 ) ) );
BOX2I big_bbox( VECTOR2I( 0, 0 ), VECTOR2I( Mils2iu( 5000 ), Mils2iu( 5000 ) ) );
count = 0;
for( auto item : m_tree.Overlapping( small_bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( small_bbox ) )
{
BOOST_CHECK( small_bbox.Intersects( item->GetBoundingBox() ) );
count++;
@ -141,7 +143,8 @@ BOOST_AUTO_TEST_CASE( Junctions )
BOOST_CHECK_EQUAL( count, 1 );
count = 0;
for( auto item : m_tree.Overlapping( SCH_JUNCTION_T, small_bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( SCH_JUNCTION_T, small_bbox ) )
{
BOOST_CHECK( small_bbox.Intersects( item->GetBoundingBox() ) );
count++;
@ -150,7 +153,8 @@ BOOST_AUTO_TEST_CASE( Junctions )
BOOST_CHECK_EQUAL( count, 1 );
count = 0;
for( auto item : m_tree.Overlapping( SCH_NO_CONNECT_T, small_bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( SCH_NO_CONNECT_T, small_bbox ) )
{
BOOST_CHECK( small_bbox.Intersects( item->GetBoundingBox() ) );
count++;
@ -159,7 +163,8 @@ BOOST_AUTO_TEST_CASE( Junctions )
BOOST_CHECK_EQUAL( count, 0 );
count = 0;
for( auto item : m_tree.Overlapping( med_bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( med_bbox ) )
{
BOOST_CHECK( med_bbox.Intersects( item->GetBoundingBox() ) );
count++;
@ -168,7 +173,8 @@ BOOST_AUTO_TEST_CASE( Junctions )
BOOST_CHECK_EQUAL( count, 2 );
count = 0;
for( auto item : m_tree.Overlapping( big_bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( big_bbox ) )
{
BOOST_CHECK( big_bbox.Intersects( item->GetBoundingBox() ) );
count++;
@ -187,18 +193,18 @@ BOOST_AUTO_TEST_CASE( MixedElements )
int x_sign = ( i % 2 == 0 ) ? -1 : 1;
int y_sign = ( i % 3 == 0 ) ? -1 : 1;
SCH_JUNCTION* junction = new SCH_JUNCTION(
VECTOR2I( Mils2iu( 100 ) * i * x_sign, Mils2iu( 100 ) * i * y_sign ) );
SCH_JUNCTION* junction = new SCH_JUNCTION( VECTOR2I( Mils2iu( 100 ) * i * x_sign,
Mils2iu( 100 ) * i * y_sign ) );
m_tree.insert( junction );
SCH_NO_CONNECT* nc = new SCH_NO_CONNECT(
VECTOR2I( Mils2iu( 150 ) * i * y_sign, Mils2iu( 150 ) * i * x_sign ) );
SCH_NO_CONNECT* nc = new SCH_NO_CONNECT( VECTOR2I( Mils2iu( 150 ) * i * y_sign,
Mils2iu( 150 ) * i * x_sign ) );
m_tree.insert( nc );
}
int count = 0;
for( auto item : m_tree.OfType( SCH_JUNCTION_T ) )
for( SCH_ITEM* item : m_tree.OfType( SCH_JUNCTION_T ) )
{
ignore_unused( item );
count++;
@ -207,7 +213,8 @@ BOOST_AUTO_TEST_CASE( MixedElements )
BOOST_CHECK_EQUAL( count, 100 );
count = 0;
for( auto item : m_tree.OfType( SCH_NO_CONNECT_T ) )
for( SCH_ITEM* item : m_tree.OfType( SCH_NO_CONNECT_T ) )
{
ignore_unused( item );
count++;
@ -218,7 +225,8 @@ BOOST_AUTO_TEST_CASE( MixedElements )
EDA_RECT small_bbox( VECTOR2I( -1, -1 ), VECTOR2I( Mils2iu( 2 ), Mils2iu( 2 ) ) );
count = 0;
for( auto item : m_tree.Overlapping( small_bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( small_bbox ) )
{
BOOST_CHECK( small_bbox.Intersects( item->GetBoundingBox() ) );
count++;
@ -227,7 +235,8 @@ BOOST_AUTO_TEST_CASE( MixedElements )
BOOST_CHECK_EQUAL( count, 2 );
count = 0;
for( auto item : m_tree.Overlapping( SCH_JUNCTION_T, small_bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( SCH_JUNCTION_T, small_bbox ) )
{
BOOST_CHECK( small_bbox.Intersects( item->GetBoundingBox() ) );
count++;
@ -236,7 +245,8 @@ BOOST_AUTO_TEST_CASE( MixedElements )
BOOST_CHECK_EQUAL( count, 1 );
count = 0;
for( auto item : m_tree.Overlapping( SCH_NO_CONNECT_T, small_bbox ) )
for( SCH_ITEM* item : m_tree.Overlapping( SCH_NO_CONNECT_T, small_bbox ) )
{
BOOST_CHECK( small_bbox.Intersects( item->GetBoundingBox() ) );
count++;