From b4492e0bd236794a9e993d36461c75ae75d41cb3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 31 Aug 2022 17:17:14 +0100 Subject: [PATCH] More EDA_RECE yeetage. --- common/bitmap_base.cpp | 1 - common/dialog_shim.cpp | 2 +- common/eda_item.cpp | 1 - common/eda_text.cpp | 23 +++++---- common/origin_viewitem.cpp | 2 +- common/stroke_params.cpp | 4 +- common/transform.cpp | 7 ++- eeschema/lib_pin.h | 1 - eeschema/sch_rtree.h | 1 - include/bitmap_base.h | 3 +- include/board_printout.h | 10 ++-- include/eda_item.h | 2 +- include/eda_text.h | 3 +- include/marker_base.h | 1 - include/transform.h | 19 ++++---- libs/kimath/include/geometry/geometry_utils.h | 4 +- libs/kimath/src/geometry/geometry_utils.cpp | 5 +- pagelayout_editor/pl_editor_layout.cpp | 14 ++---- pagelayout_editor/pl_editor_layout.h | 19 ++++---- pagelayout_editor/tools/pl_selection.cpp | 5 +- pagelayout_editor/tools/pl_selection_tool.cpp | 4 +- pcbnew/board.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 2 +- pcbnew/drc/drc_rtree.h | 17 +++---- pcbnew/drc/drc_test_provider_disallow.cpp | 10 ++-- pcbnew/drc/drc_test_provider_solder_mask.cpp | 13 +++-- pcbnew/footprint.cpp | 8 ++-- pcbnew/footprint.h | 8 ++-- pcbnew/fp_text.h | 1 - pcbnew/fp_textbox.cpp | 2 +- pcbnew/fp_textbox.h | 1 - pcbnew/netlist_reader/netlist.cpp | 4 +- pcbnew/pad.cpp | 4 +- pcbnew/pcb_bitmap.cpp | 8 ++-- pcbnew/pcb_dimension.cpp | 2 +- pcbnew/pcb_expr_evaluator.cpp | 2 +- pcbnew/pcb_marker.cpp | 3 +- pcbnew/pcb_painter.cpp | 7 +-- pcbnew/pcb_target.cpp | 2 +- pcbnew/pcb_target.h | 1 - pcbnew/pcb_text.h | 4 +- pcbnew/pcb_textbox.cpp | 2 +- pcbnew/pcb_track.cpp | 5 +- pcbnew/plugins/altium/altium_pcb.cpp | 2 +- .../specctra_export.cpp | 2 +- pcbnew/tools/edit_tool_move_fct.cpp | 4 +- pcbnew/tools/pcb_selection_tool.cpp | 6 +-- pcbnew/zone.h | 7 ++- pcbnew/zone_filler.cpp | 16 +++---- qa/unittests/eeschema/test_sch_rtree.cpp | 48 +++++++++++-------- 50 files changed, 151 insertions(+), 173 deletions(-) diff --git a/common/bitmap_base.cpp b/common/bitmap_base.cpp index 1025095d6d..8731c34cd5 100644 --- a/common/bitmap_base.cpp +++ b/common/bitmap_base.cpp @@ -23,7 +23,6 @@ */ #include -#include // for EDA_RECT #include #include // for KiROUND #include // for make_unique, unique_ptr diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 983a722523..0b0c03e582 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -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 ) diff --git a/common/eda_item.cpp b/common/eda_item.cpp index c0e5bc5d66..7d1a96b130 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 05ea226d8c..a46f8f9c58 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include // for EDA_TEXT, TEXT_EFFECTS, GR_TEXT_VJUSTIF... #include // for COLOR4D, COLOR4D::BLACK #include @@ -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; } diff --git a/common/origin_viewitem.cpp b/common/origin_viewitem.cpp index 898e60daa4..d81e391b9a 100644 --- a/common/origin_viewitem.cpp +++ b/common/origin_viewitem.cpp @@ -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 ); diff --git a/common/stroke_params.cpp b/common/stroke_params.cpp index ba37160f80..443b041315 100644 --- a/common/stroke_params.cpp +++ b/common/stroke_params.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -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 ); diff --git a/common/transform.cpp b/common/transform.cpp index 2e42ff1a81..ec8e650baa 100644 --- a/common/transform.cpp +++ b/common/transform.cpp @@ -26,9 +26,8 @@ #include #include #include -#include #include // for KiROUND - +#include 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; diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 50ec134b06..2954b00ebc 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -27,7 +27,6 @@ #ifndef CLASS_PIN_H #define CLASS_PIN_H -#include #include #include #include diff --git a/eeschema/sch_rtree.h b/eeschema/sch_rtree.h index 48a0999198..a63697e17b 100644 --- a/eeschema/sch_rtree.h +++ b/eeschema/sch_rtree.h @@ -26,7 +26,6 @@ #define EESCHEMA_SCH_RTREE_H_ #include -#include #include #include #include diff --git a/include/bitmap_base.h b/include/bitmap_base.h index 3c18dcf969..16a0d480a0 100644 --- a/include/bitmap_base.h +++ b/include/bitmap_base.h @@ -25,10 +25,9 @@ #ifndef BITMAP_BASE_H #define BITMAP_BASE_H -#include - #include #include +#include namespace KIGFX { diff --git a/include/board_printout.h b/include/board_printout.h index 7bb9c7f3e7..7de963cb1a 100644 --- a/include/board_printout.h +++ b/include/board_printout.h @@ -25,22 +25,18 @@ */ -/** - * @file board_printout.h - * @brief Board print handler definition file. - */ - #ifndef BOARD_PRINTOUT_H #define BOARD_PRINTOUT_H #include #include -#include #include +#include #include -namespace KIGFX { +namespace KIGFX +{ class GAL; class VIEW; class PAINTER; diff --git a/include/eda_item.h b/include/eda_item.h index 3b711323f8..117c0d7b11 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -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. diff --git a/include/eda_text.h b/include/eda_text.h index ee9ef525b8..dfdc7c820f 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -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; diff --git a/include/marker_base.h b/include/marker_base.h index 34cbaf213b..3095e2a8f2 100644 --- a/include/marker_base.h +++ b/include/marker_base.h @@ -30,7 +30,6 @@ #include #include -#include class SHAPE_LINE_CHAIN; diff --git a/include/transform.h b/include/transform.h index 298a84c1f6..726302bfe8 100644 --- a/include/transform.h +++ b/include/transform.h @@ -32,8 +32,8 @@ #include #include +#include -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; diff --git a/libs/kimath/include/geometry/geometry_utils.h b/libs/kimath/include/geometry/geometry_utils.h index 607353e022..b80d1e9bf7 100644 --- a/libs/kimath/include/geometry/geometry_utils.h +++ b/libs/kimath/include/geometry/geometry_utils.h @@ -32,7 +32,7 @@ #include // for copysign #include // for abs -#include +#include #include class EDA_RECT; @@ -187,7 +187,7 @@ VECTOR2 GetClampedCoords( const VECTOR2& 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 diff --git a/libs/kimath/src/geometry/geometry_utils.cpp b/libs/kimath/src/geometry/geometry_utils.cpp index 8c89096420..adb2888ae8 100644 --- a/libs/kimath/src/geometry/geometry_utils.cpp +++ b/libs/kimath/src/geometry/geometry_utils.cpp @@ -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; } diff --git a/pagelayout_editor/pl_editor_layout.cpp b/pagelayout_editor/pl_editor_layout.cpp index 7ccd9d14cf..66b7adaddd 100644 --- a/pagelayout_editor/pl_editor_layout.cpp +++ b/pagelayout_editor/pl_editor_layout.cpp @@ -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 -#include - #include -#include -#include #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; diff --git a/pagelayout_editor/pl_editor_layout.h b/pagelayout_editor/pl_editor_layout.h index 8bce30cd76..40da21ed0e 100644 --- a/pagelayout_editor/pl_editor_layout.h +++ b/pagelayout_editor/pl_editor_layout.h @@ -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 diff --git a/pagelayout_editor/tools/pl_selection.cpp b/pagelayout_editor/tools/pl_selection.cpp index a33ab2a15a..2a146e99e2 100644 --- a/pagelayout_editor/tools/pl_selection.cpp +++ b/pagelayout_editor/tools/pl_selection.cpp @@ -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 -#include -#include "tools/pl_selection.h" +#include EDA_ITEM* PL_SELECTION::GetTopLeftItem( bool onlyModules ) const diff --git a/pagelayout_editor/tools/pl_selection_tool.cpp b/pagelayout_editor/tools/pl_selection_tool.cpp index 84a07a5b52..e67324d0c7 100644 --- a/pagelayout_editor/tools/pl_selection_tool.cpp +++ b/pagelayout_editor/tools/pl_selection_tool.cpp @@ -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(); diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index b2db121305..158475b071 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -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; diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 86902c9e59..687ae2b6ba 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -1296,7 +1296,7 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK() { for( const std::shared_ptr& shape : m_dummyPad->GetPrimitives() ) { - EDA_RECT shapeBBox = shape->GetBoundingBox(); + BOX2I shapeBBox = shape->GetBoundingBox(); if( absMargin > shapeBBox.GetWidth() || absMargin > shapeBBox.GetHeight() ) { diff --git a/pcbnew/drc/drc_rtree.h b/pcbnew/drc/drc_rtree.h index 264f56dcd2..3d171282ab 100644 --- a/pcbnew/drc/drc_rtree.h +++ b/pcbnew/drc/drc_rtree.h @@ -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( 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 ); } diff --git a/pcbnew/drc/drc_test_provider_disallow.cpp b/pcbnew/drc/drc_test_provider_disallow.cpp index 25a81c4f68..5f6af5a508 100644 --- a/pcbnew/drc/drc_test_provider_disallow.cpp +++ b/pcbnew/drc/drc_test_provider_disallow.cpp @@ -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 ) ) { diff --git a/pcbnew/drc/drc_test_provider_solder_mask.cpp b/pcbnew/drc/drc_test_provider_solder_mask.cpp index 1e427a65ca..1a0873c357 100644 --- a/pcbnew/drc/drc_test_provider_solder_mask.cpp +++ b/pcbnew/drc/drc_test_provider_solder_mask.cpp @@ -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( aItem )->GetSolderMaskExpansion(); diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index d5552fb4c0..b6be8fccfb 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -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( bbox.GetWidth() ) ) + aPadding; double h = std::abs( static_cast( 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). diff --git a/pcbnew/footprint.h b/pcbnew/footprint.h index ee091e1e06..daeec91130 100644 --- a/pcbnew/footprint.h +++ b/pcbnew/footprint.h @@ -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; diff --git a/pcbnew/fp_text.h b/pcbnew/fp_text.h index 4fa9d68683..7eade6f8a3 100644 --- a/pcbnew/fp_text.h +++ b/pcbnew/fp_text.h @@ -29,7 +29,6 @@ #include class LINE_READER; -class EDA_RECT; class FOOTPRINT; class MSG_PANEL_ITEM; class PCB_BASE_FRAME; diff --git a/pcbnew/fp_textbox.cpp b/pcbnew/fp_textbox.cpp index 40e1f32032..b480704eb5 100644 --- a/pcbnew/fp_textbox.cpp +++ b/pcbnew/fp_textbox.cpp @@ -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 ); diff --git a/pcbnew/fp_textbox.h b/pcbnew/fp_textbox.h index 1e9a977613..e865901ec1 100644 --- a/pcbnew/fp_textbox.h +++ b/pcbnew/fp_textbox.h @@ -28,7 +28,6 @@ #include class LINE_READER; -class EDA_RECT; class FOOTPRINT; class MSG_PANEL_ITEM; class PCB_BASE_FRAME; diff --git a/pcbnew/netlist_reader/netlist.cpp b/pcbnew/netlist_reader/netlist.cpp index f7831b08c1..55174e99fb 100644 --- a/pcbnew/netlist_reader/netlist.cpp +++ b/pcbnew/netlist_reader/netlist.cpp @@ -100,8 +100,8 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater, bool* aR std::vector 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 ); diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index c0861b7add..ca79f452fa 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -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; diff --git a/pcbnew/pcb_bitmap.cpp b/pcbnew/pcb_bitmap.cpp index d4a82ae68a..d3ea64fd80 100644 --- a/pcbnew/pcb_bitmap.cpp +++ b/pcbnew/pcb_bitmap.cpp @@ -132,9 +132,9 @@ const BOX2I PCB_BITMAP::GetBoundingBox() const std::shared_ptr PCB_BITMAP::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const { - EDA_RECT box = GetBoundingBox(); - return std::shared_ptr( - new SHAPE_RECT( box.GetCenter(), box.GetWidth(), box.GetHeight() ) ); + BOX2I box = GetBoundingBox(); + return std::shared_ptr( 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 ); diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index 58e879fafe..d762244aec 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -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 ); diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp index 4a051f4cf1..df7820d0e3 100644 --- a/pcbnew/pcb_expr_evaluator.cpp +++ b/pcbnew/pcb_expr_evaluator.cpp @@ -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; // Collisions include touching, so we need to deflate outline by enough to exclude it. diff --git a/pcbnew/pcb_marker.cpp b/pcbnew/pcb_marker.cpp index 807c7edb42..97d4f72774 100644 --- a/pcbnew/pcb_marker.cpp +++ b/pcbnew/pcb_marker.cpp @@ -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(); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 8bb7717304..a9e930760e 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -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(); diff --git a/pcbnew/pcb_target.cpp b/pcbnew/pcb_target.cpp index c2e2c5f905..c20fa6fcd4 100644 --- a/pcbnew/pcb_target.cpp +++ b/pcbnew/pcb_target.cpp @@ -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 ); diff --git a/pcbnew/pcb_target.h b/pcbnew/pcb_target.h index 9c5ec92d22..62f8854cf3 100644 --- a/pcbnew/pcb_target.h +++ b/pcbnew/pcb_target.h @@ -28,7 +28,6 @@ #include -class EDA_RECT; class LINE_READER; diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index 1b8cea0763..2e1a42e2d9 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -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 { diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index d3c2156904..730d6967e7 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -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 ); diff --git a/pcbnew/pcb_track.cpp b/pcbnew/pcb_track.cpp index 76642b4cd1..9f9d340927 100644 --- a/pcbnew/pcb_track.cpp +++ b/pcbnew/pcb_track.cpp @@ -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() ); diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 3514b0b49b..d32f8a87b1 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -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 diff --git a/pcbnew/specctra_import_export/specctra_export.cpp b/pcbnew/specctra_import_export/specctra_export.cpp index afdb058b51..64c254f608 100644 --- a/pcbnew/specctra_import_export/specctra_export.cpp +++ b/pcbnew/specctra_import_export/specctra_export.cpp @@ -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(), diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index bd721ca3ad..3df0a88ff5 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -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; diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index c319b52d12..5fcdf0f63a 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -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( aItem ); - EDA_RECT bbox = footprint->GetBoundingBox( false, false ); + BOX2I bbox = footprint->GetBoundingBox( false, false ); try { diff --git a/pcbnew/zone.h b/pcbnew/zone.h index 5542238bbb..8840db2ac5 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -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> m_FilledPolysList; /// Temp variables used while filling - EDA_RECT m_bboxCache; + BOX2I m_bboxCache; std::map m_fillFlags; /// A hash value used in zone filling calculations to see if the filled areas are up to date diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 1b989416da..888da6b5cd 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -203,7 +203,7 @@ bool ZONE_FILLER::Fill( std::vector& 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& 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& 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; diff --git a/qa/unittests/eeschema/test_sch_rtree.cpp b/qa/unittests/eeschema/test_sch_rtree.cpp index 16c741078d..e435465be5 100644 --- a/qa/unittests/eeschema/test_sch_rtree.cpp +++ b/qa/unittests/eeschema/test_sch_rtree.cpp @@ -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++;