Swap out some wxSize for VECTOR2I

This commit is contained in:
Marek Roszko 2022-01-04 20:42:27 -05:00
parent 98ee6c5f85
commit e4dbfcd92d
18 changed files with 64 additions and 66 deletions

View File

@ -792,8 +792,8 @@ void RENDER_3D_OPENGL::generateViasAndPads()
{
if( pad->GetAttribute() != PAD_ATTRIB::NPTH )
{
const wxSize drillsize = pad->GetDrillSize();
const bool hasHole = drillsize.x && drillsize.y;
const VECTOR2I drillsize = pad->GetDrillSize();
const bool hasHole = drillsize.x && drillsize.y;
if( !hasHole )
continue;

View File

@ -128,7 +128,7 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aSta
* @param aErrorLoc determines if the approximation error be placed outside or inside the polygon.
*/
void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aPosition,
const wxSize& aSize, double aRotation, int aDeltaX, int aDeltaY,
const VECTOR2I& aSize, double aRotation, int aDeltaX, int aDeltaY,
int aInflate, int aError, ERROR_LOC aErrorLoc );
/**

View File

@ -362,11 +362,11 @@ void CornerListRemoveDuplicates( std::vector<ROUNDED_CORNER>& aCorners )
void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aPosition,
const wxSize& aSize, double aRotation, int aDeltaX, int aDeltaY,
const VECTOR2I& aSize, double aRotation, int aDeltaX, int aDeltaY,
int aInflate, int aError, ERROR_LOC aErrorLoc )
{
SHAPE_POLY_SET outline;
wxSize size( aSize / 2 );
VECTOR2I size( aSize / 2 );
std::vector<ROUNDED_CORNER> corners;
if( aInflate < 0 )

View File

@ -1233,8 +1233,8 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
wxArrayString error_msgs;
wxArrayString warning_msgs;
wxString msg;
wxSize pad_size = m_dummyPad->GetSize();
wxSize drill_size = m_dummyPad->GetDrillSize();
VECTOR2I pad_size = m_dummyPad->GetSize();
VECTOR2I drill_size = m_dummyPad->GetDrillSize();
if( m_dummyPad->GetShape() == PAD_SHAPE::CUSTOM )
{
@ -1579,7 +1579,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
if( !m_locked->GetValue() || m_isFpEditor )
m_currentPad->SetPosition( m_padMaster->GetPosition() );
wxSize size;
VECTOR2I size;
FOOTPRINT* footprint = m_currentPad->GetParent();
m_currentPad->SetSize( m_padMaster->GetSize() );

View File

@ -111,7 +111,7 @@ static void build_pad_testpoints( BOARD *aPcb, std::vector <D356_RECORD>& aRecor
rk.pin = pad->GetNumber();
rk.refdes = footprint->GetReference();
rk.midpoint = false; // XXX MAYBE need to be computed (how?)
const wxSize& drill = pad->GetDrillSize();
const VECTOR2I& drill = pad->GetDrillSize();
rk.drill = std::min( drill.x, drill.y );
rk.hole = (rk.drill != 0);
rk.smd = pad->GetAttribute() == PAD_ATTRIB::SMD;

View File

@ -470,7 +470,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
case PAD_SHAPE::ROUNDRECT:
case PAD_SHAPE::OVAL:
{
const wxSize& size = pad->GetSize();
const VECTOR2I& size = pad->GetSize();
int radius = std::min( size.x, size.y ) / 2;
if( pad->GetShape() == PAD_SHAPE::ROUNDRECT )

View File

@ -2341,7 +2341,7 @@ void FOOTPRINT::TransformPadsWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuff
if( aSkipNonPlatedPads && !isPlated )
continue;
wxSize clearance( aClearance, aClearance );
VECTOR2I clearance( aClearance, aClearance );
switch( aLayer )
{
@ -2370,7 +2370,7 @@ void FOOTPRINT::TransformPadsWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuff
if( ( clearance.x < 0 || clearance.x != clearance.y )
&& pad->GetShape() != PAD_SHAPE::CUSTOM )
{
wxSize dummySize = pad->GetSize() + clearance + clearance;
VECTOR2I dummySize = pad->GetSize() + clearance + clearance;
if( dummySize.x <= 0 || dummySize.y <= 0 )
continue;

View File

@ -374,7 +374,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
}
else
{
wxSize half_size = m_size / 2;
VECTOR2I half_size = m_size / 2;
int half_width = std::min( half_size.x, half_size.y );
VECTOR2I half_len( half_size.x - half_width, half_size.y - half_width );
RotatePoint( half_len, m_orient );
@ -389,7 +389,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
{
int r = ( effectiveShape == PAD_SHAPE::ROUNDRECT ) ? GetRoundRectCornerRadius() : 0;
VECTOR2I half_size( m_size.x / 2, m_size.y / 2 );
wxSize trap_delta( 0, 0 );
VECTOR2I trap_delta( 0, 0 );
if( r )
{
@ -490,11 +490,10 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
}
BOX2I bbox = m_effectiveShape->BBox();
m_effectiveBoundingBox = EDA_RECT( bbox.GetPosition(),
wxSize( bbox.GetWidth(), bbox.GetHeight() ) );
m_effectiveBoundingBox = EDA_RECT( bbox.GetPosition(), VECTOR2I( bbox.GetWidth(), bbox.GetHeight() ) );
// Hole shape
wxSize half_size = m_drill / 2;
VECTOR2I half_size = m_drill / 2;
int half_width = std::min( half_size.x, half_size.y );
VECTOR2I half_len( half_size.x - half_width, half_size.y - half_width );
@ -503,8 +502,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
m_effectiveHoleShape = std::make_shared<SHAPE_SEGMENT>( m_pos - half_len, m_pos + half_len,
half_width * 2 );
bbox = m_effectiveHoleShape->BBox();
m_effectiveBoundingBox.Merge( EDA_RECT( bbox.GetPosition(),
wxSize( bbox.GetWidth(), bbox.GetHeight() ) ) );
m_effectiveBoundingBox.Merge( EDA_RECT( bbox.GetPosition(), VECTOR2I( bbox.GetWidth(), bbox.GetHeight() ) ) );
// All done
m_shapesDirty = false;
@ -597,7 +595,7 @@ void PAD::SetAttribute( PAD_ATTRIB aAttribute )
m_attribute = aAttribute;
if( aAttribute == PAD_ATTRIB::SMD )
m_drill = wxSize( 0, 0 );
m_drill = VECTOR2I( 0, 0 );
SetDirty();
}
@ -770,7 +768,7 @@ int PAD::GetSolderMaskExpansion() const
}
wxSize PAD::GetSolderPasteMargin() const
VECTOR2I PAD::GetSolderPasteMargin() const
{
// The pad inherits the margin only to calculate a default shape,
// therefore only if it is also a copper layer.
@ -779,7 +777,7 @@ wxSize PAD::GetSolderPasteMargin() const
bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
if( !isOnCopperLayer )
return wxSize( 0, 0 );
return VECTOR2I( 0, 0 );
int margin = m_localSolderPasteMargin;
double mratio = m_localSolderPasteMarginRatio;
@ -805,7 +803,7 @@ wxSize PAD::GetSolderPasteMargin() const
}
}
wxSize pad_margin;
VECTOR2I pad_margin;
pad_margin.x = margin + KiROUND( m_size.x * mratio );
pad_margin.y = margin + KiROUND( m_size.y * mratio );
@ -1415,7 +1413,7 @@ void PAD::ImportSettingsFrom( const PAD& aMasterPad )
SetOrientation( pad_rot );
SetSize( aMasterPad.GetSize() );
SetDelta( wxSize( 0, 0 ) );
SetDelta( VECTOR2I( 0, 0 ) );
SetOffset( aMasterPad.GetOffset() );
SetDrillSize( aMasterPad.GetDrillSize() );
SetDrillShape( aMasterPad.GetDrillShape() );
@ -1431,7 +1429,7 @@ void PAD::ImportSettingsFrom( const PAD& aMasterPad )
case PAD_SHAPE::CIRCLE:
// ensure size.y == size.x
SetSize( wxSize( GetSize().x, GetSize().x ) );
SetSize( VECTOR2I( GetSize().x, GetSize().x ) );
break;
default:
@ -1444,7 +1442,7 @@ void PAD::ImportSettingsFrom( const PAD& aMasterPad )
case PAD_ATTRIB::CONN:
// These pads do not have hole (they are expected to be only on one
// external copper layer)
SetDrillSize( wxSize( 0, 0 ) );
SetDrillSize( VECTOR2I( 0, 0 ) );
break;
default:
@ -1483,7 +1481,7 @@ void PAD::SwapData( BOARD_ITEM* aImage )
bool PAD::TransformHoleWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aInflateValue,
int aError, ERROR_LOC aErrorLoc ) const
{
wxSize drillsize = GetDrillSize();
VECTOR2I drillsize = GetDrillSize();
if( !drillsize.x || !drillsize.y )
return false;

View File

@ -229,18 +229,18 @@ public:
void SetY0( int y ) { m_pos0.y = y; }
void SetX0( int x ) { m_pos0.x = x; }
void SetSize( const wxSize& aSize ) { m_size = aSize; SetDirty(); }
const wxSize& GetSize() const { return m_size; }
void SetSize( const VECTOR2I& aSize ) { m_size = aSize; SetDirty(); }
const VECTOR2I& GetSize() const { return m_size; }
void SetSizeX( const int aX ) { m_size.x = aX; SetDirty(); }
const int GetSizeX() const { return m_size.x; }
void SetSizeY( const int aY ) { m_size.y = aY; SetDirty(); }
const int GetSizeY() const { return m_size.y; }
void SetDelta( const wxSize& aSize ) { m_deltaSize = aSize; SetDirty(); }
const wxSize& GetDelta() const { return m_deltaSize; }
void SetDelta( const VECTOR2I& aSize ) { m_deltaSize = aSize; SetDirty(); }
const VECTOR2I& GetDelta() const { return m_deltaSize; }
void SetDrillSize( const wxSize& aSize ) { m_drill = aSize; SetDirty(); }
const wxSize& GetDrillSize() const { return m_drill; }
void SetDrillSize( const VECTOR2I& aSize ) { m_drill = aSize; SetDirty(); }
const VECTOR2I& GetDrillSize() const { return m_drill; }
void SetDrillSizeX( const int aX ) { m_drill.x = aX; SetDirty(); }
const int GetDrillSizeX() const { return m_drill.x; }
void SetDrillSizeY( const int aY ) { m_drill.y = aY; SetDirty(); }
@ -470,7 +470,7 @@ public:
*
* @return the margin for the solder mask layer.
*/
wxSize GetSolderPasteMargin() const;
VECTOR2I GetSolderPasteMargin() const;
void SetZoneConnection( ZONE_CONNECTION aType ) { m_zoneConnection = aType; }
ZONE_CONNECTION GetZoneConnection() const { return m_zoneConnection; }
@ -707,8 +707,8 @@ private:
int m_subRatsnest; // Variable used to handle subnet (block) number in
// ratsnest computations
wxSize m_drill; // Drill diameter (x == y) or slot dimensions (x != y)
wxSize m_size; // X and Y size (relative to orient 0)
VECTOR2I m_drill; // Drill diameter (x == y) or slot dimensions (x != y)
VECTOR2I m_size; // X and Y size (relative to orient 0)
PAD_DRILL_SHAPE_T m_drillShape; // PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG
@ -733,7 +733,7 @@ private:
LSET m_layerMask; // Bitwise layer: 1 = copper layer, 15 = cmp,
// 2..14 = internal layers, 16..31 = technical layers
wxSize m_deltaSize; // Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes
VECTOR2I m_deltaSize; // Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes
// one end and half expands the other. It is only valid
// to have a single axis be non-0.

View File

@ -1045,8 +1045,8 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
}
else
{
wxSize pad_size = aPad->GetSize();
wxSize margin;
VECTOR2I pad_size = aPad->GetSize();
VECTOR2I margin;
switch( aLayer )
{

View File

@ -133,7 +133,8 @@ private:
* It compensate and clamp the drill mark size depending on the current plot options.
*/
void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const VECTOR2I& aDrillPos,
const wxSize& aDrillSize, const wxSize& aPadSize, double aOrientation,
const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
double aOrientation,
int aSmallDrill );
PLOTTER* m_plotter;

View File

@ -281,7 +281,7 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
else if( sketchPads && aLayerMask[B_Fab] )
color = aPlotOpt.ColorSettings()->GetColor( B_Fab );
wxSize margin;
VECTOR2I margin;
int width_adj = 0;
if( onCopperLayer )
@ -300,12 +300,12 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
int mask_clearance = margin.x;
// Now offset the pad size by margin + width_adj
wxSize padPlotsSize = pad->GetSize() + margin * 2 + wxSize( width_adj, width_adj );
VECTOR2I padPlotsSize = pad->GetSize() + margin * 2 + VECTOR2I( width_adj, width_adj );
// Store these parameters that can be modified to plot inflated/deflated pads shape
PAD_SHAPE padShape = pad->GetShape();
wxSize padSize = pad->GetSize();
wxSize padDelta = pad->GetDelta(); // has meaning only for trapezoidal pads
VECTOR2I padSize = pad->GetSize();
VECTOR2I padDelta = pad->GetDelta(); // has meaning only for trapezoidal pads
double padCornerRadius = pad->GetRoundRectCornerRadius();
// Don't draw a 0 sized pad.
@ -744,7 +744,7 @@ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
{
for( PAD* pad : footprint->Pads() )
{
wxSize hole = pad->GetDrillSize();
VECTOR2I hole = pad->GetDrillSize();
if( hole.x == 0 || hole.y == 0 )
continue;

View File

@ -1059,10 +1059,10 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const VECTOR2I& aDrillPos,
const wxSize& aDrillSize, const wxSize& aPadSize,
const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
double aOrientation, int aSmallDrill )
{
wxSize drillSize = aDrillSize;
VECTOR2I drillSize = aDrillSize;
// Small drill marks have no significance when applied to slots
if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )

View File

@ -1895,7 +1895,7 @@ void EAGLE_PLUGIN::packagePad( FOOTPRINT* aFootprint, wxXmlNode* aTree )
{
// The Eagle "long" pad is wider than it is tall,
// m_elongation is percent elongation
wxSize sz = pad->GetSize();
VECTOR2I sz = pad->GetSize();
sz.x = ( sz.x * ( 100 + m_rules->psElongationLong ) ) / 100;
pad->SetSize( sz );
@ -2414,7 +2414,7 @@ void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, PAD* aPad ) const
aPad->SetPos0( padPos );
// Solder mask
const wxSize& padSize( aPad->GetSize() );
const VECTOR2I& padSize( aPad->GetSize() );
aPad->SetLocalSolderMaskMargin(
eagleClamp( m_rules->mlMinStopFrame,

View File

@ -4219,7 +4219,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
case T_drill:
{
bool haveWidth = false;
wxSize drillSize = pad->GetDrillSize();
VECTOR2I drillSize = pad->GetDrillSize();
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
@ -4234,15 +4234,15 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
{
if( !haveWidth )
{
drillSize.SetWidth( parseBoardUnits() );
drillSize.x = parseBoardUnits();
// If height is not defined the width and height are the same.
drillSize.SetHeight( drillSize.GetWidth() );
drillSize.y = drillSize.x;
haveWidth = true;
}
else
{
drillSize.SetHeight( parseBoardUnits() );
drillSize.y = parseBoardUnits();
}
}

View File

@ -1454,13 +1454,13 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const
m_out->Print( 0, " (size %s)", FormatInternalUnits( aPad->GetSize() ).c_str() );
if( (aPad->GetDelta().GetWidth()) != 0 || (aPad->GetDelta().GetHeight() != 0 ) )
if( (aPad->GetDelta().x) != 0 || (aPad->GetDelta().y != 0 ) )
m_out->Print( 0, " (rect_delta %s)", FormatInternalUnits( aPad->GetDelta() ).c_str() );
wxSize sz = aPad->GetDrillSize();
VECTOR2I sz = aPad->GetDrillSize();
VECTOR2I shapeoffset = aPad->GetOffset();
if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ||
if( (sz.x > 0) || (sz.y > 0) ||
(shapeoffset.x != 0) || (shapeoffset.y != 0) )
{
m_out->Print( 0, " (drill" );
@ -1468,11 +1468,11 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const
if( aPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG )
m_out->Print( 0, " oval" );
if( sz.GetWidth() > 0 )
m_out->Print( 0, " %s", FormatInternalUnits( sz.GetWidth() ).c_str() );
if( sz.x > 0 )
m_out->Print( 0, " %s", FormatInternalUnits( sz.x ).c_str() );
if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() )
m_out->Print( 0, " %s", FormatInternalUnits( sz.GetHeight() ).c_str() );
if( sz.y > 0 && sz.x != sz.y )
m_out->Print( 0, " %s", FormatInternalUnits( sz.y ).c_str() );
if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
m_out->Print( 0, " (offset %s)", FormatInternalUnits( aPad->GetOffset() ).c_str() );

View File

@ -33,7 +33,6 @@
#include <trigo.h>
#include <xnode.h>
#include <wx/gdicmn.h>
#include <wx/string.h>
namespace PCAD2KICAD {
@ -287,13 +286,13 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
pad->SetShape( PAD_SHAPE::RECT ); // approximation
}
pad->SetSize( wxSize( width, height ) );
pad->SetDelta( wxSize( 0, 0 ) );
pad->SetSize( VECTOR2I( width, height ) );
pad->SetDelta( VECTOR2I( 0, 0 ) );
pad->SetOrientation( m_rotation + aRotation );
pad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
pad->SetOffset( wxPoint( 0, 0 ) );
pad->SetDrillSize( wxSize( m_Hole, m_Hole ) );
pad->SetOffset( VECTOR2I( 0, 0 ) );
pad->SetDrillSize( VECTOR2I( m_Hole, m_Hole ) );
pad->SetAttribute( padType );

View File

@ -493,7 +493,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, PAD* aPad )
*/
double correctionFactor = cos( M_PI / (double) circleToSegmentsCount );
int extra_clearance = KiROUND( rradius * ( 1.0 - correctionFactor ) );
wxSize psize = aPad->GetSize();
VECTOR2I psize = aPad->GetSize();
psize.x += extra_clearance * 2;
psize.y += extra_clearance * 2;
rradius += extra_clearance;