7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 09:51:40 +00:00

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 ) )
{

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