Cvpcb: EQU file association associates to all components
Fixes: lp:1697150 https://bugs.launchpad.net/kicad/+bug/1697150
This commit is contained in:
parent
eadfff8ac4
commit
ee5565ae33
|
@ -169,9 +169,7 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx
|
|||
void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
||||
{
|
||||
FOOTPRINT_EQUIVALENCE_LIST equiv_List;
|
||||
COMPONENT* component;
|
||||
wxString msg, error_msg;
|
||||
size_t ii;
|
||||
|
||||
if( m_netlist.IsEmpty() )
|
||||
return;
|
||||
|
@ -191,15 +189,13 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
|||
// Now, associate each free component with a footprint, when the association
|
||||
// is found in list
|
||||
m_skipComponentSelect = true;
|
||||
ii = 0;
|
||||
error_msg.Empty();
|
||||
|
||||
for( unsigned kk = 0; kk < m_netlist.GetCount(); kk++ )
|
||||
{
|
||||
component = m_netlist.GetComponent( kk );
|
||||
COMPONENT* component = m_netlist.GetComponent( kk );
|
||||
|
||||
bool found = false;
|
||||
m_compListBox->SetSelection( ii++, true );
|
||||
|
||||
if( !component->GetFPID().empty() ) // the component has already a footprint
|
||||
continue;
|
||||
|
@ -232,7 +228,7 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
|||
// If the equivalence is unique, no ambiguity: use the association
|
||||
if( module && equ_is_unique )
|
||||
{
|
||||
SetNewPkg( equivItem.m_FootprintFPID );
|
||||
SetNewPkg( equivItem.m_FootprintFPID, kk );
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -264,7 +260,7 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
|||
|
||||
if( found )
|
||||
{
|
||||
SetNewPkg( equivItem.m_FootprintFPID );
|
||||
SetNewPkg( equivItem.m_FootprintFPID, kk );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +276,9 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
|||
const FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( component->GetFootprintFilters()[0] );
|
||||
|
||||
if( module )
|
||||
SetNewPkg( component->GetFootprintFilters()[0] );
|
||||
{
|
||||
SetNewPkg( component->GetFootprintFilters()[0], kk );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,4 +286,5 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
|||
wxMessageBox( error_msg, _( "CvPcb Warning" ), wxOK | wxICON_WARNING, this );
|
||||
|
||||
m_skipComponentSelect = false;
|
||||
m_compListBox->Refresh();
|
||||
}
|
||||
|
|
|
@ -168,12 +168,21 @@ public:
|
|||
|
||||
/**
|
||||
* Function SetNewPkg
|
||||
* links the footprint to the current selected component
|
||||
* set the footprint name for all selected components in component list
|
||||
* and selects the next component.
|
||||
* @param aFootprintName = the selected footprint
|
||||
* @param aFootprintName = the new footprint name
|
||||
*/
|
||||
void SetNewPkg( const wxString& aFootprintName );
|
||||
|
||||
/**
|
||||
* Function SetNewPkg
|
||||
* Set the footprint name for the component of position aIndex in the component list
|
||||
*
|
||||
* @param aFootprintName = the new footprint name
|
||||
* @param aIndex = the index of the component to modify in the component list
|
||||
*/
|
||||
void SetNewPkg( const wxString& aFootprintName, int aIndex );
|
||||
|
||||
void BuildCmpListBox();
|
||||
void BuildFOOTPRINTS_LISTBOX();
|
||||
void BuildLIBRARY_LISTBOX();
|
||||
|
|
|
@ -90,9 +90,10 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
|
|||
|
||||
preferencesMenu->AppendSeparator();
|
||||
AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT,
|
||||
_( "&Edit Footprint Association File" ),
|
||||
_( "Modify footprint association file (.equ). This is the file which "
|
||||
"assigns the footprint name by the component value" ),
|
||||
_( "&Footprint &Association Files" ),
|
||||
_( "Configure footprint association file (.equ) list."
|
||||
"These files are used to automatically assign"
|
||||
"the footprint name from the component value" ),
|
||||
KiBitmap( library_table_xpm ) );
|
||||
preferencesMenu->AppendSeparator();
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
|
||||
{
|
||||
COMPONENT* component;
|
||||
bool hasFootprint = false;
|
||||
int componentIndex;
|
||||
|
||||
if( m_netlist.IsEmpty() )
|
||||
|
@ -70,40 +69,11 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
|
|||
if( component == NULL )
|
||||
return;
|
||||
|
||||
// Check to see if the component has already a footprint set.
|
||||
hasFootprint = !component->GetFPID().empty();
|
||||
SetNewPkg( aFootprintName, componentIndex );
|
||||
|
||||
LIB_ID fpid;
|
||||
|
||||
if( !aFootprintName.IsEmpty() )
|
||||
{
|
||||
wxCHECK_RET( fpid.Parse( TO_UTF8( aFootprintName ) ) < 0,
|
||||
wxString::Format( wxT( "<%s> is not a valid LIB_ID." ),
|
||||
GetChars( aFootprintName ) ) );
|
||||
}
|
||||
|
||||
component->SetFPID( fpid );
|
||||
|
||||
// create the new component description
|
||||
wxString description = wxString::Format( CMP_FORMAT, componentIndex + 1,
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetValue() ),
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
|
||||
// If the component hasn't had a footprint associated with it
|
||||
// it now has, so we decrement the count of components without
|
||||
// a footprint assigned.
|
||||
if( !hasFootprint )
|
||||
m_undefinedComponentCnt -= 1;
|
||||
|
||||
// Set the new description and deselect the processed component
|
||||
m_compListBox->SetString( componentIndex, description );
|
||||
m_compListBox->SetSelection( componentIndex, false );
|
||||
}
|
||||
|
||||
// Mark this "session" as modified
|
||||
m_modified = true;
|
||||
|
||||
// select the next component, if there is one
|
||||
if( componentIndex < (m_compListBox->GetCount() - 1) )
|
||||
componentIndex++;
|
||||
|
@ -115,6 +85,55 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName, int aIndex )
|
||||
{
|
||||
COMPONENT* component;
|
||||
|
||||
if( m_netlist.IsEmpty() )
|
||||
return;
|
||||
|
||||
component = m_netlist.GetComponent( aIndex );
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
|
||||
// Check to see if the component has already a footprint set.
|
||||
bool hasFootprint = !component->GetFPID().empty();
|
||||
|
||||
LIB_ID fpid;
|
||||
|
||||
if( !aFootprintName.IsEmpty() )
|
||||
{
|
||||
wxCHECK_RET( fpid.Parse( TO_UTF8( aFootprintName ) ) < 0,
|
||||
wxString::Format( wxT( "<%s> is not a valid LIB_ID." ),
|
||||
GetChars( aFootprintName ) ) );
|
||||
}
|
||||
|
||||
component->SetFPID( fpid );
|
||||
|
||||
// create the new component description
|
||||
wxString description = wxString::Format( CMP_FORMAT, aIndex + 1,
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetValue() ),
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
|
||||
// If the component hasn't had a footprint associated with it
|
||||
// it now has, so we decrement the count of components without
|
||||
// a footprint assigned.
|
||||
if( !hasFootprint )
|
||||
m_undefinedComponentCnt -= 1;
|
||||
|
||||
// Set the new description and deselect the processed component
|
||||
m_compListBox->SetString( aIndex, description );
|
||||
|
||||
// Mark this "session" as modified
|
||||
m_modified = true;
|
||||
|
||||
// update the statusbar
|
||||
DisplayStatus();
|
||||
}
|
||||
|
||||
|
||||
/// Return true if the resultant LIB_ID has a certain nickname. The guess
|
||||
/// is only made if this footprint resides in only one library.
|
||||
/// @return int - 0 on success, 1 on not found, 2 on ambiguous i.e. multiple matches
|
||||
|
|
Loading…
Reference in New Issue