本文整理汇总了C++中LIB_PART::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ LIB_PART::GetName方法的具体用法?C++ LIB_PART::GetName怎么用?C++ LIB_PART::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LIB_PART
的用法示例。
在下文中一共展示了LIB_PART::GetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveOnePart
bool LIB_EDIT_FRAME::SaveOnePart( PART_LIB* aLib, bool aPromptUser )
{
wxString msg;
LIB_PART* part = GetCurPart();
GetScreen()->ClrModify();
LIB_PART* old_part = aLib->FindPart( part->GetName() );
if( old_part && aPromptUser )
{
msg.Printf( _( "Part '%s' already exists. Change it?" ),
GetChars( part->GetName() ) );
if( !IsOK( this, msg ) )
return false;
}
m_drawItem = m_lastDrawItem = NULL;
if( old_part )
aLib->ReplacePart( old_part, part );
else
aLib->AddPart( part );
msg.Printf( _( "Part '%s' saved in library '%s'" ),
GetChars( part->GetName() ),
GetChars( aLib->GetName() ) );
SetStatusText( msg );
return true;
}
示例2: initDlg
/* Initialize state of check boxes and texts
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg()
{
m_AliasLocation = -1;
LIB_PART* component = m_Parent->GetCurPart();
if( component == NULL )
{
SetTitle( _( "Library Component Properties" ) );
return;
}
wxString title;
bool isRoot = m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0;
if( !isRoot )
{
title.Printf( _( "Properties for %s (alias of %s)" ),
GetChars( m_Parent->GetAliasName() ),
GetChars( component->GetName() ) );
}
else
title.Printf( _( "Properties for %s" ), GetChars( component->GetName() ) );
SetTitle( title );
InitPanelDoc();
InitBasicPanel();
if( isRoot && component->GetAliasCount() == 1 )
m_ButtonDeleteAllAlias->Enable( false );
/* Place list of alias names in listbox */
m_PartAliasListCtrl->Append( component->GetAliasNames( false ) );
if( component->GetAliasCount() <= 1 )
{
m_ButtonDeleteAllAlias->Enable( false );
m_ButtonDeleteOneAlias->Enable( false );
}
/* Read the Footprint Filter list */
m_FootprintFilterListBox->Append( component->GetFootPrints() );
if( component->GetFootPrints().GetCount() == 0 )
{
m_ButtonDeleteAllFootprintFilter->Enable( false );
m_ButtonDeleteOneFootprintFilter->Enable( false );
m_buttonEditOneFootprintFilter->Enable( false );
}
m_NoteBook->SetSelection( m_lastOpenedPage );
m_stdSizerButtonOK->SetDefault();
}
示例3: RedrawActiveWindow
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );
if( !entry )
return;
LIB_PART* part = entry->GetPart();
if( !part )
return;
wxString msg;
wxString tmp;
m_canvas->DrawBackGround( DC );
if( !entry->IsRoot() )
{
// Temporarily change the name field text to reflect the alias name.
msg = entry->GetName();
tmp = part->GetName();
part->SetName( msg );
if( m_unit < 1 )
m_unit = 1;
if( m_convert < 1 )
m_convert = 1;
}
else
msg = _( "None" );
part->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE );
// Redraw the cursor
m_canvas->DrawCrossHair( DC );
if( !tmp.IsEmpty() )
part->SetName( tmp );
ClearMsgPanel();
AppendMsgPanel( _( "Part" ), part->GetName(), BLUE, 6 );
AppendMsgPanel( _( "Alias" ), msg, RED, 6 );
AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 );
AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY );
}
示例4: DisplayCmpDoc
void LIB_EDIT_FRAME::DisplayCmpDoc()
{
LIB_ALIAS* alias;
PART_LIB* lib = GetCurLib();
LIB_PART* part = GetCurPart();
ClearMsgPanel();
if( !lib || !part )
return;
wxString msg = part->GetName();
AppendMsgPanel( _( "Name" ), msg, BLUE, 8 );
if( m_aliasName == part->GetName() )
msg = _( "None" );
else
msg = m_aliasName;
alias = part->GetAlias( m_aliasName );
wxCHECK_RET( alias != NULL, "Alias not found in component." );
AppendMsgPanel( _( "Alias" ), msg, RED, 8 );
static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
msg = UnitLetter[m_unit];
AppendMsgPanel( _( "Unit" ), msg, BROWN, 8 );
if( m_convert > 1 )
msg = _( "Convert" );
else
msg = _( "Normal" );
AppendMsgPanel( _( "Body" ), msg, GREEN, 8 );
if( part->IsPower() )
msg = _( "Power Symbol" );
else
msg = _( "Part" );
AppendMsgPanel( _( "Type" ), msg, MAGENTA, 8 );
AppendMsgPanel( _( "Description" ), alias->GetDescription(), CYAN, 8 );
AppendMsgPanel( _( "Key words" ), alias->GetKeyWords(), DARKDARKGRAY );
AppendMsgPanel( _( "Datasheet" ), alias->GetDocFileName(), DARKDARKGRAY );
}
示例5: OnHandlePreviewRepaint
void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEvent )
{
int unit = 0;
LIB_ALIAS* selection = m_search_container->GetSelectedAlias( &unit );
LIB_PART* part = selection ? selection->GetPart() : NULL;
// Don't draw anything (not even the background) if we don't have
// a part to show
if( !part )
return;
if( selection->IsRoot() )
{
// just show the part directly
renderPreview( part, unit );
}
else
{
// switch out the name temporarily for the alias name
wxString tmp( part->GetName() );
part->SetName( selection->GetName() );
renderPreview( part, unit );
part->SetName( tmp );
}
}
示例6: OnSelectUnit
void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
{
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T,
wxT( "Cannot select unit of invalid schematic item." ) );
INSTALL_UNBUFFERED_DC( dc, m_canvas );
m_canvas->MoveCursorToCrossHair();
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
int unit = aEvent.GetId() + 1 - ID_POPUP_SCH_SELECT_UNIT1;
LIB_PART* part = GetLibPart( component->GetLibId() );
if( !part )
return;
int unitCount = part->GetUnitCount();
wxCHECK_RET( (unit >= 1) && (unit <= unitCount),
wxString::Format( wxT( "Cannot select unit %d from component " ), unit ) +
part->GetName() );
if( unitCount <= 1 || component->GetUnit() == unit )
return;
if( unit > unitCount )
unit = unitCount;
STATUS_FLAGS flags = component->GetFlags();
if( !flags ) // No command in progress: save in undo list
SaveCopyInUndoList( component, UR_CHANGED );
if( flags )
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
else
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
/* Update the unit number. */
component->SetUnitSelection( m_CurrentSheet, unit );
component->SetUnit( unit );
component->ClearFlags();
component->SetFlags( flags ); // Restore m_Flag modified by SetUnit()
if( m_autoplaceFields )
component->AutoAutoplaceFields( GetScreen() );
if( screen->TestDanglingEnds() )
m_canvas->Refresh();
OnModify();
}
示例7: OnPasteDuplicatePart
void LIB_EDIT_FRAME::OnPasteDuplicatePart( wxCommandEvent& aEvent )
{
int dummyUnit;
LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit );
wxString lib = libId.GetLibNickname();
if( !m_libMgr->LibraryExists( lib ) )
return;
LIB_PART* srcPart = nullptr;
LIB_PART* newPart = nullptr;
if( aEvent.GetId() == ID_LIBEDIT_DUPLICATE_PART )
{
srcPart = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib );
newPart = new LIB_PART( *srcPart );
}
else if( aEvent.GetId() == ID_LIBEDIT_PASTE_PART )
{
auto clipboard = wxTheClipboard;
wxClipboardLocker clipboardLock( clipboard );
if( !clipboardLock || ! clipboard->IsSupported( wxDF_TEXT ) )
return;
wxTextDataObject data;
clipboard->GetData( data );
wxString partSource = data.GetText();
STRING_LINE_READER reader( TO_UTF8( partSource ), "Clipboard" );
try
{
reader.ReadLine();
newPart = SCH_LEGACY_PLUGIN::ParsePart( reader );
}
catch( IO_ERROR& e )
{
wxLogError( wxString::Format( "Malformed clipboard: %s" ), GetChars( e.What() ) );
return;
}
}
else
wxFAIL;
if( !newPart )
return;
fixDuplicateAliases( newPart, lib );
m_libMgr->UpdatePart( newPart, lib );
SyncLibraries( false );
m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, newPart->GetName() ) );
delete newPart;
}
示例8: SetHtmlAliasOf
void SetHtmlAliasOf()
{
if( m_part->IsRoot() )
{
m_html.Replace( "__ALIASOF__", wxEmptyString );
}
else
{
LIB_PART* root = m_part->GetPart();
const wxString root_name = ( root ? root->GetName() : _( "Unknown" ) );
m_html.Replace(
"__ALIASOF__", wxString::Format( AliasOfFormat, EscapedHTML( root_name ) ) );
}
}
示例9: AddAliasOfPart
/* Add a new name to the alias list box
* New name cannot be the root name, and must not exists
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event )
{
wxString aliasname;
LIB_PART* component = m_Parent->GetCurPart();
PART_LIB* library = m_Parent->GetCurLib();
if( component == NULL )
return;
wxTextEntryDialog dlg( this, _( "New alias:" ), _( "Component Alias" ), aliasname );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
aliasname = dlg.GetValue( );
aliasname.Replace( wxT( " " ), wxT( "_" ) );
if( aliasname.IsEmpty() )
return;
if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND )
{
wxString msg;
msg.Printf( _( "Alias or component name <%s> already in use." ),
GetChars( aliasname ) );
DisplayError( this, msg );
return;
}
if( library && library->FindEntry( aliasname ) != NULL )
{
wxString msg;
msg.Printf( _( "Alias or component name <%s> already exists in library <%s>." ),
GetChars( aliasname ),
GetChars( library->GetName() ) );
DisplayError( this, msg );
return;
}
m_PartAliasListCtrl->Append( aliasname );
if( m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0 )
m_ButtonDeleteAllAlias->Enable( true );
m_ButtonDeleteOneAlias->Enable( true );
}
示例10: GetComponentFromUndoList
void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
{
if( GetScreen()->GetUndoCommandCount() <= 0 )
return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
LIB_PART* part = GetCurPart();
ITEM_PICKER wrapper( part, UR_LIBEDIT );
lastcmd->PushItem( wrapper );
GetScreen()->PushCommandToRedoList( lastcmd );
lastcmd = GetScreen()->PopCommandFromUndoList();
wrapper = lastcmd->PopItem();
part = (LIB_PART* ) wrapper.GetItem();
// Do not delete the previous part by calling SetCurPart( part ),
// which calls delete <previous part>.
// <previous part> is now put in redo list and is owned by this list.
// Just set the current part to the part which come from the undo list
m_my_part = part;
if( !part )
return;
if( !m_aliasName.IsEmpty() && !part->HasAlias( m_aliasName ) )
m_aliasName = part->GetName();
m_drawItem = NULL;
UpdateAliasSelectList();
UpdatePartSelectList();
SetShowDeMorgan( part->HasConversion() );
DisplayLibInfos();
DisplayCmpDoc();
OnModify();
m_canvas->Refresh();
}
示例11: makeLibParts
XNODE* NETLIST_EXPORTER_GENERIC::makeLibParts()
{
XNODE* xlibparts = node( wxT( "libparts" ) ); // auto_ptr
wxString sLibpart = wxT( "libpart" );
wxString sLib = wxT( "lib" );
wxString sPart = wxT( "part" );
wxString sAliases = wxT( "aliases" );
wxString sAlias = wxT( "alias" );
wxString sPins = wxT( "pins" ); // key for library component pins list
wxString sPin = wxT( "pin" ); // key for one library component pin descr
wxString sPinNum = wxT( "num" ); // key for one library component pin num
wxString sPinName = wxT( "name" ); // key for one library component pin name
wxString sPinType = wxT( "type" ); // key for one library component pin electrical type
wxString sName = wxT( "name" );
wxString sField = wxT( "field" );
wxString sFields = wxT( "fields" );
wxString sDescr = wxT( "description" );
wxString sDocs = wxT( "docs" );
wxString sFprints = wxT( "footprints" );
wxString sFp = wxT( "fp" );
LIB_PINS pinList;
LIB_FIELDS fieldList;
m_Libraries.clear();
for( std::set<LIB_PART*>::iterator it = m_LibParts.begin(); it!=m_LibParts.end(); ++it )
{
LIB_PART* lcomp = *it;
PART_LIB* library = lcomp->GetLib();
m_Libraries.insert( library ); // inserts component's library if unique
XNODE* xlibpart;
xlibparts->AddChild( xlibpart = node( sLibpart ) );
xlibpart->AddAttribute( sLib, library->GetLogicalName() );
xlibpart->AddAttribute( sPart, lcomp->GetName() );
if( lcomp->GetAliasCount() )
{
wxArrayString aliases = lcomp->GetAliasNames( false );
if( aliases.GetCount() )
{
XNODE* xaliases = node( sAliases );
xlibpart->AddChild( xaliases );
for( unsigned i=0; i<aliases.GetCount(); ++i )
{
xaliases->AddChild( node( sAlias, aliases[i] ) );
}
}
}
//----- show the important properties -------------------------
if( !lcomp->GetAlias( 0 )->GetDescription().IsEmpty() )
xlibpart->AddChild( node( sDescr, lcomp->GetAlias( 0 )->GetDescription() ) );
if( !lcomp->GetAlias( 0 )->GetDocFileName().IsEmpty() )
xlibpart->AddChild( node( sDocs, lcomp->GetAlias( 0 )->GetDocFileName() ) );
// Write the footprint list
if( lcomp->GetFootPrints().GetCount() )
{
XNODE* xfootprints;
xlibpart->AddChild( xfootprints = node( sFprints ) );
for( unsigned i=0; i<lcomp->GetFootPrints().GetCount(); ++i )
{
xfootprints->AddChild( node( sFp, lcomp->GetFootPrints()[i] ) );
}
}
//----- show the fields here ----------------------------------
fieldList.clear();
lcomp->GetFields( fieldList );
XNODE* xfields;
xlibpart->AddChild( xfields = node( sFields ) );
for( unsigned i=0; i<fieldList.size(); ++i )
{
if( !fieldList[i].GetText().IsEmpty() )
{
XNODE* xfield;
xfields->AddChild( xfield = node( sField, fieldList[i].GetText() ) );
xfield->AddAttribute( sName, fieldList[i].GetName(false) );
}
}
//----- show the pins here ------------------------------------
pinList.clear();
lcomp->GetPins( pinList, 0, 0 );
/* we must erase redundant Pins references in pinList
* These redundant pins exist because some pins
* are found more than one time when a component has
* multiple parts per package or has 2 representations (DeMorgan conversion)
* For instance, a 74ls00 has DeMorgan conversion, with different pin shapes,
* and therefore each pin appears 2 times in the list.
* Common pins (VCC, GND) can also be found more than once.
*/
//.........这里部分代码省略.........
示例12: OnExportPart
void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event )
{
wxString msg, title;
bool createLib = ( event.GetId() == ExportPartId ) ? false : true;
LIB_PART* part = GetCurPart();
if( !part )
{
DisplayError( this, _( "There is no component selected to save." ) );
return;
}
wxFileName fn = part->GetName().Lower();
fn.SetExt( SchematicLibraryFileExtension );
title = createLib ? _( "New Library" ) : _( "Export Component" );
wxFileDialog dlg( this, title, m_mruPath, fn.GetFullName(),
SchematicLibraryFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
fn = dlg.GetPath();
std::unique_ptr<PART_LIB> temp_lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, fn.GetFullPath() ) );
SaveOnePart( temp_lib.get() );
bool result = false;
try
{
FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
result = temp_lib.get()->Save( formatter );
}
catch( ... /* IO_ERROR ioe */ )
{
fn.MakeAbsolute();
msg = wxT( "Failed to create component library file " ) + fn.GetFullPath();
DisplayError( this, msg );
return;
}
try
{
wxFileName docFileName = fn;
docFileName.SetExt( DOC_EXT );
FILE_OUTPUTFORMATTER formatter( docFileName.GetFullPath() );
result = temp_lib.get()->SaveDocs( formatter );
}
catch( ... /* IO_ERROR ioe */ )
{
fn.MakeAbsolute();
msg = wxT( "Failed to create component library document file " ) + fn.GetFullPath();
DisplayError( this, msg );
return;
}
if( result )
m_mruPath = fn.GetPath();
if( result )
{
if( createLib )
{
msg.Printf( _( "'%s' - OK" ), GetChars( fn.GetFullPath() ) );
DisplayInfoMessage( this, _(
"This library will not be available until it is loaded by Eeschema.\n\n"
"Modify the Eeschema library configuration if you want to include it"
" as part of this project." ) );
}
else
{
msg.Printf( _( "'%s' - Export OK" ), GetChars( fn.GetFullPath() ) );
}
}
else // Error
{
msg.Printf( _( "Error creating '%s'" ), GetChars( fn.GetFullName() ) );
}
SetStatusText( msg );
}
示例13: OnPlotCurrentComponent
void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
{
wxString fullFileName;
wxString file_ext;
wxString mask;
LIB_PART* part = GetCurPart();
if( !part )
{
wxMessageBox( _( "No component" ) );
return;
}
switch( event.GetId() )
{
case ID_LIBEDIT_GEN_PNG_FILE:
{
bool fmt_is_jpeg = false; // could be selectable later. so keep this option.
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( part->GetName() );
fn.SetExt( file_ext );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( fullFileName.IsEmpty() )
return;
// calling wxYield is mandatory under Linux, after closing the file selector dialog
// to refresh the screen before creating the PNG or JPEG image from screen
wxYield();
CreatePNGorJPEGFile( fullFileName, fmt_is_jpeg );
}
break;
case ID_LIBEDIT_GEN_SVG_FILE:
{
file_ext = wxT( "svg" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( part->GetName() );
fn.SetExt( file_ext );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( fullFileName.IsEmpty() )
return;
PAGE_INFO pageSave = GetScreen()->GetPageSettings();
PAGE_INFO pageTemp = pageSave;
wxSize componentSize = part->GetUnitBoundingBox( m_unit, m_convert ).GetSize();
// Add a small margin to the plot bounding box
pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) );
pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) );
GetScreen()->SetPageSettings( pageTemp );
SVG_PlotComponent( fullFileName );
GetScreen()->SetPageSettings( pageSave );
}
break;
}
}
示例14: DeleteOnePart
void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
{
wxString cmp_name;
LIB_ALIAS* libEntry;
wxArrayString nameList;
wxString msg;
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
m_lastDrawItem = NULL;
m_drawItem = NULL;
LIB_PART *part = GetCurPart();
PART_LIB* lib = GetCurLib();
if( !lib )
{
SelectActiveLibrary();
lib = GetCurLib();
if( !lib )
{
DisplayError( this, _( "Please select a component library." ) );
return;
}
}
auto adapter( CMP_TREE_MODEL_ADAPTER::Create( Prj().SchLibs() ) );
wxString name = part ? part->GetName() : wxString( wxEmptyString );
adapter->SetPreselectNode( name, /* aUnit */ 0 );
adapter->ShowUnits( false );
adapter->AddLibrary( *lib );
wxString dialogTitle;
dialogTitle.Printf( _( "Delete Component (%u items loaded)" ), adapter->GetComponentsCount() );
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapter, m_convert );
if( dlg.ShowModal() == wxID_CANCEL )
{
return;
}
libEntry = dlg.GetSelectedAlias( NULL );
if( !libEntry )
{
msg.Printf( _( "Entry '%s' not found in library '%s'." ),
GetChars( libEntry->GetName() ),
GetChars( lib->GetName() ) );
DisplayError( this, msg );
return;
}
msg.Printf( _( "Delete component '%s' from library '%s' ?" ),
GetChars( libEntry->GetName() ),
GetChars( lib->GetName() ) );
if( !IsOK( this, msg ) )
return;
part = GetCurPart();
if( !part || !part->HasAlias( libEntry->GetName() ) )
{
lib->RemoveAlias( libEntry );
m_canvas->Refresh();
return;
}
// If deleting the current entry or removing one of the aliases for
// the current entry, sync the changes in the current entry as well.
if( GetScreen()->IsModify() && !IsOK( this, _(
"The component being deleted has been modified."
" All changes will be lost. Discard changes?" ) ) )
{
return;
}
LIB_ALIAS* nextEntry = lib->RemoveAlias( libEntry );
if( nextEntry != NULL )
{
if( LoadOneLibraryPartAux( nextEntry, lib ) )
Zoom_Automatique( false );
}
else
{
SetCurPart( NULL ); // delete CurPart
m_aliasName.Empty();
}
m_canvas->Refresh();
}
示例15: SaveOneSymbol
void LIB_EDIT_FRAME::SaveOneSymbol()
{
wxString msg;
PROJECT& prj = Prj();
SEARCH_STACK* search = prj.SchSearchS();
LIB_PART* part = GetCurPart();
if( !part || part->GetDrawItemList().empty() )
return;
wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
if( !default_path )
default_path = search->LastVisitedPath();
wxFileDialog dlg( this, _( "Export Symbol Drawings" ), default_path,
part->GetName(), SchematicSymbolFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxFileName fn = dlg.GetPath();
/* The GTK file chooser doesn't return the file extension added to
* file name so add it here. */
if( fn.GetExt().IsEmpty() )
fn.SetExt( SchematicSymbolFileExtension );
prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() );
msg.Printf( _( "Saving symbol in '%s'" ), GetChars( fn.GetPath() ) );
SetStatusText( msg );
wxString line;
// File header
line << wxT( LIBFILE_IDENT ) << wxT( " " ) << LIB_VERSION_MAJOR
<< wxT( "." ) << LIB_VERSION_MINOR << wxT( " SYMBOL " )
<< wxT( "Date: " ) << DateAndTime() << wxT( "\n" );
// Component name comment and definition.
line << wxT( "# SYMBOL " ) << part->GetName() << wxT( "\n#\nDEF " )
<< part->GetName() << wxT( " " );
if( !part->GetReferenceField().GetText().IsEmpty() )
line << part->GetReferenceField().GetText() << wxT( " " );
else
line << wxT( "~ " );
line << 0 << wxT( " " ) << part->GetPinNameOffset() << wxT( " " );
if( part->ShowPinNumbers() )
line << wxT( "Y " );
else
line << wxT( "N " );
if( part->ShowPinNames() )
line << wxT( "Y " );
else
line << wxT( "N " );
line << wxT( "1 0 N\n" );
try
{
FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
try
{
formatter.Print( 0, "%s", TO_UTF8( line ) );
part->GetReferenceField().Save( formatter );
part->GetValueField().Save( formatter );
formatter.Print( 0, "DRAW\n" );
LIB_ITEMS& drawList = part->GetDrawItemList();
for( LIB_ITEM& item : drawList )
{
if( item.Type() == LIB_FIELD_T )
continue;
// Don't save unused parts or alternate body styles.
if( m_unit && item.GetUnit() && ( item.GetUnit() != m_unit ) )
continue;
if( m_convert && item.GetConvert() && ( item.GetConvert() != m_convert ) )
continue;
item.Save( formatter );
}
formatter.Print( 0, "ENDDRAW\n" );
formatter.Print( 0, "ENDDEF\n" );
}
catch( const IO_ERROR& ioe )
{
msg.Printf( _( "An error occurred attempting to save symbol file '%s'" ),
GetChars( fn.GetFullPath() ) );
DisplayError( this, msg );
}
//.........这里部分代码省略.........