本文整理汇总了C++中LIB_ID类的典型用法代码示例。如果您正苦于以下问题:C++ LIB_ID类的具体用法?C++ LIB_ID怎么用?C++ LIB_ID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LIB_ID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCopyCutPart
void LIB_EDIT_FRAME::OnCopyCutPart( wxCommandEvent& aEvent )
{
int dummyUnit;
LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit );
LIB_PART* part = m_libMgr->GetBufferedPart( libId.GetLibItemName(), libId.GetLibNickname() );
if( !part )
return;
STRING_FORMATTER formatter;
SCH_LEGACY_PLUGIN::FormatPart( part, formatter );
auto clipboard = wxTheClipboard;
wxClipboardLocker clipboardLock( clipboard );
if( !clipboardLock || !clipboard->IsOpened() )
return;
auto data = new wxTextDataObject( wxString( formatter.GetString().c_str(), wxConvUTF8 ) );
clipboard->SetData( data );
clipboard->Flush();
if( aEvent.GetId() == ID_LIBEDIT_CUT_PART )
OnRemovePart( aEvent );
}
示例2: GetLoadedFPID
void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
{
wxString fullFileName;
LIB_ID id = GetLoadedFPID();
if( id.empty() )
{
wxMessageBox( _( "No footprint selected." ) );
return;
}
wxFileName fn( id.GetLibItemName() );
fn.SetExt( "png" );
wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().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();
saveCanvasImageToFile( dlg.GetPath() );
}
示例3: isCurrentPart
bool LIB_EDIT_FRAME::isCurrentPart( const LIB_ID& aLibId ) const
{
// This will return the root part of any alias
LIB_PART* part = m_libMgr->GetBufferedPart( aLibId.GetLibItemName(), aLibId.GetLibNickname() );
// Now we can compare the libId of the current part and the root part
return ( part && GetCurPart() && part->GetLibId() == GetCurPart()->GetLibId() );
}
示例4: wxASSERT
int SCH_SCREENS::ChangeSymbolLibNickname( const wxString& aFrom, const wxString& aTo )
{
SCH_COMPONENT* symbol;
SCH_ITEM* item;
SCH_ITEM* nextItem;
SCH_SCREEN* screen;
int cnt = 0;
for( screen = GetFirst(); screen; screen = GetNext() )
{
for( item = screen->GetDrawItems(); item; item = nextItem )
{
nextItem = item->Next();
if( item->Type() != SCH_COMPONENT_T )
continue;
symbol = dynamic_cast< SCH_COMPONENT* >( item );
wxASSERT( symbol );
if( symbol->GetLibId().GetLibNickname() != aFrom )
continue;
LIB_ID id = symbol->GetLibId();
id.SetLibNickname( aTo );
symbol->SetLibId( id );
cnt++;
}
}
return cnt;
}
示例5: getTargetFPID
void FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs( wxUpdateUIEvent& aEvent )
{
LIB_ID libId = getTargetFPID();
const wxString& libName = libId.GetLibNickname();
const wxString& partName = libId.GetLibItemName();
aEvent.Enable( !libName.IsEmpty() || !partName.IsEmpty() );
}
示例6: progressDlg
void LIB_EDIT_FRAME::SyncLibraries( bool aShowProgress )
{
LIB_ID selected;
if( m_treePane )
selected = m_treePane->GetLibTree()->GetSelectedLibId();
if( aShowProgress )
{
wxProgressDialog progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
m_libMgr->GetAdapter()->GetLibrariesCount(), this );
m_libMgr->Sync( true, [&]( int progress, int max, const wxString& libName )
{
progressDlg.Update( progress, wxString::Format( _( "Loading library \"%s\"" ), libName ) );
} );
}
else
{
m_libMgr->Sync( true );
}
if( m_treePane )
{
wxDataViewItem found;
if( selected.IsValid() )
{
// Check if the previously selected item is still valid,
// if not - it has to be unselected to prevent crash
found = m_libMgr->GetAdapter()->FindItem( selected );
if( !found )
m_treePane->GetLibTree()->Unselect();
}
m_treePane->Regenerate();
// Try to select the parent library, in case the part is not found
if( !found && selected.IsValid() )
{
selected.SetLibItemName( "" );
found = m_libMgr->GetAdapter()->FindItem( selected );
if( found )
m_treePane->GetLibTree()->SelectLibId( selected );
}
// If no selection, see if there's a current part to centre
if( !selected.IsValid() && GetCurPart() )
{
LIB_ID current( GetCurLib(), GetCurPart()->GetName() );
m_treePane->GetLibTree()->CenterLibId( current );
}
}
}
示例7: getTargetLibId
LIB_ID LIB_EDIT_FRAME::getTargetLibId() const
{
LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId();
wxString nickname = id.GetLibNickname();
if( nickname.IsEmpty() && GetCurPart() )
id = GetCurPart()->GetLibId();
return id;
}
示例8: getTargetFPID
LIB_ID FOOTPRINT_EDIT_FRAME::getTargetFPID() const
{
LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId();
wxString nickname = id.GetLibNickname();
if( nickname.IsEmpty() )
return GetLoadedFPID();
return id;
}
示例9: LIB_PART
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;
}
示例10: ConvertPart
void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent, wxDC* DC )
{
if( !aComponent )
return;
LIB_ID id = aComponent->GetLibId();
LIB_PART* part = GetLibPart( id );
if( part )
{
wxString msg;
if( !part->HasConversion() )
{
msg.Printf( _( "No alternate body style found for symbol \"%s\" in library \"%s\"." ),
id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
DisplayError( this, msg );
return;
}
STATUS_FLAGS flags = aComponent->GetFlags();
if( aComponent->GetFlags() )
aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
else
aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
aComponent->SetConvert( aComponent->GetConvert() + 1 );
// ensure m_Convert = 0, 1 or 2
// 0 and 1 = shape 1 = not converted
// 2 = shape 2 = first converted shape
// > 2 is not used but could be used for more shapes
// like multiple shapes for a programmable component
// When m_Convert = val max, return to the first shape
if( aComponent->GetConvert() > 2 )
aComponent->SetConvert( 1 );
// The alternate symbol may cause a change in the connection status so test the
// connections so the connection indicators are drawn correctly.
GetScreen()->TestDanglingEnds();
aComponent->ClearFlags();
aComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert())
/* Redraw the component in the new position. */
if( aComponent->IsMoving() )
aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
else
aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
OnModify();
}
}
示例11: LoadComponentAndSelectLib
bool LIB_EDIT_FRAME::LoadComponentAndSelectLib( const LIB_ID& aLibId, int aUnit, int aConvert )
{
if( GetScreen()->IsModify() && GetCurPart() )
{
if( !HandleUnsavedChanges( this, _( "The current symbol has been modified. Save changes?" ),
[&]()->bool { return saveCurrentPart(); } ) )
{
return false;
}
}
SelectActiveLibrary( aLibId.GetLibNickname() );
return LoadComponentFromCurrentLib( aLibId.GetLibItemName(), aUnit, aConvert );
}
示例12: getTargetLibId
void LIB_EDIT_FRAME::OnSaveAs( wxCommandEvent& aEvent )
{
LIB_ID libId = getTargetLibId();
const wxString& libName = libId.GetLibNickname();
const wxString& partName = libId.GetLibItemName();
if( partName.IsEmpty() )
saveLibrary( libName, true );
else
savePartAs();
m_treePane->Refresh();
refreshSchematic();
}
示例13: setCurFootprintName
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( getCurFootprintName().CmpNoCase( name ) != 0 )
{
setCurFootprintName( name );
// Delete the current footprint (MUST reset tools first)
GetToolManager()->ResetTools( TOOL_BASE::MODEL_RELOAD );
SetCurItem( nullptr );
GetBoard()->m_Modules.DeleteAll();
LIB_ID id;
id.SetLibNickname( getCurNickname() );
id.SetLibItemName( getCurFootprintName() );
try
{
GetBoard()->Add( loadFootprint( id ) );
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format(
_( "Could not load footprint \"%s\" from library \"%s\".\n\nError %s." ),
GetChars( getCurFootprintName() ),
GetChars( getCurNickname() ),
GetChars( ioe.What() ) );
DisplayError( this, msg );
}
UpdateTitle();
updateView();
m_canvas->Refresh();
Update3D_Frame();
}
}
示例14: ConvertPart
void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent )
{
if( !aComponent )
return;
LIB_ID id = aComponent->GetLibId();
LIB_PART* part = GetLibPart( id );
if( part )
{
wxString msg;
if( !part->HasConversion() )
{
msg.Printf( _( "No alternate body style found for symbol \"%s\" in library \"%s\"." ),
id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
DisplayError( this, msg );
return;
}
STATUS_FLAGS savedFlags = aComponent->GetFlags();
aComponent->SetConvert( aComponent->GetConvert() + 1 );
// ensure m_Convert = 1 or 2
// 1 = shape 1 = not converted
// 2 = shape 2 = first converted shape
// > 2 is not used but could be used for more shapes
// like multiple shapes for a programmable component
// When m_Convert = val max, return to the first shape
if( aComponent->GetConvert() > LIB_ITEM::LIB_CONVERT::DEMORGAN )
aComponent->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
// The alternate symbol may cause a change in the connection status so test the
// connections so the connection indicators are drawn correctly.
aComponent->UpdatePins();
TestDanglingEnds();
aComponent->ClearFlags();
aComponent->SetFlags( savedFlags ); // Restore m_Flags (modified by SetConvert())
// If selected make sure all the now-included pins are selected
if( aComponent->IsSelected() )
m_toolManager->RunAction( EE_ACTIONS::addItemToSel, true, aComponent );
RefreshItem( aComponent );
OnModify();
}
}
示例15: getTargetPart
LIB_PART* LIB_EDIT_FRAME::getTargetPart() const
{
LIB_ALIAS* alias = nullptr;
if( m_treePane->GetLibTree()->IsMenuActive() )
{
LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId();
alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
}
else if( LIB_PART* part = GetCurPart() )
{
alias = part->GetAlias( 0 );
}
return alias ? alias->GetPart() : nullptr;
}