Retire Local/Draw coords distinction from PAD (the last object to have it).

This commit is contained in:
Jeff Young 2023-04-02 18:02:41 +01:00
parent 7ca057ea02
commit 28028c941e
27 changed files with 58 additions and 183 deletions

View File

@ -88,7 +88,7 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags )
if( aFlags & HASH_POS ) if( aFlags & HASH_POS )
{ {
if( aFlags & REL_COORD ) if( aFlags & REL_COORD )
hash_combine( ret, pad->GetPos0().x, pad->GetPos0().y ); hash_combine( ret, pad->GetFPRelativePosition().x, pad->GetFPRelativePosition().y );
else else
hash_combine( ret, pad->GetPosition().x, pad->GetPosition().y ); hash_combine( ret, pad->GetPosition().x, pad->GetPosition().y );
} }

View File

@ -1653,11 +1653,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
if( footprint ) if( footprint )
{ {
// compute the pos 0 value, i.e. pad position for footprint with orientation = 0 m_currentPad->SetFPRelativePosition( m_currentPad->GetPosition() );
// i.e. relative to footprint origin (footprint position)
VECTOR2I pt = m_currentPad->GetPosition() - footprint->GetPosition();
RotatePoint( pt, -footprint->GetOrientation() );
m_currentPad->SetPos0( pt );
m_currentPad->SetOrientation( m_currentPad->GetOrientation() + footprint->GetOrientation() ); m_currentPad->SetOrientation( m_currentPad->GetOrientation() + footprint->GetOrientation() );
} }

View File

@ -179,7 +179,7 @@ bool padNeedsUpdate( const PAD* a, const PAD* b )
bool diff = false; bool diff = false;
TEST( a->GetPadToDieLength(), b->GetPadToDieLength(), "" ); TEST( a->GetPadToDieLength(), b->GetPadToDieLength(), "" );
TEST( a->GetPos0(), b->GetPos0(), "" ); TEST( a->GetFPRelativePosition(), b->GetFPRelativePosition(), "" );
TEST( a->GetNumber(), b->GetNumber(), "" ); TEST( a->GetNumber(), b->GetNumber(), "" );

View File

@ -830,13 +830,15 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
EDA_ANGLE orient = pad->GetOrientation() - footprint->GetOrientation(); EDA_ANGLE orient = pad->GetOrientation() - footprint->GetOrientation();
orient.Normalize(); orient.Normalize();
VECTOR2I padPos = pad->GetFPRelativePosition();
// Bottom side footprints use the flipped padstack // Bottom side footprints use the flipped padstack
fprintf( aFile, ( flipBottomPads && footprint->GetFlag() ) ? fprintf( aFile, ( flipBottomPads && footprint->GetFlag() ) ?
"PIN \"%s\" PAD%dF %g %g %s %g %s\n" : "PIN \"%s\" PAD%dF %g %g %s %g %s\n" :
"PIN \"%s\" PAD%d %g %g %s %g %s\n", "PIN \"%s\" PAD%d %g %g %s %g %s\n",
TO_UTF8( escapeString( pinname ) ), pad->GetSubRatsnest(), TO_UTF8( escapeString( pinname ) ), pad->GetSubRatsnest(),
pad->GetPos0().x / SCALE_FACTOR, padPos.x / SCALE_FACTOR,
-pad->GetPos0().y / SCALE_FACTOR, -padPos.y / SCALE_FACTOR,
layer, orient.AsDegrees(), mirror ); layer, orient.AsDegrees(), mirror );
} }
} }

View File

@ -233,7 +233,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
buffer += "\n"; buffer += "\n";
snprintf(line, sizeof(line), "%-*s %-*s %-*s %9.9s %9.9s %8.8s %s\n", snprintf( line, sizeof(line), "%-*s %-*s %-*s %9.9s %9.9s %8.8s %s\n",
int(lenRefText), "# Ref", int(lenRefText), "# Ref",
int(lenValText), "Val", int(lenValText), "Val",
int(lenPkgText), "Package", int(lenPkgText), "Package",
@ -258,7 +258,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
ref.Replace( wxT( " " ), wxT( "_" ) ); ref.Replace( wxT( " " ), wxT( "_" ) );
val.Replace( wxT( " " ), wxT( "_" ) ); val.Replace( wxT( " " ), wxT( "_" ) );
pkg.Replace( wxT( " " ), wxT( "_" ) ); pkg.Replace( wxT( " " ), wxT( "_" ) );
snprintf(line, sizeof(line), "%-*s %-*s %-*s %9.4f %9.4f %8.4f %s\n", snprintf( line, sizeof(line), "%-*s %-*s %-*s %9.4f %9.4f %8.4f %s\n",
lenRefText, TO_UTF8( ref ), lenRefText, TO_UTF8( ref ),
lenValText, TO_UTF8( val ), lenValText, TO_UTF8( val ),
lenPkgText, TO_UTF8( pkg ), lenPkgText, TO_UTF8( pkg ),
@ -400,9 +400,11 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
layer_name[layer] ); layer_name[layer] );
buffer += line; buffer += line;
VECTOR2I padPos = pad->GetFPRelativePosition();
snprintf( line, sizeof(line), "position %9.6f %9.6f size %9.6f %9.6f orientation %.2f\n", snprintf( line, sizeof(line), "position %9.6f %9.6f size %9.6f %9.6f orientation %.2f\n",
pad->GetPos0().x * conv_unit, padPos.x * conv_unit,
pad->GetPos0().y * conv_unit, padPos.y * conv_unit,
pad->GetSize().x * conv_unit, pad->GetSize().x * conv_unit,
pad->GetSize().y * conv_unit, pad->GetSize().y * conv_unit,
( pad->GetOrientation() - footprint->GetOrientation() ).AsDegrees() ); ( pad->GetOrientation() - footprint->GetOrientation() ).AsDegrees() );

View File

@ -1692,10 +1692,7 @@ void FOOTPRINT::MoveAnchorPosition( const VECTOR2I& aMoveVector )
// Update the pad local coordinates. // Update the pad local coordinates.
for( PAD* pad : m_pads ) for( PAD* pad : m_pads )
{ pad->Move( moveVector );
pad->SetPos0( pad->GetPos0() + moveVector );
pad->SetDrawCoord();
}
// Update the draw element coordinates. // Update the draw element coordinates.
for( BOARD_ITEM* item : GraphicalItems() ) for( BOARD_ITEM* item : GraphicalItems() )
@ -1727,10 +1724,7 @@ void FOOTPRINT::SetOrientation( const EDA_ANGLE& aNewAngle )
m_orient.Normalize180(); m_orient.Normalize180();
for( PAD* pad : m_pads ) for( PAD* pad : m_pads )
{ pad->Rotate( GetPosition(), angleChange );
pad->SetOrientation( pad->GetOrientation() + angleChange );
pad->SetDrawCoord();
}
for( ZONE* zone : m_zones ) for( ZONE* zone : m_zones )
zone->Rotate( GetPosition(), angleChange ); zone->Rotate( GetPosition(), angleChange );
@ -2598,7 +2592,7 @@ bool FOOTPRINT::cmp_pads::operator()( const PAD* aFirst, const PAD* aSecond ) co
if( aFirst->GetNumber() != aSecond->GetNumber() ) if( aFirst->GetNumber() != aSecond->GetNumber() )
return StrNumCmp( aFirst->GetNumber(), aSecond->GetNumber() ) < 0; return StrNumCmp( aFirst->GetNumber(), aSecond->GetNumber() ) < 0;
TEST_PT( aFirst->GetPos0(), aSecond->GetPos0() ); TEST_PT( aFirst->GetFPRelativePosition(), aSecond->GetFPRelativePosition() );
TEST_PT( aFirst->GetSize(), aSecond->GetSize() ); TEST_PT( aFirst->GetSize(), aSecond->GetSize() );
TEST( aFirst->GetShape(), aSecond->GetShape() ); TEST( aFirst->GetShape(), aSecond->GetShape() );
TEST( aFirst->GetLayerSet().Seq(), aSecond->GetLayerSet().Seq() ); TEST( aFirst->GetLayerSet().Seq(), aSecond->GetLayerSet().Seq() );

View File

@ -213,7 +213,6 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
PAD* pad = (PAD*) item->Clone(); PAD* pad = (PAD*) item->Clone();
footprint->SetPosition( pad->GetPosition() ); footprint->SetPosition( pad->GetPosition() );
pad->SetPos0( VECTOR2I() );
footprint->Add( pad ); footprint->Add( pad );
copy = footprint; copy = footprint;
} }

View File

@ -33,7 +33,8 @@
FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprintShape ) FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprintShape )
{ {
int oX; int offsetX;
int offsetY;
PAD* pad; PAD* pad;
FOOTPRINT* footprint; FOOTPRINT* footprint;
wxString msg; wxString msg;
@ -125,23 +126,22 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
switch( aFootprintShape ) switch( aFootprintShape )
{ {
case MICROWAVE_FOOTPRINT_SHAPE::GAP: //Gap : case MICROWAVE_FOOTPRINT_SHAPE::GAP: //Gap :
oX = -( gap_size + pad->GetSize().x ) / 2; offsetX = -( gap_size + pad->GetSize().x ) / 2;
pad->SetX0( oX );
pad->SetX( pad->GetPos0().x + pad->GetPosition().x ); pad->SetX( pad->GetPosition().x + offsetX );
pad = *( it + 1 ); pad = *( it + 1 );
pad->SetX0( oX + gap_size + pad->GetSize().x ); pad->SetX( pad->GetPosition().x + offsetX + gap_size + pad->GetSize().x );
pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
break; break;
case MICROWAVE_FOOTPRINT_SHAPE::STUB: //Stub : case MICROWAVE_FOOTPRINT_SHAPE::STUB: //Stub :
pad->SetNumber( wxT( "1" ) ); pad->SetNumber( wxT( "1" ) );
offsetY = -( gap_size + pad->GetSize().y ) / 2;
pad = *( it + 1 ); pad = *( it + 1 );
pad->SetY0( -( gap_size + pad->GetSize().y ) / 2 );
pad->SetSize( VECTOR2I( pad->GetSize().x, gap_size ) ); pad->SetSize( VECTOR2I( pad->GetSize().x, gap_size ) );
pad->SetY( pad->GetPos0().y + pad->GetPosition().y ); pad->SetY( pad->GetPosition().y + offsetY );
break; break;
case MICROWAVE_FOOTPRINT_SHAPE::STUB_ARC: // Arc Stub created by a polygonal approach: case MICROWAVE_FOOTPRINT_SHAPE::STUB_ARC: // Arc Stub created by a polygonal approach:

View File

@ -432,7 +432,6 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
pad->SetNumber( wxT( "1" ) ); pad->SetNumber( wxT( "1" ) );
pad->SetPosition( aInductorPattern.m_End ); pad->SetPosition( aInductorPattern.m_End );
pad->SetPos0( pad->GetPosition() - footprint->GetPosition() );
pad->SetSize( VECTOR2I( aInductorPattern.m_Width, aInductorPattern.m_Width ) ); pad->SetSize( VECTOR2I( aInductorPattern.m_Width, aInductorPattern.m_Width ) );
@ -448,7 +447,6 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
pad = newpad; pad = newpad;
pad->SetNumber( wxT( "2" ) ); pad->SetNumber( wxT( "2" ) );
pad->SetPosition( aInductorPattern.m_Start ); pad->SetPosition( aInductorPattern.m_Start );
pad->SetPos0( pad->GetPosition() - footprint->GetPosition() );
// Modify text positions. // Modify text positions.
VECTOR2I refPos( ( aInductorPattern.m_Start.x + aInductorPattern.m_End.x ) / 2, VECTOR2I refPos( ( aInductorPattern.m_Start.x + aInductorPattern.m_End.x ) / 2,

View File

@ -333,12 +333,10 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
auto it = footprint->Pads().begin(); auto it = footprint->Pads().begin();
pad1 = *it; pad1 = *it;
pad1->SetX0( offset.x ); pad1->SetX( offset.x );
pad1->SetX( pad1->GetPos0().x );
pad2 = *( ++it ); pad2 = *( ++it );
pad2->SetX0( offset.x + g_ShapeSize.x ); pad2->SetX( offset.x + g_ShapeSize.x );
pad2->SetX( pad2->GetPos0().x );
// Add a polygonal edge (corners will be added later) on copper layer // Add a polygonal edge (corners will be added later) on copper layer
shape = new PCB_SHAPE( footprint, SHAPE_T::POLY ); shape = new PCB_SHAPE( footprint, SHAPE_T::POLY );
@ -386,8 +384,6 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
} }
shape->SetPolyPoints( polyPoints ); shape->SetPolyPoints( polyPoints );
shape->Rotate( { 0, 0 }, footprint->GetOrientation() );
shape->Move( footprint->GetPosition() );
// Set the polygon outline thickness to 0, only the polygonal shape is filled // Set the polygon outline thickness to 0, only the polygonal shape is filled
// without extra thickness. // without extra thickness.

View File

@ -126,7 +126,6 @@ PAD& PAD::operator=( const PAD &aOther )
ImportSettingsFrom( aOther ); ImportSettingsFrom( aOther );
SetPadToDieLength( aOther.GetPadToDieLength() ); SetPadToDieLength( aOther.GetPadToDieLength() );
SetPosition( aOther.GetPosition() ); SetPosition( aOther.GetPosition() );
SetPos0( aOther.GetPos0() );
SetNumber( aOther.GetNumber() ); SetNumber( aOther.GetNumber() );
SetPinType( aOther.GetPinType() ); SetPinType( aOther.GetPinType() );
SetPinFunction( aOther.GetPinFunction() ); SetPinFunction( aOther.GetPinFunction() );
@ -641,37 +640,6 @@ const BOX2I PAD::GetBoundingBox() const
} }
void PAD::SetDrawCoord()
{
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
m_pos = m_pos0;
if( parentFootprint == nullptr )
return;
RotatePoint( &m_pos.x, &m_pos.y, parentFootprint->GetOrientation() );
m_pos += parentFootprint->GetPosition();
SetDirty();
}
void PAD::SetLocalCoord()
{
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
if( parentFootprint == nullptr )
{
m_pos0 = m_pos;
return;
}
m_pos0 = m_pos - parentFootprint->GetPosition();
RotatePoint( &m_pos0.x, &m_pos0.y, -parentFootprint->GetOrientation() );
}
void PAD::SetAttribute( PAD_ATTRIB aAttribute ) void PAD::SetAttribute( PAD_ATTRIB aAttribute )
{ {
m_attribute = aAttribute; m_attribute = aAttribute;
@ -705,14 +673,12 @@ void PAD::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
if( aFlipLeftRight ) if( aFlipLeftRight )
{ {
MIRROR( m_pos.x, aCentre.x ); MIRROR( m_pos.x, aCentre.x );
MIRROR( m_pos0.x, 0 );
MIRROR( m_offset.x, 0 ); MIRROR( m_offset.x, 0 );
MIRROR( m_deltaSize.x, 0 ); MIRROR( m_deltaSize.x, 0 );
} }
else else
{ {
MIRROR( m_pos.y, aCentre.y ); MIRROR( m_pos.y, aCentre.y );
MIRROR( m_pos0.y, 0 );
MIRROR( m_offset.y, 0 ); MIRROR( m_offset.y, 0 );
MIRROR( m_deltaSize.y, 0 ); MIRROR( m_deltaSize.y, 0 );
} }
@ -1204,8 +1170,6 @@ void PAD::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
m_orient += aAngle; m_orient += aAngle;
m_orient.Normalize(); m_orient.Normalize();
SetLocalCoord();
SetDirty(); SetDirty();
} }

View File

@ -247,12 +247,6 @@ public:
void SetY( int y ) { m_pos.y = y; SetDirty(); } void SetY( int y ) { m_pos.y = y; SetDirty(); }
void SetX( int x ) { m_pos.x = x; SetDirty(); } void SetX( int x ) { m_pos.x = x; SetDirty(); }
void SetPos0( const VECTOR2I& aPos ) { m_pos0 = aPos; }
const VECTOR2I& GetPos0() const { return m_pos0; }
void SetY0( int y ) { m_pos0.y = y; }
void SetX0( int x ) { m_pos0.x = x; }
void SetSize( const VECTOR2I& aSize ) { m_size = aSize; SetDirty(); } void SetSize( const VECTOR2I& aSize ) { m_size = aSize; SetDirty(); }
const VECTOR2I& GetSize() const { return m_size; } const VECTOR2I& GetSize() const { return m_size; }
void SetSizeX( const int aX ) { m_size.x = aX; SetDirty(); } void SetSizeX( const int aX ) { m_size.x = aX; SetDirty(); }
@ -676,13 +670,6 @@ public:
*/ */
const BOX2I GetBoundingBox() const override; const BOX2I GetBoundingBox() const override;
/// Set absolute coordinates.
void SetDrawCoord();
//todo: Remove SetLocalCoord along with m_pos
/// Set relative coordinates.
void SetLocalCoord();
/** /**
* Compare two pads and return 0 if they are equal. * Compare two pads and return 0 if they are equal.
* *
@ -694,7 +681,6 @@ public:
void Move( const VECTOR2I& aMoveVector ) override void Move( const VECTOR2I& aMoveVector ) override
{ {
m_pos += aMoveVector; m_pos += aMoveVector;
SetLocalCoord();
SetDirty(); SetDirty();
} }
@ -834,9 +820,6 @@ private:
// one end and half expands the other. It is only valid // one end and half expands the other. It is only valid
// to have a single axis be non-0. // to have a single axis be non-0.
VECTOR2I m_pos0; // Initial Pad position (i.e. pad position relative to the
// footprint anchor, orientation 0)
PAD_ATTRIB m_attribute; // PAD_ATTRIB_NORMAL, PAD_ATTRIB::SMD, PAD_ATTRIB::CONN, PAD_ATTRIB m_attribute; // PAD_ATTRIB_NORMAL, PAD_ATTRIB::SMD, PAD_ATTRIB::CONN,
// PAD_ATTRIB::NPTH // PAD_ATTRIB::NPTH
PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.) PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)

View File

@ -2373,8 +2373,6 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con
pad->SetPosition( aElem.position ); pad->SetPosition( aElem.position );
pad->SetOrientationDegrees( aElem.direction ); pad->SetOrientationDegrees( aElem.direction );
pad->SetLocalCoord();
pad->SetSize( aElem.topsize ); pad->SetSize( aElem.topsize );
if( aElem.holesize == 0 ) if( aElem.holesize == 0 )

View File

@ -898,7 +898,6 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers( const SYMDEF_PCB& aComponen
pad->SetAnchorPadShape( PAD_SHAPE::CIRCLE ); pad->SetAnchorPadShape( PAD_SHAPE::CIRCLE );
pad->SetSize( { anchorSize, anchorSize } ); pad->SetSize( { anchorSize, anchorSize } );
pad->SetPosition( anchorPos ); pad->SetPosition( anchorPos );
pad->SetLocalCoord();
SHAPE_POLY_SET shapePolys = getPolySetFromCadstarShape( compCopper.Shape, SHAPE_POLY_SET shapePolys = getPolySetFromCadstarShape( compCopper.Shape,
lineThickness, lineThickness,
@ -1243,7 +1242,6 @@ PAD* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad( const COMPONENT_PAD& aCadstarPad,
int maxError = m_board->GetDesignSettings().m_MaxError; int maxError = m_board->GetDesignSettings().m_MaxError;
pad->SetPosition( { 0, 0 } ); pad->SetPosition( { 0, 0 } );
pad->SetPos0( { 0, 0 } );
pad->TransformShapeToPolygon( padOutline, layer, 0, maxError, ERROR_INSIDE ); pad->TransformShapeToPolygon( padOutline, layer, 0, maxError, ERROR_INSIDE );
PCB_SHAPE* padShape = new PCB_SHAPE; PCB_SHAPE* padShape = new PCB_SHAPE;
@ -1296,8 +1294,6 @@ PAD* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad( const COMPONENT_PAD& aCadstarPad,
RotatePoint( padOffset, padOrientation ); RotatePoint( padOffset, padOrientation );
RotatePoint( drillOffset, padOrientation ); RotatePoint( drillOffset, padOrientation );
pad->SetPos0( getKiCadPoint( aCadstarPad.Position ) - aParent->GetPosition() - padOffset
- drillOffset );
pad->SetPosition( getKiCadPoint( aCadstarPad.Position ) - padOffset - drillOffset ); pad->SetPosition( getKiCadPoint( aCadstarPad.Position ) - padOffset - drillOffset );
pad->SetOrientation( padOrientation + getAngle( csPadcode.SlotOrientation ) ); pad->SetOrientation( padOrientation + getAngle( csPadcode.SlotOrientation ) );

View File

@ -2355,13 +2355,11 @@ void EAGLE_PLUGIN::packageHole( FOOTPRINT* aFootprint, wxXmlNode* aTree, bool aC
if( aCenter ) if( aCenter )
{ {
pad->SetPos0( VECTOR2I( 0, 0 ) );
aFootprint->SetPosition( padpos ); aFootprint->SetPosition( padpos );
pad->SetPosition( padpos ); pad->SetPosition( padpos );
} }
else else
{ {
pad->SetPos0( padpos );
pad->SetPosition( padpos + aFootprint->GetPosition() ); pad->SetPosition( padpos + aFootprint->GetPosition() );
} }
@ -2453,10 +2451,7 @@ void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, PAD* aPad ) const
{ {
aPad->SetNumber( aEaglePad.name ); aPad->SetNumber( aEaglePad.name );
// pad's "Position" is not relative to the footprint's,
// whereas Pos0 is relative to the footprint's but is the unrotated coordinate.
VECTOR2I padPos( kicad_x( aEaglePad.x ), kicad_y( aEaglePad.y ) ); VECTOR2I padPos( kicad_x( aEaglePad.x ), kicad_y( aEaglePad.y ) );
aPad->SetPos0( padPos );
// Solder mask // Solder mask
const VECTOR2I& padSize( aPad->GetSize() ); const VECTOR2I& padSize( aPad->GetSize() );

View File

@ -2409,8 +2409,6 @@ bool FABMASTER::loadFootprints( BOARD* aBoard )
} }
} }
newpad->SetLocalCoord();
if( src->mirror ) if( src->mirror )
newpad->SetOrientation( EDA_ANGLE( -src->rotate + pin->rotation, DEGREES_T ) ); newpad->SetOrientation( EDA_ANGLE( -src->rotate + pin->rotation, DEGREES_T ) );
else else

View File

@ -596,8 +596,6 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
pad->SetSize( VECTOR2I( KiROUND( EuclideanNorm( delta ) ) + width, width ) ); pad->SetSize( VECTOR2I( KiROUND( EuclideanNorm( delta ) ) + width, width ) );
// Set the relative position before adjusting the absolute position
pad->SetPos0( padPos );
padPos += footprint->GetPosition(); padPos += footprint->GetPosition();
pad->SetPosition( padPos ); pad->SetPosition( padPos );
@ -688,8 +686,6 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
pad->SetDrillSize( VECTOR2I( drillSize, drillSize ) ); pad->SetDrillSize( VECTOR2I( drillSize, drillSize ) );
// Set the relative position before adjusting the absolute position
pad->SetPos0( padPos );
padPos += footprint->GetPosition(); padPos += footprint->GetPosition();
pad->SetPosition( padPos ); pad->SetPosition( padPos );

View File

@ -3931,14 +3931,8 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
case T_pad: case T_pad:
{ {
if( PAD* pad = parsePAD( footprint.get() ) ) PAD* pad = parsePAD( footprint.get() );
{
pt = pad->GetPos0();
RotatePoint( pt, footprint->GetOrientation() );
pad->SetPosition( pt + footprint->GetPosition() );
footprint->Add( pad, ADD_MODE::APPEND, true ); footprint->Add( pad, ADD_MODE::APPEND, true );
}
break; break;
} }
@ -4121,7 +4115,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
case T_at: case T_at:
pt.x = parseBoardUnits( "X coordinate" ); pt.x = parseBoardUnits( "X coordinate" );
pt.y = parseBoardUnits( "Y coordinate" ); pt.y = parseBoardUnits( "Y coordinate" );
pad->SetPos0( pt ); pad->SetFPRelativePosition( pt );
token = NextTok(); token = NextTok();
if( token == T_NUMBER ) if( token == T_NUMBER )

View File

@ -1396,7 +1396,7 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const
if( aPad->IsLocked() ) if( aPad->IsLocked() )
m_out->Print( 0, " locked" ); m_out->Print( 0, " locked" );
m_out->Print( 0, " (at %s", formatInternalUnits( aPad->GetPos0() ).c_str() ); m_out->Print( 0, " (at %s", formatInternalUnits( aPad->GetFPRelativePosition() ).c_str() );
if( !aPad->GetOrientation().IsZero() ) if( !aPad->GetOrientation().IsZero() )
m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatAngle( aPad->GetOrientation() ).c_str() ); m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatAngle( aPad->GetOrientation() ).c_str() );

View File

@ -1459,8 +1459,7 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
pos.x = biuParse( line + SZ( "Po" ), &data ); pos.x = biuParse( line + SZ( "Po" ), &data );
pos.y = biuParse( data ); pos.y = biuParse( data );
pad->SetPos0( pos ); pad->SetFPRelativePosition( pos );
// pad->SetPosition( pos ); set at function return
} }
else if( TESTLINE( "Le" ) ) else if( TESTLINE( "Le" ) )
{ {
@ -1504,15 +1503,6 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
} }
else if( TESTLINE( "$EndPAD" ) ) else if( TESTLINE( "$EndPAD" ) )
{ {
// pad's "Position" is not relative to the footprint's, whereas Pos0 is relative
// to the footprint's but is the unrotated coordinate.
VECTOR2I padpos = pad->GetPos0();
RotatePoint( padpos, aFootprint->GetOrientation() );
pad->SetPosition( padpos + aFootprint->GetPosition() );
if( pad->GetSizeX() > 0 && pad->GetSizeY() > 0 ) if( pad->GetSizeX() > 0 && pad->GetSizeY() > 0 )
{ {
aFootprint->Add( pad.release() ); aFootprint->Add( pad.release() );

View File

@ -312,10 +312,7 @@ void PCAD_PAD::AddToFootprint( FOOTPRINT* aFootprint, const EDA_ANGLE& aRotation
if( !aEncapsulatedPad ) if( !aEncapsulatedPad )
{ {
// pad's "Position" is not relative to the footprint's, whereas Pos0 is relative to
// the footprint's but is the unrotated coordinate.
VECTOR2I padpos( m_PositionX, m_PositionY ); VECTOR2I padpos( m_PositionX, m_PositionY );
pad->SetPos0( padpos );
RotatePoint( padpos, aFootprint->GetOrientation() ); RotatePoint( padpos, aFootprint->GetOrientation() );
pad->SetPosition( padpos + aFootprint->GetPosition() ); pad->SetPosition( padpos + aFootprint->GetPosition() );
} }

View File

@ -627,7 +627,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
if( isRoundKeepout( pad ) ) if( isRoundKeepout( pad ) )
{ {
double diameter = scale( pad->GetDrillSize().x ); double diameter = scale( pad->GetDrillSize().x );
POINT vertex = mapPt( pad->GetPos0() ); POINT vertex = mapPt( pad->GetFPRelativePosition() );
diameter += scale( aBoard->GetDesignSettings().m_HoleClearance * 2 ); diameter += scale( aBoard->GetDesignSettings().m_HoleClearance * 2 );
@ -699,7 +699,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
EDA_ANGLE angle = pad->GetOrientation() - aFootprint->GetOrientation(); EDA_ANGLE angle = pad->GetOrientation() - aFootprint->GetOrientation();
pin->SetRotation( angle.Normalize().AsDegrees() ); pin->SetRotation( angle.Normalize().AsDegrees() );
VECTOR2I pos( pad->GetPos0() ); VECTOR2I pos( pad->GetFPRelativePosition() );
pin->SetVertex( mapPt( pos ) ); pin->SetVertex( mapPt( pos ) );
} }

View File

@ -1537,8 +1537,6 @@ static void mirrorPadX( PAD& aPad, const VECTOR2I& aMirrorPoint )
VECTOR2I tmpPt = mirrorPointX( aPad.GetPosition(), aMirrorPoint ); VECTOR2I tmpPt = mirrorPointX( aPad.GetPosition(), aMirrorPoint );
aPad.SetPosition( tmpPt ); aPad.SetPosition( tmpPt );
aPad.SetX0( aPad.GetPosition().x );
tmpPt = aPad.GetOffset(); tmpPt = aPad.GetOffset();
tmpPt.x = -tmpPt.x; tmpPt.x = -tmpPt.x;
aPad.SetOffset( tmpPt ); aPad.SetOffset( tmpPt );
@ -1562,8 +1560,6 @@ static void mirrorPadY( PAD& aPad, const VECTOR2I& aMirrorPoint )
VECTOR2I tmpPt = mirrorPointY( aPad.GetPosition(), aMirrorPoint ); VECTOR2I tmpPt = mirrorPointY( aPad.GetPosition(), aMirrorPoint );
aPad.SetPosition( tmpPt ); aPad.SetPosition( tmpPt );
aPad.SetY0( aPad.GetPosition().y );
tmpPt = aPad.GetOffset(); tmpPt = aPad.GetOffset();
tmpPt.y = -tmpPt.y; tmpPt.y = -tmpPt.y;
aPad.SetOffset( tmpPt ); aPad.SetOffset( tmpPt );

View File

@ -140,13 +140,6 @@ int EDIT_TOOL::Swap( const TOOL_EVENT& aEvent )
a->SetPosition( aPos ); a->SetPosition( aPos );
b->SetPosition( bPos ); b->SetPosition( bPos );
// Pads need special handling to keep their offset from their parent
if( a->Type() == PCB_PAD_T )
static_cast<PAD*>( a )->SetLocalCoord();
if( b->Type() == PCB_PAD_T )
static_cast<PAD*>( b )->SetLocalCoord();
// Handle footprints specially. They can be flipped to the back of the board which // Handle footprints specially. They can be flipped to the back of the board which
// requires a special transformation. // requires a special transformation.
if( a->Type() == PCB_FOOTPRINT_T && b->Type() == PCB_FOOTPRINT_T ) if( a->Type() == PCB_FOOTPRINT_T && b->Type() == PCB_FOOTPRINT_T )

View File

@ -555,7 +555,6 @@ int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
if( pad ) if( pad )
{ {
m_frame->GetDesignSettings().m_Pad_Master->ImportSettingsFrom( *pad ); m_frame->GetDesignSettings().m_Pad_Master->ImportSettingsFrom( *pad );
pad->SetLocalCoord();
aCommit.Add( aItem ); aCommit.Add( aItem );
return true; return true;
} }

View File

@ -1375,7 +1375,6 @@ void PCB_POINT_EDITOR::updateItem() const
pad->SetSize( padSize ); pad->SetSize( padSize );
pad->SetPosition( VECTOR2I( ( left + right ) / 2, ( top + bottom ) / 2 ) ); pad->SetPosition( VECTOR2I( ( left + right ) / 2, ( top + bottom ) / 2 ) );
pad->SetLocalCoord();
} }
break; break;
} }

View File

@ -192,15 +192,6 @@ void PCB_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
} }
void setLocalCoord( BOARD_ITEM* aItem )
{
// TODO: we really need to get rid of this local/draw coords stuff, but for now, it is what it is.
if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
pad->SetLocalCoord();
}
void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent ) void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
{ {
PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>(); PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
@ -217,7 +208,6 @@ void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( edaItem ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( edaItem );
changes.Modify( item ); changes.Modify( item );
item->Set( property, newValue ); item->Set( property, newValue );
setLocalCoord( item );
} }
changes.Push( _( "Change property" ) ); changes.Push( _( "Change property" ) );