More module -> footprint.

This commit is contained in:
Jeff Young 2020-11-13 01:12:36 +00:00
parent fc9cf1d827
commit 8c947b69b0
11 changed files with 300 additions and 278 deletions

View File

@ -545,13 +545,13 @@ class BOARD_ADAPTER
COBJECT2D *createNewPadDrill( const PAD* aPad, int aInflateValue );
void AddPadsWithClearanceToContainer( const MODULE *aModule,
void AddPadsWithClearanceToContainer( const MODULE *aFootprint,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue,
bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads,
bool aSkipNonPlatedPads );
void AddFPShapesWithClearanceToContainer( const MODULE *aModule,
void AddFPShapesWithClearanceToContainer( const MODULE *aFootprint,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue );

View File

@ -185,7 +185,7 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DIMENSION_BASE* aDim
// Based on
// void FOOTPRINT::TransformFPShapesWithClearanceToPolygonSet
// board_items_to_polygon_shape_transform.cpp#L204
void BOARD_ADAPTER::AddFPShapesWithClearanceToContainer( const MODULE* aModule,
void BOARD_ADAPTER::AddFPShapesWithClearanceToContainer( const MODULE* aFootprint,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId,
int aInflateValue )
@ -193,7 +193,7 @@ void BOARD_ADAPTER::AddFPShapesWithClearanceToContainer( const MODULE* aModule,
std::vector<FP_TEXT*> texts; // List of FP_TEXT to convert
FP_SHAPE* outline;
for( BOARD_ITEM* item : aModule->GraphicalItems() )
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
{
switch( item->Type() )
{
@ -225,13 +225,13 @@ void BOARD_ADAPTER::AddFPShapesWithClearanceToContainer( const MODULE* aModule,
}
// Convert texts sur footprints
if( aModule->Reference().GetLayer() == aLayerId && aModule->Reference().IsVisible() )
texts.push_back( &aModule->Reference() );
if( aFootprint->Reference().GetLayer() == aLayerId && aFootprint->Reference().IsVisible() )
texts.push_back( &aFootprint->Reference() );
if( aModule->Value().GetLayer() == aLayerId && aModule->Value().IsVisible() )
texts.push_back( &aModule->Value() );
if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() )
texts.push_back( &aFootprint->Value() );
s_boardItem = (const BOARD_ITEM *)&aModule->Value();
s_boardItem = (const BOARD_ITEM *)&aFootprint->Value();
s_dstcontainer = aDstContainer;
s_biuTo3Dunits = m_biuTo3Dunits;
@ -473,7 +473,7 @@ COBJECT2D *BOARD_ADAPTER::createNewPadDrill( const PAD* aPad, int aInflateValue
}
void BOARD_ADAPTER::AddPadsWithClearanceToContainer( const MODULE* aModule,
void BOARD_ADAPTER::AddPadsWithClearanceToContainer( const MODULE* aFootprint,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId,
int aInflateValue,
@ -481,7 +481,7 @@ void BOARD_ADAPTER::AddPadsWithClearanceToContainer( const MODULE* aModule,
bool aSkipPlatedPads,
bool aSkipNonPlatedPads )
{
for( PAD* pad : aModule->Pads() )
for( PAD* pad : aFootprint->Pads() )
{
if( !pad->IsOnLayer( aLayerId ) )
continue;

View File

@ -92,13 +92,14 @@ AR_AUTOPLACER::AR_AUTOPLACER( BOARD* aBoard )
}
void AR_AUTOPLACER::placeModule( MODULE* aModule, bool aDoNotRecreateRatsnest, const wxPoint& aPos )
void AR_AUTOPLACER::placeFootprint( MODULE* aFootprint, bool aDoNotRecreateRatsnest,
const wxPoint& aPos )
{
if( !aModule )
if( !aFootprint )
return;
aModule->SetPosition( aPos );
m_connectivity->Update( aModule );
aFootprint->SetPosition( aPos );
m_connectivity->Update( aFootprint );
}
@ -270,18 +271,18 @@ bool AR_AUTOPLACER::fillMatrix()
}
void AR_AUTOPLACER::rotateModule( MODULE* module, double angle, bool incremental )
void AR_AUTOPLACER::rotateFootprint( MODULE* aFootprint, double angle, bool incremental )
{
if( module == NULL )
if( aFootprint == NULL )
return;
if( incremental )
module->SetOrientation( module->GetOrientation() + angle );
aFootprint->SetOrientation( aFootprint->GetOrientation() + angle );
else
module->SetOrientation( angle );
aFootprint->SetOrientation( angle );
m_board->GetConnectivity()->Update( module );
m_board->GetConnectivity()->Update( aFootprint );
}
@ -545,22 +546,23 @@ unsigned int AR_AUTOPLACER::calculateKeepOutArea( const EDA_RECT& aRect, int sid
* Returns the value TstRectangle().
* Module is known by its bounding box
*/
int AR_AUTOPLACER::testModuleOnBoard( MODULE* aModule, bool TstOtherSide, const wxPoint& aOffset )
int AR_AUTOPLACER::testModuleOnBoard( MODULE* aFootprint, bool TstOtherSide,
const wxPoint& aOffset )
{
int side = AR_SIDE_TOP;
int otherside = AR_SIDE_BOTTOM;
if( aModule->GetLayer() == B_Cu )
if( aFootprint->GetLayer() == B_Cu )
{
side = AR_SIDE_BOTTOM; otherside = AR_SIDE_TOP;
}
EDA_RECT fpBBox = aModule->GetFootprintRect();
EDA_RECT fpBBox = aFootprint->GetFootprintRect();
fpBBox.Move( -aOffset );
buildFpAreas( aModule, 0 );
buildFpAreas( aFootprint, 0 );
int diag = //testModuleByPolygon( aModule, side, aOffset );
int diag = //testModuleByPolygon( aFootprint, side, aOffset );
testRectangle( fpBBox, side );
if( diag != AR_FREE_CELL )
@ -568,33 +570,33 @@ int AR_AUTOPLACER::testModuleOnBoard( MODULE* aModule, bool TstOtherSide, const
if( TstOtherSide )
{
diag = //testModuleByPolygon( aModule, otherside, aOffset );
diag = //testModuleByPolygon( aFootprint, otherside, aOffset );
testRectangle( fpBBox, otherside );
if( diag != AR_FREE_CELL )
return diag;
}
int marge = ( m_matrix.m_GridRouting * aModule->GetPadCount() ) / AR_GAIN;
int marge = ( m_matrix.m_GridRouting * aFootprint->GetPadCount() ) / AR_GAIN;
fpBBox.Inflate( marge );
return calculateKeepOutArea( fpBBox, side );
}
int AR_AUTOPLACER::getOptimalModulePlacement(MODULE* aModule)
int AR_AUTOPLACER::getOptimalFPPlacement( MODULE* aFootprint )
{
int error = 1;
wxPoint LastPosOK;
double min_cost, curr_cost, Score;
bool TstOtherSide;
aModule->CalculateBoundingBox();
aFootprint->CalculateBoundingBox();
LastPosOK = m_matrix.m_BrdBox.GetOrigin();
wxPoint mod_pos = aModule->GetPosition();
EDA_RECT fpBBox = aModule->GetFootprintRect();
wxPoint mod_pos = aFootprint->GetPosition();
EDA_RECT fpBBox = aFootprint->GetFootprintRect();
// Move fpBBox to have the footprint position at (0,0)
fpBBox.Move( -mod_pos );
@ -620,9 +622,9 @@ int AR_AUTOPLACER::getOptimalModulePlacement(MODULE* aModule)
if( m_matrix.m_RoutingLayersCount > 1 )
{
LSET other( aModule->GetLayer() == B_Cu ? F_Cu : B_Cu );
LSET other( aFootprint->GetLayer() == B_Cu ? F_Cu : B_Cu );
for( auto pad : aModule->Pads() )
for( PAD* pad : aFootprint->Pads() )
{
if( !( pad->GetLayerSet() & other ).any() )
continue;
@ -647,13 +649,13 @@ int AR_AUTOPLACER::getOptimalModulePlacement(MODULE* aModule)
fpBBox.SetOrigin( fpBBoxOrg + m_curPosition );
moduleOffset = mod_pos - m_curPosition;
int keepOutCost = testModuleOnBoard( aModule, TstOtherSide, moduleOffset );
int keepOutCost = testModuleOnBoard( aFootprint, TstOtherSide, moduleOffset );
if( keepOutCost >= 0 ) // i.e. if the module can be put here
{
error = 0;
// m_frame->build_ratsnest_module( aModule ); // fixme
curr_cost = computePlacementRatsnestCost( aModule, moduleOffset );
// m_frame->build_ratsnest_module( aFootprint ); // fixme
curr_cost = computePlacementRatsnestCost( aFootprint, moduleOffset );
Score = curr_cost + keepOutCost;
if( (min_cost >= Score ) || (min_cost < 0 ) )
@ -679,14 +681,14 @@ int AR_AUTOPLACER::getOptimalModulePlacement(MODULE* aModule)
}
const PAD* AR_AUTOPLACER::nearestPad( MODULE *aRefModule, PAD* aRefPad, const wxPoint& aOffset)
const PAD* AR_AUTOPLACER::nearestPad( MODULE *aRefFP, PAD* aRefPad, const wxPoint& aOffset)
{
const PAD* nearest = nullptr;
int64_t nearestDist = INT64_MAX;
for ( MODULE* footprint : m_board->Footprints() )
{
if ( footprint == aRefModule )
if ( footprint == aRefFP )
continue;
if( !m_matrix.m_BrdBox.Contains( footprint->GetPosition() ) )
@ -711,7 +713,7 @@ const PAD* AR_AUTOPLACER::nearestPad( MODULE *aRefModule, PAD* aRefPad, const wx
}
double AR_AUTOPLACER::computePlacementRatsnestCost( MODULE *aModule, const wxPoint& aOffset )
double AR_AUTOPLACER::computePlacementRatsnestCost( MODULE *aFootprint, const wxPoint& aOffset )
{
double curr_cost;
VECTOR2I start; // start point of a ratsnest
@ -720,9 +722,9 @@ double AR_AUTOPLACER::computePlacementRatsnestCost( MODULE *aModule, const wxPoi
curr_cost = 0;
for ( auto pad : aModule->Pads() )
for ( PAD* pad : aFootprint->Pads() )
{
auto nearest = nearestPad( aModule, pad, aOffset );
const PAD* nearest = nearestPad( aFootprint, pad, aOffset );
if( !nearest )
continue;
@ -780,61 +782,60 @@ static bool sortFootprintsByRatsnestSize( MODULE* ref, MODULE* compare )
}
MODULE* AR_AUTOPLACER::pickModule( )
MODULE* AR_AUTOPLACER::pickFootprint( )
{
MODULE* module;
std::vector <MODULE*> moduleList;
std::vector<MODULE*> fpList;
for( MODULE* footprint : m_board->Footprints() )
{
footprint->CalculateBoundingBox();
moduleList.push_back( footprint );
fpList.push_back( footprint );
}
sort( moduleList.begin(), moduleList.end(), sortFootprintsByComplexity );
sort( fpList.begin(), fpList.end(), sortFootprintsByComplexity );
for( unsigned kk = 0; kk < moduleList.size(); kk++ )
for( unsigned kk = 0; kk < fpList.size(); kk++ )
{
module = moduleList[kk];
module->SetFlag( 0 );
MODULE* footprint = fpList[kk];
footprint->SetFlag( 0 );
if( !module->NeedsPlaced() )
if( !footprint->NeedsPlaced() )
continue;
m_connectivity->Update( module );
m_connectivity->Update( footprint );
}
m_connectivity->RecalculateRatsnest();
for( unsigned kk = 0; kk < moduleList.size(); kk++ )
for( unsigned kk = 0; kk < fpList.size(); kk++ )
{
module = moduleList[kk];
MODULE* footprint = fpList[kk];
auto edges = m_connectivity->GetRatsnestForComponent( module, true );
auto edges = m_connectivity->GetRatsnestForComponent( footprint, true );
module->SetFlag( edges.size() ) ;
footprint->SetFlag( edges.size() ) ;
}
sort( moduleList.begin(), moduleList.end(), sortFootprintsByRatsnestSize );
sort( fpList.begin(), fpList.end(), sortFootprintsByRatsnestSize );
// Search for "best" module.
MODULE* bestModule = nullptr;
MODULE* altModule = nullptr;
for( unsigned ii = 0; ii < moduleList.size(); ii++ )
for( unsigned ii = 0; ii < fpList.size(); ii++ )
{
module = moduleList[ii];
MODULE* footprint = fpList[ii];
if( !module->NeedsPlaced() )
if( !footprint->NeedsPlaced() )
continue;
altModule = module;
altModule = footprint;
if( module->GetFlag() == 0 )
if( footprint->GetFlag() == 0 )
continue;
bestModule = module;
bestModule = footprint;
break;
}
@ -876,12 +877,12 @@ void AR_AUTOPLACER::drawPlacementRoutingMatrix( )
}
AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD_COMMIT* aCommit,
bool aPlaceOffboardModules )
AR_RESULT AR_AUTOPLACER::AutoplaceFootprints( std::vector<MODULE*>& aFootprints,
BOARD_COMMIT* aCommit,
bool aPlaceOffboardModules )
{
wxPoint memopos;
int error;
MODULE* module = nullptr;
bool cancelled = false;
memopos = m_curPosition;
@ -912,7 +913,7 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD
}
}
for( MODULE* footprint : aModules )
for( MODULE* footprint : aFootprints )
{
footprint->SetNeedsPlaced( true );
aCommit->Modify( footprint );
@ -947,19 +948,20 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD
if( m_refreshCallback )
m_refreshCallback( nullptr );
MODULE* footprint;
while( ( module = pickModule( ) ) != nullptr )
while( ( footprint = pickFootprint() ) != nullptr )
{
// Display some info about activity, module placement can take a while:
// Display some info about activity, footprint placement can take a while:
//m_frame->SetStatusText( msg );
if( m_progressReporter )
m_progressReporter->SetTitle( wxString::Format(
_( "Autoplacing %s" ), module->GetReference() ) );
_( "Autoplacing %s" ), footprint->GetReference() ) );
double initialOrient = module->GetOrientation();
double initialOrient = footprint->GetOrientation();
error = getOptimalModulePlacement( module );
error = getOptimalFPPlacement( footprint );
double bestScore = m_minCost;
double bestRotation = 0.0;
int rotAllowed;
@ -968,12 +970,12 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD
goto end_of_tst;
// Try orientations 90, 180, 270 degrees from initial orientation
rotAllowed = module->GetPlacementCost180();
rotAllowed = footprint->GetPlacementCost180();
if( rotAllowed != 0 )
{
rotateModule( module, 1800.0, true );
error = getOptimalModulePlacement( module );
rotateFootprint( footprint, 1800.0, true );
error = getOptimalFPPlacement( footprint );
m_minCost *= OrientationPenalty[rotAllowed];
if( bestScore > m_minCost ) // This orientation is better.
@ -983,7 +985,7 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD
}
else
{
rotateModule( module, initialOrient, false );
rotateFootprint( footprint, initialOrient, false );
}
if( error == AR_ABORT_PLACEMENT )
@ -991,12 +993,12 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD
}
// Determine if the best orientation of a module is 90.
rotAllowed = module->GetPlacementCost90();
rotAllowed = footprint->GetPlacementCost90();
if( rotAllowed != 0 )
{
rotateModule( module, 900.0, true );
error = getOptimalModulePlacement( module );
rotateFootprint( footprint, 900.0, true );
error = getOptimalFPPlacement( footprint );
m_minCost *= OrientationPenalty[rotAllowed];
if( bestScore > m_minCost ) // This orientation is better.
@ -1006,7 +1008,7 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD
}
else
{
rotateModule( module, initialOrient, false );
rotateFootprint( footprint, initialOrient, false );
}
if( error == AR_ABORT_PLACEMENT )
@ -1016,8 +1018,8 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD
// Determine if the best orientation of a module is -90.
if( rotAllowed != 0 )
{
rotateModule( module, 2700.0, true );
error = getOptimalModulePlacement( module );
rotateFootprint( footprint, 2700.0, true );
error = getOptimalFPPlacement( footprint );
m_minCost *= OrientationPenalty[rotAllowed];
if( bestScore > m_minCost ) // This orientation is better.
@ -1027,7 +1029,7 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector<MODULE*>& aModules, BOARD
}
else
{
rotateModule( module, initialOrient, false );
rotateFootprint( footprint, initialOrient, false );
}
if( error == AR_ABORT_PLACEMENT )
@ -1042,22 +1044,22 @@ end_of_tst:
bestRotation += initialOrient;
if( bestRotation != module->GetOrientation() )
if( bestRotation != footprint->GetOrientation() )
{
rotateModule( module, bestRotation, false );
rotateFootprint( footprint, bestRotation, false );
}
// Place module.
placeModule( module, true, m_curPosition );
placeFootprint( footprint, true, m_curPosition );
module->CalculateBoundingBox();
genModuleOnRoutingMatrix( module );
module->SetIsPlaced( true );
module->SetNeedsPlaced( false );
footprint->CalculateBoundingBox();
genModuleOnRoutingMatrix( footprint );
footprint->SetIsPlaced( true );
footprint->SetNeedsPlaced( false );
drawPlacementRoutingMatrix();
if( m_refreshCallback )
m_refreshCallback( module );
m_refreshCallback( footprint );
if( m_progressReporter )

View File

@ -59,8 +59,8 @@ class AR_AUTOPLACER
public:
AR_AUTOPLACER( BOARD* aBoard );
AR_RESULT AutoplaceModules( std::vector<MODULE*>& aModules, BOARD_COMMIT* aCommit,
bool aPlaceOffboardModules = false );
AR_RESULT AutoplaceFootprints( std::vector<MODULE*>& aFootprints, BOARD_COMMIT* aCommit,
bool aPlaceOffboardModules = false );
/**
* Set a VIEW overlay to draw items during a autoplace session.
@ -86,7 +86,7 @@ public:
private:
void drawPlacementRoutingMatrix(); // draw the working area (shows free and occupied areas)
void rotateModule( MODULE* module, double angle, bool incremental );
void rotateFootprint( MODULE* aFootprint, double angle, bool incremental );
int genPlacementRoutingMatrix();
/** fills m_matrix cells from m_boardShape.
@ -97,19 +97,21 @@ private:
int testRectangle( const EDA_RECT& aRect, int side );
unsigned int calculateKeepOutArea( const EDA_RECT& aRect, int side );
int testModuleOnBoard( MODULE* aModule, bool TstOtherSide, const wxPoint& aOffset );
int getOptimalModulePlacement( MODULE* aModule );
double computePlacementRatsnestCost( MODULE* aModule, const wxPoint& aOffset );
int testModuleOnBoard( MODULE* aFootprint, bool TstOtherSide, const wxPoint& aOffset );
int getOptimalFPPlacement( MODULE* aFootprint );
double computePlacementRatsnestCost( MODULE* aFootprint, const wxPoint& aOffset );
/**
* Find the "best" module place. The criteria are:
* - Maximum ratsnest with footprints already placed
* - Max size, and number of pads max
*/
MODULE* pickModule();
MODULE* pickFootprint();
void placeModule( MODULE* aModule, bool aDoNotRecreateRatsnest, const wxPoint& aPos );
const PAD* nearestPad( MODULE* aRefModule, PAD* aRefPad, const wxPoint& aOffset );
void placeFootprint( MODULE* aFootprint, bool aDoNotRecreateRatsnest,
const wxPoint& aPos );
const PAD* nearestPad( MODULE* aRefFP, PAD* aRefPad, const wxPoint& aOffset );
// Add a polygonal shape (rectangle) to m_fpAreaFront and/or m_fpAreaBack
void addFpBody( wxPoint aStart, wxPoint aEnd, LSET aLayerMask );

View File

@ -46,10 +46,10 @@ AUTOPLACE_TOOL::~AUTOPLACE_TOOL()
// especially each time a footprint is autoplaced,
static PCB_BASE_EDIT_FRAME* fparent;
static int refreshCallback( MODULE* aModule )
static int refreshCallback( MODULE* aFootprint )
{
if( aModule )
fparent->GetCanvas()->GetView()->Update( aModule );
if( aFootprint )
fparent->GetCanvas()->GetView()->Update( aFootprint );
fparent->GetCanvas()->GetView()->MarkDirty();
fparent->GetCanvas()->Refresh();
@ -59,7 +59,7 @@ static int refreshCallback( MODULE* aModule )
}
int AUTOPLACE_TOOL::autoplace( std::vector<MODULE*>& aModules, bool aPlaceOffboard )
int AUTOPLACE_TOOL::autoplace( std::vector<MODULE*>& aFootprints, bool aPlaceOffboard )
{
EDA_RECT bbox = board()->GetBoardEdgesBoundingBox();
@ -82,14 +82,14 @@ int AUTOPLACE_TOOL::autoplace( std::vector<MODULE*>& aModules, bool aPlaceOffboa
autoplacer.SetOverlay( overlay );
fparent = frame();
std::function<int( MODULE* aModule )> callback = refreshCallback;
std::function<int( MODULE* aFootprint )> callback = refreshCallback;
autoplacer.SetRefreshCallback( callback );
std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
new WX_PROGRESS_REPORTER( frame(), _( "Autoplace Components" ), 1 ) );
autoplacer.SetProgressReporter( progressReporter.get() );
auto result = autoplacer.AutoplaceModules( aModules, &commit, aPlaceOffboard );
auto result = autoplacer.AutoplaceFootprints( aFootprints, &commit, aPlaceOffboard );
if( result == AR_COMPLETED )
commit.Push( _( "Autoplace components" ) );
@ -102,23 +102,23 @@ int AUTOPLACE_TOOL::autoplace( std::vector<MODULE*>& aModules, bool aPlaceOffboa
int AUTOPLACE_TOOL::autoplaceSelected( const TOOL_EVENT& aEvent )
{
std::vector<MODULE*> mods;
std::vector<MODULE*> footprints;
for( EDA_ITEM* item : selection() )
{
if( item->Type() == PCB_MODULE_T )
mods.push_back( static_cast<MODULE*>( item ) );
footprints.push_back( static_cast<MODULE*>( item ) );
}
return autoplace( mods, false );
return autoplace( footprints, false );
}
int AUTOPLACE_TOOL::autoplaceOffboard( const TOOL_EVENT& aEvent )
{
std::vector<MODULE*> mods;
std::vector<MODULE*> footprints;
return autoplace( mods, true );
return autoplace( footprints, true );
}

View File

@ -42,7 +42,7 @@ public:
void setTransitions() override;
private:
int autoplace( std::vector<MODULE*>& aModules, bool aPlaceOffboard );
int autoplace( std::vector<MODULE*>& aFootprints, bool aPlaceOffboard );
int autoplaceSelected( const TOOL_EVENT& aEvent );
int autoplaceOffboard( const TOOL_EVENT& aEvent );

View File

@ -626,35 +626,41 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponentLibrary()
}
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryFigures( const SYMDEF_PCB& aComponent, MODULE* aModule )
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryFigures( const SYMDEF_PCB& aComponent,
MODULE* aFootprint )
{
for( std::pair<FIGURE_ID, FIGURE> figPair : aComponent.Figures )
{
FIGURE& fig = figPair.second;
drawCadstarShape( fig.Shape, getKiCadLayer( fig.LayerID ),
getLineThickness( fig.LineCodeID ),
wxString::Format( "Component %s:%s -> Figure %s", aComponent.ReferenceName,
aComponent.Alternate, fig.ID ),
aModule );
getLineThickness( fig.LineCodeID ),
wxString::Format( "Component %s:%s -> Figure %s",
aComponent.ReferenceName,
aComponent.Alternate,
fig.ID ),
aFootprint );
}
}
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers( const SYMDEF_PCB& aComponent, MODULE* aModule )
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers( const SYMDEF_PCB& aComponent, MODULE* aFootprint )
{
for( COMPONENT_COPPER compCopper : aComponent.ComponentCoppers )
{
int lineThickness = getKiCadLength( getCopperCode( compCopper.CopperCodeID ).CopperWidth );
drawCadstarShape( compCopper.Shape, getKiCadLayer( compCopper.LayerID ), lineThickness,
wxString::Format( "Component %s:%s -> Copper element", aComponent.ReferenceName,
aComponent.Alternate ),
aModule );
wxString::Format( "Component %s:%s -> Copper element",
aComponent.ReferenceName,
aComponent.Alternate ),
aFootprint );
}
}
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas( const SYMDEF_PCB& aComponent, MODULE* aModule )
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas( const SYMDEF_PCB& aComponent,
MODULE* aFootprint )
{
for( std::pair<COMP_AREA_ID, COMPONENT_AREA> areaPair : aComponent.ComponentAreas )
{
@ -663,9 +669,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas( const SYMDEF_PCB& aComponent,
if( area.NoVias || area.NoTracks )
{
ZONE* zone = getZoneFromCadstarShape( area.Shape, getLineThickness( area.LineCodeID ),
aModule );
aFootprint );
aModule->Add( zone, ADD_MODE::APPEND );
aFootprint->Add( zone, ADD_MODE::APPEND );
if( isLayerSet( area.LayerID ) )
zone->SetLayerSet( getKiCadLayerSet( area.LayerID ) );
@ -699,14 +705,14 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas( const SYMDEF_PCB& aComponent,
}
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryPads( const SYMDEF_PCB& aComponent, MODULE* aModule )
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryPads( const SYMDEF_PCB& aComponent,
MODULE* aFootprint )
{
for( std::pair<PAD_ID, COMPONENT_PAD> padPair : aComponent.ComponentPads )
{
PAD* pad = getKiCadPad( padPair.second, aModule );
aModule->Add( pad,
ADD_MODE::INSERT ); // insert so that we get correct behaviour when finding pads
// in the module by PAD_ID - see loadNets()
PAD* pad = getKiCadPad( padPair.second, aFootprint );
aFootprint->Add( pad, ADD_MODE::INSERT ); // insert so that we get correct behaviour
// when finding pads by PAD_ID - see loadNets()
}
}
@ -1604,15 +1610,18 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNets()
}
void CADSTAR_PCB_ARCHIVE_LOADER::loadComponentAttributes(
const COMPONENT& aComponent, MODULE* aModule )
void CADSTAR_PCB_ARCHIVE_LOADER::loadComponentAttributes( const COMPONENT& aComponent,
MODULE* aFootprint )
{
for( std::pair<ATTRIBUTE_ID, ATTRIBUTE_VALUE> attrPair : aComponent.AttributeValues )
{
ATTRIBUTE_VALUE& attrval = attrPair.second;
if( attrval.HasLocation ) //only import attributes with location. Ignore the rest
addAttribute( attrval.AttributeLocation, attrval.AttributeID, aModule, attrval.Value );
{
addAttribute( attrval.AttributeLocation, attrval.AttributeID, aFootprint,
attrval.Value );
}
}
for( std::pair<ATTRIBUTE_ID, TEXT_LOCATION> textlocPair : aComponent.TextLocations )
@ -1635,7 +1644,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponentAttributes(
else
attrval = getAttributeValue( textloc.AttributeID, aComponent.AttributeValues );
addAttribute( textloc, textloc.AttributeID, aModule, attrval );
addAttribute( textloc, textloc.AttributeID, aFootprint, attrval );
}
}
@ -2279,26 +2288,28 @@ std::vector<TRACK*> CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromDrawsegments(
void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc,
const ATTRIBUTE_ID& aCadstarAttributeID, MODULE* aModule, const wxString& aAttributeValue )
const ATTRIBUTE_ID& aCadstarAttributeID,
MODULE* aFootprint,
const wxString& aAttributeValue )
{
FP_TEXT* txt;
if( aCadstarAttributeID == COMPONENT_NAME_ATTRID )
{
txt = &aModule->Reference(); //text should be set outside this function
txt = &aFootprint->Reference(); //text should be set outside this function
}
else if( aCadstarAttributeID == PART_NAME_ATTRID )
{
if( aModule->Value().GetText().IsEmpty() )
if( aFootprint->Value().GetText().IsEmpty() )
{
// Use PART_NAME_ATTRID as the value is value field is blank
aModule->SetValue( aAttributeValue );
txt = &aModule->Value();
aFootprint->SetValue( aAttributeValue );
txt = &aFootprint->Value();
}
else
{
txt = new FP_TEXT( aModule );
aModule->Add( txt );
txt = new FP_TEXT( aFootprint );
aFootprint->Add( txt );
txt->SetText( aAttributeValue );
}
txt->SetVisible( false ); //make invisible to avoid clutter.
@ -2306,34 +2317,34 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
else if( aCadstarAttributeID != COMPONENT_NAME_2_ATTRID
&& getAttributeName( aCadstarAttributeID ) == wxT( "Value" ) )
{
if( !aModule->Value().GetText().IsEmpty() )
if( !aFootprint->Value().GetText().IsEmpty() )
{
//copy the object
aModule->Add( new FP_TEXT( aModule->Value() ) );
aFootprint->Add( new FP_TEXT( aFootprint->Value() ) );
}
aModule->SetValue( aAttributeValue );
txt = &aModule->Value();
aFootprint->SetValue( aAttributeValue );
txt = &aFootprint->Value();
txt->SetVisible( false ); //make invisible to avoid clutter.
}
else
{
txt = new FP_TEXT( aModule );
aModule->Add( txt );
txt = new FP_TEXT( aFootprint );
aFootprint->Add( txt );
txt->SetText( aAttributeValue );
txt->SetVisible( false ); //make all user attributes invisible to avoid clutter.
//TODO: Future improvement - allow user to decide what to do with attributes
}
wxPoint rotatedTextPos = getKiCadPoint( aCadstarAttrLoc.Position ) - aModule->GetPosition();
RotatePoint( &rotatedTextPos, -aModule->GetOrientation() );
wxPoint rotatedTextPos = getKiCadPoint( aCadstarAttrLoc.Position ) - aFootprint->GetPosition();
RotatePoint( &rotatedTextPos, -aFootprint->GetOrientation() );
txt->SetTextPos( getKiCadPoint( aCadstarAttrLoc.Position ) );
txt->SetPos0( rotatedTextPos );
txt->SetLayer( getKiCadLayer( aCadstarAttrLoc.LayerID ) );
txt->SetMirrored( aCadstarAttrLoc.Mirror );
txt->SetTextAngle(
getAngleTenthDegree( aCadstarAttrLoc.OrientAngle ) - aModule->GetOrientation() );
getAngleTenthDegree( aCadstarAttrLoc.OrientAngle ) - aFootprint->GetOrientation() );
if( aCadstarAttrLoc.Mirror ) // If mirroring, invert angle to match CADSTAR
txt->SetTextAngle( -txt->GetTextAngle() );

View File

@ -133,11 +133,11 @@ private:
const PCB_LAYER_ID& aKiCadLayer );
void logBoardStackupMessage( const wxString& aCadstarLayerName,
const PCB_LAYER_ID& aKiCadLayer );
void loadLibraryFigures( const SYMDEF_PCB& aComponent, MODULE* aModule );
void loadLibraryCoppers( const SYMDEF_PCB& aComponent, MODULE* aModule );
void loadLibraryAreas( const SYMDEF_PCB& aComponent, MODULE* aModule );
void loadLibraryPads( const SYMDEF_PCB& aComponent, MODULE* aModule );
void loadComponentAttributes( const COMPONENT& aComponent, MODULE* aModule );
void loadLibraryFigures( const SYMDEF_PCB& aComponent, MODULE* aFootprint );
void loadLibraryCoppers( const SYMDEF_PCB& aComponent, MODULE* aFootprint );
void loadLibraryAreas( const SYMDEF_PCB& aComponent, MODULE* aFootprint );
void loadLibraryPads( const SYMDEF_PCB& aComponent, MODULE* aFootprint );
void loadComponentAttributes( const COMPONENT& aComponent, MODULE* aFootprint );
void loadNetTracks( const NET_ID& aCadstarNetID, const NET_PCB::ROUTE& aCadstarRoute );
void loadNetVia( const NET_ID& aCadstarNetID, const NET_PCB::VIA& aCadstarVia );
void checkAndLogHatchCode( const HATCHCODE_ID& aCadstarHatchcodeID );
@ -315,11 +315,11 @@ private:
* @brief Adds a CADSTAR Attribute to a KiCad module
* @param aCadstarAttrLoc
* @param aCadstarAttributeID
* @param aModule
* @param aFootprint
* @param aAttributeValue
*/
void addAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc,
const ATTRIBUTE_ID& aCadstarAttributeID, MODULE* aModule,
const ATTRIBUTE_ID& aCadstarAttributeID, MODULE* aFootprint,
const wxString& aAttributeValue );
//Helper Functions for obtaining CADSTAR elements in the parsed structures

View File

@ -1387,27 +1387,29 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
}
void EAGLE_PLUGIN::orientModuleAndText( MODULE* m, const EELEMENT& e, const EATTR* nameAttr,
const EATTR* valueAttr )
void EAGLE_PLUGIN::orientModuleAndText( MODULE* aFootprint, const EELEMENT& e,
const EATTR* aNameAttr, const EATTR* aValueAttr )
{
if( e.rot )
{
if( e.rot->mirror )
{
double orientation = e.rot->degrees + 180.0;
m->SetOrientation( orientation * 10 );
m->Flip( m->GetPosition(), false );
aFootprint->SetOrientation( orientation * 10 );
aFootprint->Flip( aFootprint->GetPosition(), false );
}
else
m->SetOrientation( e.rot->degrees * 10 );
{
aFootprint->SetOrientation( e.rot->degrees * 10 );
}
}
orientModuleText( m, e, &m->Reference(), nameAttr );
orientModuleText( m, e, &m->Value(), valueAttr );
orientModuleText( aFootprint, e, &aFootprint->Reference(), aNameAttr );
orientModuleText( aFootprint, e, &aFootprint->Value(), aValueAttr );
}
void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e, FP_TEXT* txt,
void EAGLE_PLUGIN::orientModuleText( MODULE* aFootprint, const EELEMENT& e, FP_TEXT* aFPText,
const EATTR* aAttr )
{
// Smashed part ?
@ -1417,26 +1419,26 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e, FP_TEXT* txt,
if( a.value )
{
txt->SetText( FROM_UTF8( a.value->c_str() ) );
aFPText->SetText( FROM_UTF8( a.value->c_str() ) );
}
if( a.x && a.y ) // OPT
{
wxPoint pos( kicad_x( *a.x ), kicad_y( *a.y ) );
txt->SetTextPos( pos );
aFPText->SetTextPos( pos );
}
// Even though size and ratio are both optional, I am not seeing
// a case where ratio is present but size is not.
double ratio = 8;
wxSize fontz = txt->GetTextSize();
wxSize fontz = aFPText->GetTextSize();
int textThickness = KiROUND( fontz.y * ratio / 100 );
txt->SetTextThickness( textThickness );
aFPText->SetTextThickness( textThickness );
if( a.size )
{
fontz = kicad_fontz( *a.size, textThickness );
txt->SetTextSize( fontz );
aFPText->SetTextSize( fontz );
if( a.ratio )
ratio = *a.ratio;
@ -1463,62 +1465,62 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e, FP_TEXT* txt,
{
spin = a.rot->spin;
sign = a.rot->mirror ? -1 : 1;
txt->SetMirrored( a.rot->mirror );
aFPText->SetMirrored( a.rot->mirror );
}
if( degrees == 90 || degrees == 0 || spin )
{
orient = degrees - m->GetOrientation() / 10;
txt->SetTextAngle( sign * orient * 10 );
orient = degrees - aFootprint->GetOrientation() / 10;
aFPText->SetTextAngle( sign * orient * 10 );
}
else if( degrees == 180 )
{
orient = 0 - m->GetOrientation() / 10;
txt->SetTextAngle( sign * orient * 10 );
orient = 0 - aFootprint->GetOrientation() / 10;
aFPText->SetTextAngle( sign * orient * 10 );
align = -align;
}
else if( degrees == 270 )
{
orient = 90 - m->GetOrientation() / 10;
orient = 90 - aFootprint->GetOrientation() / 10;
align = -align;
txt->SetTextAngle( sign * orient * 10 );
aFPText->SetTextAngle( sign * orient * 10 );
}
else
{
orient = 90 - degrees - m->GetOrientation() / 10;
txt->SetTextAngle( sign * orient * 10 );
orient = 90 - degrees - aFootprint->GetOrientation() / 10;
aFPText->SetTextAngle( sign * orient * 10 );
}
switch( align )
{
case ETEXT::TOP_RIGHT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
break;
case ETEXT::BOTTOM_LEFT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
break;
case ETEXT::TOP_LEFT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
break;
case ETEXT::BOTTOM_RIGHT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
break;
case ETEXT::TOP_CENTER:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
break;
case ETEXT::BOTTOM_CENTER:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
break;
default:
@ -1527,15 +1529,15 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e, FP_TEXT* txt,
}
else // Part is not smash so use Lib default for NAME/VALUE // the text is per the original package, sans <attribute>
{
double degrees = ( txt->GetTextAngle() + m->GetOrientation() ) / 10;
double degrees = ( aFPText->GetTextAngle() + aFootprint->GetOrientation() ) / 10;
// @todo there are a few more cases than these to contend with:
if( (!txt->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ))
|| ( txt->IsMirrored() && ( degrees == 360 ) ) )
if( ( !aFPText->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ))
|| ( aFPText->IsMirrored() && ( degrees == 360 ) ) )
{
// ETEXT::TOP_RIGHT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
}
}
}
@ -1590,7 +1592,7 @@ MODULE* EAGLE_PLUGIN::makeModule( wxXmlNode* aPackage, const wxString& aPkgName
}
void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
void EAGLE_PLUGIN::packageWire( MODULE* aFootprint, wxXmlNode* aTree ) const
{
EWIRE w( aTree );
PCB_LAYER_ID layer = kicad_layer( w.layer );
@ -1598,19 +1600,19 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
int width = w.width.ToPcbUnits();
if( layer == UNDEFINED_LAYER ) {
wxLogMessage( wxString::Format(
_( "Ignoring a wire since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( w.layer ),
w.layer ) );
if( layer == UNDEFINED_LAYER )
{
wxLogMessage( wxString::Format( _( "Ignoring a wire since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( w.layer ),
w.layer ) );
return;
}
// KiCad cannot handle zero or negative line widths which apparently have meaning in Eagle.
if( width <= 0 )
{
BOARD* board = aModule->GetBoard();
BOARD* board = aFootprint->GetBoard();
if( board )
{
@ -1641,14 +1643,14 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
if( !w.curve )
{
dwg = new FP_SHAPE( aModule, S_SEGMENT );
dwg = new FP_SHAPE( aFootprint, S_SEGMENT );
dwg->SetStart0( start );
dwg->SetEnd0( end );
}
else
{
dwg = new FP_SHAPE( aModule, S_ARC );
dwg = new FP_SHAPE( aFootprint, S_ARC );
wxPoint center = ConvertArcCenter( start, end, *w.curve );
dwg->SetStart0( center );
@ -1660,26 +1662,26 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
dwg->SetWidth( width );
dwg->SetDrawCoord();
aModule->Add( dwg );
aFootprint->Add( dwg );
}
void EAGLE_PLUGIN::packagePad( MODULE* aModule, wxXmlNode* aTree )
void EAGLE_PLUGIN::packagePad( MODULE* aFootprint, wxXmlNode* aTree )
{
// this is thru hole technology here, no SMDs
EPAD e( aTree );
int shape = EPAD::UNDEF;
int eagleDrillz = e.drill.ToPcbUnits();
PAD* pad = new PAD( aModule );
aModule->Add( pad );
PAD* pad = new PAD( aFootprint );
aFootprint->Add( pad );
transferPad( e, pad );
if( e.first && *e.first && m_rules->psFirst != EPAD::UNDEF )
shape = m_rules->psFirst;
else if( aModule->GetLayer() == F_Cu && m_rules->psTop != EPAD::UNDEF )
else if( aFootprint->GetLayer() == F_Cu && m_rules->psTop != EPAD::UNDEF )
shape = m_rules->psTop;
else if( aModule->GetLayer() == B_Cu && m_rules->psBottom != EPAD::UNDEF )
else if( aFootprint->GetLayer() == B_Cu && m_rules->psBottom != EPAD::UNDEF )
shape = m_rules->psBottom;
pad->SetDrillSize( wxSize( eagleDrillz, eagleDrillz ) );
@ -1766,31 +1768,31 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, wxXmlNode* aTree )
}
void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const
void EAGLE_PLUGIN::packageText( MODULE* aFootprint, wxXmlNode* aTree ) const
{
ETEXT t( aTree );
PCB_LAYER_ID layer = kicad_layer( t.layer );
if( layer == UNDEFINED_LAYER ) {
wxLogMessage( wxString::Format(
_( "Ignoring a text since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( t.layer ),
t.layer ) );
if( layer == UNDEFINED_LAYER )
{
wxLogMessage( wxString::Format( _( "Ignoring a text since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( t.layer ),
t.layer ) );
return;
}
FP_TEXT* txt;
if( t.text == ">NAME" || t.text == ">name" )
txt = &aModule->Reference();
txt = &aFootprint->Reference();
else if( t.text == ">VALUE" || t.text == ">value" )
txt = &aModule->Value();
txt = &aFootprint->Value();
else
{
// FIXME: graphical text items are rotated for some reason.
txt = new FP_TEXT( aModule );
aModule->Add( txt );
txt = new FP_TEXT( aFootprint );
aFootprint->Add( txt );
}
txt->SetText( FROM_UTF8( t.text.c_str() ) );
@ -1798,7 +1800,7 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const
wxPoint pos( kicad_x( t.x ), kicad_y( t.y ) );
txt->SetTextPos( pos );
txt->SetPos0( pos - aModule->GetPosition() );
txt->SetPos0( pos - aFootprint->GetPosition() );
txt->SetLayer( layer );
@ -1812,7 +1814,7 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const
int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT; // bottom-left is eagle default
// An eagle package is never rotated, the DTD does not allow it.
// angle -= aModule->GetOrienation();
// angle -= aFootprint->GetOrienation();
if( t.rot )
{
@ -1877,15 +1879,15 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const
}
void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
void EAGLE_PLUGIN::packageRectangle( MODULE* aFootprint, wxXmlNode* aTree ) const
{
ERECT r( aTree );
if( r.layer == EAGLE_LAYER::TRESTRICT || r.layer == EAGLE_LAYER::BRESTRICT
|| r.layer == EAGLE_LAYER::VRESTRICT )
{
FP_ZONE* zone = new FP_ZONE( aModule );
aModule->Add( zone, ADD_MODE::APPEND );
FP_ZONE* zone = new FP_ZONE( aFootprint );
aFootprint->Add( zone, ADD_MODE::APPEND );
setKeepoutSettingsToZone( zone, r.layer );
@ -1908,18 +1910,19 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
else
{
PCB_LAYER_ID layer = kicad_layer( r.layer );
if( layer == UNDEFINED_LAYER ) {
wxLogMessage( wxString::Format(
_( "Ignoring a rectange since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( r.layer ),
r.layer ) );
if( layer == UNDEFINED_LAYER )
{
wxLogMessage( wxString::Format( _( "Ignoring a rectange since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( r.layer ),
r.layer ) );
return;
}
FP_SHAPE* dwg = new FP_SHAPE( aModule, S_POLYGON );
FP_SHAPE* dwg = new FP_SHAPE( aFootprint, S_POLYGON );
aModule->Add( dwg );
aFootprint->Add( dwg );
dwg->SetLayer( layer );
dwg->SetWidth( 0 );
@ -1945,7 +1948,7 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
}
void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
void EAGLE_PLUGIN::packagePolygon( MODULE* aFootprint, wxXmlNode* aTree ) const
{
EPOLYGON p( aTree );
@ -2007,8 +2010,8 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
|| p.layer == EAGLE_LAYER::BRESTRICT
|| p.layer == EAGLE_LAYER::VRESTRICT )
{
FP_ZONE* zone = new FP_ZONE( aModule );
aModule->Add( zone, ADD_MODE::APPEND );
FP_ZONE* zone = new FP_ZONE( aFootprint );
aFootprint->Add( zone, ADD_MODE::APPEND );
setKeepoutSettingsToZone( zone, p.layer );
@ -2022,18 +2025,19 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
else
{
PCB_LAYER_ID layer = kicad_layer( p.layer );
if( layer == UNDEFINED_LAYER ) {
wxLogMessage( wxString::Format(
_( "Ignoring a polygon since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( p.layer ),
p.layer ) );
if( layer == UNDEFINED_LAYER )
{
wxLogMessage( wxString::Format( _( "Ignoring a polygon since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( p.layer ),
p.layer ) );
return;
}
FP_SHAPE* dwg = new FP_SHAPE( aModule, S_POLYGON );
FP_SHAPE* dwg = new FP_SHAPE( aFootprint, S_POLYGON );
aModule->Add( dwg );
aFootprint->Add( dwg );
dwg->SetWidth( 0 ); // it's filled, no need for boundary width
dwg->SetLayer( layer );
@ -2047,7 +2051,7 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
}
}
void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
void EAGLE_PLUGIN::packageCircle( MODULE* aFootprint, wxXmlNode* aTree ) const
{
ECIRCLE e( aTree );
@ -2058,8 +2062,8 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
|| e.layer == EAGLE_LAYER::BRESTRICT
|| e.layer == EAGLE_LAYER::VRESTRICT )
{
FP_ZONE* zone = new FP_ZONE( aModule );
aModule->Add( zone, ADD_MODE::APPEND );
FP_ZONE* zone = new FP_ZONE( aFootprint );
aFootprint->Add( zone, ADD_MODE::APPEND );
setKeepoutSettingsToZone( zone, e.layer );
@ -2091,16 +2095,17 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
else
{
PCB_LAYER_ID layer = kicad_layer( e.layer );
if( layer == UNDEFINED_LAYER ) {
wxLogMessage( wxString::Format(
_( "Ignoring a cricle since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( e.layer ),
e.layer ) );
if( layer == UNDEFINED_LAYER )
{
wxLogMessage( wxString::Format( _( "Ignoring a cricle since Eagle layer '%s' (%d) "
"was not mapped" ),
eagle_layer_name( e.layer ),
e.layer ) );
return;
}
FP_SHAPE* gr = new FP_SHAPE( aModule, S_CIRCLE );
FP_SHAPE* gr = new FP_SHAPE( aFootprint, S_CIRCLE );
// with == 0 means filled circle
if( width <= 0 )
@ -2109,7 +2114,7 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
radius = radius / 2;
}
aModule->Add( gr );
aFootprint->Add( gr );
gr->SetWidth( width );
switch( (int) layer )
@ -2129,13 +2134,13 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
}
void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree, bool aCenter ) const
void EAGLE_PLUGIN::packageHole( MODULE* aFootprint, wxXmlNode* aTree, bool aCenter ) const
{
EHOLE e( aTree );
// we add a PAD_ATTRIB_NPTH pad to this module.
PAD* pad = new PAD( aModule );
aModule->Add( pad );
PAD* pad = new PAD( aFootprint );
aFootprint->Add( pad );
pad->SetShape( PAD_SHAPE_CIRCLE );
pad->SetAttribute( PAD_ATTRIB_NPTH );
@ -2150,13 +2155,13 @@ void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree, bool aCenter
if( aCenter )
{
pad->SetPos0( wxPoint( 0, 0 ) );
aModule->SetPosition( padpos );
aFootprint->SetPosition( padpos );
pad->SetPosition( padpos );
}
else
{
pad->SetPos0( padpos );
pad->SetPosition( padpos + aModule->GetPosition() );
pad->SetPosition( padpos + aFootprint->GetPosition() );
}
wxSize sz( e.drill.ToPcbUnits(), e.drill.ToPcbUnits() );
@ -2168,7 +2173,7 @@ void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree, bool aCenter
}
void EAGLE_PLUGIN::packageSMD( MODULE* aModule, wxXmlNode* aTree ) const
void EAGLE_PLUGIN::packageSMD( MODULE* aFootprint, wxXmlNode* aTree ) const
{
ESMD e( aTree );
PCB_LAYER_ID layer = kicad_layer( e.layer );
@ -2176,8 +2181,8 @@ void EAGLE_PLUGIN::packageSMD( MODULE* aModule, wxXmlNode* aTree ) const
if( !IsCopperLayer( layer ) )
return;
PAD* pad = new PAD( aModule );
aModule->Add( pad );
PAD* pad = new PAD( aFootprint );
aFootprint->Add( pad );
transferPad( e, pad );
pad->SetShape( PAD_SHAPE_RECT );

View File

@ -276,8 +276,10 @@ private:
*/
ZONE* loadPolygon( wxXmlNode* aPolyNode );
void orientModuleAndText( MODULE* m, const EELEMENT& e, const EATTR* nameAttr, const EATTR* valueAttr );
void orientModuleText( MODULE* m, const EELEMENT& e, FP_TEXT* txt, const EATTR* a );
void orientModuleAndText( MODULE* aFootprint, const EELEMENT& e, const EATTR* aNameAttr,
const EATTR* aValueAttr );
void orientModuleText( MODULE* aFootprint, const EELEMENT& e, FP_TEXT* aFPText, const EATTR* a );
/// move the BOARD into the center of the page
@ -289,22 +291,22 @@ private:
*/
MODULE* makeModule( wxXmlNode* aPackage, const wxString& aPkgName );
void packageWire( MODULE* aModule, wxXmlNode* aTree ) const;
void packagePad( MODULE* aModule, wxXmlNode* aTree );
void packageText( MODULE* aModule, wxXmlNode* aTree ) const;
void packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const;
void packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const;
void packageCircle( MODULE* aModule, wxXmlNode* aTree ) const;
void packageWire( MODULE* aFootprint, wxXmlNode* aTree ) const;
void packagePad( MODULE* aFootprint, wxXmlNode* aTree );
void packageText( MODULE* aFootprint, wxXmlNode* aTree ) const;
void packageRectangle( MODULE* aFootprint, wxXmlNode* aTree ) const;
void packagePolygon( MODULE* aFootprint, wxXmlNode* aTree ) const;
void packageCircle( MODULE* aFootprint, wxXmlNode* aTree ) const;
/**
* Function packageHole
* @parameter aModule - The KiCad module to which to assign the hole
* @parameter aFootprint - The KiCad module to which to assign the hole
* @parameter aTree - The Eagle XML node that is of type "hole"
* @parameter aCenter - If true, center the hole in the module and
* offset the module position
*/
void packageHole( MODULE* aModule, wxXmlNode* aTree, bool aCenter ) const;
void packageSMD( MODULE* aModule, wxXmlNode* aTree ) const;
void packageHole( MODULE* aFootprint, wxXmlNode* aTree, bool aCenter ) const;
void packageSMD( MODULE* aFootprint, wxXmlNode* aTree ) const;
///> Handles common pad properties
void transferPad( const EPAD_COMMON& aEaglePad, PAD* aPad ) const;

View File

@ -111,16 +111,16 @@ class GPCB_FPL_CACHE_ITEM
std::unique_ptr<MODULE> m_module;
public:
GPCB_FPL_CACHE_ITEM( MODULE* aModule, const WX_FILENAME& aFileName );
GPCB_FPL_CACHE_ITEM( MODULE* aFootprint, const WX_FILENAME& aFileName );
WX_FILENAME GetFileName() const { return m_filename; }
MODULE* GetModule() const { return m_module.get(); }
};
GPCB_FPL_CACHE_ITEM::GPCB_FPL_CACHE_ITEM( MODULE* aModule, const WX_FILENAME& aFileName ) :
GPCB_FPL_CACHE_ITEM::GPCB_FPL_CACHE_ITEM( MODULE* aFootprint, const WX_FILENAME& aFileName ) :
m_filename( aFileName ),
m_module( aModule )
m_module( aFootprint )
{
}