More module -> footprint.

This commit is contained in:
Jeff Young 2020-11-13 01:33:30 +00:00
parent 8c947b69b0
commit 2cc9dad4ff
29 changed files with 258 additions and 259 deletions

View File

@ -63,13 +63,13 @@ const int scale = (int)(0.01 * IU_PER_MM);
const int PADDING = (int)(1 * IU_PER_MM);
// Populates a list of rectangles, from a list of footprints
void fillRectList( CSubRectArray& vecSubRects, std::vector <MODULE*>& aModuleList )
void fillRectList( CSubRectArray& vecSubRects, std::vector <MODULE*>& aFootprintList )
{
vecSubRects.clear();
for( unsigned ii = 0; ii < aModuleList.size(); ii++ )
for( unsigned ii = 0; ii < aFootprintList.size(); ii++ )
{
EDA_RECT fpBox = aModuleList[ii]->GetFootprintRect();
EDA_RECT fpBox = aFootprintList[ii]->GetFootprintRect();
TSubRect fpRect( ( fpBox.GetWidth() + PADDING ) / scale,
( fpBox.GetHeight() + PADDING ) / scale, ii );
vecSubRects.push_back( fpRect );
@ -148,16 +148,13 @@ void spreadRectangles( CRectPlacement& aPlacementArea,
}
void moveFootprintsInArea( CRectPlacement& aPlacementArea,
std::vector <MODULE*>& aModuleList,
EDA_RECT& aFreeArea,
bool aFindAreaOnly )
void moveFootprintsInArea( CRectPlacement& aPlacementArea, std::vector <MODULE*>& aFootprintList,
EDA_RECT& aFreeArea, bool aFindAreaOnly )
{
CSubRectArray vecSubRects;
fillRectList( vecSubRects, aModuleList );
spreadRectangles( aPlacementArea, vecSubRects,
aFreeArea.GetWidth(), aFreeArea.GetHeight() );
fillRectList( vecSubRects, aFootprintList );
spreadRectangles( aPlacementArea, vecSubRects, aFreeArea.GetWidth(), aFreeArea.GetHeight() );
if( aFindAreaOnly )
return;
@ -168,7 +165,7 @@ void moveFootprintsInArea( CRectPlacement& aPlacementArea,
pos.x *= scale;
pos.y *= scale;
MODULE * module = aModuleList[vecSubRects[it].n];
MODULE * module = aFootprintList[vecSubRects[it].n];
EDA_RECT fpBBox = module->GetFootprintRect();
wxPoint mod_pos = pos + ( module->GetPosition() - fpBBox.GetOrigin() )
@ -189,8 +186,7 @@ static bool sortFootprintsbySheetPath( MODULE* ref, MODULE* compare );
* @param aSpreadAreaPosition the position of the upper left corner of the
* area allowed to spread footprints
*/
void SpreadFootprints( std::vector<MODULE*>* aFootprints,
wxPoint aSpreadAreaPosition )
void SpreadFootprints( std::vector<MODULE*>* aFootprints, wxPoint aSpreadAreaPosition )
{
// Build candidate list
// calculate also the area needed by these footprints
@ -271,8 +267,7 @@ void SpreadFootprints( std::vector<MODULE*>* aFootprints,
}
bool findAreaOnly = pass == 0;
moveFootprintsInArea( placementArea, footprintListBySheet,
freeArea, findAreaOnly );
moveFootprintsInArea( placementArea, footprintListBySheet, freeArea, findAreaOnly );
if( pass == 0 )
{

View File

@ -556,24 +556,25 @@ void DIALOG_BOARD_REANNOTATE::LogChangePlan()
//
/// Create a list of the footprints and their coordinates
void DIALOG_BOARD_REANNOTATE::LogModules( wxString& aMessage, std::vector<RefDesInfo>& aModules )
void DIALOG_BOARD_REANNOTATE::LogFootprints( wxString& aMessage,
std::vector<RefDesInfo>& aFootprints )
{
wxString message = aMessage;
if( aModules.empty() )
if( aFootprints.empty() )
message += _( "\nNo footprints" );
else
{
int i = 1;
bool moduleLocations = m_locationChoice->GetSelection() == 0;
bool fpLocations = m_locationChoice->GetSelection() == 0;
message += wxString::Format( _( "\n*********** Sort on %s ***********" ),
moduleLocations ? _( "Footprint Coordinates" )
: _( "Reference Designator Coordinates" ) );
fpLocations ? _( "Footprint Coordinates" )
: _( "Reference Designator Coordinates" ) );
message += wxString::Format( _( "\nSort Code %d" ), m_SortCode );
for( const RefDesInfo& mod : aModules )
for( const RefDesInfo& mod : aFootprints )
{
message += wxString::Format( _( "\n%d %s Uuid: [%s], X, Y: %s, Rounded X, Y, %s" ),
i++,
@ -858,7 +859,7 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
//
/// Scan through the module arrays and create the from -> to array
void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aModules,
void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aFootprints,
unsigned int aStartRefDes, wxString aPrefix,
bool aRemovePrefix,
std::vector<RefDesInfo>& aBadRefDes )
@ -876,50 +877,52 @@ void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aModule
bool prefixpresent; //Prefix found
wxString logstring = ( aModules.front().Front ) ? _( "\n\nFront Footprints" )
: _( "\n\nBack Footprints" );
LogModules( logstring, aModules );
wxString logstring = ( aFootprints.front().Front ) ? _( "\n\nFront Footprints" )
: _( "\n\nBack Footprints" );
LogFootprints( logstring, aFootprints );
if( 0 != aStartRefDes ) //Initialize the change array if present
{
for( i = 0; i < m_RefDesTypes.size(); i++ )
m_RefDesTypes[i].RefDesCount = aStartRefDes;
}
for( RefDesInfo Mod : aModules )
for( RefDesInfo footprint : aFootprints )
{ //For each module
change.Uuid = Mod.Uuid;
change.Action = Mod.Action;
change.OldRefDesString = Mod.RefDesString;
change.NewRefDes = Mod.RefDesString;
change.Front = Mod.Front;
change.Uuid = footprint.Uuid;
change.Action = footprint.Action;
change.OldRefDesString = footprint.RefDesString;
change.NewRefDes = footprint.RefDesString;
change.Front = footprint.Front;
if( Mod.RefDesString.IsEmpty() )
Mod.Action = EmptyRefDes;
if( footprint.RefDesString.IsEmpty() )
footprint.Action = EmptyRefDes;
if( ( change.Action == EmptyRefDes ) || ( change.Action == InvalidRefDes ) )
{
m_ChangeArray.push_back( change );
aBadRefDes.push_back( Mod );
aBadRefDes.push_back( footprint );
continue;
}
if( change.Action == UpdateRefDes )
{
refdestype = Mod.RefDesType;
prefixpresent = ( 0 == Mod.RefDesType.find( aPrefix ) );
refdestype = footprint.RefDesType;
prefixpresent = ( 0 == footprint.RefDesType.find( aPrefix ) );
if( addprefix && !prefixpresent )
Mod.RefDesType.insert( 0, aPrefix ); //Add prefix once only
footprint.RefDesType.insert( 0, aPrefix ); //Add prefix once only
if( aRemovePrefix && prefixpresent ) //If there is a prefix remove it
Mod.RefDesType.erase( 0, prefixsize );
footprint.RefDesType.erase( 0, prefixsize );
for( i = 0; i < m_RefDesTypes.size(); i++ ) //See if it is in the types array
if( m_RefDesTypes[i].RefDesType == Mod.RefDesType ) //Found it!
if( m_RefDesTypes[i].RefDesType == footprint.RefDesType ) //Found it!
break;
if( i == m_RefDesTypes.size() )
{ //Wasn't in the types array so add it
newtype.RefDesType = Mod.RefDesType;
newtype.RefDesType = footprint.RefDesType;
newtype.RefDesCount = ( aStartRefDes == 0 ? 1 : aStartRefDes );
m_RefDesTypes.push_back( newtype );
}

View File

@ -156,13 +156,13 @@ private:
void FilterBackPrefix( wxCommandEvent& event ) override;
void ShowReport( wxString aMessage, SEVERITY aSeverity );
void LogModules( wxString& aMessage, std::vector<RefDesInfo>& aModules );
void LogFootprints( wxString& aMessage, std::vector<RefDesInfo>& aFootprints );
void LogChangePlan( void );
bool ReannotateBoard( void );
bool BuildModuleList( std::vector<RefDesInfo>& aBadRefDes );
void BuildChangeArray( std::vector<RefDesInfo>& aModules, unsigned int aStartRefDes,
wxString aPrefix, bool aRemovePrefix, std::vector<RefDesInfo>& aBadRefDes );
void BuildChangeArray( std::vector<RefDesInfo>& aFootprints, unsigned int aStartRefDes,
wxString aPrefix, bool aRemovePrefix, std::vector<RefDesInfo>& aBadRefDes );
RefDesChange* GetNewRefDes( MODULE* aMod );

View File

@ -184,14 +184,14 @@ static int GencadOffsetX, GencadOffsetY;
static std::map<MODULE*, int> componentShapes;
static std::map<int, wxString> shapeNames;
static const wxString getShapeName( MODULE* aModule )
static const wxString getShapeName( MODULE* aFootprint )
{
static const wxString invalid( "invalid" );
if( individualShapes )
return aModule->GetReference();
return aFootprint->GetReference();
auto itShape = componentShapes.find( aModule );
auto itShape = componentShapes.find( aFootprint );
wxCHECK( itShape != componentShapes.end(), invalid );
auto itName = shapeNames.find( itShape->second );
@ -664,17 +664,17 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
/// Compute hashes for footprints without taking into account their position, rotation or layer
static size_t hashModule( const MODULE* aModule )
static size_t hashModule( const MODULE* aFootprint )
{
size_t ret = 0x11223344;
constexpr int flags = HASH_FLAGS::HASH_POS | HASH_FLAGS::REL_COORD
| HASH_FLAGS::HASH_ROT | HASH_FLAGS::HASH_LAYER;
for( auto i : aModule->GraphicalItems() )
for( auto i : aFootprint->GraphicalItems() )
ret += hash_eda( i, flags );
for( auto i : aModule->Pads() )
for( auto i : aFootprint->Pads() )
ret += hash_eda( i, flags );
return ret;

View File

@ -70,7 +70,7 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
// NOTE: IMPLEMENTATION
// If/when component cutouts are allowed, we must implement them separately. Cutouts
// must be added to the board outline section and not to the Other Outline section.
// The module cutouts should be handled via the idf_export_module() routine.
// The module cutouts should be handled via the idf_export_footprint() routine.
double offX, offY;
aIDFBoard.GetUserOffset( offX, offY );
@ -268,20 +268,20 @@ UseBoundingBox:
/**
* Function idf_export_module
* Function idf_export_footprint
* retrieves information from all board footprints, adds drill holes to
* the DRILLED_HOLES or BOARD_OUTLINE section as appropriate,
* compiles data for the PLACEMENT section and compiles data for
* the library ELECTRICAL section.
*/
static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoard )
static void idf_export_footprint( BOARD* aPcb, MODULE* aFootprint, IDF3_BOARD& aIDFBoard )
{
// Reference Designator
std::string crefdes = TO_UTF8( aModule->Reference().GetShownText() );
std::string crefdes = TO_UTF8( aFootprint->Reference().GetShownText() );
if( crefdes.empty() || !crefdes.compare( "~" ) )
{
std::string cvalue = TO_UTF8( aModule->Value().GetShownText() );
std::string cvalue = TO_UTF8( aFootprint->Value().GetShownText() );
// if both the RefDes and Value are empty or set to '~' the board owns the part,
// otherwise associated parts of the module must be marked NOREFDES.
@ -292,7 +292,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
}
// TODO: If module cutouts are supported we must add code here
// for( EDA_ITEM* item = aModule->GraphicalItems(); item != NULL; item = item->Next() )
// for( EDA_ITEM* item = aFootprint->GraphicalItems(); item != NULL; item = item->Next() )
// {
// if( item->Type() != PCB_FP_SHAPE_T || item->GetLayer() != Edge_Cuts )
// continue;
@ -310,7 +310,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
aIDFBoard.GetUserOffset( dx, dy );
for( auto pad : aModule->Pads() )
for( auto pad : aFootprint->Pads() )
{
drill = (double) pad->GetDrillSize().x * scale;
x = pad->GetPosition().x * scale + dx;
@ -402,8 +402,8 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
IDF3_COMPONENT* comp = NULL;
auto sM = aModule->Models().begin();
auto eM = aModule->Models().end();
auto sM = aFootprint->Models().begin();
auto eM = aFootprint->Models().end();
wxFileName idfFile;
wxString idfExt;
@ -420,7 +420,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
if( refdes.empty() )
{
refdes = TO_UTF8( aModule->Reference().GetShownText() );
refdes = TO_UTF8( aFootprint->Reference().GetShownText() );
// NOREFDES cannot be used or else the software gets confused
// when writing out the placement data due to conflicting
@ -437,25 +437,25 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
if( !outline )
throw( std::runtime_error( aIDFBoard.GetError() ) );
double rotz = aModule->GetOrientation() / 10.0;
double rotz = aFootprint->GetOrientation() / 10.0;
double locx = sM->m_Offset.x * 25.4; // part offsets are in inches
double locy = sM->m_Offset.y * 25.4;
double locz = sM->m_Offset.z * 25.4;
double lrot = sM->m_Rotation.z;
bool top = ( aModule->GetLayer() == B_Cu ) ? false : true;
bool top = ( aFootprint->GetLayer() == B_Cu ) ? false : true;
if( top )
{
locy = -locy;
RotatePoint( &locx, &locy, aModule->GetOrientation() );
RotatePoint( &locx, &locy, aFootprint->GetOrientation() );
locy = -locy;
}
if( !top )
{
lrot = -lrot;
RotatePoint( &locx, &locy, aModule->GetOrientation() );
RotatePoint( &locx, &locy, aFootprint->GetOrientation() );
locy = -locy;
rotz = 180.0 - rotz;
@ -480,12 +480,12 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
comp->SetRefDes( refdes );
if( top )
comp->SetPosition( aModule->GetPosition().x * scale + dx,
-aModule->GetPosition().y * scale + dy,
comp->SetPosition( aFootprint->GetPosition().x * scale + dx,
-aFootprint->GetPosition().y * scale + dy,
rotz, IDF3::LYR_TOP );
else
comp->SetPosition( aModule->GetPosition().x * scale + dx,
-aModule->GetPosition().y * scale + dy,
comp->SetPosition( aFootprint->GetPosition().x * scale + dx,
-aFootprint->GetPosition().y * scale + dy,
rotz, IDF3::LYR_BOTTOM );
comp->SetPlacement( IDF3::PS_ECAD );
@ -501,12 +501,12 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
{
// place the item
if( top )
comp->SetPosition( aModule->GetPosition().x * scale + dx,
-aModule->GetPosition().y * scale + dy,
comp->SetPosition( aFootprint->GetPosition().x * scale + dx,
-aFootprint->GetPosition().y * scale + dy,
rotz, IDF3::LYR_TOP );
else
comp->SetPosition( aModule->GetPosition().x * scale + dx,
-aModule->GetPosition().y * scale + dy,
comp->SetPosition( aFootprint->GetPosition().x * scale + dx,
-aFootprint->GetPosition().y * scale + dy,
rotz, IDF3::LYR_BOTTOM );
comp->SetPlacement( IDF3::PS_ECAD );
@ -515,8 +515,8 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
else
{
// check that the retrieved component matches this one
refX = refX - ( aModule->GetPosition().x * scale + dx );
refY = refY - ( -aModule->GetPosition().y * scale + dy );
refX = refX - ( aFootprint->GetPosition().x * scale + dx );
refY = refY - ( -aFootprint->GetPosition().y * scale + dy );
refA = refA - rotz;
refA *= refA;
refX *= refX;
@ -533,9 +533,9 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, IDF3_BOARD& aIDFBoa
std::ostringstream ostr;
ostr << "* " << __FILE__ << ":" << __LINE__ << ":" << __FUNCTION__ << "():\n";
ostr << "* conflicting Reference Designator '" << refdes << "'\n";
ostr << "* X loc: " << (aModule->GetPosition().x * scale + dx);
ostr << "* X loc: " << ( aFootprint->GetPosition().x * scale + dx);
ostr << " vs. " << refX << "\n";
ostr << "* Y loc: " << (-aModule->GetPosition().y * scale + dy);
ostr << "* Y loc: " << ( -aFootprint->GetPosition().y * scale + dy);
ostr << " vs. " << refY << "\n";
ostr << "* angle: " << rotz;
ostr << " vs. " << refA << "\n";
@ -618,7 +618,7 @@ bool PCB_EDIT_FRAME::Export_IDF3( BOARD* aPcb, const wxString& aFullFileName,
// Output the drill holes and module (library) data.
for( MODULE* footprint : aPcb->Footprints() )
idf_export_module( aPcb, footprint, idfBoard );
idf_export_footprint( aPcb, footprint, idfBoard );
if( !idfBoard.WriteFile( aFullFileName, idfUnit, false ) )
{

View File

@ -1047,7 +1047,7 @@ static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb, COMMIT* aCommit
}
static void export_vrml_text_module( FP_TEXT* item )
static void export_vrml_fp_text( FP_TEXT* item )
{
if( item->IsVisible() )
{
@ -1069,7 +1069,7 @@ static void export_vrml_text_module( FP_TEXT* item )
}
static void export_vrml_edge_module( MODEL_VRML& aModel, FP_SHAPE* aOutline, MODULE* aModule )
static void export_vrml_fp_shape( MODEL_VRML& aModel, FP_SHAPE* aOutline, MODULE* aFootprint )
{
LAYER_NUM layer = aOutline->GetLayer();
double x = aOutline->GetStart().x * BOARD_SCALE;
@ -1093,8 +1093,8 @@ static void export_vrml_edge_module( MODEL_VRML& aModel, FP_SHAPE* aOutline, MOD
break;
case S_POLYGON:
export_vrml_polygon( aModel, layer, aOutline, aModule->GetOrientationRadians(),
aModule->GetPosition() );
export_vrml_polygon( aModel, layer, aOutline, aFootprint->GetOrientationRadians(),
aFootprint->GetPosition() );
break;
case S_RECT:
@ -1361,30 +1361,30 @@ static void compose_quat( double q1[4], double q2[4], double qr[4] )
}
static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb,
MODULE* aModule, std::ostream* aOutputFile )
static void export_vrml_footprint( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aFootprint,
std::ostream* aOutputFile )
{
if( !aModel.m_plainPCB )
{
// Reference and value
if( aModule->Reference().IsVisible() )
export_vrml_text_module( &aModule->Reference() );
if( aFootprint->Reference().IsVisible() )
export_vrml_fp_text( &aFootprint->Reference());
if( aModule->Value().IsVisible() )
export_vrml_text_module( &aModule->Value() );
if( aFootprint->Value().IsVisible() )
export_vrml_fp_text( &aFootprint->Value());
// Export module edges
for( BOARD_ITEM* item : aModule->GraphicalItems() )
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
{
switch( item->Type() )
{
case PCB_FP_TEXT_T:
export_vrml_text_module( static_cast<FP_TEXT*>( item ) );
export_vrml_fp_text( static_cast<FP_TEXT*>( item ));
break;
case PCB_FP_SHAPE_T:
export_vrml_edge_module( aModel, static_cast<FP_SHAPE*>( item ), aModule );
export_vrml_fp_shape( aModel, static_cast<FP_SHAPE*>( item ), aFootprint );
break;
default:
@ -1394,14 +1394,14 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb,
}
// Export pads
for( PAD* pad : aModule->Pads() )
for( PAD* pad : aFootprint->Pads() )
export_vrml_pad( aModel, aPcb, pad );
bool isFlipped = aModule->GetLayer() == B_Cu;
bool isFlipped = aFootprint->GetLayer() == B_Cu;
// Export the object VRML model(s)
auto sM = aModule->Models().begin();
auto eM = aModule->Models().end();
auto sM = aFootprint->Models().begin();
auto eM = aFootprint->Models().end();
wxFileName subdir( SUBDIR_3D, "" );
@ -1439,9 +1439,9 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb,
build_quat( 0, 0, 1, DEG2RAD( rotz ), q2 );
compose_quat( q1, q2, q1 );
// Note here aModule->GetOrientation() is in 0.1 degrees,
// Note here aFootprint->GetOrientation() is in 0.1 degrees,
// so module rotation has to be converted to radians
build_quat( 0, 0, 1, DECIDEG2RAD( aModule->GetOrientation() ), q2 );
build_quat( 0, 0, 1, DECIDEG2RAD( aFootprint->GetOrientation() ), q2 );
compose_quat( q1, q2, q1 );
from_quat( q1, rot );
@ -1458,12 +1458,12 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb,
else // In normal mode, Y axis is reversed in Pcbnew.
offsety = -offsety;
RotatePoint( &offsetx, &offsety, aModule->GetOrientation() );
RotatePoint( &offsetx, &offsety, aFootprint->GetOrientation() );
SGPOINT trans;
trans.x = ( offsetx + aModule->GetPosition().x ) * BOARD_SCALE + aModel.m_tx;
trans.y = -(offsety + aModule->GetPosition().y) * BOARD_SCALE - aModel.m_ty;
trans.z = (offsetz * BOARD_SCALE ) + aModel.GetLayerZ( aModule->GetLayer() );
trans.x = ( offsetx + aFootprint->GetPosition().x ) * BOARD_SCALE + aModel.m_tx;
trans.y = -( offsety + aFootprint->GetPosition().y) * BOARD_SCALE - aModel.m_ty;
trans.z = (offsetz * BOARD_SCALE ) + aModel.GetLayerZ( aFootprint->GetLayer() );
if( USE_INLINES )
{
@ -1656,7 +1656,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMt
// Export footprints
for( MODULE* footprint : pcb->Footprints() )
export_vrml_module( model3d, pcb, footprint, &output_file );
export_vrml_footprint( model3d, pcb, footprint, &output_file );
// write out the board and all layers
write_layers( model3d, pcb, TO_UTF8( aFullFileName ), &output_file );
@ -1670,7 +1670,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMt
{
// Export footprints
for( MODULE* footprint : pcb->Footprints() )
export_vrml_module( model3d, pcb, footprint, NULL );
export_vrml_footprint( model3d, pcb, footprint, NULL );
// write out the board and all layers
write_layers( model3d, pcb, TO_UTF8( aFullFileName ), NULL );

View File

@ -49,7 +49,7 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFoo
m_parent = aParent;
if( aImportAsFootprintGraphic )
m_importer = std::make_unique<GRAPHICS_IMPORTER_MODULE>( m_parent->GetBoard()->GetFirstFootprint() );
m_importer = std::make_unique<GRAPHICS_IMPORTER_FOOTPRINT>( m_parent->GetBoard()->GetFirstFootprint() );
else
m_importer = std::make_unique<GRAPHICS_IMPORTER_BOARD>( m_parent->GetBoard() );

View File

@ -187,14 +187,14 @@ std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> GRAPHICS_IMPORTER_BOARD::creat
}
std::unique_ptr<PCB_SHAPE> GRAPHICS_IMPORTER_MODULE::createDrawing()
std::unique_ptr<PCB_SHAPE> GRAPHICS_IMPORTER_FOOTPRINT::createDrawing()
{
return std::make_unique<FP_SHAPE>( m_module );
return std::make_unique<FP_SHAPE>( m_footprint );
}
std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> GRAPHICS_IMPORTER_MODULE::createText()
std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> GRAPHICS_IMPORTER_FOOTPRINT::createText()
{
FP_TEXT* text = new FP_TEXT( m_module );
FP_TEXT* text = new FP_TEXT( m_footprint );
return make_pair( std::unique_ptr<BOARD_ITEM>( text ), static_cast<EDA_TEXT*>( text ) );
}

View File

@ -116,11 +116,11 @@ protected:
};
class GRAPHICS_IMPORTER_MODULE : public GRAPHICS_IMPORTER_PCBNEW
class GRAPHICS_IMPORTER_FOOTPRINT : public GRAPHICS_IMPORTER_PCBNEW
{
public:
GRAPHICS_IMPORTER_MODULE( MODULE* aModule )
: m_module( aModule )
GRAPHICS_IMPORTER_FOOTPRINT( MODULE* aFootprint )
: m_footprint( aFootprint )
{
}
@ -128,7 +128,7 @@ protected:
std::unique_ptr<PCB_SHAPE> createDrawing() override;
std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> createText() override;
MODULE* m_module;
MODULE* m_footprint;
};
#endif /* GRAPHICS_IMPORTER_PCBNEW */

View File

@ -37,18 +37,18 @@ int COMPONENT_NET::Format( OUTPUTFORMATTER* aOut, int aNestLevel, int aCtl )
}
void COMPONENT::SetModule( MODULE* aModule )
void COMPONENT::SetModule( MODULE* aFootprint )
{
m_footprint.reset( aModule );
m_footprint.reset( aFootprint );
if( aModule == NULL )
if( aFootprint == NULL )
return;
aModule->SetReference( m_reference );
aModule->SetValue( m_value );
aModule->SetFPID( m_fpid );
aModule->SetPath( m_path );
aModule->SetProperties( m_properties );
aFootprint->SetReference( m_reference );
aFootprint->SetValue( m_value );
aFootprint->SetFPID( m_fpid );
aFootprint->SetPath( m_path );
aFootprint->SetProperties( m_properties );
}

View File

@ -172,7 +172,7 @@ public:
return ( aRelease ) ? m_footprint.release() : m_footprint.get();
}
void SetModule( MODULE* aModule );
void SetModule( MODULE* aFootprint );
bool IsLibSource( const wxString& aLibrary, const wxString& aName ) const
{

View File

@ -448,7 +448,7 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend )
module->SetFPID( fpid );
loadMODULE( module.get() );
loadFOOTPRINT( module.get());
m_board->Add( module.release(), ADD_MODE::APPEND );
}
@ -1178,7 +1178,7 @@ void LEGACY_PLUGIN::loadSETUP()
}
void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
void LEGACY_PLUGIN::loadFOOTPRINT( MODULE* aFootprint )
{
char* line;
@ -1190,12 +1190,12 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
if( TESTSUBSTR( "D" ) && strchr( "SCAP", line[1] ) ) // read a drawing item, e.g. "DS"
{
loadMODULE_EDGE( aModule );
loadFP_SHAPE( aFootprint );
}
else if( TESTLINE( "$PAD" ) )
{
loadPAD( aModule );
loadPAD( aFootprint );
}
// Read a footprint text description (ref, value, or drawing)
@ -1209,17 +1209,17 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
switch( tnum )
{
case FP_TEXT::TEXT_is_REFERENCE:
text = &aModule->Reference();
text = &aFootprint->Reference();
break;
case FP_TEXT::TEXT_is_VALUE:
text = &aModule->Value();
text = &aFootprint->Value();
break;
// All other fields greater than 1.
default:
text = new FP_TEXT( aModule );
aModule->Add( text );
text = new FP_TEXT( aFootprint );
aFootprint->Add( text );
}
loadMODULE_TEXT( text );
@ -1241,31 +1241,31 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
// data is now a two character long string
// Note: some old files do not have this field
if( data && data[0] == 'F' )
aModule->SetLocked( true );
aFootprint->SetLocked( true );
if( data && data[1] == 'P' )
aModule->SetIsPlaced( true );
aFootprint->SetIsPlaced( true );
aModule->SetPosition( wxPoint( pos_x, pos_y ) );
aModule->SetLayer( layer_id );
aModule->SetOrientation( orient );
const_cast<KIID&>( aModule->m_Uuid ) = KIID( uuid );
aModule->SetLastEditTime( edittime );
aFootprint->SetPosition( wxPoint( pos_x, pos_y ) );
aFootprint->SetLayer( layer_id );
aFootprint->SetOrientation( orient );
const_cast<KIID&>( aFootprint->m_Uuid ) = KIID( uuid );
aFootprint->SetLastEditTime( edittime );
}
/* footprint name set earlier, immediately after MODULE construction
/* footprint name set earlier, immediately after FOOTPRINT construction
else if( TESTLINE( "Li" ) ) // Library name of footprint
{
// There can be whitespace in the footprint name on some old libraries.
// Grab everything after "Li" up to end of line:
//aModule->SetFPID( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) );
//aFootprint->SetFPID( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) );
}
*/
else if( TESTLINE( "Sc" ) ) // timestamp
{
char* uuid = strtok_r( (char*) line + SZ( "Sc" ), delims, (char**) &data );
const_cast<KIID&>( aModule->m_Uuid ) = KIID( uuid );
const_cast<KIID&>( aFootprint->m_Uuid ) = KIID( uuid );
}
else if( TESTLINE( "Op" ) ) // (Op)tions for auto placement
@ -1277,7 +1277,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
if( cntRot180 > 10 )
cntRot180 = 10;
aModule->SetPlacementCost180( cntRot180 );
aFootprint->SetPlacementCost180( cntRot180 );
int cntRot90 = itmp1 & 0x0F;
if( cntRot90 > 10 )
@ -1287,7 +1287,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
if( itmp1 > 10 )
itmp1 = 0;
aModule->SetPlacementCost90( (itmp1 << 4) | cntRot90 );
aFootprint->SetPlacementCost90((itmp1 << 4) | cntRot90 );
}
else if( TESTLINE( "At" ) ) // (At)tributes of module
@ -1303,7 +1303,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
else
attrs |= MOD_THROUGH_HOLE | MOD_EXCLUDE_FROM_POS_FILES;
aModule->SetAttributes( attrs );
aFootprint->SetAttributes( attrs );
}
else if( TESTLINE( "AR" ) ) // Alternate Reference
@ -1312,23 +1312,23 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
data = strtok_r( line + SZ( "AR" ), delims, (char**) &data );
if( data )
aModule->SetPath( KIID_PATH( FROM_UTF8( data ) ) );
aFootprint->SetPath( KIID_PATH( FROM_UTF8( data ) ) );
}
else if( TESTLINE( "$SHAPE3D" ) )
{
load3D( aModule );
load3D( aFootprint );
}
else if( TESTLINE( "Cd" ) )
{
// e.g. "Cd Double rangee de contacts 2 x 4 pins\r\n"
aModule->SetDescription( FROM_UTF8( StrPurge( line + SZ( "Cd" ) ) ) );
aFootprint->SetDescription( FROM_UTF8( StrPurge( line + SZ( "Cd" ) ) ) );
}
else if( TESTLINE( "Kw" ) ) // Key words
{
aModule->SetKeywords( FROM_UTF8( StrPurge( line + SZ( "Kw" ) ) ) );
aFootprint->SetKeywords( FROM_UTF8( StrPurge( line + SZ( "Kw" ) ) ) );
}
else if( TESTLINE( ".SolderPasteRatio" ) )
@ -1342,63 +1342,63 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
tmp = -0.50;
if( tmp > 0.0 )
tmp = 0.0;
aModule->SetLocalSolderPasteMarginRatio( tmp );
aFootprint->SetLocalSolderPasteMarginRatio( tmp );
}
else if( TESTLINE( ".SolderPaste" ) )
{
BIU tmp = biuParse( line + SZ( ".SolderPaste" ) );
aModule->SetLocalSolderPasteMargin( tmp );
aFootprint->SetLocalSolderPasteMargin( tmp );
}
else if( TESTLINE( ".SolderMask" ) )
{
BIU tmp = biuParse( line + SZ( ".SolderMask" ) );
aModule->SetLocalSolderMaskMargin( tmp );
aFootprint->SetLocalSolderMaskMargin( tmp );
}
else if( TESTLINE( ".LocalClearance" ) )
{
BIU tmp = biuParse( line + SZ( ".LocalClearance" ) );
aModule->SetLocalClearance( tmp );
aFootprint->SetLocalClearance( tmp );
}
else if( TESTLINE( ".ZoneConnection" ) )
{
int tmp = intParse( line + SZ( ".ZoneConnection" ) );
aModule->SetZoneConnection( (ZONE_CONNECTION) tmp );
aFootprint->SetZoneConnection((ZONE_CONNECTION) tmp );
}
else if( TESTLINE( ".ThermalWidth" ) )
{
BIU tmp = biuParse( line + SZ( ".ThermalWidth" ) );
aModule->SetThermalWidth( tmp );
aFootprint->SetThermalWidth( tmp );
}
else if( TESTLINE( ".ThermalGap" ) )
{
BIU tmp = biuParse( line + SZ( ".ThermalGap" ) );
aModule->SetThermalGap( tmp );
aFootprint->SetThermalGap( tmp );
}
else if( TESTLINE( "$EndMODULE" ) )
{
aModule->CalculateBoundingBox();
aFootprint->CalculateBoundingBox();
return; // preferred exit
}
}
wxString msg = wxString::Format(
_( "Missing '$EndMODULE' for MODULE \"%s\"" ), aModule->GetFPID().GetLibItemName().wx_str() );
_( "Missing '$EndMODULE' for MODULE \"%s\"" ), aFootprint->GetFPID().GetLibItemName().wx_str() );
THROW_IO_ERROR( msg );
}
void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
void LEGACY_PLUGIN::loadPAD( MODULE* aFootprint )
{
std::unique_ptr<PAD> pad = std::make_unique<PAD>( aModule );
std::unique_ptr<PAD> pad = std::make_unique<PAD>( aFootprint );
char* line;
char* saveptr;
@ -1444,7 +1444,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
padchar,
padchar,
m_reader->LineNumber(),
aModule->GetFPID().GetLibItemName().wx_str()
aFootprint->GetFPID().GetLibItemName().wx_str()
);
THROW_IO_ERROR( m_error );
}
@ -1618,11 +1618,11 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
wxPoint padpos = pad->GetPos0();
RotatePoint( &padpos, aModule->GetOrientation() );
RotatePoint( &padpos, aFootprint->GetOrientation() );
pad->SetPosition( padpos + aModule->GetPosition() );
pad->SetPosition( padpos + aFootprint->GetPosition() );
aModule->Add( pad.release() );
aFootprint->Add( pad.release() );
return; // preferred exit
}
}
@ -1631,7 +1631,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
}
void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
void LEGACY_PLUGIN::loadFP_SHAPE( MODULE* aFootprint )
{
PCB_SHAPE_TYPE_T shape;
char* line = m_reader->Line(); // obtain current (old) line
@ -1647,12 +1647,12 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
(unsigned char) line[1],
(unsigned char) line[1],
m_reader->LineNumber(),
aModule->GetFPID().GetLibItemName().wx_str()
aFootprint->GetFPID().GetLibItemName().wx_str()
);
THROW_IO_ERROR( m_error );
}
std::unique_ptr<FP_SHAPE> dwg = std::make_unique<FP_SHAPE>( aModule, shape ); // a drawing
std::unique_ptr<FP_SHAPE> dwg = std::make_unique<FP_SHAPE>( aFootprint, shape ); // a drawing
const char* data;
@ -1757,7 +1757,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
FP_SHAPE* fpShape = dwg.release();
aModule->Add( fpShape );
aFootprint->Add( fpShape );
// this had been done at the MODULE level before, presumably because the
// FP_SHAPE needs to be already added to a module before this function will work.
@ -1859,7 +1859,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( FP_TEXT* aText )
}
void LEGACY_PLUGIN::load3D( MODULE* aModule )
void LEGACY_PLUGIN::load3D( MODULE* aFootprint )
{
FP_3DMODEL t3D;
@ -1899,7 +1899,7 @@ void LEGACY_PLUGIN::load3D( MODULE* aModule )
else if( TESTLINE( "$EndSHAPE3D" ) )
{
aModule->Models().push_back( t3D );
aFootprint->Models().push_back( t3D );
return; // preferred exit
}
}
@ -3254,7 +3254,7 @@ void LP_CACHE::LoadModules( LINE_READER* aReader )
// set the footprint name first thing, so exceptions can use name.
module->SetFPID( LIB_ID( wxEmptyString, footprintName ) );
m_owner->loadMODULE( module.get() );
m_owner->loadFOOTPRINT( module.get());
MODULE* m = module.release(); // exceptions after this are not expected.

View File

@ -190,16 +190,16 @@ protected:
void loadSETUP();
void loadSHEET();
void load3D( MODULE* aModule );
void loadPAD( MODULE* aModule );
void load3D( MODULE* aFootprint );
void loadPAD( MODULE* aFootprint );
void loadMODULE_TEXT( FP_TEXT* aText );
void loadMODULE_EDGE( MODULE* aModule );
void loadFP_SHAPE( MODULE* aFootprint );
void loadPCB_LINE();
void loadNETINFO_ITEM();
void loadPCB_TEXT();
void loadNETCLASS();
void loadMODULE( MODULE* aModule );
void loadFOOTPRINT( MODULE* aFootprint );
/**
* Function loadTrackList

View File

@ -156,7 +156,7 @@ void PCB_ARC::Flip()
}
void PCB_ARC::AddToModule( MODULE* aModule )
void PCB_ARC::AddToFootprint( MODULE* aModule )
{
if( IsNonCopperLayer( m_KiCadLayer ) )
{

View File

@ -54,7 +54,7 @@ public:
virtual void SetPosOffset( int aX_offs, int aY_offs ) override;
virtual void Flip() override;
void AddToModule( MODULE* aModule ) override;
void AddToFootprint( MODULE* aModule ) override;
void AddToBoard() override;
private:

View File

@ -61,7 +61,7 @@ PCB_COMPONENT::~PCB_COMPONENT()
}
void PCB_COMPONENT::AddToModule( MODULE* aModule )
void PCB_COMPONENT::AddToFootprint( MODULE* aModule )
{
}

View File

@ -64,7 +64,7 @@ public:
virtual void SetPosOffset( int aX_offs, int aY_offs );
virtual void Flip();
virtual void AddToModule( MODULE* aModule );
virtual void AddToFootprint( MODULE* aModule );
virtual void AddToBoard() = 0;
PCB_LAYER_ID GetKiCadLayer() { return m_callbacks->GetKiCadLayer( m_PCadLayer ); }

View File

@ -115,7 +115,7 @@ void PCB_LINE::Flip()
}
void PCB_LINE::AddToModule( MODULE* aModule )
void PCB_LINE::AddToFootprint( MODULE* aModule )
{
if( IsNonCopperLayer( m_KiCadLayer ) )
{

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.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
@ -53,7 +53,7 @@ public:
const wxString& aActualConversion );
virtual void SetPosOffset( int aX_offs, int aY_offs ) override;
virtual void Flip() override;
void AddToModule( MODULE* aModule ) override;
void AddToFootprint( MODULE* aModule ) override;
void AddToBoard() override;
};

View File

@ -574,7 +574,7 @@ void PCB_MODULE::AddToBoard()
if( m_moduleObjects[i]->m_objType == wxT( 'T' ) )
{
( (PCB_TEXT*) m_moduleObjects[i] )->m_tag = i + 2;
m_moduleObjects[i]->AddToModule( module );
m_moduleObjects[ i ]->AddToFootprint( module );
}
}
@ -582,35 +582,35 @@ void PCB_MODULE::AddToBoard()
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
{
if( m_moduleObjects[i]->m_objType == wxT( 'L' ) )
m_moduleObjects[i]->AddToModule( module );
m_moduleObjects[ i ]->AddToFootprint( module );
}
// MODULE Arcs
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
{
if( m_moduleObjects[i]->m_objType == wxT( 'A' ) )
m_moduleObjects[i]->AddToModule( module );
m_moduleObjects[ i ]->AddToFootprint( module );
}
// MODULE POLYGONS
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
{
if( m_moduleObjects[i]->m_objType == wxT( 'Z' ) )
m_moduleObjects[i]->AddToModule( module );
m_moduleObjects[ i ]->AddToFootprint( module );
}
// PADS
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
{
if( m_moduleObjects[i]->m_objType == wxT( 'P' ) )
( (PCB_PAD*) m_moduleObjects[i] )->AddToModule( module, m_rotation, false );
((PCB_PAD*) m_moduleObjects[ i ] )->AddToFootprint( module, m_rotation, false );
}
// VIAS
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
{
if( m_moduleObjects[i]->m_objType == wxT( 'V' ) )
( (PCB_VIA*) m_moduleObjects[i] )->AddToModule( module, m_rotation, false );
((PCB_VIA*) m_moduleObjects[ i ] )->AddToFootprint( module, m_rotation, false );
}
module->CalculateBoundingBox();

View File

@ -34,7 +34,8 @@
namespace PCAD2KICAD {
PCB_PAD::PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard )
PCB_PAD::PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard )
{
m_objType = wxT( 'P' );
m_number = 0;
@ -49,17 +50,15 @@ PCB_PAD::~PCB_PAD()
int i;
for( i = 0; i < (int) m_shapes.GetCount(); i++ )
{
delete m_shapes[i];
}
}
void PCB_PAD::Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion )
{
XNODE* lNode, *cNode;
XNODE* lNode;
XNODE* cNode;
long num;
wxString propValue, str, emsg;
PCB_PAD_SHAPE* padShape;
@ -85,8 +84,10 @@ void PCB_PAD::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "pt" ) );
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_positionX, &m_positionY, aActualConversion );
{
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_positionX, &m_positionY,
aActualConversion );
}
lNode = FindNode( aNode, wxT( "rotation" ) );
@ -123,6 +124,7 @@ void PCB_PAD::Parse( XNODE* aNode,
lNode = lNode->GetParent();
lNode = FindNode( lNode, wxT( "library" ) );
if ( !lNode )
THROW_IO_ERROR( wxT( "Unable to find library section" ) );
@ -184,7 +186,7 @@ void PCB_PAD::Flip()
}
void PCB_PAD::AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad )
void PCB_PAD::AddToFootprint( MODULE* aFootprint, int aRotation, bool aEncapsulatedPad )
{
PCB_PAD_SHAPE* padShape;
wxString padShapeName = wxT( "Ellipse" );
@ -193,7 +195,7 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad
int width = 0;
int height = 0;
PAD* pad = new PAD( aModule );
PAD* pad = new PAD( aFootprint );
if( !m_isHolePlated && m_hole )
{
@ -300,11 +302,11 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad
// whereas Pos0 is relative to the module's but is the unrotated coordinate.
wxPoint padpos( m_positionX, m_positionY );
pad->SetPos0( padpos );
RotatePoint( &padpos, aModule->GetOrientation() );
pad->SetPosition( padpos + aModule->GetPosition() );
RotatePoint( &padpos, aFootprint->GetOrientation() );
pad->SetPosition( padpos + aFootprint->GetPosition() );
}
aModule->Add( pad );
aFootprint->Add( pad );
}
@ -363,7 +365,7 @@ void PCB_PAD::AddToBoard()
m_name.text = m_defaultPinDes;
module->SetPosition( wxPoint( m_positionX, m_positionY ) );
AddToModule( module, 0, true );
AddToFootprint( module, 0, true );
}
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.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,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pcb_pad.h
*/
#ifndef PCB_PAD_H_
#define PCB_PAD_H_
@ -40,24 +36,27 @@ namespace PCAD2KICAD {
class PCB_PAD : public PCB_COMPONENT
{
public:
int m_number;
int m_hole;
bool m_isHolePlated;
int m_number;
int m_hole;
bool m_isHolePlated;
PCB_PAD_SHAPES_ARRAY m_shapes;
PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_PAD();
virtual void Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion );
virtual void Flip() override;
void AddToModule( MODULE* aModule ) override
virtual void Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion );
virtual void Flip() override;
void AddToFootprint( MODULE* aFootprint ) override
{
AddToModule( aModule, 0, true );
AddToFootprint( aFootprint, 0, true );
}
void AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad );
void AddToBoard() override;
void AddToFootprint( MODULE* aFootprint, int aRotation, bool aEncapsulatedPad );
void AddToBoard() override;
private:
wxString m_defaultPinDes;

View File

@ -42,8 +42,7 @@ public:
PCB_PLANE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
~PCB_PLANE();
virtual bool Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
virtual bool Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion ) override;
};

View File

@ -160,12 +160,12 @@ bool PCB_POLYGON::Parse( XNODE* aNode,
}
void PCB_POLYGON::AddToModule( MODULE* aModule )
void PCB_POLYGON::AddToFootprint( MODULE* aFootprint )
{
if( IsNonCopperLayer( m_KiCadLayer ) )
{
FP_SHAPE* dwg = new FP_SHAPE( aModule, S_POLYGON );
aModule->Add( dwg );
FP_SHAPE* dwg = new FP_SHAPE( aFootprint, S_POLYGON );
aFootprint->Add( dwg );
dwg->SetWidth( 0 );
dwg->SetLayer( m_KiCadLayer );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.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
@ -51,22 +51,24 @@ public:
PCB_POLYGON( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
~PCB_POLYGON();
virtual bool Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
virtual bool Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion );
virtual void SetPosOffset( int aX_offs, int aY_offs ) override;
virtual void Flip() override;
void AddToModule( MODULE* aModule ) override;
void AddToBoard() override;
virtual void SetPosOffset( int aX_offs, int aY_offs ) override;
virtual void Flip() override;
void AddToFootprint( MODULE* aFootprint ) override;
void AddToBoard() override;
// protected:
void AssignNet( const wxString& aNetName );
void SetOutline( VERTICES_ARRAY* aOutline );
void AssignNet( const wxString& aNetName );
void FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
const wxString& aDefaultMeasurementUnit,
const wxString& actualConversion );
void SetOutline( VERTICES_ARRAY* aOutline );
void FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
const wxString& aDefaultMeasurementUnit, const wxString& actualConversion );
protected:
bool m_filled;
};

View File

@ -31,8 +31,8 @@
namespace PCAD2KICAD {
PCB_TEXT::PCB_TEXT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks,
aBoard )
PCB_TEXT::PCB_TEXT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard )
{
m_objType = wxT( 'T' );
}
@ -43,9 +43,7 @@ PCB_TEXT::~PCB_TEXT()
}
void PCB_TEXT::Parse( XNODE* aNode,
int aLayer,
const wxString& aDefaultMeasurementUnit,
void PCB_TEXT::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -59,8 +57,10 @@ void PCB_TEXT::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "pt" ) );
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_positionX, &m_positionY, aActualConversion );
{
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_positionX, &m_positionY,
aActualConversion );
}
lNode = FindNode( aNode, wxT( "rotation" ) );
@ -89,7 +89,7 @@ void PCB_TEXT::Parse( XNODE* aNode,
}
void PCB_TEXT::AddToModule( MODULE* aModule )
void PCB_TEXT::AddToFootprint( MODULE* aFootprint )
{
}
@ -114,8 +114,7 @@ void PCB_TEXT::AddToBoard()
pcbtxt->SetTextThickness( m_name.textstrokeWidth );
SetTextJustify( pcbtxt, m_name.justify );
pcbtxt->SetTextPos( wxPoint( m_name.textPositionX,
m_name.textPositionY ) );
pcbtxt->SetTextPos( wxPoint( m_name.textPositionX, m_name.textPositionY ) );
pcbtxt->SetMirrored( m_name.mirror );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.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
@ -44,12 +44,12 @@ public:
PCB_TEXT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_TEXT();
virtual void Parse( XNODE* aNode,
int aLayer,
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion );
void AddToModule( MODULE* aModule ) override;
void AddToBoard() override;
virtual void Parse( XNODE* aNode, int aLayer, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion );
void AddToFootprint( MODULE* aFootprint ) override;
void AddToBoard() override;
// virtual void SetPosOffset( int aX_offs, int aY_offs );
};

View File

@ -3765,10 +3765,10 @@ class SPECCTRA_DB : public SPECCTRA_LEXER
* allocates an IMAGE on the heap and creates all the PINs according
* to the D_PADs in the MODULE.
* @param aBoard The owner of the MODULE.
* @param aModule The MODULE from which to build the IMAGE.
* @param aFootprint The MODULE from which to build the IMAGE.
* @return IMAGE* - not tested for duplication yet.
*/
IMAGE* makeIMAGE( BOARD* aBoard, MODULE* aModule );
IMAGE* makeIMAGE( BOARD* aBoard, MODULE* aFootprint );
/**
* Function makePADSTACK

View File

@ -593,24 +593,24 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, PAD* aPad )
typedef std::map<wxString, int> PINMAP;
IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aFootprint )
{
PINMAP pinmap;
wxString padName;
PCB_TYPE_COLLECTOR moduleItems;
PCB_TYPE_COLLECTOR fpItems;
// get all the MODULE's pads.
moduleItems.Collect( aModule, scanPADs );
fpItems.Collect( aFootprint, scanPADs );
IMAGE* image = new IMAGE(0);
image->image_id = aModule->GetFPID().Format().c_str();
image->image_id = aFootprint->GetFPID().Format().c_str();
// from the pads, and make an IMAGE using collated padstacks.
for( int p=0; p < moduleItems.GetCount(); ++p )
for( int p=0; p < fpItems.GetCount(); ++p )
{
PAD* pad = (PAD*) moduleItems[p];
PAD* pad = (PAD*) fpItems[p];
// see if this pad is a through hole with no copper on its perimeter
if( isRoundKeepout( pad ) )
@ -686,7 +686,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
pin->padstack_id = padstack->padstack_id;
double angle = pad->GetOrientationDegrees() - aModule->GetOrientationDegrees();
double angle = pad->GetOrientationDegrees() - aFootprint->GetOrientationDegrees();
NORMALIZE_ANGLE_DEGREES_POS( angle );
pin->SetRotation( angle );
@ -700,11 +700,11 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
static const KICAD_T scanEDGEs[] = { PCB_FP_SHAPE_T, EOT };
// get all the MODULE's EDGE_MODULEs and convert those to DSN outlines.
moduleItems.Collect( aModule, scanEDGEs );
fpItems.Collect( aFootprint, scanEDGEs );
for( int i = 0; i<moduleItems.GetCount(); ++i )
for( int i = 0; i < fpItems.GetCount(); ++i )
{
FP_SHAPE* graphic = (FP_SHAPE*) moduleItems[i];
FP_SHAPE* graphic = (FP_SHAPE*) fpItems[i];
SHAPE* outline;
PATH* path;