本文整理汇总了C++中FPID类的典型用法代码示例。如果您正苦于以下问题:C++ FPID类的具体用法?C++ FPID怎么用?C++ FPID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FPID类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetCurItem
void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
{
if( m_footprintList->GetCount() == 0 )
return;
int ii = m_footprintList->GetSelection();
if( ii < 0 )
return;
wxString name = m_footprintList->GetString( ii );
if( m_footprintName.CmpNoCase( name ) != 0 )
{
m_footprintName = name;
SetCurItem( NULL );
// Delete the current footprint
GetBoard()->m_Modules.DeleteAll();
FPID id;
id.SetLibNickname( m_libraryName );
id.SetFootprintName( m_footprintName );
try
{
GetBoard()->Add( loadFootprint( id ) );
}
catch( const IO_ERROR& ioe )
{
wxString msg;
msg.Printf( _( "Could not load footprint \"%s\" from library \"%s\".\n\n"
"Error %s." ), GetChars( m_footprintName ), GetChars( m_libraryName ),
GetChars( ioe.errorText ) );
DisplayError( this, msg );
}
UpdateTitle();
Zoom_Automatique( false );
m_canvas->Refresh();
Update3D_Frame();
}
}
示例2: BOOST_FOREACH
FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
{
if( aFootprintName.IsEmpty() )
return NULL;
BOOST_FOREACH( FOOTPRINT_INFO& fp, m_list )
{
FPID fpid;
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
wxString::Format( wxT( "'%s' is not a valid FPID." ),
GetChars( aFootprintName ) ) );
wxString libNickname = fpid.GetLibNickname();
wxString footprintName = fpid.GetFootprintName();
if( libNickname == fp.GetNickname() && footprintName == fp.GetFootprintName() )
return &fp;
}
示例3: Get_Module
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
MODULE* footprint = NULL;
try
{
FPID fpid;
if( fpid.Parse( aFootprintName ) >= 0 )
{
DisplayInfoMessage( this, wxString::Format( wxT( "Footprint ID <%s> is not valid." ),
GetChars( aFootprintName ) ) );
return NULL;
}
std::string nickname = fpid.GetLibNickname();
std::string fpname = fpid.GetFootprintName();
wxLogDebug( wxT( "Load footprint <%s> from library <%s>." ),
fpname.c_str(), nickname.c_str() );
footprint = Prj().PcbFootprintLibs()->FootprintLoad(
FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
}
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
}
if( footprint )
{
footprint->SetParent( (EDA_ITEM*) GetBoard() );
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
DisplayError( this, msg );
return NULL;
}
示例4: throw
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: throw
void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR, boost::bad_pointer )
{
/* Parses a section like
* (comp (ref P1)
* (value DB25FEMELLE)
* (footprint DB25FC)
* (libsource (lib conn) (part DB25))
* (sheetpath (names /) (tstamps /))
* (tstamp 3256759C))
*
* other fields (unused) are skipped
* A component need a reference, value, footprint name and a full time stamp
* The full time stamp is the sheetpath time stamp + the component time stamp
*/
FPID fpid;
wxString footprint;
wxString tmp;
wxString ref;
wxString value;
wxString library;
wxString name;
wxString pathtimestamp, timestamp;
// The token comp was read, so the next data is (ref P1)
while( (token = NextTok()) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_ref:
NeedSYMBOLorNUMBER();
ref = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_value:
NeedSYMBOLorNUMBER();
value = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_footprint:
NeedSYMBOLorNUMBER();
footprint = FromUTF8();
NeedRIGHT();
break;
case T_libsource:
// Read libsource
while( (token = NextTok()) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
if( token == T_lib )
{
NeedSYMBOLorNUMBER();
library = FROM_UTF8( CurText() );
NeedRIGHT();
}
else if( token == T_part )
{
NeedSYMBOLorNUMBER();
name = FROM_UTF8( CurText() );
NeedRIGHT();
}
else
{
Expecting( "part or lib" );
}
}
break;
case T_sheetpath:
while( ( token = NextTok() ) != T_tstamps );
NeedSYMBOLorNUMBER();
pathtimestamp = FROM_UTF8( CurText() );
NeedRIGHT();
NeedRIGHT();
break;
case T_tstamp:
NeedSYMBOLorNUMBER();
timestamp = FROM_UTF8( CurText() );
NeedRIGHT();
break;
default:
// Skip not used data (i.e all other tokens)
skipCurrent();
break;
}
}
if( !footprint.IsEmpty() && fpid.Parse( footprint ) >= 0 )
{
wxString error;
error.Printf( _( "invalid PFID in\nfile: <%s>\nline: %d\noffset: %d" ),
//.........这里部分代码省略.........
示例6: GetCrossHairPosition
MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
FP_LIB_TABLE* aTable,
bool aUseFootprintViewer,
wxDC* aDC )
{
MODULE* module = NULL;
wxPoint curspos = GetCrossHairPosition();
wxString moduleName, keys;
wxString libName = aLibrary;
bool allowWildSeach = true;
static wxArrayString HistoryList;
static wxString lastComponentName;
// Ask for a component name or key words
DIALOG_GET_COMPONENT dlg( this, HistoryList, _( "Load Module" ), aUseFootprintViewer );
dlg.SetComponentName( lastComponentName );
if( dlg.ShowModal() == wxID_CANCEL )
return NULL;
if( dlg.m_GetExtraFunction )
{
// SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e.
// <lib_name>/<footprint name> or FPID format "lib_name:fp_name:rev#"
moduleName = SelectFootprintFromLibBrowser();
}
else
{
moduleName = dlg.GetComponentName();
}
if( moduleName.IsEmpty() ) // Cancel command
{
m_canvas->MoveCursorToCrossHair();
return NULL;
}
if( dlg.IsKeyword() ) // Selection by keywords
{
allowWildSeach = false;
keys = moduleName;
moduleName = SelectFootprint( this, libName, wxEmptyString, keys, aTable );
if( moduleName.IsEmpty() ) // Cancel command
{
m_canvas->MoveCursorToCrossHair();
return NULL;
}
}
else if( moduleName.Contains( wxT( "?" ) )
|| moduleName.Contains( wxT( "*" ) ) ) // Selection wild card
{
allowWildSeach = false;
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );
if( moduleName.IsEmpty() )
{
m_canvas->MoveCursorToCrossHair();
return NULL; // Cancel command.
}
}
FPID fpid;
wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
wxString::Format( wxT( "Could not parse FPID string '%s'." ),
GetChars( moduleName ) ) );
try
{
module = loadFootprint( fpid );
}
catch( const IO_ERROR& ioe )
{
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
fpid.Format().c_str(), GetChars( ioe.errorText ) );
}
if( !module && allowWildSeach ) // Search with wild card
{
allowWildSeach = false;
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
moduleName = wildname;
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );
if( moduleName.IsEmpty() )
{
m_canvas->MoveCursorToCrossHair();
return NULL; // Cancel command.
}
else
{
FPID fpid;
wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
wxString::Format( wxT( "Could not parse FPID string '%s'." ),
//.........这里部分代码省略.........
示例7: PCB_BASE_FRAME
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) :
PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
wxDefaultPosition, wxDefaultSize,
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ?
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT :
KICAD_DEFAULT_DRAWFRAME_STYLE,
GetFootprintViewerFrameName() )
{
wxASSERT( aFrameType==FRAME_PCB_MODULE_VIEWER || aFrameType==FRAME_PCB_MODULE_VIEWER_MODAL );
if( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL )
SetModal( true );
wxAcceleratorTable table( DIM( accels ), accels );
m_FrameName = GetFootprintViewerFrameName();
m_configPath = wxT( "FootprintViewer" );
m_showAxis = true; // true to draw axis.
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) );
SetIcon( icon );
m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr;
m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST,
wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL );
m_footprintList = new wxListBox( this, ID_MODVIEW_FOOTPRINT_LIST,
wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL );
SetBoard( new BOARD() );
// Ensure all layers and items are visible:
GetBoard()->SetVisibleAlls();
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
GetScreen()->m_Center = true; // Center coordinate origins on screen.
LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateHToolbar();
ReCreateVToolbar();
ReCreateLibraryList();
UpdateTitle();
// If a footprint was previously loaded, reload it
if( getCurNickname().size() && getCurFootprintName().size() )
{
FPID id;
id.SetLibNickname( getCurNickname() );
id.SetFootprintName( getCurFootprintName() );
GetBoard()->Add( loadFootprint( id ) );
}
if( m_canvas )
m_canvas->SetAcceleratorTable( table );
m_auimgr.SetManagedWindow( this );
wxSize minsize(100,-1); // Min size of list boxes
// Main toolbar is initially docked at the top of the main window and dockable on any side.
// The close button is disable because the footprint viewer has no main menu to re-enable it.
// The tool bar will only be dockable on the top or bottom of the main frame window. This is
// most likely due to the fact that the other windows are not dockable and are preventing the
// tool bar from docking on the right and left.
wxAuiPaneInfo toolbarPaneInfo;
toolbarPaneInfo.Name( wxT( "m_mainToolBar" ) ).ToolbarPane().Top().CloseButton( false );
EDA_PANEINFO info;
info.InfoToolbarPane();
EDA_PANEINFO mesg;
mesg.MessageToolbarPane();
// Manage main toolbar, top pane
m_auimgr.AddPane( m_mainToolBar, toolbarPaneInfo );
// Manage the list of libraries, left pane.
m_auimgr.AddPane( m_libList,
wxAuiPaneInfo( info ).Name( wxT( "m_libList" ) )
.Left().Row( 1 ).MinSize( minsize ) );
// Manage the list of footprints, center pane.
m_auimgr.AddPane( m_footprintList,
wxAuiPaneInfo( info ).Name( wxT( "m_footprintList" ) )
.Left().Row( 2 ).MinSize( minsize ) );
// Manage the draw panel, right pane.
m_auimgr.AddPane( m_canvas,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
// Manage the message panel, bottom pane.
//.........这里部分代码省略.........
示例8: throw
COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText )
throw( PARSE_ERROR, boost::bad_pointer )
{
char* text;
wxString msg;
wxString timeStamp; // the full time stamp read from netlist
wxString footprintName; // the footprint name read from netlist
wxString value; // the component value read from netlist
wxString reference; // the component schematic reference designator read from netlist
wxString name; // the name of component that was placed in the schematic
char line[1024];
strcpy( line, aText );
value = wxT( "~" );
// Sample component line: /40C08647 $noname R20 4.7K {Lib=R}
// Read time stamp (first word)
if( ( text = strtok( line, " ()\t\n" ) ) == NULL )
{
msg = _( "Cannot parse time stamp in component section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), line, m_lineReader->LineNumber(),
m_lineReader->Length() );
}
timeStamp = FROM_UTF8( text );
// Read footprint name (second word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
{
msg = _( "Cannot parse footprint name in component section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(),
m_lineReader->Length() );
}
footprintName = FROM_UTF8( text );
// The footprint name will have to be looked up in the *.cmp file.
if( footprintName == wxT( "$noname" ) )
footprintName = wxEmptyString;
// Read schematic reference designator (third word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
{
msg = _( "Cannot parse reference designator in component section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(),
m_lineReader->Length() );
}
reference = FROM_UTF8( text );
// Read schematic value (forth word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
{
msg = _( "Cannot parse value in component section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(),
m_lineReader->Length() );
}
value = FROM_UTF8( text );
// Read component name (fifth word) {Lib=C}
// This is an optional field (a comment), which does not always exists
if( ( text = strtok( NULL, " ()\t\n" ) ) != NULL )
{
name = FROM_UTF8( text ).AfterFirst( wxChar( '=' ) ).BeforeLast( wxChar( '}' ) );
}
FPID fpid;
if( !footprintName.IsEmpty() )
fpid.SetFootprintName( footprintName );
COMPONENT* component = new COMPONENT( fpid, reference, value, timeStamp );
component->SetName( name );
m_netlist->AddComponent( component );
return component;
}
示例9: while
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();
}
示例10: 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() )
{
//.........这里部分代码省略.........