本文整理汇总了C++中COMPONENT::GetFPID方法的典型用法代码示例。如果您正苦于以下问题:C++ COMPONENT::GetFPID方法的具体用法?C++ COMPONENT::GetFPID怎么用?C++ COMPONENT::GetFPID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COMPONENT
的用法示例。
在下文中一共展示了COMPONENT::GetFPID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetNewPkg
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;
LIB_ID fpid;
if( !aFootprintName.IsEmpty() )
{
wxCHECK_RET( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) < 0,
wxString::Format( _( "\"%s\" is not a valid LIB_ID." ), 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() ) ) );
// 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();
}
示例2: BuildCmpListBox
void CVPCB_MAINFRAME::BuildCmpListBox()
{
wxString msg;
COMPONENT* component;
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
if( m_compListBox == NULL )
{
m_compListBox = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST,
wxDefaultPosition, wxDefaultSize );
m_compListBox->SetFont( wxFont( guiFont.GetPointSize(),
wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL ) );
}
m_compListBox->m_ComponentList.Clear();
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
component = m_netlist.GetComponent( i );
msg.Printf( CMP_FORMAT, m_compListBox->GetCount() + 1,
GetChars( component->GetReference() ),
GetChars( component->GetValue() ),
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
m_compListBox->m_ComponentList.Add( msg );
}
if( m_compListBox->m_ComponentList.Count() )
{
m_compListBox->SetItemCount( m_compListBox->m_ComponentList.Count() );
m_compListBox->SetSelection( 0, true );
m_compListBox->RefreshItems( 0L, m_compListBox->m_ComponentList.Count()-1 );
m_compListBox->UpdateWidth();
}
}
示例3: OnSelectComponent
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
{
if( m_skipComponentSelect )
return;
wxString libraryName;
COMPONENT* component = NULL;
int filter = FOOTPRINTS_LISTBOX::UNFILTERED;
if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) )
filter |= FOOTPRINTS_LISTBOX::BY_COMPONENT;
if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) )
filter |= FOOTPRINTS_LISTBOX::BY_PIN_COUNT;
if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) )
filter |= FOOTPRINTS_LISTBOX::BY_LIBRARY;
component = GetSelectedComponent();
libraryName = m_libListBox->GetSelectedLibrary();
m_footprintListBox->SetFootprints( m_footprints, libraryName, component, filter );
// Tell AuiMgr that objects are changed !
if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
// (could be not the case when starting CvPcb
m_auimgr.Update();
if( component == NULL )
return;
// Preview of the already assigned footprint.
// Find the footprint that was already chosen for this component and select it,
// but only if the selection is made from the component list or the library list.
// If the selection is made from the footprint list, do not change the current
// selected footprint.
if( FindFocus() == m_compListBox || FindFocus() == m_libListBox )
{
wxString module = FROM_UTF8( component->GetFPID().Format().c_str() );
bool found = false;
for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
{
wxString footprintName;
wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
msg.Trim( true );
msg.Trim( false );
footprintName = msg.AfterFirst( wxChar( ' ' ) );
if( module.Cmp( footprintName ) == 0 )
{
m_footprintListBox->SetSelection( ii, true );
found = true;
break;
}
}
if( !found )
{
int ii = m_footprintListBox->GetSelection();
if ( ii >= 0 )
m_footprintListBox->SetSelection( ii, false );
if( GetFpViewerFrame() )
{
CreateScreenCmp();
}
}
}
SendMessageToEESCHEMA();
DisplayStatus();
}
示例4: Load
bool CMP_READER::Load( NETLIST* aNetlist ) throw( IO_ERROR, PARSE_ERROR )
{
wxCHECK_MSG( aNetlist != NULL,true, wxT( "No netlist passed to CMP_READER::Load()" ) );
wxString reference; // Stores value read from line like Reference = BUS1;
wxString timestamp; // Stores value read from line like TimeStamp = /32307DE2/AA450F67;
wxString footprint; // Stores value read from line like IdModule = CP6;
wxString buffer;
wxString value;
bool ok = true;
while( m_lineReader->ReadLine() )
{
buffer = FROM_UTF8( m_lineReader->Line() );
if( !buffer.StartsWith( wxT( "BeginCmp" ) ) )
continue;
// Begin component description.
reference.Empty();
footprint.Empty();
timestamp.Empty();
while( m_lineReader->ReadLine() )
{
buffer = FROM_UTF8( m_lineReader->Line() );
if( buffer.StartsWith( wxT( "EndCmp" ) ) )
break;
// store string value, stored between '=' and ';' delimiters.
value = buffer.AfterFirst( '=' );
value = value.BeforeLast( ';' );
value.Trim( true );
value.Trim( false );
if( buffer.StartsWith( wxT( "Reference" ) ) )
{
reference = value;
continue;
}
if( buffer.StartsWith( wxT( "IdModule =" ) ) )
{
footprint = value;
continue;
}
if( buffer.StartsWith( wxT( "TimeStamp =" ) ) )
{
timestamp = value;
continue;
}
}
// Find the corresponding item in component list:
COMPONENT* component = aNetlist->GetComponentByReference( reference );
// The corresponding component could no longer existing in the netlist. This
// can happen when it is removed from schematic and still exists in footprint
// assignment list. This is an usual case during the life of a design.
if( component )
{
FPID fpid;
if( !footprint.IsEmpty() && fpid.Parse( footprint ) >= 0 )
{
wxString error;
error.Printf( _( "invalid footprint ID in\nfile: <%s>\nline: %d" ),
GetChars( m_lineReader->GetSource() ),
m_lineReader->LineNumber() );
THROW_IO_ERROR( error );
}
// For checking purpose, store the existing FPID (if any) in the alternate fpid copy
// if this existing FPID differs from the FPID read from the .cmp file.
// CvPcb can ask for user to chose the right FPID.
// It happens if the FPID was modified outside CvPcb.
if( fpid != component->GetFPID() && !component->GetFPID().empty() )
component->SetAltFPID( component->GetFPID() );
component->SetFPID( fpid );
}
else
{
ok = false; // can be used to display a warning in Pcbnew.
}
}
return ok;
}
示例5: LoadFootprints
void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
{
wxString msg;
LIB_ID lastFPID;
COMPONENT* component;
MODULE* module = 0;
MODULE* fpOnBoard;
if( aNetlist.IsEmpty() || Prj().PcbFootprintLibs()->IsEmpty() )
return;
aNetlist.SortByFPID();
for( unsigned ii = 0; ii < aNetlist.GetCount(); ii++ )
{
component = aNetlist.GetComponent( ii );
#if ALLOW_PARTIAL_FPID
// The FPID is ok as long as there is a footprint portion coming
// from eeschema.
if( !component->GetFPID().GetLibItemName().size() )
#else
if( component->GetFPID().empty() )
#endif
{
if( aReporter )
{
msg.Printf( _( "No footprint defined for symbol \"%s\".\n" ),
GetChars( component->GetReference() ) );
aReporter->Report( msg, REPORTER::RPT_ERROR );
}
continue;
}
// Check if component footprint is already on BOARD and only load the footprint from
// the library if it's needed. Nickname can be blank.
if( aNetlist.IsFindByTimeStamp() )
fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetTimeStamp(), true );
else
fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetReference() );
bool footprintMisMatch = fpOnBoard &&
fpOnBoard->GetFPID() != component->GetFPID();
if( footprintMisMatch && !aNetlist.GetReplaceFootprints() )
{
if( aReporter )
{
msg.Printf( _( "Footprint of symbol \"%s\" changed: board footprint \"%s\", netlist footprint \"%s\"\n" ),
GetChars( component->GetReference() ),
GetChars( fpOnBoard->GetFPID().Format() ),
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_WARNING );
}
continue;
}
if( !aNetlist.GetReplaceFootprints() )
footprintMisMatch = false;
if( fpOnBoard && !footprintMisMatch ) // nothing else to do here
continue;
if( component->GetFPID() != lastFPID )
{
module = NULL;
#if ALLOW_PARTIAL_FPID
// The LIB_ID is ok as long as there is a footprint portion coming
// the library if it's needed. Nickname can be blank.
if( !component->GetFPID().GetLibItemName().size() )
#else
if( !component->GetFPID().IsValid() )
#endif
{
if( aReporter )
{
msg.Printf( _( "Component \"%s\" footprint ID \"%s\" is not "
"valid.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_ERROR );
}
continue;
}
// loadFootprint() can find a footprint with an empty nickname in fpid.
module = PCB_BASE_FRAME::loadFootprint( component->GetFPID() );
if( module )
{
lastFPID = component->GetFPID();
}
else
{
if( aReporter )
{
//.........这里部分代码省略.........
示例6: ReadNetListAndFpFiles
bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist )
{
wxString msg;
bool hasMissingNicks = false;
ReadSchematicNetlist( aNetlist );
if( m_compListBox == NULL )
return false;
LoadProjectFile();
wxSafeYield();
LoadFootprintFiles();
BuildFOOTPRINTS_LISTBOX();
BuildLIBRARY_LISTBOX();
m_compListBox->Clear();
if( m_netlist.AnyFootprintsLinked() )
{
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
COMPONENT* component = m_netlist.GetComponent( i );
if( component->GetFPID().empty() )
continue;
if( component->GetFPID().IsLegacy() )
hasMissingNicks = true;
}
}
// Check if footprint links were generated before the footprint library table was implemented.
if( hasMissingNicks )
{
msg = _(
"Some of the assigned footprints are legacy entries (are missing lib nicknames). "
"Would you like CvPcb to attempt to convert them to the new required LIB_ID format? "
"(If you answer no, then these assignments will be cleared out and you will "
"have to re-assign these footprints yourself.)"
);
if( IsOK( this, msg ) )
{
msg.Clear();
try
{
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
COMPONENT* component = m_netlist.GetComponent( i );
if( component->GetFPID().IsLegacy() )
{
// get this first here, it's possibly obsoleted if we get it too soon.
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs( Kiway() );
int guess = guessNickname( tbl, (LIB_ID*) &component->GetFPID() );
switch( guess )
{
case 0:
DBG(printf("%s: guessed OK ref:%s fpid:%s\n", __func__,
TO_UTF8( component->GetReference() ), component->GetFPID().Format().c_str() );)
m_modified = true;
break;
case 1:
msg += wxString::Format( _(
"Component \"%s\" footprint \"%s\" was <b>not found</b> in any library.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().GetLibItemName() )
);
break;
case 2:
msg += wxString::Format( _(
"Component \"%s\" footprint \"%s\" was found in <b>multiple</b> libraries.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().GetLibItemName() )
);
break;
}
}
}
}
示例7: loadFootprints
void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
throw( IO_ERROR, PARSE_ERROR )
{
wxString msg;
FPID lastFPID;
COMPONENT* component;
MODULE* module = 0;
MODULE* fpOnBoard;
if( aNetlist.IsEmpty() || FootprintLibs()->IsEmpty() )
return;
aNetlist.SortByFPID();
for( unsigned ii = 0; ii < aNetlist.GetCount(); ii++ )
{
component = aNetlist.GetComponent( ii );
#if ALLOW_PARTIAL_FPID
// The FPID is ok as long as there is a footprint portion coming
// from eeschema.
if( !component->GetFPID().GetFootprintName().size() )
#else
if( component->GetFPID().empty() )
#endif
{
if( aReporter )
{
msg.Printf( _( "No footprint defined for component '%s'.\n" ),
GetChars( component->GetReference() ) );
aReporter->Report( msg );
}
continue;
}
// Check if component footprint is already on BOARD and only load the footprint from
// the library if it's needed. Nickname can be blank.
if( aNetlist.IsFindByTimeStamp() )
fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetTimeStamp(), true );
else
fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetReference() );
bool footprintMisMatch = fpOnBoard &&
fpOnBoard->GetFPID() != component->GetFPID();
if( footprintMisMatch && !aNetlist.GetReplaceFootprints() )
{
if( aReporter )
{
msg.Printf( _( "* Warning: component '%s' has footprint '%s' and should be '%s'\n" ),
GetChars( component->GetReference() ),
fpOnBoard->GetFPID().GetFootprintName().c_str(),
component->GetFPID().GetFootprintName().c_str() );
aReporter->Report( msg );
}
continue;
}
if( !aNetlist.GetReplaceFootprints() )
footprintMisMatch = false;
bool loadFootprint = (fpOnBoard == NULL) || footprintMisMatch;
if( loadFootprint && (component->GetFPID() != lastFPID) )
{
module = NULL;
#if ALLOW_PARTIAL_FPID
// The FPID is ok as long as there is a footprint portion coming
// the library if it's needed. Nickname can be blank.
if( !component->GetFPID().GetFootprintName().size() )
#else
if( !component->GetFPID().IsValid() )
#endif
{
if( aReporter )
{
msg.Printf( _( "*** Warning: Component '%s' footprint ID '%s' is not "
"valid. ***\n" ),
GetChars( component->GetReference() ),
component->GetFPID().GetFootprintName().c_str() );
aReporter->Report( msg );
}
continue;
}
// loadFootprint() can find a footprint with an empty nickname in fpid.
module = PCB_BASE_FRAME::loadFootprint( component->GetFPID() );
if( module )
{
lastFPID = component->GetFPID();
}
else
{
if( aReporter )
{
//.........这里部分代码省略.........
示例8: UpdateNetlist
bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
{
wxString msg;
m_errorCount = 0;
m_warningCount = 0;
if( !m_isDryRun )
{
m_board->SetStatus( 0 );
}
for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
{
COMPONENT* component = aNetlist.GetComponent( i );
MODULE* footprint = NULL;
msg.Printf( _( "Processing component \"%s:%s:%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( component->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO );
if( aNetlist.IsFindByTimeStamp() )
footprint = m_board->FindModule( component->GetTimeStamp(), true );
else
footprint = m_board->FindModule( component->GetReference() );
if( footprint ) // An existing footprint.
{
MODULE* newFootprint = replaceComponent( aNetlist, footprint, component );
if( newFootprint )
footprint = newFootprint;
}
else
{
footprint = addNewComponent( component );
}
if( footprint )
{
updateComponentParameters( footprint, component );
updateComponentPadConnections( footprint, component );
}
}
//aNetlist.GetDeleteExtraFootprints()
if( m_deleteUnusedComponents )
deleteUnusedComponents( aNetlist );
if( m_deleteSinglePadNets )
deleteSinglePadNets();
if( !m_isDryRun )
{
m_commit.Push( _( "Update netlist" ) );
m_frame->Compile_Ratsnest( NULL, false );
m_board->GetRatsnest()->ProcessBoard();
testConnectivity( aNetlist );
}
// Update the ratsnest
m_reporter->Report( wxT( "" ), REPORTER::RPT_ACTION );
m_reporter->Report( wxT( "" ), REPORTER::RPT_ACTION );
msg.Printf( _( "Total warnings: %d, errors: %d." ), m_warningCount, m_errorCount );
m_reporter->Report( msg, REPORTER::RPT_ACTION );
if( m_errorCount )
{
m_reporter->Report( _( "Errors occured during the netlist update. Unless you "
"fix them, your board will not be consistent with the schematics." ),
REPORTER::RPT_ERROR );
return false;
}
else
{
m_reporter->Report( _( "Netlist update successful!" ), REPORTER::RPT_ACTION );
}
return true;
}
示例9: ByFPID
/**
* Function ByFPID
* is a helper function used to sort the component list used by loadNewModules.
*/
static bool ByFPID( const COMPONENT& ref, const COMPONENT& cmp )
{
return ref.GetFPID() > cmp.GetFPID();
}
示例10: AssocieModule
void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
{
FOOTPRINT_ALIAS_LIST aliases;
FOOTPRINT_ALIAS* alias;
COMPONENT* component;
wxFileName fn;
wxString msg, tmp;
char Line[1024];
FILE* file;
size_t ii;
SEARCH_STACK& search = Kiface().KifaceSearch();
if( m_netlist.IsEmpty() )
return;
// Find equivalents in all available files.
for( ii = 0; ii < m_AliasLibNames.GetCount(); ii++ )
{
fn = m_AliasLibNames[ii];
if( !fn.HasExt() )
{
fn.SetExt( FootprintAliasFileExtension );
// above fails if filename has more than one point
}
else
{
fn.SetExt( fn.GetExt() + wxT( "." ) + FootprintAliasFileExtension );
}
tmp = search.FindValidPath( fn.GetFullPath() );
if( !tmp )
{
msg.Printf( _( "Footprint alias library file '%s' could not be found in the "
"default search paths." ),
GetChars( fn.GetFullName() ) );
wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR );
continue;
}
file = wxFopen( tmp, wxT( "rt" ) );
if( file == NULL )
{
msg.Printf( _( "Error opening alias library '%s'." ), GetChars( tmp ) );
wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR );
continue;
}
while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
{
char* text = Line;
wxString value, footprint, wtext = FROM_UTF8( Line );
value = GetQuotedText( wtext );
if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
continue;
footprint = GetQuotedText( wtext );
if( footprint.IsEmpty() )
continue;
value.Replace( wxT( " " ), wxT( "_" ) );
alias = new FOOTPRINT_ALIAS();
alias->m_Name = value;
alias->m_FootprintName = footprint;
aliases.push_back( alias );
}
fclose( file );
}
// Display the number of footprint aliases.
msg.Printf( _( "%d footprint aliases found." ), aliases.size() );
SetStatusText( msg, 0 );
m_skipComponentSelect = true;
ii = 0;
for( unsigned kk = 0; kk < m_netlist.GetCount(); kk++ )
{
component = m_netlist.GetComponent( kk );
bool found = false;
m_compListBox->SetSelection( ii++, true );
if( !component->GetFPID().empty() )
continue;
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
{
if( alias.m_Name.CmpNoCase( component->GetValue() ) != 0 )
continue;
//.........这里部分代码省略.........
示例11: AutomaticFootprintMatching
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;
if( buildEquivalenceList( equiv_List, &error_msg ) )
wxMessageBox( error_msg, _( "Equivalence File Load Error" ), wxOK | wxICON_WARNING, this );
// Sort the association list by component value.
// When sorted, find duplicate definitions (i.e. 2 or more items
// having the same component value) is more easy.
std::sort( equiv_List.begin(), equiv_List.end(), sortListbyCmpValue );
// Display the number of footprint/component equivalences.
msg.Printf( _( "%lu footprint/cmp equivalences found." ), (unsigned long)equiv_List.size() );
SetStatusText( msg, 0 );
// 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 );
bool found = false;
m_compListBox->SetSelection( ii++, true );
if( !component->GetFPID().empty() ) // the component has already a footprint
continue;
// Here a first attempt is made. We can have multiple equivItem of the same value.
// When happens, using the footprint filter of components can remove the ambiguity by
// filtering equivItem so one can use multiple equiv_List (for polar and
// non-polar caps for example)
for( unsigned idx = 0; idx < equiv_List.size(); idx++ )
{
FOOTPRINT_EQUIVALENCE& equivItem = equiv_List[idx];
if( equivItem.m_ComponentValue.CmpNoCase( component->GetValue() ) != 0 )
continue;
const FOOTPRINT_INFO *module = m_FootprintsList.GetModuleInfo( equivItem.m_FootprintFPID );
bool equ_is_unique = true;
unsigned next = idx+1;
int previous = idx-1;
if( next < equiv_List.size() &&
equivItem.m_ComponentValue == equiv_List[next].m_ComponentValue )
equ_is_unique = false;
if( previous >= 0 &&
equivItem.m_ComponentValue == equiv_List[previous].m_ComponentValue )
equ_is_unique = false;
// If the equivalence is unique, no ambiguity: use the association
if( module && equ_is_unique )
{
SetNewPkg( equivItem.m_FootprintFPID );
found = true;
break;
}
// The equivalence is not unique: use the footprint filter to try to remove
// ambiguity
if( module )
{
size_t filtercount = component->GetFootprintFilters().GetCount();
found = ( 0 == filtercount ); // if no entries, do not filter
for( size_t jj = 0; jj < filtercount && !found; jj++ )
{
found = module->GetFootprintName().Matches( component->GetFootprintFilters()[jj] );
}
}
else
{
msg.Printf( _( "Component %s: footprint %s not found in any of the project "
"footprint libraries." ),
GetChars( component->GetReference() ),
GetChars( equivItem.m_FootprintFPID ) );
if( ! error_msg.IsEmpty() )
error_msg << wxT("\n\n");
error_msg += msg;
}
if( found )
{
SetNewPkg( equivItem.m_FootprintFPID );
break;
//.........这里部分代码省略.........
示例12: SetNewPkg
void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
{
COMPONENT* component;
bool hasFootprint = false;
int componentIndex;
if( m_netlist.IsEmpty() )
return;
// If no component is selected, select the first one
if( m_compListBox->GetFirstSelected() < 0 )
{
componentIndex = 0;
m_compListBox->SetSelection( componentIndex, true );
}
// iterate over the selection
while( m_compListBox->GetFirstSelected() != -1 )
{
// Get the component for the current iteration
componentIndex = m_compListBox->GetFirstSelected();
component = m_netlist.GetComponent( componentIndex );
if( component == NULL )
return;
// Check to see if the component has already a footprint set.
hasFootprint = !component->GetFPID().empty();
FPID fpid;
if( !aFootprintName.IsEmpty() )
{
wxCHECK_RET( fpid.Parse( aFootprintName ) < 0,
wxString::Format( wxT( "<%s> is not a valid FPID." ),
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 )
{
hasFootprint = true;
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++;
m_compListBox->SetSelection( componentIndex, true );
// update the statusbar
DisplayStatus();
}
示例13: ReadNetListAndLinkFiles
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
{
COMPONENT* component;
wxString msg;
bool isLegacy = true;
ReadSchematicNetlist();
if( m_ListCmp == NULL )
return false;
LoadProjectFile( m_NetlistFileName.GetFullPath() );
LoadFootprintFiles();
BuildFOOTPRINTS_LISTBOX();
BuildLIBRARY_LISTBOX();
m_ListCmp->Clear();
m_undefinedComponentCnt = 0;
if( m_netlist.AnyFootprintsLinked() )
{
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
component = m_netlist.GetComponent( i );
if( component->GetFPID().empty() )
continue;
if( isLegacy )
{
if( !component->GetFPID().IsLegacy() )
isLegacy = false;
}
}
}
else
{
isLegacy = false; // None of the components have footprints assigned.
}
wxString missingLibs;
// Check if footprint links were generated before the footprint library table was implemented.
if( isLegacy )
{
if( m_footprintLibTable->MissingLegacyLibs( m_ModuleLibNames, &missingLibs ) )
{
msg = wxT( "The following legacy libraries are defined in the project file "
"were not found in the footprint library table:\n\n" ) + missingLibs;
msg += wxT( "\nDo you want to update the footprint library table before "
"attempting to update the assigned footprints?" );
if( IsOK( this, msg ) )
{
wxCommandEvent cmd;
OnEditFootprintLibraryTable( cmd );
}
}
msg = wxT( "Some or all of the assigned footprints contain legacy entries. Would you "
"like CvPcb to attempt to convert them to the new footprint library table "
"format?" );
if( IsOK( this, msg ) )
{
msg.Clear();
WX_STRING_REPORTER reporter( &msg );
if( !m_footprintLibTable->ConvertFromLegacy( m_netlist, m_ModuleLibNames, &reporter ) )
{
HTML_MESSAGE_BOX dlg( this, wxEmptyString );
dlg.MessageSet( wxT( "The following errors occurred attempt to convert the "
"footprint assignments:\n\n" ) );
dlg.ListSet( msg );
dlg.MessageSet( wxT( "\nYou will need to reassign them manually if you want them "
"to be updated correctly the next time you import the "
"netlist in Pcbnew." ) );
dlg.ShowModal();
}
m_modified = true;
}
else
{
// Clear the legacy footprint assignments.
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
FPID emptyFPID;
component = m_netlist.GetComponent( i );
component->SetFPID( emptyFPID );
m_modified = true;
}
}
}
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
component = m_netlist.GetComponent( i );
//.........这里部分代码省略.........
示例14: ReadNetListAndLinkFiles
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
{
wxString msg;
bool hasMissingNicks = false;
FP_LIB_TABLE* tbl = FootprintLibs();
ReadSchematicNetlist();
if( m_ListCmp == NULL )
return false;
LoadProjectFile( m_NetlistFileName.GetFullPath() );
LoadFootprintFiles();
BuildFOOTPRINTS_LISTBOX();
BuildLIBRARY_LISTBOX();
m_ListCmp->Clear();
m_undefinedComponentCnt = 0;
if( m_netlist.AnyFootprintsLinked() )
{
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
COMPONENT* component = m_netlist.GetComponent( i );
if( component->GetFPID().empty() )
continue;
if( component->GetFPID().IsLegacy() )
hasMissingNicks = true;
}
}
// Check if footprint links were generated before the footprint library table was implemented.
if( hasMissingNicks )
{
msg = wxT(
"Some of the assigned footprints are legacy entries (are missing lib nicknames). "
"Would you like CvPcb to attempt to convert them to the new required FPID format? "
"(If you answer no, then these assignments will be cleared out and you will "
"have to re-assign these footprints yourself.)"
);
if( IsOK( this, msg ) )
{
msg.Clear();
try
{
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
COMPONENT* component = m_netlist.GetComponent( i );
if( component->GetFPID().IsLegacy() )
{
int guess = guessNickname( tbl, (FPID*) &component->GetFPID() );
switch( guess )
{
case 0:
DBG(printf("%s: guessed OK ref:%s fpid:%s\n", __func__,
TO_UTF8( component->GetReference() ), component->GetFPID().Format().c_str() );)
m_modified = true;
break;
case 1:
msg += wxString::Format( _(
"Component '%s' footprint '%s' was <b>not found</b> in any library.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().GetFootprintName() )
);
break;
case 2:
msg += wxString::Format( _(
"Component '%s' footprint '%s' was found in <b>multiple</b> libraries.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().GetFootprintName() )
);
break;
}
}
}
}
示例15: convertFromLegacy
/**
* Function convertFromLegacy
* converts the footprint names in \a aNetList from the legacy format to the #FPID format.
*
* @param aNetList is the #NETLIST object to convert.
* @param aLibNames is the list of legacy footprint library names from the currently loaded
* project.
* @param aReporter is the #REPORTER object to dump messages into.
* @return true if all footprint names were successfully converted to a valid FPID.
*/
static bool convertFromLegacy( FP_LIB_TABLE* aTbl, SEARCH_STACK& aSStack, NETLIST& aNetList,
const wxArrayString& aLibNames, REPORTER* aReporter = NULL ) throw( IO_ERROR )
{
wxString msg;
FPID lastFPID;
COMPONENT* component;
MODULE* module = 0;
bool retv = true;
if( aNetList.IsEmpty() )
return true;
aNetList.SortByFPID();
wxString libPath;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
for( unsigned ii = 0; ii < aNetList.GetCount(); ii++ )
{
component = aNetList.GetComponent( ii );
// The footprint hasn't been assigned yet so ignore it.
if( component->GetFPID().empty() )
continue;
if( component->GetFPID() != lastFPID )
{
module = NULL;
for( unsigned ii = 0; ii < aLibNames.GetCount(); ii++ )
{
wxFileName fn( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
libPath = aSStack.FindValidPath( fn.GetFullPath() );
if( !libPath )
{
if( aReporter )
{
msg.Printf( _( "Cannot find footprint library file '%s' in any of the "
"KiCad legacy library search paths.\n" ),
GetChars( fn.GetFullPath() ) );
aReporter->Report( msg );
}
retv = false;
continue;
}
module = pi->FootprintLoad( libPath, component->GetFPID().GetFootprintName() );
if( module )
{
lastFPID = component->GetFPID();
break;
}
}
}
if( !module )
{
if( aReporter )
{
msg.Printf( _( "Component '%s' footprint '%s' was not found in any legacy "
"library.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg );
}
// Clear the footprint assignment since the old library lookup method is no
// longer valid.
FPID emptyFPID;
component->SetFPID( emptyFPID );
retv = false;
continue;
}
else
{
wxString libNickname;
const FP_LIB_TABLE::ROW* row;
if( ( row = aTbl->FindRowByURI( libPath ) ) != NULL )
libNickname = row->GetNickName();
if( libNickname.IsEmpty() )
{
//.........这里部分代码省略.........