Browse Source

EasyEDA import: Build basic Courtyard box for footprints.

9.0
Alex Shvartzkop 2 months ago
parent
commit
8cd7b73b2a
  1. 17
      pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp
  2. 28
      pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp

17
pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp

@ -1119,6 +1119,23 @@ FOOTPRINT* PCB_IO_EASYEDA_PARSER::ParseFootprint(
for( std::unique_ptr<PCB_SHAPE>& ptr : newShapes )
footprint->Add( ptr.release(), ADD_MODE::APPEND );
// EasyEDA footprints don't have courtyard, so build a box ourselves
if( !footprint->IsOnLayer( F_CrtYd ) )
{
BOX2I bbox = footprint->GetLayerBoundingBox( { F_Cu, F_Fab, F_Paste, F_Mask, Edge_Cuts } );
bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Default courtyard clearance
std::unique_ptr<PCB_SHAPE> shape =
std::make_unique<PCB_SHAPE>( footprint.get(), SHAPE_T::RECTANGLE );
shape->SetWidth( pcbIUScale.mmToIU( DEFAULT_COURTYARD_WIDTH ) );
shape->SetLayer( F_CrtYd );
shape->SetStart( bbox.GetOrigin() );
shape->SetEnd( bbox.GetEnd() );
footprint->Add( shape.release(), ADD_MODE::APPEND );
}
return footprint.release();
}

28
pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp

@ -927,23 +927,37 @@ FOOTPRINT* PCB_IO_EASYEDAPRO_PARSER::ParseFootprint( const nlohmann::json&
}
// Heal board outlines
std::vector<PCB_SHAPE*> shapes;
std::vector<PCB_SHAPE*> edgeShapes;
std::vector<std::unique_ptr<PCB_SHAPE>> newShapes;
for( BOARD_ITEM* item : footprint->GraphicalItems() )
{
if( !item->IsOnLayer( Edge_Cuts ) )
continue;
if( item->Type() == PCB_SHAPE_T )
shapes.push_back( static_cast<PCB_SHAPE*>( item ) );
if( item->IsOnLayer( Edge_Cuts ) && item->Type() == PCB_SHAPE_T )
edgeShapes.push_back( static_cast<PCB_SHAPE*>( item ) );
}
ConnectBoardShapes( shapes, newShapes, SHAPE_JOIN_DISTANCE );
ConnectBoardShapes( edgeShapes, newShapes, SHAPE_JOIN_DISTANCE );
for( std::unique_ptr<PCB_SHAPE>& ptr : newShapes )
footprint->Add( ptr.release(), ADD_MODE::APPEND );
// EasyEDA footprints don't have courtyard, so build a box ourselves
if( !footprint->IsOnLayer( F_CrtYd ) )
{
BOX2I bbox = footprint->GetLayerBoundingBox( { F_Cu, F_Fab, F_Paste, F_Mask, Edge_Cuts } );
bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Default courtyard clearance
std::unique_ptr<PCB_SHAPE> shape =
std::make_unique<PCB_SHAPE>( footprint, SHAPE_T::RECTANGLE );
shape->SetWidth( pcbIUScale.mmToIU( DEFAULT_COURTYARD_WIDTH ) );
shape->SetLayer( F_CrtYd );
shape->SetStart( bbox.GetOrigin() );
shape->SetEnd( bbox.GetEnd() );
footprint->Add( shape.release(), ADD_MODE::APPEND );
}
return footprintPtr.release();
}

Loading…
Cancel
Save