本文整理汇总了C++中LIB_ID::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ LIB_ID::IsValid方法的具体用法?C++ LIB_ID::IsValid怎么用?C++ LIB_ID::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LIB_ID
的用法示例。
在下文中一共展示了LIB_ID::IsValid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SyncLibraries
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 );
}
}
}
示例2: retainLastFootprint
void FOOTPRINT_EDIT_FRAME::retainLastFootprint()
{
LIB_ID id = GetLoadedFPID();
if( id.IsValid() )
{
Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME, id.GetLibNickname() );
Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME, id.GetLibItemName() );
}
}
示例3: DeleteModuleFromLibrary
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aConfirm )
{
if( !aFPID.IsValid() )
return false;
wxString nickname = aFPID.GetLibNickname();
wxString fpname = aFPID.GetLibItemName();
// Legacy libraries are readable, but modifying legacy format is not allowed
// So prompt the user if he try to delete a footprint from a legacy lib
wxString libfullname = Prj().PcbFootprintLibs()->FindRow( nickname )->GetFullURI();
if( IO_MGR::GuessPluginTypeFromLibPath( libfullname ) == IO_MGR::LEGACY )
{
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_DELETE );
return false;
}
if( !Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname ) )
{
wxString msg = wxString::Format( _( "Library \"%s\" is read only" ), nickname );
DisplayError( this, msg );
return false;
}
// Confirmation
wxString msg = wxString::Format( FMT_OK_DELETE, fpname.GetData(), nickname.GetData() );
if( aConfirm && !IsOK( this, msg ) )
return false;
try
{
Prj().PcbFootprintLibs()->FootprintDelete( nickname, fpname );
}
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.What() );
return false;
}
msg.Printf( FMT_MOD_DELETED, fpname.GetData(), nickname.GetData() );
SetStatusText( msg );
return true;
}
示例4: SelectComponentFromLibBrowser
SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser(
wxTopLevelWindow* aParent,
const SCHLIB_FILTER* aFilter, const LIB_ID& aPreselectedLibId,
int aUnit, int aConvert )
{
// Close any open non-modal Lib browser, and open a new one, in "modal" mode:
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
if( viewlibFrame )
viewlibFrame->Destroy();
viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, true, aParent );
if( aFilter )
viewlibFrame->SetFilter( aFilter );
if( aPreselectedLibId.IsValid() )
{
viewlibFrame->SetSelectedLibrary( aPreselectedLibId.GetLibNickname() );
viewlibFrame->SetSelectedComponent( aPreselectedLibId.GetLibItemName() );
}
viewlibFrame->SetUnitAndConvert( aUnit, aConvert );
viewlibFrame->Refresh();
COMPONENT_SELECTION sel;
wxString symbol = sel.LibId.Format();
if( viewlibFrame->ShowModal( &symbol, aParent ) )
{
LIB_ID id;
if( id.Parse( symbol, LIB_ID::ID_SCH ) == -1 )
sel.LibId = id;
sel.Unit = viewlibFrame->GetUnit();
sel.Convert = viewlibFrame->GetConvert();
}
viewlibFrame->Destroy();
return sel;
}
示例5: SyncLibraryTree
void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
{
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
LIB_ID target = getTargetFPID();
bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
// Sync FOOTPRINT_INFO list to the libraries on disk
if( aProgress )
{
WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
progressReporter.Show( false );
}
else
{
GFootprintList.ReadFootprintFiles( fpTable, NULL, NULL );
}
// Sync the LIB_TREE to the FOOTPRINT_INFO list
adapter->Sync();
m_treePane->GetLibTree()->Unselect();
m_treePane->Regenerate();
if( target.IsValid() )
{
if( adapter->FindItem( target ) )
{
if( targetSelected )
m_treePane->GetLibTree()->SelectLibId( target );
else
m_treePane->GetLibTree()->CenterLibId( target );
}
else
{
// Try to focus on parent
target.SetLibItemName( wxEmptyString );
m_treePane->GetLibTree()->CenterLibId( target );
}
}
}
示例6: ShowModal
bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
{
if( aFootprint && !aFootprint->IsEmpty() )
{
wxString msg;
LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
LIB_ID fpid;
fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
if( fpid.IsValid() )
{
wxString nickname = fpid.GetLibNickname();
if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
{
msg.sprintf( _( "The current configuration does not include a library with the\n"
"nickname \"%s\". Use Manage Footprint Libraries\n"
"to edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
}
else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
{
msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
"in the current configuration. Use Manage Footprint Libraries to\n"
"edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
}
else
{
setCurNickname( nickname );
setCurFootprintName( fpid.GetLibItemName() );
ReCreateFootprintList();
}
SelectAndViewFootprint( NEW_PART );
}
}
return KIWAY_PLAYER::ShowModal( aFootprint, aParent );
}
示例7: updateTitle
void FOOTPRINT_EDIT_FRAME::updateTitle()
{
wxString title = _( "Footprint Editor" );
LIB_ID fpid = GetLoadedFPID();
bool writable = true;
if( IsCurrentFPFromBoard() )
{
title += wxString::Format( wxT( " \u2014 %s [from %s.%s]" ),
GetBoard()->m_Modules->GetReference(),
Prj().GetProjectName(), PcbFileExtension );
}
else if( fpid.IsValid() )
{
try
{
writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
}
catch( const IO_ERROR& )
{
// best efforts...
}
// Note: don't used GetLoadedFPID(); footprint name may have been edited
title += wxString::Format( wxT( " \u2014 %s %s" ),
FROM_UTF8( GetBoard()->m_Modules->GetFPID().Format().c_str() ),
writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) );
}
else if( !fpid.GetLibItemName().empty() )
{
// Note: don't used GetLoadedFPID(); footprint name may have been edited
title += wxString::Format( wxT( " \u2014 %s %s" ),
FROM_UTF8( GetBoard()->m_Modules->GetFPID().GetLibItemName().c_str() ),
_( "[Unsaved]" ) );
}
SetTitle( title );
}
示例8: ShowModal
bool LIB_VIEW_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
{
if( aSymbol && !aSymbol->IsEmpty() )
{
wxString msg;
LIB_TABLE* libTable = Prj().SchSymbolLibTable();
LIB_ID libid;
libid.Parse( *aSymbol, LIB_ID::ID_SCH, true );
if( libid.IsValid() )
{
wxString nickname = libid.GetLibNickname();
if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
{
msg.sprintf( _( "The current configuration does not include a library with the\n"
"nickname \"%s\". Use Manage Symbol Libraries\n"
"to edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Symbol library not found." ), msg );
}
else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
{
msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
"in the current configuration. Use Manage Symbol Libraries to\n"
"edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
}
else
{
SetSelectedLibrary( libid.GetLibNickname() );
SetSelectedComponent( libid.GetLibItemName() );
}
}
}
return KIWAY_PLAYER::ShowModal( aSymbol, aParent );
}
示例9: SelectComponentFromLibTree
SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibTree(
const SCHLIB_FILTER* aFilter,
std::vector<COMPONENT_SELECTION>& aHistoryList,
bool aAllowBrowser,
int aUnit,
int aConvert,
bool aShowFootprints,
const LIB_ID* aHighlight,
bool aAllowFields )
{
std::unique_lock<std::mutex> dialogLock( DIALOG_CHOOSE_COMPONENT::g_Mutex, std::defer_lock );
wxString dialogTitle;
SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
// One CHOOSE_COMPONENT dialog at a time. User probaby can't handle more anyway.
if( !dialogLock.try_lock() )
return COMPONENT_SELECTION();
auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( libs ) );
auto adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
bool loaded = false;
if( aFilter )
{
const wxArrayString& liblist = aFilter->GetAllowedLibList();
for( unsigned ii = 0; ii < liblist.GetCount(); ii++ )
{
if( libs->HasLibrary( liblist[ii], true ) )
{
loaded = true;
adapter->AddLibrary( liblist[ii] );
}
}
adapter->AssignIntrinsicRanks();
if( aFilter->GetFilterPowerParts() )
adapter->SetFilter( SYMBOL_TREE_MODEL_ADAPTER::CMP_FILTER_POWER );
}
std::vector< LIB_TREE_ITEM* > history_list;
for( auto const& i : aHistoryList )
{
LIB_ALIAS* alias = GetLibAlias( i.LibId );
if( alias )
history_list.push_back( alias );
}
adapter->DoAddLibrary( "-- " + _( "Recently Used" ) + " --", wxEmptyString, history_list, true );
if( !aHistoryList.empty() )
adapter->SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit );
const std::vector< wxString > libNicknames = libs->GetLogicalLibs();
if( !loaded )
adapter->AddLibraries( libNicknames, this );
if( aHighlight && aHighlight->IsValid() )
adapter->SetPreselectNode( *aHighlight, /* aUnit */ 0 );
if( adapter->GetFilter() == SYMBOL_TREE_MODEL_ADAPTER::CMP_FILTER_POWER )
dialogTitle.Printf( _( "Choose Power Symbol (%d items loaded)" ), adapter->GetItemCount() );
else
dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), adapter->GetItemCount() );
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapterPtr, aConvert,
aAllowFields, aShowFootprints, aAllowBrowser );
if( dlg.ShowQuasiModal() == wxID_CANCEL )
return COMPONENT_SELECTION();
COMPONENT_SELECTION sel;
LIB_ID id = dlg.GetSelectedLibId( &sel.Unit );
if( dlg.IsExternalBrowserSelected() ) // User requested component browser.
{
sel = SelectComponentFromLibBrowser( this, aFilter, id, sel.Unit, sel.Convert );
id = sel.LibId;
}
if( !id.IsValid() ) // Dialog closed by OK button,
// or the selection by lib browser was requested,
// but no symbol selected
return COMPONENT_SELECTION();
if( sel.Unit == 0 )
sel.Unit = 1;
sel.Fields = dlg.GetFields();
sel.LibId = id;
if( sel.LibId.IsValid() )
{
aHistoryList.erase(
std::remove_if(
aHistoryList.begin(),
//.........这里部分代码省略.........