More module -> footprint.

This commit is contained in:
Jeff Young 2020-11-13 11:17:15 +00:00
parent 522d64968e
commit 63a54d003e
44 changed files with 513 additions and 488 deletions

View File

@ -287,7 +287,7 @@ void PANEL_PREV_3D::updateOrientation( wxCommandEvent &event )
modelInfo->m_Offset.y = DoubleValueFromString( m_userUnits, yoff->GetValue() ) / IU_PER_MM; modelInfo->m_Offset.y = DoubleValueFromString( m_userUnits, yoff->GetValue() ) / IU_PER_MM;
modelInfo->m_Offset.z = DoubleValueFromString( m_userUnits, zoff->GetValue() ) / IU_PER_MM; modelInfo->m_Offset.z = DoubleValueFromString( m_userUnits, zoff->GetValue() ) / IU_PER_MM;
// Update the dummy module for the preview // Update the dummy footprint for the preview
UpdateDummyFootprint( false ); UpdateDummyFootprint( false );
} }
} }
@ -302,7 +302,7 @@ void PANEL_PREV_3D::onOpacitySlider( wxCommandEvent& event )
modelInfo->m_Opacity = m_opacity->GetValue() / 100.0; modelInfo->m_Opacity = m_opacity->GetValue() / 100.0;
// Update the dummy module for the preview // Update the dummy footprint for the preview
UpdateDummyFootprint( false ); UpdateDummyFootprint( false );
} }
} }

View File

@ -27,7 +27,7 @@
* @file panel_prev_model.h * @file panel_prev_model.h
* @brief Defines a panel which is to be added to a wxFileDialog via * @brief Defines a panel which is to be added to a wxFileDialog via
* SetExtraControl(); * SetExtraControl();
* The panel shows a preview of the module being edited and provides controls * The panel shows a preview of the footprint being edited and provides controls
* to set the offset/rotation/scale of each model 3d shape as per KiCad's * to set the offset/rotation/scale of each model 3d shape as per KiCad's
* current behavior. The panel may also be used in the 3D configuration dialog * current behavior. The panel may also be used in the 3D configuration dialog
* to tune the positioning of the models without invoking a file selector dialog. * to tune the positioning of the models without invoking a file selector dialog.
@ -201,14 +201,14 @@ public:
CCAMERA& GetCurrentCamera() override { return m_currentCamera; } CCAMERA& GetCurrentCamera() override { return m_currentCamera; }
/** /**
* @brief SetModelDataIdx - Sets the currently selected index in the model list so that * @brief SetSelectedModel - Sets the currently selected index in the model list so that
* the scale/rotation/offset controls can be updated. * the scale/rotation/offset controls can be updated.
*/ */
void SetSelectedModel( int idx ); void SetSelectedModel( int idx );
/** /**
* @brief UpdateModelInfoList - copy shapes from the current shape list which are flagged * @brief UpdateDummyFootprint - copy shapes from the current shape list which are flagged
* for preview to the copy of module that is on the preview dummy board * for preview to the copy of footprint that is on the preview dummy board
*/ */
void UpdateDummyFootprint( bool aRelaodRequired = true ); void UpdateDummyFootprint( bool aRelaodRequired = true );
}; };

View File

@ -108,14 +108,12 @@ class BOARD_ADAPTER
/** /**
* @brief Is3DLayerEnabled - Check if a layer is enabled * @brief Is3DLayerEnabled - Check if a layer is enabled
* @param aLayer: layer ID to get status * @param aLayer: layer ID to get status
* @return true if layer should be displayed, false if not
*/ */
bool Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const; bool Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const;
/** /**
* @brief ShouldModuleBeDisplayed - Test if module should be displayed in * @brief ShouldFPBeDisplayed - Test if footprint should be displayed in relation to
* relation to attributs and the flags * attributes and the flags
* @return true if module should be displayed, false if not
*/ */
bool ShouldFPBeDisplayed( FOOTPRINT_ATTR_T aFPAttributes ) const; bool ShouldFPBeDisplayed( FOOTPRINT_ATTR_T aFPAttributes ) const;
@ -229,10 +227,10 @@ class BOARD_ADAPTER
} }
/** /**
* @brief GetModulesZcoord3DIU - Get the position of the module in 3d integer units * @brief GetModulesZcoord3DIU - Get the position of the footprint in 3d integer units
* considering if it is flipped or not. * considering if it is flipped or not.
* @param aIsFlipped: true for use in footprints on Front (top) layer, false * @param aIsFlipped: true for use in footprints on Front (top) layer, false
* if module is on back (bottom) layer * if footprint is on back (bottom) layer
* @return the Z position of 3D shapes, in 3D integer units * @return the Z position of 3D shapes, in 3D integer units
*/ */
float GetModulesZcoord3DIU( bool aIsFlipped ) const ; float GetModulesZcoord3DIU( bool aIsFlipped ) const ;

View File

@ -1292,7 +1292,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_models_selected( bool aRenderTopOrBot,
if( ( aRenderTopOrBot && !fp->IsFlipped() ) if( ( aRenderTopOrBot && !fp->IsFlipped() )
|| ( !aRenderTopOrBot && fp->IsFlipped() ) ) || ( !aRenderTopOrBot && fp->IsFlipped() ) )
{ {
render_3D_module( fp, aRenderTransparentOnly, isIntersected ); render_3D_footprint( fp, aRenderTransparentOnly, isIntersected );
} }
} }
} }
@ -1319,26 +1319,26 @@ void C3D_RENDER_OGL_LEGACY::render_3D_models( bool aRenderTopOrBot,
} }
void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module, void C3D_RENDER_OGL_LEGACY::render_3D_footprint( const MODULE* aFootprint,
bool aRenderTransparentOnly, bool aRenderTransparentOnly,
bool aIsSelected ) bool aIsSelected )
{ {
if( !module->Models().empty() ) if( !aFootprint->Models().empty() )
{ {
const double zpos = m_boardAdapter.GetModulesZcoord3DIU( module->IsFlipped() ); const double zpos = m_boardAdapter.GetModulesZcoord3DIU( aFootprint->IsFlipped() );
glPushMatrix(); glPushMatrix();
wxPoint pos = module->GetPosition(); wxPoint pos = aFootprint->GetPosition();
glTranslatef( pos.x * m_boardAdapter.BiuTo3Dunits(), glTranslatef( pos.x * m_boardAdapter.BiuTo3Dunits(),
-pos.y * m_boardAdapter.BiuTo3Dunits(), -pos.y * m_boardAdapter.BiuTo3Dunits(),
zpos ); zpos );
if( module->GetOrientation() ) if( aFootprint->GetOrientation() )
glRotated( (double) module->GetOrientation() / 10.0, 0.0, 0.0, 1.0 ); glRotated((double) aFootprint->GetOrientation() / 10.0, 0.0, 0.0, 1.0 );
if( module->IsFlipped() ) if( aFootprint->IsFlipped() )
{ {
glRotatef( 180.0f, 0.0f, 1.0f, 0.0f ); glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
glRotatef( 180.0f, 0.0f, 0.0f, 1.0f ); glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
@ -1351,7 +1351,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module,
modelunit_to_3d_units_factor ); modelunit_to_3d_units_factor );
// Get the list of model files for this model // Get the list of model files for this model
for( const FP_3DMODEL& sM : module->Models() ) for( const FP_3DMODEL& sM : aFootprint->Models() )
{ {
if( !sM.m_Show || sM.m_Filename.empty() ) if( !sM.m_Show || sM.m_Filename.empty() )
continue; continue;
@ -1386,10 +1386,10 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module,
if( aRenderTransparentOnly ) if( aRenderTransparentOnly )
modelPtr->Draw_transparent( sM.m_Opacity, modelPtr->Draw_transparent( sM.m_Opacity,
module->IsSelected() || aIsSelected, aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_opengl_selectionColor ); m_boardAdapter.m_opengl_selectionColor );
else else
modelPtr->Draw_opaque( module->IsSelected() || aIsSelected, modelPtr->Draw_opaque( aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_opengl_selectionColor ); m_boardAdapter.m_opengl_selectionColor );
if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) ) if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) )

View File

@ -203,7 +203,7 @@ private:
void render_3D_models_selected( bool aRenderTopOrBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly ); void render_3D_models_selected( bool aRenderTopOrBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly );
void render_3D_module( const MODULE* module, bool aRenderTransparentOnly, bool aIsSelected ); void render_3D_footprint( const MODULE* aFootprint, bool aRenderTransparentOnly, bool aIsSelected );
void setLight_Front( bool enabled ); void setLight_Front( bool enabled );
void setLight_Top( bool enabled ); void setLight_Top( bool enabled );

View File

@ -106,7 +106,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
/** /**
* Function GRText * Function GRText
* Draw a graphic text (like module texts) * Draw a graphic text (like footprint texts)
* @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas * @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas
* @param aPos = text position (according to h_justify, v_justify) * @param aPos = text position (according to h_justify, v_justify)
* @param aColor (COLOR4D) = text color * @param aColor (COLOR4D) = text color

View File

@ -374,8 +374,7 @@ bool LIB_ID::isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType )
if( aUniChar < ' ' ) if( aUniChar < ' ' )
return false; return false;
// This list of characters is also duplicated in validators.cpp and // This list of characters is also duplicated in validators.cpp and footprint.cpp
// class_module.cpp
// TODO: Unify forbidden character lists // TODO: Unify forbidden character lists
switch( aUniChar ) switch( aUniChar )
{ {

View File

@ -71,8 +71,8 @@ void GRID_CELL_TEXT_EDITOR::StartingKey( wxKeyEvent& event )
FOOTPRINT_NAME_VALIDATOR::FOOTPRINT_NAME_VALIDATOR( wxString* aValue ) : FOOTPRINT_NAME_VALIDATOR::FOOTPRINT_NAME_VALIDATOR( wxString* aValue ) :
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ) wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
{ {
// This list of characters follows the string from class_module.cpp // This list of characters follows the string from footprint.cpp which, in turn mimics the
// which, in turn mimics the strings from lib_id.cpp // strings from lib_id.cpp
// TODO: Unify forbidden character lists // TODO: Unify forbidden character lists
wxString illegalChars = "%$<>\t\n\r\"\\/:"; wxString illegalChars = "%$<>\t\n\r\"\\/:";
SetCharExcludes( illegalChars ); SetCharExcludes( illegalChars );

View File

@ -62,7 +62,7 @@ bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName, unsig
ret |= fprintf( f, "\"%s\"\n", TO_UTF8( title ) ); ret |= fprintf( f, "\"%s\"\n", TO_UTF8( title ) );
ret |= fprintf( f, ".TYP FULL\n\n" ); ret |= fprintf( f, ".TYP FULL\n\n" );
// Create netlist module section // Create netlist footprints section
m_ReferencesAlreadyFound.Clear(); m_ReferencesAlreadyFound.Clear();
SCH_SHEET_LIST sheetList = m_schematic->GetSheets(); SCH_SHEET_LIST sheetList = m_schematic->GetSheets();

View File

@ -60,7 +60,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
ret |= fprintf( f, "( { %s created %s }\n", ret |= fprintf( f, "( { %s created %s }\n",
NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) ); NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
// Create netlist module section // Create netlist footprints section
m_ReferencesAlreadyFound.Clear(); m_ReferencesAlreadyFound.Clear();
SCH_SHEET_LIST sheetList = m_schematic->GetSheets(); SCH_SHEET_LIST sheetList = m_schematic->GetSheets();

View File

@ -138,7 +138,7 @@ void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
PTREE& tree = doc.get_child( "pcb_netlist" ); PTREE& tree = doc.get_child( "pcb_netlist" );
wxString msg; wxString msg;
m_pcbModules.clear(); m_pcbFootprints.clear();
for( const std::pair<const std::string, PTREE>& item : tree ) for( const std::pair<const std::string, PTREE>& item : tree )
{ {
@ -184,9 +184,9 @@ void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
} }
// Use lower_bound for not to iterate over map twice // Use lower_bound for not to iterate over map twice
auto nearestItem = m_pcbModules.lower_bound( path ); auto nearestItem = m_pcbFootprints.lower_bound( path );
if( nearestItem != m_pcbModules.end() && nearestItem->first == path ) if( nearestItem != m_pcbFootprints.end() && nearestItem->first == path )
{ {
// Module with this path already exists - generate error // Module with this path already exists - generate error
msg.Printf( _( "Pcb footprints '%s' and '%s' linked to same symbol." ), msg.Printf( _( "Pcb footprints '%s' and '%s' linked to same symbol." ),
@ -196,9 +196,9 @@ void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
} }
else else
{ {
// Add module to the map // Add footprint to the map
auto data = std::make_shared<PCB_FP_DATA>( ref, footprint, value, pinNetMap ); auto data = std::make_shared<PCB_FP_DATA>( ref, footprint, value, pinNetMap );
m_pcbModules.insert( nearestItem, std::make_pair( path, data ) ); m_pcbFootprints.insert( nearestItem, std::make_pair( path, data ) );
} }
} }
} }
@ -206,10 +206,10 @@ void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
void BACK_ANNOTATE::getChangeList() void BACK_ANNOTATE::getChangeList()
{ {
for( std::pair<const wxString, std::shared_ptr<PCB_FP_DATA>>& module : m_pcbModules ) for( std::pair<const wxString, std::shared_ptr<PCB_FP_DATA>>& fpData : m_pcbFootprints )
{ {
const wxString& pcbPath = module.first; const wxString& pcbPath = fpData.first;
auto& pcbData = module.second; auto& pcbData = fpData.second;
int refIndex; int refIndex;
bool foundInMultiunit = false; bool foundInMultiunit = false;
@ -224,7 +224,7 @@ void BACK_ANNOTATE::getChangeList()
if( refIndex >= 0 ) if( refIndex >= 0 )
{ {
// If module linked to multi unit symbol, we add all symbol's units to // If footprint linked to multi unit symbol, we add all symbol's units to
// the change list // the change list
foundInMultiunit = true; foundInMultiunit = true;

View File

@ -111,7 +111,7 @@ private:
bool m_processNetNames; bool m_processNetNames;
bool m_dryRun; bool m_dryRun;
PCB_MODULES_MAP m_pcbModules; PCB_MODULES_MAP m_pcbFootprints;
SCH_REFERENCE_LIST m_refs; SCH_REFERENCE_LIST m_refs;
SCH_MULTI_UNIT_REFERENCE_MAP m_multiUnitsRefs; SCH_MULTI_UNIT_REFERENCE_MAP m_multiUnitsRefs;
std::deque<CHANGELIST_ITEM> m_changelist; std::deque<CHANGELIST_ITEM> m_changelist;

View File

@ -301,11 +301,11 @@ public:
MODULE* CreateNewFootprint( const wxString& aFootprintName ); MODULE* CreateNewFootprint( const wxString& aFootprintName );
/** /**
* Function PlaceModule * Function PlaceFootprint
* places \a aModule at the current cursor position and updates module coordinates * places \a aFootprint at the current cursor position and updates footprint coordinates
* with the new position. * with the new position.
* *
* @param aRecreateRatsnest A bool true redraws the module rats nest. * @param aRecreateRatsnest A bool true redraws the footprint ratsnest.
*/ */
void PlaceFootprint( MODULE* aFootprint, bool aRecreateRatsnest = true ); void PlaceFootprint( MODULE* aFootprint, bool aRecreateRatsnest = true );
@ -320,7 +320,7 @@ public:
MODULE* SelectFootprintFromLibTree( LIB_ID aPreselect = LIB_ID() ); MODULE* SelectFootprintFromLibTree( LIB_ID aPreselect = LIB_ID() );
/** /**
* Adds the given module to the board. * Adds the given footprint to the board.
* @param aFootprint * @param aFootprint
* @param aDC (can be NULL ) = the current Device Context, to draw the new footprint * @param aDC (can be NULL ) = the current Device Context, to draw the new footprint
*/ */

View File

@ -52,7 +52,7 @@
/* Bits characterizing cell */ /* Bits characterizing cell */
#define CELL_IS_EMPTY 0x00 #define CELL_IS_EMPTY 0x00
#define CELL_IS_HOLE 0x01 /* a conducting hole or obstacle */ #define CELL_IS_HOLE 0x01 /* a conducting hole or obstacle */
#define CELL_IS_MODULE 0x02 /* auto placement occupied by a module */ #define CELL_IS_MODULE 0x02 /* auto placement occupied by a footprint */
#define CELL_IS_EDGE 0x20 /* Area and auto-placement: limiting cell contour (Board, Zone) */ #define CELL_IS_EDGE 0x20 /* Area and auto-placement: limiting cell contour (Board, Zone) */
#define CELL_IS_FRIEND 0x40 /* Area and auto-placement: cell part of the net */ #define CELL_IS_FRIEND 0x40 /* Area and auto-placement: cell part of the net */
#define CELL_IS_ZONE 0x80 /* Area and auto-placement: cell available */ #define CELL_IS_ZONE 0x80 /* Area and auto-placement: cell available */
@ -542,7 +542,7 @@ unsigned int AR_AUTOPLACER::calculateKeepOutArea( const EDA_RECT& aRect, int sid
} }
/* Test if the module can be placed on the board. /* Test if the footprint can be placed on the board.
* Returns the value TstRectangle(). * Returns the value TstRectangle().
* Module is known by its bounding box * Module is known by its bounding box
*/ */
@ -651,7 +651,7 @@ int AR_AUTOPLACER::getOptimalFPPlacement( MODULE* aFootprint )
if( keepOutCost >= 0 ) // i.e. if the footprint can be put here if( keepOutCost >= 0 ) // i.e. if the footprint can be put here
{ {
error = 0; error = 0;
// m_frame->build_ratsnest_module( aFootprint ); // fixme // m_frame->build_ratsnest_footprint( aFootprint ); // fixme
curr_cost = computePlacementRatsnestCost( aFootprint, fpOffset ); curr_cost = computePlacementRatsnestCost( aFootprint, fpOffset );
Score = curr_cost + keepOutCost; Score = curr_cost + keepOutCost;
@ -816,9 +816,9 @@ MODULE* AR_AUTOPLACER::pickFootprint( )
sort( fpList.begin(), fpList.end(), sortFootprintsByRatsnestSize ); sort( fpList.begin(), fpList.end(), sortFootprintsByRatsnestSize );
// Search for "best" module. // Search for "best" footprint.
MODULE* bestModule = nullptr; MODULE* bestFootprint = nullptr;
MODULE* altModule = nullptr; MODULE* altFootprint = nullptr;
for( unsigned ii = 0; ii < fpList.size(); ii++ ) for( unsigned ii = 0; ii < fpList.size(); ii++ )
{ {
@ -827,19 +827,19 @@ MODULE* AR_AUTOPLACER::pickFootprint( )
if( !footprint->NeedsPlaced() ) if( !footprint->NeedsPlaced() )
continue; continue;
altModule = footprint; altFootprint = footprint;
if( footprint->GetFlag() == 0 ) if( footprint->GetFlag() == 0 )
continue; continue;
bestModule = footprint; bestFootprint = footprint;
break; break;
} }
if( bestModule ) if( bestFootprint )
return bestModule; return bestFootprint;
else else
return altModule; return altFootprint;
} }
@ -890,7 +890,7 @@ AR_RESULT AR_AUTOPLACER::AutoplaceFootprints( std::vector<MODULE*>& aFootprints,
if( m_matrix.m_GridRouting < Millimeter2iu( 0.25 ) ) if( m_matrix.m_GridRouting < Millimeter2iu( 0.25 ) )
m_matrix.m_GridRouting = Millimeter2iu( 0.25 ); m_matrix.m_GridRouting = Millimeter2iu( 0.25 );
// Compute module parameters used in auto place // Compute footprint parameters used in autoplace
if( genPlacementRoutingMatrix( ) == 0 ) if( genPlacementRoutingMatrix( ) == 0 )
return AR_FAILURE; return AR_FAILURE;

View File

@ -532,7 +532,7 @@ void BOARD::SetElementVisibility( GAL_LAYER_ID aLayer, bool isEnabled )
} }
bool BOARD::IsModuleLayerVisible( PCB_LAYER_ID aLayer ) bool BOARD::IsFootprintLayerVisible( PCB_LAYER_ID aLayer )
{ {
switch( aLayer ) switch( aLayer )
{ {
@ -1109,11 +1109,10 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s
++p; ++p;
break; break;
/* Instances of the requested KICAD_T live in a list, either one /*
* that I manage, or that my footprints manage. If it's a type managed * Instances of the requested KICAD_T live in a list, either one that I manage, or one
* by class MODULE, then simply pass it on to each module's * that my footprints manage. If it's a type managed by class FOOTPRINT, then simply
* MODULE::Visit() function by way of the * pass it on to each footprint's Visit() function via IterateForward( m_footprints, ... ).
* IterateForward( m_Modules, ... ) call.
*/ */
case PCB_MODULE_T: case PCB_MODULE_T:
@ -1122,7 +1121,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s
case PCB_FP_SHAPE_T: case PCB_FP_SHAPE_T:
case PCB_FP_ZONE_T: case PCB_FP_ZONE_T:
// this calls MODULE::Visit() on each module. // this calls FOOTPRINT::Visit() on each footprint.
result = IterateForward<MODULE*>( m_footprints, inspector, testData, p ); result = IterateForward<MODULE*>( m_footprints, inspector, testData, p );
// skip over any types handled in the above call. // skip over any types handled in the above call.
@ -1689,7 +1688,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer
PCB_LAYER_ID layer = candidate->GetLayer(); PCB_LAYER_ID layer = candidate->GetLayer();
// Filter non visible footprints if requested // Filter non visible footprints if requested
if( !aVisibleOnly || IsModuleLayerVisible( layer ) ) if( !aVisibleOnly || IsFootprintLayerVisible( layer ) )
{ {
EDA_RECT bb = candidate->GetFootprintRect(); EDA_RECT bb = candidate->GetFootprintRect();
@ -1709,7 +1708,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer
min_dim = dist; min_dim = dist;
} }
} }
else if( aVisibleOnly && IsModuleLayerVisible( layer ) ) else if( aVisibleOnly && IsFootprintLayerVisible( layer ) )
{ {
if( dist <= alt_min_dim ) if( dist <= alt_min_dim )
{ {

View File

@ -343,7 +343,7 @@ public:
/** /**
* Gets the first footprint on the board or nullptr. * Gets the first footprint on the board or nullptr.
* This is used primarily by the footprint editor which knows there is only one. * This is used primarily by the footprint editor which knows there is only one.
* @return first module or null pointer * @return first footprint or null pointer
*/ */
MODULE* GetFirstFootprint() const MODULE* GetFirstFootprint() const
{ {
@ -546,12 +546,12 @@ public:
void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState ); void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
/** /**
* Expect either of the two layers on which a module can reside, and returns * Expect either of the two layers on which a footprint can reside, and returns
* whether that layer is visible. * whether that layer is visible.
* @param aLayer One of the two allowed layers for footprints: F_Cu or B_Cu * @param aLayer One of the two allowed layers for footprints: F_Cu or B_Cu
* @return bool - true if the layer is visible, else false. * @return bool - true if the layer is visible, else false.
*/ */
bool IsModuleLayerVisible( PCB_LAYER_ID aLayer ); bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer );
/** /**
* @return the BOARD_DESIGN_SETTINGS for this BOARD * @return the BOARD_DESIGN_SETTINGS for this BOARD
@ -1035,18 +1035,17 @@ public:
PAD* GetPad( std::vector<PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerMask ); PAD* GetPad( std::vector<PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerMask );
/** /**
* Delete a given pad from the BOARD by removing it from its module and * Delete a given pad from the BOARD by removing it from its footprint and from the
* from the m_NetInfo. Makes no UI calls. * m_NetInfo. Makes no UI calls.
* @param aPad is the pad to delete. * @param aPad is the pad to delete.
*/ */
void PadDelete( PAD* aPad ); void PadDelete( PAD* aPad );
/** /**
* First empties then fills the vector with all pads and sorts them by * First empties then fills the vector with all pads and sorts them by increasing x
* increasing x coordinate, and for increasing y coordinate for same values of x coordinates. * coordinate, and for increasing y coordinate for same values of x coordinates. The vector
* The vector only holds pointers to the pads and * only holds pointers to the pads and those pointers are only references to pads which are
* those pointers are only references to pads which are owned by the BOARD * owned by the BOARD through other links.
* through other links.
* @param aVector Where to put the pad pointers. * @param aVector Where to put the pad pointers.
* @param aNetCode = the netcode filter: * @param aNetCode = the netcode filter:
* = -1 to build the full pad list. * = -1 to build the full pad list.
@ -1082,7 +1081,6 @@ public:
* @param aActiveLayer Layer to test. * @param aActiveLayer Layer to test.
* @param aVisibleOnly Search only the visible layers if true. * @param aVisibleOnly Search only the visible layers if true.
* @param aIgnoreLocked Ignore locked footprints when true. * @param aIgnoreLocked Ignore locked footprints when true.
* @return MODULE* The best module or NULL if none.
*/ */
MODULE* GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer, MODULE* GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked = false ); bool aVisibleOnly, bool aIgnoreLocked = false );

View File

@ -105,11 +105,11 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
// Module items need to be saved in the undo buffer before modification // Module items need to be saved in the undo buffer before modification
if( m_isFootprintEditor ) if( m_isFootprintEditor )
{ {
// Be sure that we are storing a module // Be sure that we are storing a footprint
if( ent.m_item->Type() != PCB_MODULE_T ) if( ent.m_item->Type() != PCB_MODULE_T )
ent.m_item = ent.m_item->GetParent(); ent.m_item = ent.m_item->GetParent();
// We have not saved the module yet, so let's create an entry // We have not saved the footprint yet, so let's create an entry
if( savedModules.count( ent.m_item ) == 0 ) if( savedModules.count( ent.m_item ) == 0 )
{ {
if( !ent.m_copy ) if( !ent.m_copy )
@ -188,7 +188,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case PCB_FP_SHAPE_T: case PCB_FP_SHAPE_T:
case PCB_FP_TEXT_T: case PCB_FP_TEXT_T:
case PCB_FP_ZONE_T: case PCB_FP_ZONE_T:
// This level can only handle module items when editing footprints // This level can only handle footprint children when editing footprints
wxASSERT( m_isFootprintEditor ); wxASSERT( m_isFootprintEditor );
if( boardItem->Type() == PCB_FP_TEXT_T ) if( boardItem->Type() == PCB_FP_TEXT_T )
@ -204,9 +204,9 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
if( !( changeFlags & CHT_DONE ) ) if( !( changeFlags & CHT_DONE ) )
{ {
MODULE* module = static_cast<MODULE*>( boardItem->GetParent() ); MODULE* footprint = static_cast<MODULE*>( boardItem->GetParent() );
wxASSERT( module && module->Type() == PCB_MODULE_T ); wxASSERT( footprint && footprint->Type() == PCB_MODULE_T );
module->Delete( boardItem ); footprint->Delete( boardItem );
} }
break; break;
@ -233,15 +233,15 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case PCB_MODULE_T: case PCB_MODULE_T:
{ {
// There are no footprints inside a module yet // No support for nested footprints (yet)
wxASSERT( !m_isFootprintEditor ); wxASSERT( !m_isFootprintEditor );
MODULE* module = static_cast<MODULE*>( boardItem ); MODULE* footprint = static_cast<MODULE*>( boardItem );
view->Remove( module ); view->Remove( footprint );
module->ClearFlags(); footprint->ClearFlags();
if( !( changeFlags & CHT_DONE ) ) if( !( changeFlags & CHT_DONE ) )
board->Remove( module ); // handles connectivity board->Remove( footprint ); // handles connectivity
} }
break; break;

View File

@ -601,7 +601,7 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard()
RefDesChange* newref; RefDesChange* newref;
NETLIST netlist; NETLIST netlist;
if( !BuildModuleList( BadRefDes ) ) if( !BuildFootprintList( BadRefDes ) )
{ {
ShowReport( "Selected options resulted in errors! Change them and try again.", ShowReport( "Selected options resulted in errors! Change them and try again.",
RPT_SEVERITY_ERROR ); RPT_SEVERITY_ERROR );
@ -664,41 +664,41 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard()
} //If updating schematic } //If updating schematic
bool reannotateok = payload.size( ) == 0; bool reannotateOk = payload.size( ) == 0;
ShowReport( payload, reannotateok ? RPT_SEVERITY_ACTION : RPT_SEVERITY_ERROR ); ShowReport( payload, reannotateOk ? RPT_SEVERITY_ACTION : RPT_SEVERITY_ERROR );
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
if( reannotateok ) if( reannotateOk )//Only update if no errors
{ //Only update if no errors {
for( MODULE* mod : m_footprints ) for( MODULE* footprint : m_footprints )
{ // Create a netlist {
newref = GetNewRefDes( mod ); newref = GetNewRefDes( footprint );
if( nullptr == newref ) if( nullptr == newref )
return false; return false;
commit.Modify( mod ); //Make a copy for undo commit.Modify( footprint ); // Make a copy for undo
mod->SetReference( newref->NewRefDes ); //Update the PCB reference footprint->SetReference( newref->NewRefDes ); // Update the PCB reference
m_frame->GetCanvas()->GetView()->Update( mod ); //Touch the module m_frame->GetCanvas()->GetView()->Update( footprint ); // Touch the footprint
} }
} }
commit.Push( "Geographic reannotation" ); commit.Push( "Geographic reannotation" );
return reannotateok; return reannotateOk;
} }
// //
/// Build the module lists, sort it, filter for excludes, then build the change list /// Build the footprint lists, sort it, filter for excludes, then build the change list
/// @returns true if success, false if errors /// @returns true if success, false if errors
bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefDes ) bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector<RefDesInfo>& aBadRefDes )
{ {
bool annotateselected; bool annotateSelected;
bool annotatefront = m_AnnotateFront->GetValue(); //Unless only doing back bool annotateFront = m_AnnotateFront->GetValue(); //Unless only doing back
bool annotateback = m_AnnotateBack->GetValue(); //Unless only doing front bool annotateBack = m_AnnotateBack->GetValue(); //Unless only doing front
bool skiplocked = m_ExcludeLocked->GetValue(); bool skipLocked = m_ExcludeLocked->GetValue();
int errorcount = 0; int errorcount = 0;
unsigned int backstartrefdes; unsigned int backstartrefdes;
@ -721,7 +721,7 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
} }
} }
annotateselected = !selected.empty(); annotateSelected = !selected.empty();
wxString exclude; wxString exclude;
@ -740,70 +740,72 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
m_excludeArray.push_back( exclude ); m_excludeArray.push_back( exclude );
} }
RefDesInfo thismodule; RefDesInfo fpData;
bool useModuleLocation = m_locationChoice->GetSelection() == 0; bool useModuleLocation = m_locationChoice->GetSelection() == 0;
for( MODULE* mod : m_footprints ) for( MODULE* footprint : m_footprints )
{ {
thismodule.Uuid = mod->m_Uuid; fpData.Uuid = footprint->m_Uuid;
thismodule.RefDesString = mod->GetReference(); fpData.RefDesString = footprint->GetReference();
thismodule.FPID = mod->GetFPID(); fpData.FPID = footprint->GetFPID();
thismodule.x = useModuleLocation ? mod->GetPosition().x fpData.x = useModuleLocation ? footprint->GetPosition().x
: mod->Reference().GetPosition().x; : footprint->Reference().GetPosition().x;
thismodule.y = useModuleLocation ? mod->GetPosition().y fpData.y = useModuleLocation ? footprint->GetPosition().y
: mod->Reference().GetPosition().y; : footprint->Reference().GetPosition().y;
thismodule.roundedx = RoundToGrid( thismodule.x, m_sortGridx ); //Round to sort fpData.roundedx = RoundToGrid( fpData.x, m_sortGridx ); //Round to sort
thismodule.roundedy = RoundToGrid( thismodule.y, m_sortGridy ); fpData.roundedy = RoundToGrid( fpData.y, m_sortGridy );
thismodule.Front = mod->GetLayer() == F_Cu; fpData.Front = footprint->GetLayer() == F_Cu;
thismodule.Action = UpdateRefDes; //Usually good fpData.Action = UpdateRefDes; //Usually good
if( thismodule.RefDesString.IsEmpty() ) if( fpData.RefDesString.IsEmpty() )
thismodule.Action = EmptyRefDes; {
fpData.Action = EmptyRefDes;
}
else else
{ {
firstnum = thismodule.RefDesString.find_first_of( "0123456789" ); firstnum = fpData.RefDesString.find_first_of( "0123456789" );
if( std::string::npos == firstnum ) if( std::string::npos == firstnum )
thismodule.Action = InvalidRefDes; //do not change ref des such as 12 or +1, or L fpData.Action = InvalidRefDes; //do not change ref des such as 12 or +1, or L
} }
//Get the type (R, C, etc) //Get the type (R, C, etc)
thismodule.RefDesType = thismodule.RefDesString.substr( 0, firstnum ); fpData.RefDesType = fpData.RefDesString.substr( 0, firstnum );
for( wxString excluded : m_excludeArray ) for( wxString excluded : m_excludeArray )
{ {
if( excluded == thismodule.RefDesType ) //Am I supposed to exclude this type? if( excluded == fpData.RefDesType ) //Am I supposed to exclude this type?
{ {
thismodule.Action = Exclude; //Yes fpData.Action = Exclude; //Yes
break; break;
} }
} }
if( ( thismodule.Front && annotateback ) || //If a front module and doing backs only if(( fpData.Front && annotateBack ) || // If a front module and doing backs only
( !thismodule.Front && annotatefront ) || //If a back module and doing front only ( !fpData.Front && annotateFront ) || // If a back module and doing front only
( mod->IsLocked() && skiplocked ) ) //If excluding locked and it is locked ( footprint->IsLocked() && skipLocked ) ) // If excluding locked and it is locked
{ {
thismodule.Action = Exclude; fpData.Action = Exclude;
} }
if( annotateselected ) if( annotateSelected )
{ //If onnly annotating selected c { // If onnly annotating selected c
thismodule.Action = Exclude; //Assume it isn't selected fpData.Action = Exclude; // Assume it isn't selected
for( KIID sel : selected ) for( KIID sel : selected )
{ {
if( thismodule.Uuid == sel ) if( fpData.Uuid == sel )
{ //Found in selected footprints { // Found in selected footprints
thismodule.Action = UpdateRefDes; //Update it fpData.Action = UpdateRefDes; // Update it
break; break;
} }
} }
} }
if( thismodule.Front ) if( fpData.Front )
m_frontFootprints.push_back( thismodule ); m_frontFootprints.push_back( fpData );
else else
m_backFootprints.push_back( thismodule ); m_backFootprints.push_back( fpData );
} }
SetSortCodes( FrontDirectionsArray, m_sortCode ); //Determine the sort order for the front SetSortCodes( FrontDirectionsArray, m_sortCode ); //Determine the sort order for the front
@ -865,7 +867,7 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
// //
/// Scan through the module arrays and create the from -> to array /// Scan through the footprint arrays and create the from -> to array
void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aFootprints, void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aFootprints,
unsigned int aStartRefDes, wxString aPrefix, unsigned int aStartRefDes, wxString aPrefix,
bool aRemovePrefix, bool aRemovePrefix,
@ -894,44 +896,44 @@ void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aFootpr
m_refDesTypes[i].RefDesCount = aStartRefDes; m_refDesTypes[i].RefDesCount = aStartRefDes;
} }
for( RefDesInfo footprint : aFootprints ) for( RefDesInfo fpData : aFootprints )
{ //For each module {
change.Uuid = footprint.Uuid; change.Uuid = fpData.Uuid;
change.Action = footprint.Action; change.Action = fpData.Action;
change.OldRefDesString = footprint.RefDesString; change.OldRefDesString = fpData.RefDesString;
change.NewRefDes = footprint.RefDesString; change.NewRefDes = fpData.RefDesString;
change.Front = footprint.Front; change.Front = fpData.Front;
if( footprint.RefDesString.IsEmpty() ) if( fpData.RefDesString.IsEmpty() )
footprint.Action = EmptyRefDes; fpData.Action = EmptyRefDes;
if( ( change.Action == EmptyRefDes ) || ( change.Action == InvalidRefDes ) ) if( ( change.Action == EmptyRefDes ) || ( change.Action == InvalidRefDes ) )
{ {
m_changeArray.push_back( change ); m_changeArray.push_back( change );
aBadRefDes.push_back( footprint ); aBadRefDes.push_back( fpData );
continue; continue;
} }
if( change.Action == UpdateRefDes ) if( change.Action == UpdateRefDes )
{ {
refdestype = footprint.RefDesType; refdestype = fpData.RefDesType;
prefixpresent = ( 0 == footprint.RefDesType.find( aPrefix ) ); prefixpresent = ( 0 == fpData.RefDesType.find( aPrefix ) );
if( addprefix && !prefixpresent ) if( addprefix && !prefixpresent )
footprint.RefDesType.insert( 0, aPrefix ); //Add prefix once only fpData.RefDesType.insert( 0, aPrefix ); //Add prefix once only
if( aRemovePrefix && prefixpresent ) //If there is a prefix remove it if( aRemovePrefix && prefixpresent ) //If there is a prefix remove it
footprint.RefDesType.erase( 0, prefixsize ); fpData.RefDesType.erase( 0, prefixsize );
for( i = 0; i < m_refDesTypes.size(); i++ ) //See if it is in the types array for( i = 0; i < m_refDesTypes.size(); i++ ) //See if it is in the types array
{ {
if( m_refDesTypes[i].RefDesType == footprint.RefDesType ) //Found it! if( m_refDesTypes[i].RefDesType == fpData.RefDesType ) //Found it!
break; break;
} }
if( i == m_refDesTypes.size() ) if( i == m_refDesTypes.size() )
{ //Wasn't in the types array so add it { //Wasn't in the types array so add it
newtype.RefDesType = footprint.RefDesType; newtype.RefDesType = fpData.RefDesType;
newtype.RefDesCount = ( aStartRefDes == 0 ? 1 : aStartRefDes ); newtype.RefDesCount = ( aStartRefDes == 0 ? 1 : aStartRefDes );
m_refDesTypes.push_back( newtype ); m_refDesTypes.push_back( newtype );
} }

View File

@ -176,7 +176,7 @@ private:
void LogChangePlan( void ); void LogChangePlan( void );
bool ReannotateBoard( void ); bool ReannotateBoard( void );
bool BuildModuleList( std::vector<RefDesInfo>& aBadRefDes ); bool BuildFootprintList( std::vector<RefDesInfo>& aBadRefDes );
void BuildChangeArray( std::vector<RefDesInfo>& aFootprints, unsigned int aStartRefDes, void BuildChangeArray( std::vector<RefDesInfo>& aFootprints, unsigned int aStartRefDes,
wxString aPrefix, bool aRemovePrefix, wxString aPrefix, bool aRemovePrefix,
std::vector<RefDesInfo>& aBadRefDes ); std::vector<RefDesInfo>& aBadRefDes );

View File

@ -175,7 +175,7 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow()
} }
// Do not enable/disable antipad clearance and spoke width. They might be needed if // Do not enable/disable antipad clearance and spoke width. They might be needed if
// a module or pad overrides the zone to specify a thermal connection. // a footprint or pad overrides the zone to specify a thermal connection.
m_antipadClearance.SetValue( m_settings.m_ThermalReliefGap ); m_antipadClearance.SetValue( m_settings.m_ThermalReliefGap );
m_spokeWidth.SetValue( m_settings.m_ThermalReliefSpokeWidth ); m_spokeWidth.SetValue( m_settings.m_ThermalReliefSpokeWidth );

View File

@ -545,7 +545,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::Validate()
if( !DIALOG_SHIM::Validate() ) if( !DIALOG_SHIM::Validate() )
return false; return false;
// First, test for invalid chars in module name // First, test for invalid chars in footprint name
wxString footprintName = m_FootprintNameCtrl->GetValue(); wxString footprintName = m_FootprintNameCtrl->GetValue();
if( !checkFootprintName( footprintName ) ) if( !checkFootprintName( footprintName ) )
@ -703,7 +703,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataFromWindow()
m_footprint->CalculateBoundingBox(); m_footprint->CalculateBoundingBox();
commit.Push( _( "Modify module properties" ) ); commit.Push( _( "Modify footprint properties" ) );
return true; return true;
} }

View File

@ -1469,7 +1469,7 @@ void DIALOG_NET_INSPECTOR::buildNetsList()
} }
// count the pads for each net. since the nets are sorted by netcode // count the pads for each net. since the nets are sorted by netcode
// iterating over the modules' pads is faster. // iterating over the footprints' pads is faster.
for( MODULE* footprint : m_brd->Footprints() ) for( MODULE* footprint : m_brd->Footprints() )
{ {

View File

@ -249,16 +249,16 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
if( m_item->Type() == PCB_FP_TEXT_T && m_fpText ) if( m_item->Type() == PCB_FP_TEXT_T && m_fpText )
{ {
MODULE* module = dynamic_cast<MODULE*>( m_fpText->GetParent() ); MODULE* footprint = dynamic_cast<MODULE*>( m_fpText->GetParent() );
wxString msg; wxString msg;
if( module ) if( footprint )
{ {
msg.Printf( _("Footprint %s (%s), %s, rotated %.1f deg"), msg.Printf( _( "Footprint %s (%s), %s, rotated %.1f deg"),
module->GetReference(), footprint->GetReference(),
module->GetValue(), footprint->GetValue(),
module->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ), footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ),
module->GetOrientation() / 10.0 ); footprint->GetOrientation() / 10.0 );
} }
m_statusLine->SetLabel( msg ); m_statusLine->SetLabel( msg );

View File

@ -659,12 +659,12 @@ void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aT
for( ZONE* zone : m_board->Zones() ) for( ZONE* zone : m_board->Zones() )
zone->CacheBoundingBox(); zone->CacheBoundingBox();
for( MODULE* module : m_board->Footprints() ) for( MODULE* footprint : m_board->Footprints() )
{ {
for( ZONE* zone : module->Zones() ) for( ZONE* zone : footprint->Zones() )
zone->CacheBoundingBox(); zone->CacheBoundingBox();
module->BuildPolyCourtyards(); footprint->BuildPolyCourtyards();
} }
for( DRC_TEST_PROVIDER* provider : m_testProviders ) for( DRC_TEST_PROVIDER* provider : m_testProviders )

View File

@ -23,7 +23,7 @@
/* /*
* 1 - create ascii/csv files for automatic placement of smd components * 1 - create ascii/csv files for automatic placement of smd components
* 2 - create a module report (pos and module descr) (ascii file) * 2 - create a footprint report (pos and footprint descr) (ascii file)
*/ */
#include <kicad_string.h> #include <kicad_string.h>
@ -35,7 +35,7 @@
class LIST_MOD // An helper class used to build a list of useful footprints. class LIST_MOD // An helper class used to build a list of useful footprints.
{ {
public: public:
MODULE* m_Module; // Link to the actual footprint MODULE* m_Footprint; // Link to the actual footprint
wxString m_Reference; // Its schematic reference wxString m_Reference; // Its schematic reference
wxString m_Value; // Its schematic value wxString m_Value; // Its schematic value
LAYER_NUM m_Layer; // its side (B_Cu, or F_Cu) LAYER_NUM m_Layer; // its side (B_Cu, or F_Cu)
@ -132,7 +132,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
m_fpCount++; m_fpCount++;
LIST_MOD item; LIST_MOD item;
item.m_Module = footprint; item.m_Footprint = footprint;
item.m_Reference = footprint->Reference().GetShownText(); item.m_Reference = footprint->Reference().GetShownText();
item.m_Value = footprint->Value().GetShownText(); item.m_Value = footprint->Value().GetShownText();
item.m_Layer = footprint->GetLayer(); item.m_Layer = footprint->GetLayer();
@ -140,7 +140,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
lenRefText = std::max( lenRefText, (int) item.m_Reference.length() ); lenRefText = std::max( lenRefText, (int) item.m_Reference.length() );
lenValText = std::max( lenValText, (int) item.m_Value.length() ); lenValText = std::max( lenValText, (int) item.m_Value.length() );
lenPkgText = std::max( lenPkgText, (int) item.m_Module->GetFPID().GetLibItemName().length() ); lenPkgText = std::max( lenPkgText, (int) item.m_Footprint->GetFPID().GetLibItemName().length() );
} }
if( list.size() > 1 ) if( list.size() > 1 )
@ -162,10 +162,10 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
for( int ii = 0; ii < m_fpCount; ii++ ) for( int ii = 0; ii < m_fpCount; ii++ )
{ {
wxPoint footprint_pos; wxPoint footprint_pos;
footprint_pos = list[ii].m_Module->GetPosition(); footprint_pos = list[ii].m_Footprint->GetPosition();
footprint_pos -= m_place_Offset; footprint_pos -= m_place_Offset;
LAYER_NUM layer = list[ii].m_Module->GetLayer(); LAYER_NUM layer = list[ii].m_Footprint->GetLayer();
wxASSERT( layer == F_Cu || layer == B_Cu ); wxASSERT( layer == F_Cu || layer == B_Cu );
if( layer == B_Cu ) if( layer == B_Cu )
@ -175,7 +175,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
tmp << "\"" << csv_sep; tmp << "\"" << csv_sep;
tmp << "\"" << list[ii].m_Value; tmp << "\"" << list[ii].m_Value;
tmp << "\"" << csv_sep; tmp << "\"" << csv_sep;
tmp << "\"" << list[ii].m_Module->GetFPID().GetLibItemName().wx_str(); tmp << "\"" << list[ii].m_Footprint->GetFPID().GetLibItemName().wx_str();
tmp << "\"" << csv_sep; tmp << "\"" << csv_sep;
tmp << wxString::Format( "%f%c%f%c%f", tmp << wxString::Format( "%f%c%f%c%f",
@ -183,7 +183,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
// Keep the Y axis oriented from bottom to top, // Keep the Y axis oriented from bottom to top,
// ( change y coordinate sign ) // ( change y coordinate sign )
-footprint_pos.y * conv_unit, csv_sep, -footprint_pos.y * conv_unit, csv_sep,
list[ii].m_Module->GetOrientation() / 10.0 ); list[ii].m_Footprint->GetOrientation() / 10.0 );
tmp << csv_sep; tmp << csv_sep;
tmp << ( (layer == F_Cu ) ? PLACE_FILE_EXPORTER::GetFrontSideName() tmp << ( (layer == F_Cu ) ? PLACE_FILE_EXPORTER::GetFrontSideName()
@ -228,10 +228,10 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
for( int ii = 0; ii < m_fpCount; ii++ ) for( int ii = 0; ii < m_fpCount; ii++ )
{ {
wxPoint footprint_pos; wxPoint footprint_pos;
footprint_pos = list[ii].m_Module->GetPosition(); footprint_pos = list[ii].m_Footprint->GetPosition();
footprint_pos -= m_place_Offset; footprint_pos -= m_place_Offset;
LAYER_NUM layer = list[ii].m_Module->GetLayer(); LAYER_NUM layer = list[ii].m_Footprint->GetLayer();
wxASSERT( layer == F_Cu || layer == B_Cu ); wxASSERT( layer == F_Cu || layer == B_Cu );
if( layer == B_Cu ) if( layer == B_Cu )
@ -239,7 +239,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
wxString ref = list[ii].m_Reference; wxString ref = list[ii].m_Reference;
wxString val = list[ii].m_Value; wxString val = list[ii].m_Value;
wxString pkg = list[ii].m_Module->GetFPID().GetLibItemName(); wxString pkg = list[ii].m_Footprint->GetFPID().GetLibItemName();
ref.Replace( wxT( " " ), wxT( "_" ) ); ref.Replace( wxT( " " ), wxT( "_" ) );
val.Replace( wxT( " " ), wxT( "_" ) ); val.Replace( wxT( " " ), wxT( "_" ) );
pkg.Replace( wxT( " " ), wxT( "_" ) ); pkg.Replace( wxT( " " ), wxT( "_" ) );
@ -251,7 +251,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
// Keep the coordinates in the first quadrant, // Keep the coordinates in the first quadrant,
// (i.e. change y sign // (i.e. change y sign
-footprint_pos.y * conv_unit, -footprint_pos.y * conv_unit,
list[ii].m_Module->GetOrientation() / 10.0, list[ii].m_Footprint->GetOrientation() / 10.0,
(layer == F_Cu ) ? GetFrontSideName().c_str() : GetBackSideName().c_str() ); (layer == F_Cu ) ? GetFrontSideName().c_str() : GetBackSideName().c_str() );
buffer += line; buffer += line;
} }

View File

@ -53,7 +53,7 @@ static void CreateRoutesSection( FILE* aFile, BOARD* aPcb );
static void CreateSignalsSection( FILE* aFile, BOARD* aPcb ); static void CreateSignalsSection( FILE* aFile, BOARD* aPcb );
static void CreateShapesSection( FILE* aFile, BOARD* aPcb ); static void CreateShapesSection( FILE* aFile, BOARD* aPcb );
static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ); static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb );
static void FootprintWriteShape( FILE* File, MODULE* module, const wxString& aShapeName ); static void FootprintWriteShape( FILE* File, MODULE* aFootprint, const wxString& aShapeName );
// layer names for Gencad export // layer names for Gencad export
@ -259,7 +259,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
// Update some board data, to ensure a reliable gencad export // Update some board data, to ensure a reliable gencad export
GetBoard()->ComputeBoundingBox(); GetBoard()->ComputeBoundingBox();
// Save the auxiliary origin for the rest of the module // Save the auxiliary origin for the rest of the footprint
wxPoint auxOrigin = m_pcb->GetDesignSettings().m_AuxOrigin; wxPoint auxOrigin = m_pcb->GetDesignSettings().m_AuxOrigin;
GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.x : 0; GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.x : 0;
GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.y : 0; GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.y : 0;
@ -1065,10 +1065,15 @@ static void CreateDevicesSection( FILE* aFile, BOARD* aPcb )
if( !newDevice ) // do not repeat device definitions if( !newDevice ) // do not repeat device definitions
continue; continue;
const MODULE* module = componentShape.first; const MODULE* footprint = componentShape.first;
fprintf( aFile, "\nDEVICE \"DEV_%s\"\n", TO_UTF8( escapeString( shapeName ) ) ); fprintf( aFile, "\nDEVICE \"DEV_%s\"\n", TO_UTF8( escapeString( shapeName ) ) );
fprintf( aFile, "PART \"%s\"\n", TO_UTF8( escapeString( module->GetValue() ) ) );
fprintf( aFile, "PACKAGE \"%s\"\n", TO_UTF8( escapeString( module->GetFPID().Format() ) ) ); fprintf( aFile, "PART \"%s\"\n",
TO_UTF8( escapeString( footprint->GetValue() ) ) );
fprintf( aFile, "PACKAGE \"%s\"\n",
TO_UTF8( escapeString( footprint->GetFPID().Format() ) ) );
} }
fputs( "$ENDDEVICES\n\n", aFile ); fputs( "$ENDDEVICES\n\n", aFile );
@ -1137,14 +1142,14 @@ static void CreateTracksInfoData( FILE* aFile, BOARD* aPcb )
* It's almost guaranteed that the silk layer will be imported wrong but * It's almost guaranteed that the silk layer will be imported wrong but
* the shape also contains the pads! * the shape also contains the pads!
*/ */
static void FootprintWriteShape( FILE* aFile, MODULE* module, const wxString& aShapeName ) static void FootprintWriteShape( FILE* aFile, MODULE* aFootprint, const wxString& aShapeName )
{ {
FP_SHAPE* shape; FP_SHAPE* shape;
/* creates header: */ /* creates header: */
fprintf( aFile, "\nSHAPE \"%s\"\n", TO_UTF8( escapeString( aShapeName ) ) ); fprintf( aFile, "\nSHAPE \"%s\"\n", TO_UTF8( escapeString( aShapeName ) ) );
if( module->GetAttributes() & FP_THROUGH_HOLE ) if( aFootprint->GetAttributes() & FP_THROUGH_HOLE )
fprintf( aFile, "INSERT TH\n" ); fprintf( aFile, "INSERT TH\n" );
else else
fprintf( aFile, "INSERT SMD\n" ); fprintf( aFile, "INSERT SMD\n" );
@ -1153,7 +1158,7 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module, const wxString& aS
// CAM350 read it right but only closed shapes // CAM350 read it right but only closed shapes
// ProntoPlace double-flip it (at least the pads are correct) // ProntoPlace double-flip it (at least the pads are correct)
// GerberTool usually get it right... // GerberTool usually get it right...
for( BOARD_ITEM* PtStruct : module->GraphicalItems() ) for( BOARD_ITEM* PtStruct : aFootprint->GraphicalItems() )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {

View File

@ -70,7 +70,7 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
// NOTE: IMPLEMENTATION // NOTE: IMPLEMENTATION
// If/when component cutouts are allowed, we must implement them separately. Cutouts // 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. // 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_footprint() routine. // The footprint cutouts should be handled via the idf_export_footprint() routine.
double offX, offY; double offX, offY;
aIDFBoard.GetUserOffset( offX, offY ); aIDFBoard.GetUserOffset( offX, offY );
@ -219,10 +219,9 @@ UseBoundingBox:
else else
outline = new IDF_OUTLINE; outline = new IDF_OUTLINE;
// fetch a rectangular bounding box for the board; // Fetch a rectangular bounding box for the board; there is always some uncertainty in the
// there is always some uncertainty in the board dimensions // board dimensions computed via ComputeBoundingBox() since this depends on the individual
// computed via ComputeBoundingBox() since this depends on the // footprint entities.
// individual module entities.
EDA_RECT bbbox = aPcb->GetBoardEdgesBoundingBox(); EDA_RECT bbbox = aPcb->GetBoardEdgesBoundingBox();
// convert to mm and compensate for an assumed LINE_WIDTH line thickness // convert to mm and compensate for an assumed LINE_WIDTH line thickness
@ -284,14 +283,14 @@ static void idf_export_footprint( BOARD* aPcb, MODULE* aFootprint, IDF3_BOARD& a
std::string cvalue = TO_UTF8( aFootprint->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, // 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. // otherwise associated parts of the footprint must be marked NOREFDES.
if( cvalue.empty() || !cvalue.compare( "~" ) ) if( cvalue.empty() || !cvalue.compare( "~" ) )
crefdes = "BOARD"; crefdes = "BOARD";
else else
crefdes = "NOREFDES"; crefdes = "NOREFDES";
} }
// TODO: If module cutouts are supported we must add code here // TODO: If footprint cutouts are supported we must add code here
// for( EDA_ITEM* item = aFootprint->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 ) // if( item->Type() != PCB_FP_SHAPE_T || item->GetLayer() != Edge_Cuts )
@ -616,7 +615,7 @@ bool PCB_EDIT_FRAME::Export_IDF3( BOARD* aPcb, const wxString& aFullFileName,
// Export the board outline // Export the board outline
idf_export_outline( aPcb, idfBoard ); idf_export_outline( aPcb, idfBoard );
// Output the drill holes and module (library) data. // Output the drill holes and footprint (library) data.
for( MODULE* footprint : aPcb->Footprints() ) for( MODULE* footprint : aPcb->Footprints() )
idf_export_footprint( aPcb, footprint, idfBoard ); idf_export_footprint( aPcb, footprint, idfBoard );

View File

@ -1373,7 +1373,7 @@ static void export_vrml_footprint( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aFoo
if( aFootprint->Value().IsVisible() ) if( aFootprint->Value().IsVisible() )
export_vrml_fp_text( &aFootprint->Value()); export_vrml_fp_text( &aFootprint->Value());
// Export module edges // Export footprint graphics
for( BOARD_ITEM* item : aFootprint->GraphicalItems() ) for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
{ {
@ -1439,8 +1439,8 @@ static void export_vrml_footprint( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aFoo
build_quat( 0, 0, 1, DEG2RAD( rotz ), q2 ); build_quat( 0, 0, 1, DEG2RAD( rotz ), q2 );
compose_quat( q1, q2, q1 ); compose_quat( q1, q2, q1 );
// Note here aFootprint->GetOrientation() is in 0.1 degrees, // Note here aFootprint->GetOrientation() is in 0.1 degrees, so footprint rotation
// so module rotation has to be converted to radians // has to be converted to radians
build_quat( 0, 0, 1, DECIDEG2RAD( aFootprint->GetOrientation() ), q2 ); build_quat( 0, 0, 1, DECIDEG2RAD( aFootprint->GetOrientation() ), q2 );
compose_quat( q1, q2, q1 ); compose_quat( q1, q2, q1 );
from_quat( q1, rot ); from_quat( q1, rot );

View File

@ -23,7 +23,7 @@
/* /*
* 1 - create ascii files for automatic placement of smd components * 1 - create ascii files for automatic placement of smd components
* 2 - create a module report (pos and module descr) (ascii file) * 2 - create a footprint report (pos and footprint descr) (ascii file)
*/ */
#include <confirm.h> #include <confirm.h>
@ -528,7 +528,7 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
} }
} }
/* Print a module report. /* Print a footprint report.
*/ */
bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM ) bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM )
{ {

View File

@ -46,7 +46,7 @@ MODULE::MODULE( BOARD* parent ) :
m_attributes = 0; m_attributes = 0;
m_Layer = F_Cu; m_Layer = F_Cu;
m_orient = 0; m_orient = 0;
m_moduleStatus = FP_PADS_are_LOCKED; m_fpStatus = FP_PADS_are_LOCKED;
m_arflag = 0; m_arflag = 0;
m_rot90Cost = m_rot180Cost = 0; m_rot90Cost = m_rot180Cost = 0;
m_link = 0; m_link = 0;
@ -73,7 +73,7 @@ MODULE::MODULE( const MODULE& aFootprint ) :
m_pos = aFootprint.m_pos; m_pos = aFootprint.m_pos;
m_fpid = aFootprint.m_fpid; m_fpid = aFootprint.m_fpid;
m_attributes = aFootprint.m_attributes; m_attributes = aFootprint.m_attributes;
m_moduleStatus = aFootprint.m_moduleStatus; m_fpStatus = aFootprint.m_fpStatus;
m_orient = aFootprint.m_orient; m_orient = aFootprint.m_orient;
m_boundingBox = aFootprint.m_boundingBox; m_boundingBox = aFootprint.m_boundingBox;
m_rot90Cost = aFootprint.m_rot90Cost; m_rot90Cost = aFootprint.m_rot90Cost;
@ -207,7 +207,7 @@ MODULE& MODULE::operator=( MODULE&& aOther )
m_pos = aOther.m_pos; m_pos = aOther.m_pos;
m_fpid = aOther.m_fpid; m_fpid = aOther.m_fpid;
m_attributes = aOther.m_attributes; m_attributes = aOther.m_attributes;
m_moduleStatus = aOther.m_moduleStatus; m_fpStatus = aOther.m_fpStatus;
m_orient = aOther.m_orient; m_orient = aOther.m_orient;
m_boundingBox = aOther.m_boundingBox; m_boundingBox = aOther.m_boundingBox;
m_rot90Cost = aOther.m_rot90Cost; m_rot90Cost = aOther.m_rot90Cost;
@ -302,7 +302,7 @@ MODULE& MODULE::operator=( const MODULE& aOther )
m_pos = aOther.m_pos; m_pos = aOther.m_pos;
m_fpid = aOther.m_fpid; m_fpid = aOther.m_fpid;
m_attributes = aOther.m_attributes; m_attributes = aOther.m_attributes;
m_moduleStatus = aOther.m_moduleStatus; m_fpStatus = aOther.m_fpStatus;
m_orient = aOther.m_orient; m_orient = aOther.m_orient;
m_boundingBox = aOther.m_boundingBox; m_boundingBox = aOther.m_boundingBox;
m_rot90Cost = aOther.m_rot90Cost; m_rot90Cost = aOther.m_rot90Cost;
@ -762,7 +762,7 @@ void MODULE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM
if( IsLocked() ) if( IsLocked() )
addToken( &status, _( "locked" ) ); addToken( &status, _( "locked" ) );
if( m_moduleStatus & FP_is_PLACED ) if( m_fpStatus & FP_is_PLACED )
addToken( &status, _( "autoplaced" ) ); addToken( &status, _( "autoplaced" ) );
if( m_attributes & FP_BOARD_ONLY ) if( m_attributes & FP_BOARD_ONLY )
@ -1293,7 +1293,7 @@ void MODULE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
m_reference->Flip( m_pos, false ); m_reference->Flip( m_pos, false );
m_value->Flip( m_pos, false ); m_value->Flip( m_pos, false );
// Reverse mirror module graphics and texts. // Reverse mirror footprint graphics and texts.
for( BOARD_ITEM* item : m_drawings ) for( BOARD_ITEM* item : m_drawings )
{ {
switch( item->Type() ) switch( item->Type() )

View File

@ -289,7 +289,7 @@ public:
bool IsLocked() const override bool IsLocked() const override
{ {
return ( m_moduleStatus & FP_is_LOCKED ) != 0; return ( m_fpStatus & FP_is_LOCKED ) != 0;
} }
/** /**
@ -300,37 +300,37 @@ public:
void SetLocked( bool isLocked ) override void SetLocked( bool isLocked ) override
{ {
if( isLocked ) if( isLocked )
m_moduleStatus |= FP_is_LOCKED; m_fpStatus |= FP_is_LOCKED;
else else
m_moduleStatus &= ~FP_is_LOCKED; m_fpStatus &= ~FP_is_LOCKED;
} }
bool IsPlaced() const { return m_moduleStatus & FP_is_PLACED; } bool IsPlaced() const { return m_fpStatus & FP_is_PLACED; }
void SetIsPlaced( bool isPlaced ) void SetIsPlaced( bool isPlaced )
{ {
if( isPlaced ) if( isPlaced )
m_moduleStatus |= FP_is_PLACED; m_fpStatus |= FP_is_PLACED;
else else
m_moduleStatus &= ~FP_is_PLACED; m_fpStatus &= ~FP_is_PLACED;
} }
bool NeedsPlaced() const { return m_moduleStatus & FP_to_PLACE; } bool NeedsPlaced() const { return m_fpStatus & FP_to_PLACE; }
void SetNeedsPlaced( bool needsPlaced ) void SetNeedsPlaced( bool needsPlaced )
{ {
if( needsPlaced ) if( needsPlaced )
m_moduleStatus |= FP_to_PLACE; m_fpStatus |= FP_to_PLACE;
else else
m_moduleStatus &= ~FP_to_PLACE; m_fpStatus &= ~FP_to_PLACE;
} }
bool PadsLocked() const { return m_moduleStatus & FP_PADS_are_LOCKED; } bool PadsLocked() const { return m_fpStatus & FP_PADS_are_LOCKED; }
void SetPadsLocked( bool aPadsLocked ) void SetPadsLocked( bool aPadsLocked )
{ {
if( aPadsLocked ) if( aPadsLocked )
m_moduleStatus |= FP_PADS_are_LOCKED; m_fpStatus |= FP_PADS_are_LOCKED;
else else
m_moduleStatus &= ~FP_PADS_are_LOCKED; m_fpStatus &= ~FP_PADS_are_LOCKED;
} }
void SetLastEditTime( timestamp_t aTime ) { m_lastEditTime = aTime; } void SetLastEditTime( timestamp_t aTime ) { m_lastEditTime = aTime; }
@ -702,7 +702,7 @@ private:
FP_TEXT* m_value; // Component value (74LS00, 22K..) FP_TEXT* m_value; // Component value (74LS00, 22K..)
LIB_ID m_fpid; // The #LIB_ID of the MODULE. LIB_ID m_fpid; // The #LIB_ID of the MODULE.
int m_attributes; // Flag bits ( see FOOTPRINT_ATTR_T ) int m_attributes; // Flag bits ( see FOOTPRINT_ATTR_T )
int m_moduleStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED) int m_fpStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED)
EDA_RECT m_boundingBox; // Bounding box : coordinates on board, real orientation. EDA_RECT m_boundingBox; // Bounding box : coordinates on board, real orientation.
ZONE_CONNECTION m_zoneConnection; ZONE_CONNECTION m_zoneConnection;

View File

@ -784,7 +784,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( MODULE* aFootprint,
bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew ) bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
{ {
// update module in the current board, // update footprint in the current board,
// not just add it to the board with total disregard for the netlist... // not just add it to the board with total disregard for the netlist...
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false ); PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
@ -824,7 +824,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true ); pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
BOARD_COMMIT commit( pcbframe ); BOARD_COMMIT commit( pcbframe );
// Create the "new" module // Create the "new" footprint
MODULE* newFootprint = new MODULE( *editorFootprint ); MODULE* newFootprint = new MODULE( *editorFootprint );
const_cast<KIID&>( newFootprint->m_Uuid ) = KIID(); const_cast<KIID&>( newFootprint->m_Uuid ) = KIID();
@ -838,7 +838,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
// deleted // deleted
pcbframe->ExchangeFootprint( sourceFootprint, newFootprint, commit ); pcbframe->ExchangeFootprint( sourceFootprint, newFootprint, commit );
const_cast<KIID&>( newFootprint->m_Uuid ) = editorFootprint->GetLink(); const_cast<KIID&>( newFootprint->m_Uuid ) = editorFootprint->GetLink();
commit.Push( wxT( "Update module" ) ); commit.Push( wxT( "Update footprint" ) );
} }
else // This is an insert command else // This is an insert command
{ {
@ -851,7 +851,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
newFootprint->SetPosition( wxPoint( 0, 0 ) ); newFootprint->SetPosition( wxPoint( 0, 0 ) );
viewControls->SetCrossHairCursorPosition( cursorPos, false ); viewControls->SetCrossHairCursorPosition( cursorPos, false );
const_cast<KIID&>( newFootprint->m_Uuid ) = KIID(); const_cast<KIID&>( newFootprint->m_Uuid ) = KIID();
commit.Push( wxT( "Insert module" ) ); commit.Push( wxT( "Insert footprint" ) );
pcbframe->Raise(); pcbframe->Raise();
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newFootprint ); pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newFootprint );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es> * Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
* Copyright (C) 2013 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -47,8 +47,8 @@ const wxString WIZARD_PARAM_UNITS_STRING = "string"; // String
/** /**
* FOOTPRINT_WIZARD * FOOTPRINT_WIZARD
* This is the parent class from where any footprint wizard class must * This is the parent class from where any footprint wizard class must derive
* derive */ */
class FOOTPRINT_WIZARD class FOOTPRINT_WIZARD
{ {
public: public:
@ -145,9 +145,9 @@ public:
virtual void ResetParameters() = 0; virtual void ResetParameters() = 0;
/** /**
* Function GetModule * Function GetFootprint
* This method builds the module itself and returns it to the caller function * This method builds the footprint itself and returns it to the caller function
* @return PCB module built from the parameters given to the class * @return PCB footprint built from the parameters given to the class
* @param aMessage a wxString to store messages (if any) generated by the * @param aMessage a wxString to store messages (if any) generated by the
* footprint generator * footprint generator
*/ */

View File

@ -101,7 +101,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
// Delete the current footprint // Delete the current footprint
GetBoard()->DeleteAllModules(); GetBoard()->DeleteAllModules();
// Creates the module // Creates the footprint
wxString msg; wxString msg;
MODULE* footprint = footprintWizard->GetFootprint( &msg ); MODULE* footprint = footprintWizard->GetFootprint( &msg );
DisplayBuildMessage( msg ); DisplayBuildMessage( msg );

View File

@ -78,13 +78,13 @@ private:
int drawMicrowaveInductor( const TOOL_EVENT& aEvent ); int drawMicrowaveInductor( const TOOL_EVENT& aEvent );
/** /**
* Creates a module "GAP" or "STUB" used in micro wave designs. * Creates a footprint "GAP" or "STUB" used in micro wave designs.
* This module has 2 pads: * This footprint has 2 pads:
* PAD_ATTRIB_SMD, rectangular, H size = V size = current track width. * PAD_ATTRIB_SMD, rectangular, H size = V size = current track width.
* the "gap" is isolation created between this 2 pads * the "gap" is isolation created between this 2 pads
* *
* @param aComponentShape is the component to create * @param aComponentShape is the component to create
* @return the new module * @return the new footprint
*/ */
MODULE* createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprintShape ); MODULE* createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprintShape );
@ -104,7 +104,7 @@ private:
* @param aValue is the text value * @param aValue is the text value
* @param aTextSize is the size of ref and value texts ( <= 0 to use board default values ) * @param aTextSize is the size of ref and value texts ( <= 0 to use board default values )
* @param aPadCount is number of pads * @param aPadCount is number of pads
* @return the new module * @return the new footprint
*/ */
MODULE* createBaseFootprint( const wxString& aValue, int aTextSize, int aPadCount ); MODULE* createBaseFootprint( const wxString& aValue, int aTextSize, int aPadCount );
}; };

View File

@ -134,7 +134,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter )
wxString msg; wxString msg;
LIB_ID lastFPID; LIB_ID lastFPID;
COMPONENT* component; COMPONENT* component;
MODULE* module = nullptr; MODULE* footprint = nullptr;
MODULE* fpOnBoard; MODULE* fpOnBoard;
if( aNetlist.IsEmpty() || Prj().PcbFootprintLibs()->IsEmpty() ) if( aNetlist.IsEmpty() || Prj().PcbFootprintLibs()->IsEmpty() )
@ -184,7 +184,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter )
if( component->GetFPID() != lastFPID ) if( component->GetFPID() != lastFPID )
{ {
module = nullptr; footprint = nullptr;
// The LIB_ID is ok as long as there is a footprint portion coming the library if // The LIB_ID is ok as long as there is a footprint portion coming the library if
// it's needed. Nickname can be blank. // it's needed. Nickname can be blank.
@ -199,15 +199,16 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter )
} }
// loadFootprint() can find a footprint with an empty nickname in fpid. // loadFootprint() can find a footprint with an empty nickname in fpid.
module = PCB_BASE_FRAME::loadFootprint( component->GetFPID() ); footprint = PCB_BASE_FRAME::loadFootprint( component->GetFPID() );
if( module ) if( footprint )
{ {
lastFPID = component->GetFPID(); lastFPID = component->GetFPID();
} }
else else
{ {
msg.Printf( _( "%s footprint \"%s\" not found in any libraries in the footprint library table.\n" ), msg.Printf( _( "%s footprint \"%s\" not found in any libraries in the footprint "
"library table.\n" ),
component->GetReference(), component->GetReference(),
component->GetFPID().GetLibItemName().wx_str() ); component->GetFPID().GetLibItemName().wx_str() );
aReporter.Report( msg, RPT_SEVERITY_ERROR ); aReporter.Report( msg, RPT_SEVERITY_ERROR );
@ -218,14 +219,14 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter )
else else
{ {
// Footprint already loaded from a library, duplicate it (faster) // Footprint already loaded from a library, duplicate it (faster)
if( !module ) if( !footprint )
continue; // Module does not exist in any library. continue; // Footprint does not exist in any library.
module = new MODULE( *module ); footprint = new MODULE( *footprint );
const_cast<KIID&>( module->m_Uuid ) = KIID(); const_cast<KIID&>( footprint->m_Uuid ) = KIID();
} }
if( module ) if( footprint )
component->SetModule( module ); component->SetModule( footprint );
} }
} }

View File

@ -346,10 +346,10 @@ private:
* (pin (num 1) (name ~) (type passive)) * (pin (num 1) (name ~) (type passive))
* (pin (num 2) (name ~) (type passive)))) * (pin (num 2) (name ~) (type passive))))
* *
* And add the strings giving the footprint filter (subsection footprints) * And add the strings giving the footprint filter (subsection footprints) of the
* of the corresponding module info * corresponding footprint info
* <p>This section is used by CvPcb, and is not useful in Pcbnew, * <p>This section is used by CvPcb, and is not useful in Pcbnew, therefore it it not
* therefore it it not always read </p> * always read </p>
*/ */
void parseLibPartList(); void parseLibPartList();

View File

@ -335,10 +335,10 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( MODULE* aModule )
} }
// plot items like text and graphics, but not tracks and module // plot items like text and graphics, but not tracks and footprints
void BRDITEMS_PLOTTER::PlotBoardGraphicItems() void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
{ {
for( auto item : m_board->Drawings() ) for( BOARD_ITEM* item : m_board->Drawings() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {

View File

@ -120,15 +120,16 @@ PCB_SHAPE* ALTIUM_PCB::HelperCreateAndAddDrawsegment( uint16_t aComponent )
{ {
if( m_components.size() <= aComponent ) if( m_components.size() <= aComponent )
{ {
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format( "Component creator tries to access component id %d "
"Component creator tries to access component id %d of %d existing components", "of %d existing components",
aComponent, m_components.size() ) ); aComponent,
m_components.size() ) );
} }
MODULE* module = m_components.at( aComponent ); MODULE* footprint = m_components.at( aComponent );
PCB_SHAPE* fpShape = new FP_SHAPE( module ); PCB_SHAPE* fpShape = new FP_SHAPE( footprint );
module->Add( fpShape, ADD_MODE::APPEND ); footprint->Add( fpShape, ADD_MODE::APPEND );
return fpShape; return fpShape;
} }
} }
@ -444,11 +445,9 @@ void ALTIUM_PCB::Parse( const CFB::CompoundFileReader& aReader,
zone.second->SetPriority( 0 ); zone.second->SetPriority( 0 );
} }
// Finish Board by recalculating module boundingboxes // Finish Board by recalculating footprint boundingboxes
for( MODULE* footprint : m_board->Footprints() ) for( MODULE* footprint : m_board->Footprints() )
{
footprint->CalculateBoundingBox(); footprint->CalculateBoundingBox();
}
// Otherwise we cannot save the imported board // Otherwise we cannot save the imported board
m_board->SetModified(); m_board->SetModified();
@ -750,28 +749,28 @@ void ALTIUM_PCB::ParseComponents6Data(
{ {
ACOMPONENT6 elem( reader ); ACOMPONENT6 elem( reader );
MODULE* module = new MODULE( m_board ); MODULE* footprint = new MODULE( m_board );
m_board->Add( module, ADD_MODE::APPEND ); m_board->Add( footprint, ADD_MODE::APPEND );
m_components.emplace_back( module ); m_components.emplace_back( footprint );
LIB_ID fpID = AltiumToKiCadLibID(LIB_ID::ID_PCB, elem.sourcefootprintlibrary, elem.sourcelibreference ); LIB_ID fpID = AltiumToKiCadLibID(LIB_ID::ID_PCB, elem.sourcefootprintlibrary, elem.sourcelibreference );
module->SetFPID( fpID ); footprint->SetFPID( fpID );
module->SetPosition( elem.position ); footprint->SetPosition( elem.position );
module->SetOrientationDegrees( elem.rotation ); footprint->SetOrientationDegrees( elem.rotation );
// KiCad netlisting requires parts to have non-digit + digit annotation. // KiCad netlisting requires parts to have non-digit + digit annotation.
// If the reference begins with a number, we prepend 'UNK' (unknown) for the source designator // If the reference begins with a number, we prepend 'UNK' (unknown) for the source designator
wxString reference = elem.sourcedesignator; wxString reference = elem.sourcedesignator;
if( reference.find_first_not_of( "0123456789" ) == wxString::npos ) if( reference.find_first_not_of( "0123456789" ) == wxString::npos )
reference.Prepend( "UNK" ); reference.Prepend( "UNK" );
module->SetReference( reference ); footprint->SetReference( reference );
module->SetLocked( elem.locked ); footprint->SetLocked( elem.locked );
module->Reference().SetVisible( elem.nameon ); footprint->Reference().SetVisible( elem.nameon );
module->Value().SetVisible( elem.commenton ); footprint->Value().SetVisible( elem.commenton );
module->SetLayer( elem.layer == ALTIUM_LAYER::TOP_LAYER ? F_Cu : B_Cu ); footprint->SetLayer( elem.layer == ALTIUM_LAYER::TOP_LAYER ? F_Cu : B_Cu );
componentId++; componentId++;
} }
@ -817,20 +816,20 @@ void ALTIUM_PCB::ParseComponentsBodies6Data(
elem.modelId ) ); elem.modelId ) );
} }
MODULE* module = m_components.at( elem.component ); MODULE* footprint = m_components.at( elem.component );
const wxPoint& modulePosition = module->GetPosition(); const wxPoint& fpPosition = footprint->GetPosition();
FP_3DMODEL modelSettings; FP_3DMODEL modelSettings;
modelSettings.m_Filename = modelTuple->second; modelSettings.m_Filename = modelTuple->second;
modelSettings.m_Offset.x = Iu2Millimeter( (int) elem.modelPosition.x - modulePosition.x ); modelSettings.m_Offset.x = Iu2Millimeter((int) elem.modelPosition.x - fpPosition.x );
modelSettings.m_Offset.y = -Iu2Millimeter( (int) elem.modelPosition.y - modulePosition.y ); modelSettings.m_Offset.y = -Iu2Millimeter((int) elem.modelPosition.y - fpPosition.y );
modelSettings.m_Offset.z = Iu2Millimeter( (int) elem.modelPosition.z ); modelSettings.m_Offset.z = Iu2Millimeter( (int) elem.modelPosition.z );
double orientation = module->GetOrientation(); double orientation = footprint->GetOrientation();
if( module->IsFlipped() ) if( footprint->IsFlipped() )
{ {
modelSettings.m_Offset.y = -modelSettings.m_Offset.y; modelSettings.m_Offset.y = -modelSettings.m_Offset.y;
orientation = -orientation; orientation = -orientation;
@ -845,7 +844,7 @@ void ALTIUM_PCB::ParseComponentsBodies6Data(
modelSettings.m_Opacity = elem.bodyOpacity; modelSettings.m_Opacity = elem.bodyOpacity;
module->Models().push_back( modelSettings ); footprint->Models().push_back( modelSettings );
} }
if( reader.GetRemainingBytes() != 0 ) if( reader.GetRemainingBytes() != 0 )
@ -1681,26 +1680,28 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
} }
// Create Pad // Create Pad
MODULE* module = nullptr; MODULE* footprint = nullptr;
if( elem.component == ALTIUM_COMPONENT_NONE ) if( elem.component == ALTIUM_COMPONENT_NONE )
{ {
module = new MODULE( m_board ); // We cannot add a pad directly into the PCB footprint = new MODULE( m_board ); // We cannot add a pad directly into the PCB
m_board->Add( module, ADD_MODE::APPEND ); m_board->Add( footprint, ADD_MODE::APPEND );
module->SetPosition( elem.position ); footprint->SetPosition( elem.position );
} }
else else
{ {
if( m_components.size() <= elem.component ) if( m_components.size() <= elem.component )
{ {
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format( "Pads6 stream tries to access component id %d "
"Pads6 stream tries to access component id %d of %d existing components", "of %d existing components",
elem.component, m_components.size() ) ); elem.component,
m_components.size() ) );
} }
module = m_components.at( elem.component ); footprint = m_components.at( elem.component );
} }
PAD* pad = new PAD( module ); PAD* pad = new PAD( footprint );
module->Add( pad, ADD_MODE::APPEND ); footprint->Add( pad, ADD_MODE::APPEND );
pad->SetName( elem.name ); pad->SetName( elem.name );
pad->SetNetCode( GetNetCode( elem.net ) ); pad->SetNetCode( GetNetCode( elem.net ) );
@ -1723,7 +1724,7 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
// TODO: I assume other values are possible as well? // TODO: I assume other values are possible as well?
wxLogError( wxString::Format( wxLogError( wxString::Format(
"Pad '%s' of Footprint %s is not marked as multilayer, but it is an THT pad", "Pad '%s' of Footprint %s is not marked as multilayer, but it is an THT pad",
elem.name, module->GetReference() ) ); elem.name, footprint->GetReference() ) );
} }
pad->SetAttribute( elem.plated ? PAD_ATTR_T::PAD_ATTRIB_PTH : pad->SetAttribute( elem.plated ? PAD_ATTR_T::PAD_ATTRIB_PTH :
PAD_ATTR_T::PAD_ATTRIB_NPTH ); PAD_ATTR_T::PAD_ATTRIB_NPTH );
@ -1743,7 +1744,7 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
case ALTIUM_PAD_HOLE_SHAPE::SQUARE: case ALTIUM_PAD_HOLE_SHAPE::SQUARE:
wxLogWarning( wxString::Format( wxLogWarning( wxString::Format(
_( "Pad '%s' of Footprint %s has a square hole. KiCad does not support this yet" ), _( "Pad '%s' of Footprint %s has a square hole. KiCad does not support this yet" ),
elem.name, module->GetReference() ) ); elem.name, footprint->GetReference() ) );
pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE ); pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE );
pad->SetDrillSize( wxSize( elem.holesize, elem.holesize ) ); // Workaround pad->SetDrillSize( wxSize( elem.holesize, elem.holesize ) ); // Workaround
// TODO: elem.sizeAndShape->slotsize was 0 in testfile. Either use holesize in this case or rect holes have a different id // TODO: elem.sizeAndShape->slotsize was 0 in testfile. Either use holesize in this case or rect holes have a different id
@ -1764,7 +1765,7 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
{ {
wxLogWarning( wxString::Format( wxLogWarning( wxString::Format(
_( "Pad '%s' of Footprint %s has a hole-rotation of %f degree. KiCad only supports 90 degree angles" ), _( "Pad '%s' of Footprint %s has a hole-rotation of %f degree. KiCad only supports 90 degree angles" ),
elem.name, module->GetReference(), normalizedSlotrotation ) ); elem.name, footprint->GetReference(), normalizedSlotrotation ) );
} }
pad->SetDrillSize( wxSize( elem.holesize, elem.sizeAndShape->slotsize ) ); pad->SetDrillSize( wxSize( elem.holesize, elem.sizeAndShape->slotsize ) );
@ -1776,7 +1777,7 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
case ALTIUM_PAD_HOLE_SHAPE::UNKNOWN: case ALTIUM_PAD_HOLE_SHAPE::UNKNOWN:
wxLogError( wxString::Format( wxLogError( wxString::Format(
"Pad '%s' of Footprint %s uses a hole of unknown kind %d", elem.name, "Pad '%s' of Footprint %s uses a hole of unknown kind %d", elem.name,
module->GetReference(), elem.sizeAndShape->holeshape ) ); footprint->GetReference(), elem.sizeAndShape->holeshape ) );
pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE ); pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE );
pad->SetDrillSize( wxSize( elem.holesize, elem.holesize ) ); // Workaround pad->SetDrillSize( wxSize( elem.holesize, elem.holesize ) ); // Workaround
break; break;
@ -1793,7 +1794,7 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
{ {
wxLogWarning( wxString::Format( wxLogWarning( wxString::Format(
_( "Pad '%s' of Footprint %s uses a complex pad stack (kind %d), which is not supported yet" ), _( "Pad '%s' of Footprint %s uses a complex pad stack (kind %d), which is not supported yet" ),
elem.name, module->GetReference(), elem.padmode ) ); elem.name, footprint->GetReference(), elem.padmode ) );
} }
switch( elem.topshape ) switch( elem.topshape )
@ -1826,7 +1827,7 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
case ALTIUM_PAD_SHAPE::UNKNOWN: case ALTIUM_PAD_SHAPE::UNKNOWN:
default: default:
wxLogError( wxString::Format( "Pad '%s' of Footprint %s uses a unknown pad-shape", wxLogError( wxString::Format( "Pad '%s' of Footprint %s uses a unknown pad-shape",
elem.name, module->GetReference() ) ); elem.name, footprint->GetReference() ) );
break; break;
} }
@ -2248,26 +2249,27 @@ void ALTIUM_PCB::ParseTexts6Data(
{ {
if( m_components.size() <= elem.component ) if( m_components.size() <= elem.component )
{ {
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format( "Texts6 stream tries to access component id %d "
"Texts6 stream tries to access component id %d of %d existing components", "of %d existing components",
elem.component, m_components.size() ) ); elem.component,
m_components.size() ) );
} }
MODULE* module = m_components.at( elem.component ); MODULE* footprint = m_components.at( elem.component );
FP_TEXT* fpText; FP_TEXT* fpText;
if( elem.isDesignator ) if( elem.isDesignator )
{ {
fpText = &module->Reference(); fpText = &footprint->Reference();
} }
else if( elem.isComment ) else if( elem.isComment )
{ {
fpText = &module->Value(); fpText = &footprint->Value();
} }
else else
{ {
fpText = new FP_TEXT( module ); fpText = new FP_TEXT( footprint );
module->Add( fpText, ADD_MODE::APPEND ); footprint->Add( fpText, ADD_MODE::APPEND );
} }
fpText->SetKeepUpright( false ); fpText->SetKeepUpright( false );

View File

@ -562,7 +562,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDesignRules()
BOARD_DESIGN_SETTINGS& ds = mBoard->GetDesignSettings(); BOARD_DESIGN_SETTINGS& ds = mBoard->GetDesignSettings();
std::map<SPACINGCODE_ID, SPACINGCODE>& spacingCodes = Assignments.Codedefs.SpacingCodes; std::map<SPACINGCODE_ID, SPACINGCODE>& spacingCodes = Assignments.Codedefs.SpacingCodes;
auto applyRule = [&]( wxString aID, int* aVal ) { auto applyRule =
[&]( wxString aID, int* aVal )
{
if( spacingCodes.find( aID ) == spacingCodes.end() ) if( spacingCodes.find( aID ) == spacingCodes.end() )
wxLogWarning( _( "Design rule %s was not found. This was ignored." ) ); wxLogWarning( _( "Design rule %s was not found. This was ignored." ) );
else else
@ -588,12 +590,10 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDesignRules()
applyNetClassRule( "T_T", ds.GetDefault(), &::NETCLASS::SetClearance ); applyNetClassRule( "T_T", ds.GetDefault(), &::NETCLASS::SetClearance );
wxLogWarning( wxLogWarning( _( "KiCad design rules are different from CADSTAR ones. Only the compatible "
_( "KiCad design rules are different from CADSTAR ones. Only the compatible "
"design rules were imported. It is recommended that you review the design " "design rules were imported. It is recommended that you review the design "
"rules that have been applied." ) ); "rules that have been applied." ) );
wxLogWarning( wxLogWarning( _( "KiCad design rules are different from CADSTAR ones. Only the compatible "
_( "KiCad design rules are different from CADSTAR ones. Only the compatible "
"design rules were imported. It is recommended that you review the design " "design rules were imported. It is recommended that you review the design "
"rules that have been applied." ) ); "rules that have been applied." ) );
} }
@ -605,23 +605,22 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponentLibrary()
{ {
SYMDEF_ID key = symPair.first; SYMDEF_ID key = symPair.first;
SYMDEF_PCB component = symPair.second; SYMDEF_PCB component = symPair.second;
wxString moduleName = component.ReferenceName wxString fpName = component.ReferenceName + ( ( component.Alternate.size() > 0 ) ?
+ ( ( component.Alternate.size() > 0 ) ?
( wxT( " (" ) + component.Alternate + wxT( ")" ) ) : ( wxT( " (" ) + component.Alternate + wxT( ")" ) ) :
wxT( "" ) ); wxT( "" ) );
MODULE* m = new MODULE( mBoard ); MODULE* footprint = new MODULE( mBoard );
m->SetPosition( getKiCadPoint( component.Origin ) ); footprint->SetPosition( getKiCadPoint( component.Origin ) );
LIB_ID libID; LIB_ID libID;
libID.Parse( moduleName, LIB_ID::LIB_ID_TYPE::ID_PCB, true ); libID.Parse( fpName, LIB_ID::LIB_ID_TYPE::ID_PCB, true );
m->SetFPID( libID ); footprint->SetFPID( libID );
loadLibraryFigures( component, m ); loadLibraryFigures( component, footprint );
loadLibraryCoppers( component, m ); loadLibraryCoppers( component, footprint );
loadLibraryAreas( component, m ); loadLibraryAreas( component, footprint );
loadLibraryPads( component, m ); loadLibraryPads( component, footprint );
mLibraryMap.insert( std::make_pair( key, m ) ); mLibraryMap.insert( std::make_pair( key, footprint ) );
} }
} }
@ -1194,20 +1193,20 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
{ {
COMPONENT& comp = compPair.second; COMPONENT& comp = compPair.second;
auto moduleIter = mLibraryMap.find( comp.SymdefID ); auto fpIter = mLibraryMap.find( comp.SymdefID );
if( moduleIter == mLibraryMap.end() ) if( fpIter == mLibraryMap.end() )
{ {
THROW_IO_ERROR( wxString::Format( _( "Unable to find component '%s' in the library" THROW_IO_ERROR( wxString::Format( _( "Unable to find component '%s' in the library"
"(Symdef ID: '%s')" ), "(Symdef ID: '%s')" ),
comp.Name, comp.SymdefID ) ); comp.Name, comp.SymdefID ) );
} }
// copy constructor to clone the module from the library // copy constructor to clone the footprint from the library
MODULE* m = new MODULE( *moduleIter->second ); MODULE* footprint = new MODULE( *fpIter->second );
const_cast<KIID&>( m->m_Uuid ) = KIID(); const_cast<KIID&>( footprint->m_Uuid ) = KIID();
mBoard->Add( m, ADD_MODE::APPEND ); mBoard->Add( footprint, ADD_MODE::APPEND );
//Override pads with pad exceptions //Override pads with pad exceptions
if( comp.PadExceptions.size() > 0 ) if( comp.PadExceptions.size() > 0 )
@ -1231,37 +1230,37 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
if( padEx.OverrideSide ) if( padEx.OverrideSide )
csPad.Side = padEx.Side; csPad.Side = padEx.Side;
//Find the pad in the module definition // Find the pad in the footprint definition
PAD* kiPad = m->Pads().at( padEx.ID - (long) 1 ); PAD* kiPad = footprint->Pads().at( padEx.ID - (long) 1 );
if( kiPad ) if( kiPad )
delete kiPad; delete kiPad;
m->Pads().at( padEx.ID - (long) 1 ) = getKiCadPad( csPad, m ); footprint->Pads().at( padEx.ID - (long) 1 ) = getKiCadPad( csPad, footprint );
} }
} }
//set to empty string to avoid duplication when loading attributes: //set to empty string to avoid duplication when loading attributes:
m->SetValue( wxEmptyString ); footprint->SetValue( wxEmptyString );
m->SetPosition( getKiCadPoint( comp.Origin ) ); footprint->SetPosition( getKiCadPoint( comp.Origin ) );
m->SetOrientation( getAngleTenthDegree( comp.OrientAngle ) ); footprint->SetOrientation( getAngleTenthDegree( comp.OrientAngle ) );
m->SetReference( comp.Name ); footprint->SetReference( comp.Name );
if( comp.Mirror ) if( comp.Mirror )
{ {
double mirroredAngle = - getAngleTenthDegree( comp.OrientAngle ); double mirroredAngle = - getAngleTenthDegree( comp.OrientAngle );
NORMALIZE_ANGLE_180( mirroredAngle ); NORMALIZE_ANGLE_180( mirroredAngle );
m->SetOrientation( mirroredAngle ); footprint->SetOrientation( mirroredAngle );
m->Flip( getKiCadPoint( comp.Origin ), true ); footprint->Flip( getKiCadPoint( comp.Origin ), true );
} }
loadComponentAttributes( comp, m ); loadComponentAttributes( comp, footprint );
if( !comp.PartID.IsEmpty() && comp.PartID != wxT( "NO_PART" ) ) if( !comp.PartID.IsEmpty() && comp.PartID != wxT( "NO_PART" ) )
m->SetDescription( getPart( comp.PartID ).Definition.Name ); footprint->SetDescription( getPart( comp.PartID ).Definition.Name );
mComponentMap.insert( { comp.ID, m } ); mComponentMap.insert( { comp.ID, footprint } );
} }
} }
@ -1601,8 +1600,8 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNets()
} }
else else
{ {
// The below works because we have added the pads in the correct order to the module and // The below works because we have added the pads in the correct order to the
// it so happens that PAD_ID in Cadstar is a sequential, numerical ID // footprint and the PAD_ID in Cadstar is a sequential, numerical ID
m->Pads().at( pin.PadID - (long) 1 )->SetNet( getKiCadNet( net.ID ) ); m->Pads().at( pin.PadID - (long) 1 )->SetNet( getKiCadNet( net.ID ) );
} }
} }

View File

@ -159,8 +159,10 @@ private:
void drawCadstarText( const TEXT& aCadstarText, BOARD_ITEM_CONTAINER* aContainer, void drawCadstarText( const TEXT& aCadstarText, BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID = wxEmptyString, const GROUP_ID& aCadstarGroupID = wxEmptyString,
const LAYER_ID& aCadstarLayerOverride = wxEmptyString, const LAYER_ID& aCadstarLayerOverride = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 }, const double& aRotationAngle = 0.0, const wxPoint& aMoveVector = { 0, 0 },
const double& aScalingFactor = 1.0, const wxPoint& aTransformCentre = { 0, 0 }, const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false ); const bool& aMirrorInvert = false );
/** /**
@ -178,10 +180,13 @@ private:
* @param aMirrorInvert if true, mirrors the shape * @param aMirrorInvert if true, mirrors the shape
*/ */
void drawCadstarShape( const SHAPE& aCadstarShape, const PCB_LAYER_ID& aKiCadLayer, void drawCadstarShape( const SHAPE& aCadstarShape, const PCB_LAYER_ID& aKiCadLayer,
const int& aLineThickness, const wxString& aShapeName, BOARD_ITEM_CONTAINER* aContainer, const int& aLineThickness, const wxString& aShapeName,
const GROUP_ID& aCadstarGroupID = wxEmptyString, const wxPoint& aMoveVector = { 0, 0 }, BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0, const double& aScalingFactor = 1.0, const double& aRotationAngle = 0.0, const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 }, const bool& aMirrorInvert = false ); const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
/** /**
* @brief Uses PCB_SHAPE to draw the cutouts on mBoard object * @brief Uses PCB_SHAPE to draw the cutouts on mBoard object
@ -198,9 +203,12 @@ private:
*/ */
void drawCadstarCutoutsAsSegments( const std::vector<CUTOUT>& aCutouts, void drawCadstarCutoutsAsSegments( const std::vector<CUTOUT>& aCutouts,
const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness, const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer, const GROUP_ID& aCadstarGroupID = wxEmptyString, BOARD_ITEM_CONTAINER* aContainer,
const wxPoint& aMoveVector = { 0, 0 }, const double& aRotationAngle = 0.0, const GROUP_ID& aCadstarGroupID = wxEmptyString,
const double& aScalingFactor = 1.0, const wxPoint& aTransformCentre = { 0, 0 }, const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false ); const bool& aMirrorInvert = false );
/** /**
@ -219,9 +227,12 @@ private:
*/ */
void drawCadstarVerticesAsSegments( const std::vector<VERTEX>& aCadstarVertices, void drawCadstarVerticesAsSegments( const std::vector<VERTEX>& aCadstarVertices,
const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness, const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer, const GROUP_ID& aCadstarGroupID = wxEmptyString, BOARD_ITEM_CONTAINER* aContainer,
const wxPoint& aMoveVector = { 0, 0 }, const double& aRotationAngle = 0.0, const GROUP_ID& aCadstarGroupID = wxEmptyString,
const double& aScalingFactor = 1.0, const wxPoint& aTransformCentre = { 0, 0 }, const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false ); const bool& aMirrorInvert = false );
/** /**
@ -236,11 +247,14 @@ private:
* @param aMirrorInvert if true, mirrors the drawsegment * @param aMirrorInvert if true, mirrors the drawsegment
* @return * @return
*/ */
std::vector<PCB_SHAPE*> getDrawSegmentsFromVertices( std::vector<PCB_SHAPE*> getDrawSegmentsFromVertices( const std::vector<VERTEX>& aCadstarVertices,
const std::vector<VERTEX>& aCadstarVertices, BOARD_ITEM_CONTAINER* aContainer = nullptr, BOARD_ITEM_CONTAINER* aContainer = nullptr,
const GROUP_ID& aCadstarGroupID = wxEmptyString, const wxPoint& aMoveVector = { 0, 0 }, const GROUP_ID& aCadstarGroupID = wxEmptyString,
const double& aRotationAngle = 0.0, const double& aScalingFactor = 1.0, const wxPoint& aMoveVector = { 0, 0 },
const wxPoint& aTransformCentre = { 0, 0 }, const bool& aMirrorInvert = false ); const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
/** /**
* @brief Returns a pointer to a PCB_SHAPE object. Caller owns the object. * @brief Returns a pointer to a PCB_SHAPE object. Caller owns the object.
@ -256,10 +270,14 @@ private:
* @return * @return
*/ */
PCB_SHAPE* getDrawSegmentFromVertex( const POINT& aCadstarStartPoint, PCB_SHAPE* getDrawSegmentFromVertex( const POINT& aCadstarStartPoint,
const VERTEX& aCadstarVertex, BOARD_ITEM_CONTAINER* aContainer = nullptr, const VERTEX& aCadstarVertex,
const GROUP_ID& aCadstarGroupID = wxEmptyString, const wxPoint& aMoveVector = { 0, 0 }, BOARD_ITEM_CONTAINER* aContainer = nullptr,
const double& aRotationAngle = 0.0, const double& aScalingFactor = 1.0, const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aTransformCentre = { 0, 0 }, const bool& aMirrorInvert = false ); const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
/** /**
* @brief * @brief
@ -284,9 +302,12 @@ private:
* @return * @return
*/ */
SHAPE_POLY_SET getPolySetFromCadstarShape( const SHAPE& aCadstarShape, SHAPE_POLY_SET getPolySetFromCadstarShape( const SHAPE& aCadstarShape,
const int& aLineThickness = -1, BOARD_ITEM_CONTAINER* aContainer = nullptr, const int& aLineThickness = -1,
const wxPoint& aMoveVector = { 0, 0 }, const double& aRotationAngle = 0.0, BOARD_ITEM_CONTAINER* aContainer = nullptr,
const double& aScalingFactor = 1.0, const wxPoint& aTransformCentre = { 0, 0 }, const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false ); const bool& aMirrorInvert = false );
/** /**
@ -308,11 +329,13 @@ private:
* @return * @return
*/ */
std::vector<TRACK*> makeTracksFromDrawsegments( const std::vector<PCB_SHAPE*> aDrawsegments, std::vector<TRACK*> makeTracksFromDrawsegments( const std::vector<PCB_SHAPE*> aDrawsegments,
BOARD_ITEM_CONTAINER* aParentContainer, NETINFO_ITEM* aNet = nullptr, BOARD_ITEM_CONTAINER* aParentContainer,
PCB_LAYER_ID aLayerOverride = PCB_LAYER_ID::UNDEFINED_LAYER, int aWidthOverride = -1 ); NETINFO_ITEM* aNet = nullptr,
PCB_LAYER_ID aLayerOverride = UNDEFINED_LAYER,
int aWidthOverride = -1 );
/** /**
* @brief Adds a CADSTAR Attribute to a KiCad module * @brief Adds a CADSTAR Attribute to a KiCad footprint
* @param aCadstarAttrLoc * @param aCadstarAttrLoc
* @param aCadstarAttributeID * @param aCadstarAttributeID
* @param aFootprint * @param aFootprint

View File

@ -838,12 +838,12 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
// Fabricate a MODULE with a single PAD_ATTRIB_NPTH pad. // Fabricate a MODULE with a single PAD_ATTRIB_NPTH pad.
// Use m_hole_count to gen up a unique name. // Use m_hole_count to gen up a unique name.
MODULE* module = new MODULE( m_board ); MODULE* footprint = new MODULE( m_board );
m_board->Add( module, ADD_MODE::APPEND ); m_board->Add( footprint, ADD_MODE::APPEND );
module->SetReference( wxString::Format( "@HOLE%d", m_hole_count++ ) ); footprint->SetReference( wxString::Format( "@HOLE%d", m_hole_count++ ) );
module->Reference().SetVisible( false ); footprint->Reference().SetVisible( false );
packageHole( module, gr, true ); packageHole( footprint, gr, true );
m_xpath->pop(); m_xpath->pop();
} }
@ -2138,7 +2138,7 @@ void EAGLE_PLUGIN::packageHole( MODULE* aFootprint, wxXmlNode* aTree, bool aCent
{ {
EHOLE e( aTree ); EHOLE e( aTree );
// we add a PAD_ATTRIB_NPTH pad to this module. // we add a PAD_ATTRIB_NPTH pad to this footprint.
PAD* pad = new PAD( aFootprint ); PAD* pad = new PAD( aFootprint );
aFootprint->Add( pad ); aFootprint->Add( pad );
@ -2249,8 +2249,8 @@ void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, PAD* aPad ) const
{ {
aPad->SetName( FROM_UTF8( aEaglePad.name.c_str() ) ); aPad->SetName( FROM_UTF8( aEaglePad.name.c_str() ) );
// pad's "Position" is not relative to the module's, // pad's "Position" is not relative to the footprint's,
// whereas Pos0 is relative to the module's but is the unrotated coordinate. // whereas Pos0 is relative to the footprint's but is the unrotated coordinate.
wxPoint padPos( kicad_x( aEaglePad.x ), kicad_y( aEaglePad.y ) ); wxPoint padPos( kicad_x( aEaglePad.x ), kicad_y( aEaglePad.y ) );
aPad->SetPos0( padPos ); aPad->SetPos0( padPos );
@ -2265,10 +2265,10 @@ void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, PAD* aPad ) const
if( aEaglePad.thermals && !*aEaglePad.thermals ) if( aEaglePad.thermals && !*aEaglePad.thermals )
aPad->SetZoneConnection( ZONE_CONNECTION::FULL ); aPad->SetZoneConnection( ZONE_CONNECTION::FULL );
MODULE* module = aPad->GetParent(); MODULE* footprint = aPad->GetParent();
wxCHECK( module, /* void */ ); wxCHECK( footprint, /* void */ );
RotatePoint( &padPos, module->GetOrientation() ); RotatePoint( &padPos, footprint->GetOrientation() );
aPad->SetPosition( padPos + module->GetPosition() ); aPad->SetPosition( padPos + footprint->GetPosition() );
} }

View File

@ -192,7 +192,7 @@ private:
XPATH* m_xpath; ///< keeps track of what we are working on within XPATH* m_xpath; ///< keeps track of what we are working on within
///< XML document during a Load(). ///< XML document during a Load().
int m_hole_count; ///< generates unique module names from eagle "hole"s. int m_hole_count; ///< generates unique footprint names from eagle "hole"s.
NET_MAP m_pads_to_nets; ///< net list NET_MAP m_pads_to_nets; ///< net list
@ -300,10 +300,10 @@ private:
/** /**
* Function packageHole * Function packageHole
* @parameter aFootprint - The KiCad module to which to assign the hole * @parameter aFootprint - The KiCad footprint to which to assign the hole
* @parameter aTree - The Eagle XML node that is of type "hole" * @parameter aTree - The Eagle XML node that is of type "hole"
* @parameter aCenter - If true, center the hole in the module and * @parameter aCenter - If true, center the hole in the footprint and
* offset the module position * offset the footprint position
*/ */
void packageHole( MODULE* aFootprint, wxXmlNode* aTree, bool aCenter ) const; void packageHole( MODULE* aFootprint, wxXmlNode* aTree, bool aCenter ) const;
void packageSMD( MODULE* aFootprint, wxXmlNode* aTree ) const; void packageSMD( MODULE* aFootprint, wxXmlNode* aTree ) const;

View File

@ -100,27 +100,27 @@ static inline long parseInt( const wxString& aValue, double aScalar )
* GPCB_FPL_CACHE_ITEM * GPCB_FPL_CACHE_ITEM
* is helper class for creating a footprint library cache. * is helper class for creating a footprint library cache.
* *
* The new footprint library design is a file path of individual module files * The new footprint library design is a file path of individual footprint files
* that contain a single module per file. This class is a helper only for the * that contain a single footprint per file. This class is a helper only for the
* footprint portion of the PLUGIN API, and only for the #PCB_IO plugin. It is * footprint portion of the PLUGIN API, and only for the #PCB_IO plugin. It is
* private to this implementation file so it is not placed into a header. * private to this implementation file so it is not placed into a header.
*/ */
class GPCB_FPL_CACHE_ITEM class GPCB_FPL_CACHE_ITEM
{ {
WX_FILENAME m_filename; ///< The the full file name and path of the footprint to cache. WX_FILENAME m_filename; ///< The the full file name and path of the footprint to cache.
std::unique_ptr<MODULE> m_module; std::unique_ptr<MODULE> m_footprint;
public: public:
GPCB_FPL_CACHE_ITEM( MODULE* aFootprint, const WX_FILENAME& aFileName ); GPCB_FPL_CACHE_ITEM( MODULE* aFootprint, const WX_FILENAME& aFileName );
WX_FILENAME GetFileName() const { return m_filename; } WX_FILENAME GetFileName() const { return m_filename; }
MODULE* GetModule() const { return m_module.get(); } MODULE* GetFootprint() const { return m_footprint.get(); }
}; };
GPCB_FPL_CACHE_ITEM::GPCB_FPL_CACHE_ITEM( MODULE* aFootprint, const WX_FILENAME& aFileName ) : GPCB_FPL_CACHE_ITEM::GPCB_FPL_CACHE_ITEM( MODULE* aFootprint, const WX_FILENAME& aFileName ) :
m_filename( aFileName ), m_filename( aFileName ),
m_module( aFootprint ) m_footprint( aFootprint )
{ {
} }
@ -132,14 +132,14 @@ typedef MODULE_MAP::const_iterator MODULE_CITER;
class GPCB_FPL_CACHE class GPCB_FPL_CACHE
{ {
GPCB_PLUGIN* m_owner; /// Plugin object that owns the cache. GPCB_PLUGIN* m_owner; ///< Plugin object that owns the cache.
wxFileName m_lib_path; /// The path of the library. wxFileName m_lib_path; ///< The path of the library.
MODULE_MAP m_modules; /// Map of footprint file name per MODULE*. MODULE_MAP m_footprints; ///< Map of footprint file name to MODULE*.
bool m_cache_dirty; // Stored separately because it's expensive to check bool m_cache_dirty; ///< Stored separately because it's expensive to check
// m_cache_timestamp against all the files. ///< m_cache_timestamp against all the files.
long long m_cache_timestamp; // A hash of the timestamps for all the footprint long long m_cache_timestamp; ///< A hash of the timestamps for all the footprint
// files. ///< files.
MODULE* parseMODULE( LINE_READER* aLineReader ); MODULE* parseMODULE( LINE_READER* aLineReader );
@ -178,7 +178,7 @@ public:
wxString GetPath() const { return m_lib_path.GetPath(); } wxString GetPath() const { return m_lib_path.GetPath(); }
bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); } bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
MODULE_MAP& GetModules() { return m_modules; } MODULE_MAP& GetModules() { return m_footprints; }
// Most all functions in this class throw IO_ERROR exceptions. There are no // Most all functions in this class throw IO_ERROR exceptions. There are no
// error codes nor user interface calls from here, nor in any PLUGIN. // error codes nor user interface calls from here, nor in any PLUGIN.
@ -258,7 +258,7 @@ void GPCB_FPL_CACHE::Load()
// The footprint name is the file name without the extension. // The footprint name is the file name without the extension.
footprint->SetFPID( LIB_ID( wxEmptyString, fn.GetName() ) ); footprint->SetFPID( LIB_ID( wxEmptyString, fn.GetName() ) );
m_modules.insert( name, new GPCB_FPL_CACHE_ITEM( footprint, fn ) ); m_footprints.insert( name, new GPCB_FPL_CACHE_ITEM( footprint, fn ) );
} }
catch( const IO_ERROR& ioe ) catch( const IO_ERROR& ioe )
{ {
@ -278,18 +278,18 @@ void GPCB_FPL_CACHE::Remove( const wxString& aFootprintName )
{ {
std::string footprintName = TO_UTF8( aFootprintName ); std::string footprintName = TO_UTF8( aFootprintName );
MODULE_CITER it = m_modules.find( footprintName ); MODULE_CITER it = m_footprints.find( footprintName );
if( it == m_modules.end() ) if( it == m_footprints.end() )
{ {
THROW_IO_ERROR( wxString::Format( _( "library \"%s\" has no footprint \"%s\" to delete" ), THROW_IO_ERROR( wxString::Format( _( "library \"%s\" has no footprint \"%s\" to delete" ),
m_lib_path.GetPath().GetData(), m_lib_path.GetPath().GetData(),
aFootprintName.GetData() ) ); aFootprintName.GetData() ) );
} }
// Remove the module from the cache and delete the module file from the library. // Remove the footprint from the cache and delete the footprint file from the library.
wxString fullPath = it->second->GetFileName().GetFullPath(); wxString fullPath = it->second->GetFileName().GetFullPath();
m_modules.erase( footprintName ); m_footprints.erase( footprintName );
wxRemoveFile( fullPath ); wxRemoveFile( fullPath );
} }
@ -323,7 +323,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
wxPoint textPos; wxPoint textPos;
wxString msg; wxString msg;
wxArrayString parameters; wxArrayString parameters;
std::unique_ptr<MODULE> module = std::make_unique<MODULE>( nullptr ); std::unique_ptr<MODULE> footprint = std::make_unique<MODULE>( nullptr );
if( aLineReader->ReadLine() == NULL ) if( aLineReader->ReadLine() == NULL )
@ -364,22 +364,22 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
if( paramCnt > 10 ) if( paramCnt > 10 )
{ {
module->SetDescription( parameters[3] ); footprint->SetDescription( parameters[3] );
module->SetReference( parameters[4] ); footprint->SetReference( parameters[4] );
} }
else else
{ {
module->SetDescription( parameters[2] ); footprint->SetDescription( parameters[2] );
module->SetReference( parameters[3] ); footprint->SetReference( parameters[3] );
} }
// Read value // Read value
if( paramCnt > 10 ) if( paramCnt > 10 )
module->SetValue( parameters[5] ); footprint->SetValue( parameters[5] );
// With gEDA/pcb, value is meaningful after instantiation, only, so it's // With gEDA/pcb, value is meaningful after instantiation, only, so it's
// often empty in bare footprints. // often empty in bare footprints.
if( module->Value().GetText().IsEmpty() ) if( footprint->Value().GetText().IsEmpty() )
module->Value().SetText( wxT( "Val**" ) ); footprint->Value().SetText( wxT( "Val**" ) );
if( paramCnt == 14 ) if( paramCnt == 14 )
@ -394,7 +394,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
} }
int orientation = parseInt( parameters[paramCnt-4], 1.0 ); int orientation = parseInt( parameters[paramCnt-4], 1.0 );
module->Reference().SetTextAngle( (orientation % 2) ? 900 : 0 ); footprint->Reference().SetTextAngle(( orientation % 2) ? 900 : 0 );
// Calculate size: default height is 40 mils, width 30 mil. // Calculate size: default height is 40 mils, width 30 mil.
// real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size // real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size
@ -406,7 +406,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
// gEDA/pcb aligns top/left, not pcbnew's default, center/center. // gEDA/pcb aligns top/left, not pcbnew's default, center/center.
// Compensate for this by shifting the insertion point instead of the // Compensate for this by shifting the insertion point instead of the
// alignment, because alignment isn't changeable in the GUI. // alignment, because alignment isn't changeable in the GUI.
textPos.x = textPos.x + twsize * module->GetReference().Len() / 2; textPos.x = textPos.x + twsize * footprint->GetReference().Len() / 2;
textPos.y += thsize / 2; textPos.y += thsize / 2;
// gEDA/pcb draws a bit too low/left, while pcbnew draws a bit too // gEDA/pcb draws a bit too low/left, while pcbnew draws a bit too
@ -414,20 +414,20 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
textPos.x -= thsize / 10; textPos.x -= thsize / 10;
textPos.y += thsize / 2; textPos.y += thsize / 2;
module->Reference().SetTextPos( textPos ); footprint->Reference().SetTextPos( textPos );
module->Reference().SetPos0( textPos ); footprint->Reference().SetPos0( textPos );
module->Reference().SetTextSize( wxSize( twsize, thsize ) ); footprint->Reference().SetTextSize( wxSize( twsize, thsize ) );
module->Reference().SetTextThickness( thickness ); footprint->Reference().SetTextThickness( thickness );
// gEDA/pcb shows only one of value/reference/description at a time. Which // gEDA/pcb shows only one of value/reference/description at a time. Which
// one is selectable by a global menu setting. pcbnew needs reference as // one is selectable by a global menu setting. pcbnew needs reference as
// well as value visible, so place the value right below the reference. // well as value visible, so place the value right below the reference.
module->Value().SetTextAngle( module->Reference().GetTextAngle() ); footprint->Value().SetTextAngle( footprint->Reference().GetTextAngle() );
module->Value().SetTextSize( module->Reference().GetTextSize() ); footprint->Value().SetTextSize( footprint->Reference().GetTextSize() );
module->Value().SetTextThickness( module->Reference().GetTextThickness()); footprint->Value().SetTextThickness( footprint->Reference().GetTextThickness());
textPos.y += thsize * 13 / 10; // 130% line height textPos.y += thsize * 13 / 10; // 130% line height
module->Value().SetTextPos( textPos ); footprint->Value().SetTextPos( textPos );
module->Value().SetPos0( textPos ); footprint->Value().SetPos0( textPos );
while( aLineReader->ReadLine() ) while( aLineReader->ReadLine() )
{ {
@ -464,7 +464,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
aLineReader->LineNumber(), 0 ); aLineReader->LineNumber(), 0 );
} }
FP_SHAPE* shape = new FP_SHAPE( module.get() ); FP_SHAPE* shape = new FP_SHAPE( footprint.get() );
shape->SetLayer( F_SilkS ); shape->SetLayer( F_SilkS );
shape->SetShape( S_SEGMENT ); shape->SetShape( S_SEGMENT );
shape->SetStart0( wxPoint( parseInt( parameters[2], conv_unit ), shape->SetStart0( wxPoint( parseInt( parameters[2], conv_unit ),
@ -473,7 +473,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
parseInt( parameters[5], conv_unit ) ) ); parseInt( parameters[5], conv_unit ) ) );
shape->SetWidth( parseInt( parameters[6], conv_unit ) ); shape->SetWidth( parseInt( parameters[6], conv_unit ) );
shape->SetDrawCoord(); shape->SetDrawCoord();
module->Add( shape ); footprint->Add( shape );
continue; continue;
} }
@ -488,10 +488,10 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
} }
// Pcbnew does know ellipse so we must have Width = Height // Pcbnew does know ellipse so we must have Width = Height
FP_SHAPE* shape = new FP_SHAPE( module.get() ); FP_SHAPE* shape = new FP_SHAPE( footprint.get() );
shape->SetLayer( F_SilkS ); shape->SetLayer( F_SilkS );
shape->SetShape( S_ARC ); shape->SetShape( S_ARC );
module->Add( shape ); footprint->Add( shape );
// for and arc: ibuf[3] = ibuf[4]. Pcbnew does not know ellipses // for and arc: ibuf[3] = ibuf[4]. Pcbnew does not know ellipses
int radius = ( parseInt( parameters[4], conv_unit ) + int radius = ( parseInt( parameters[4], conv_unit ) +
@ -539,7 +539,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
aLineReader->LineNumber(), 0 ); aLineReader->LineNumber(), 0 );
} }
PAD* pad = new PAD( module.get() ); PAD* pad = new PAD( footprint.get() );
static const LSET pad_front( 3, F_Cu, F_Mask, F_Paste ); static const LSET pad_front( 3, F_Cu, F_Mask, F_Paste );
static const LSET pad_back( 3, B_Cu, B_Mask, B_Paste ); static const LSET pad_back( 3, B_Cu, B_Mask, B_Paste );
@ -597,7 +597,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
// Set the relative position before adjusting the absolute position // Set the relative position before adjusting the absolute position
pad->SetPos0( padPos ); pad->SetPos0( padPos );
padPos += module->GetPosition(); padPos += footprint->GetPosition();
pad->SetPosition( padPos ); pad->SetPosition( padPos );
if( !testFlags( parameters[paramCnt-2], 0x0100, wxT( "square" ) ) ) if( !testFlags( parameters[paramCnt-2], 0x0100, wxT( "square" ) ) )
@ -608,7 +608,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
pad->SetShape( PAD_SHAPE_OVAL ); pad->SetShape( PAD_SHAPE_OVAL );
} }
module->Add( pad ); footprint->Add( pad );
continue; continue;
} }
@ -627,7 +627,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
aLineReader->LineNumber(), 0 ); aLineReader->LineNumber(), 0 );
} }
PAD* pad = new PAD( module.get() ); PAD* pad = new PAD( footprint.get() );
pad->SetShape( PAD_SHAPE_CIRCLE ); pad->SetShape( PAD_SHAPE_CIRCLE );
@ -680,20 +680,20 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
// Set the relative position before adjusting the absolute position // Set the relative position before adjusting the absolute position
pad->SetPos0( padPos ); pad->SetPos0( padPos );
padPos += module->GetPosition(); padPos += footprint->GetPosition();
pad->SetPosition( padPos ); pad->SetPosition( padPos );
if( pad->GetShape() == PAD_SHAPE_CIRCLE && pad->GetSize().x != pad->GetSize().y ) if( pad->GetShape() == PAD_SHAPE_CIRCLE && pad->GetSize().x != pad->GetSize().y )
pad->SetShape( PAD_SHAPE_OVAL ); pad->SetShape( PAD_SHAPE_OVAL );
module->Add( pad ); footprint->Add( pad );
continue; continue;
} }
} }
// Recalculate the bounding box // Recalculate the bounding box
module->CalculateBoundingBox(); footprint->CalculateBoundingBox();
return module.release(); return footprint.release();
} }
@ -925,7 +925,7 @@ const MODULE* GPCB_PLUGIN::getFootprint( const wxString& aLibraryPath,
return NULL; return NULL;
} }
return it->second->GetModule(); return it->second->GetFootprint();
} }