Minor fix and enhancement code.

This commit is contained in:
jean-pierre charras 2019-09-15 11:10:53 +02:00
parent 91c66a05ae
commit 64b5e8bee2
4 changed files with 26 additions and 20 deletions

View File

@ -244,7 +244,9 @@ bool GERBER_PLOTTER::EndPlot()
{ {
fputs( line, outputFile ); fputs( line, outputFile );
if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 ) char* substr = strtok( line, "\n\r" );
if( substr && strcmp( substr, "G04 APERTURE LIST*" ) == 0 )
{ {
writeApertureList(); writeApertureList();
fputs( "G04 APERTURE END LIST*\n", outputFile ); fputs( "G04 APERTURE END LIST*\n", outputFile );

View File

@ -1393,9 +1393,24 @@ bool MODULE::BuildPolyCourtyard()
return success; return success;
} }
void MODULE::SwapData( BOARD_ITEM* aImage ) void MODULE::SwapData( BOARD_ITEM* aImage )
{ {
assert( aImage->Type() == PCB_MODULE_T ); assert( aImage->Type() == PCB_MODULE_T );
std::swap( *((MODULE*) this), *((MODULE*) aImage) ); std::swap( *((MODULE*) this), *((MODULE*) aImage) );
} }
bool MODULE::HasNonSMDPins() const
{
// returns true if the given module has at lesat one non smd pin, such as through hole
for( auto pad : Pads() )
{
if( pad->GetAttribute() != PAD_ATTRIB_SMD )
return true;
}
return false;
}

View File

@ -182,6 +182,13 @@ public:
return m_drawings; return m_drawings;
} }
/**
* @return true if the given module has any non smd pins, such as through hole
* and therefore cannot be placed automatically.
* Used in Pick and Place files writers
*/
bool HasNonSMDPins() const;
std::list<MODULE_3D_SETTINGS>& Models() { return m_3D_Drawings; } std::list<MODULE_3D_SETTINGS>& Models() { return m_3D_Drawings; }
const std::list<MODULE_3D_SETTINGS>& Models() const { return m_3D_Drawings; } const std::list<MODULE_3D_SETTINGS>& Models() const { return m_3D_Drawings; }

View File

@ -62,24 +62,6 @@ static bool sortFPlist( const LIST_MOD& ref, const LIST_MOD& tst )
} }
/**
* Helper function HasNonSMDPins
* returns true if the given module has any non smd pins, such as through hole
* and therefore cannot be placed automatically.
*/
static bool HasNonSMDPins( MODULE* aModule )
{
for( auto pad : aModule->Pads() )
{
if( pad->GetAttribute() != PAD_ATTRIB_SMD )
return true;
}
return false;
}
enum SELECT_SIDE enum SELECT_SIDE
{ {
PCB_NO_SIDE, PCB_NO_SIDE,
@ -150,7 +132,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
{ {
if( m_forceSmdItems ) // true to fix a bunch of mis-labeled footprints: if( m_forceSmdItems ) // true to fix a bunch of mis-labeled footprints:
{ {
if( !HasNonSMDPins( footprint ) ) if( !footprint->HasNonSMDPins() )
{ {
// all footprint's pins are SMD, mark the part for pick and place // all footprint's pins are SMD, mark the part for pick and place
// Note: they are not necessary to pick and place, // Note: they are not necessary to pick and place,