本文整理汇总了C++中LIB_ALIAS::GetPart方法的典型用法代码示例。如果您正苦于以下问题:C++ LIB_ALIAS::GetPart方法的具体用法?C++ LIB_ALIAS::GetPart怎么用?C++ LIB_ALIAS::GetPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LIB_ALIAS
的用法示例。
在下文中一共展示了LIB_ALIAS::GetPart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetHtmlDesc
void SetHtmlDesc()
{
wxString raw_desc;
if( m_part->IsRoot() )
{
raw_desc = m_part->GetDescription();
}
else
{
LIB_PART* root = m_part->GetPart();
for( size_t i = 0; i < root->GetAliasCount(); ++i )
{
LIB_ALIAS* alias = root->GetAlias( i );
if( alias && !alias->GetDescription().empty() )
{
raw_desc = alias->GetDescription();
break;
}
}
}
m_html.Replace( "__DESC__", wxString::Format( DescFormat, EscapedHTML( raw_desc ) ) );
}
示例2: OnImportPart
void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event )
{
wxString msg;
m_lastDrawItem = NULL;
wxString libName = getTargetLib();
if( !m_libMgr->LibraryExists( libName ) )
{
libName = SelectLibraryFromList();
if( !m_libMgr->LibraryExists( libName ) )
return;
}
wxFileDialog dlg( this, _( "Import Symbol" ), m_mruPath,
wxEmptyString, SchematicLibraryFileWildcard(),
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxFileName fn = dlg.GetPath();
m_mruPath = fn.GetPath();
wxArrayString symbols;
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
// TODO dialog to select the part to be imported if there is more than one
try
{
pi->EnumerateSymbolLib( symbols, fn.GetFullPath() );
}
catch( const IO_ERROR& ioe )
{
msg.Printf( _( "Cannot import symbol library \"%s\"." ), fn.GetFullPath() );
DisplayErrorMessage( this, msg, ioe.What() );
return;
}
if( symbols.empty() )
{
msg.Printf( _( "Symbol library file \"%s\" is empty." ), fn.GetFullPath() );
DisplayError( this, msg );
return;
}
wxString symbolName = symbols[0];
LIB_ALIAS* entry = pi->LoadSymbol( fn.GetFullPath(), symbolName );
if( m_libMgr->PartExists( symbols[0], libName ) )
{
msg.Printf( _( "Symbol \"%s\" already exists in library \"%s\"." ), symbolName, libName );
DisplayError( this, msg );
return;
}
m_libMgr->UpdatePart( entry->GetPart(), libName );
SyncLibraries( false );
loadPart( symbolName, libName, 1 );
}
示例3: 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 );
}
}
示例4: SchGetLibPart
LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib,
wxWindow* aParent, bool aShowErrorMsg )
{
LIB_ALIAS* alias = SchGetLibAlias( aLibId, aLibTable, aCacheLib, aParent, aShowErrorMsg );
return ( alias ) ? alias->GetPart() : NULL;
}
示例5: getSelectedSymbol
LIB_PART* LIB_VIEW_FRAME::getSelectedSymbol() const
{
LIB_PART* symbol = NULL;
LIB_ALIAS* alias = getSelectedAlias();
if( alias )
symbol = alias->GetPart();
return symbol;
}
示例6: SetHtmlFieldTable
void SetHtmlFieldTable()
{
wxString fieldtable;
LIB_FIELDS fields;
m_part->GetPart()->GetFields( fields );
for( auto const & field: fields )
{
fieldtable += GetHtmlFieldRow( field );
}
m_html.Replace( "__FIELDS__", fieldtable );
}
示例7: 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 ) ) );
}
}
示例8: 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 );
}
示例9: 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;
}
示例10: getSelectedAlias
const BOX2I LIB_VIEW_FRAME::GetDocumentExtents() const
{
LIB_ALIAS* alias = getSelectedAlias();
LIB_PART* part = alias ? alias->GetPart() : nullptr;
if( !part )
{
return BOX2I( VECTOR2I(-200, -200), VECTOR2I( 400, 400 ) );
}
else
{
EDA_RECT bbox = part->GetUnitBoundingBox( m_unit, m_convert );
return BOX2I( bbox.GetOrigin(), VECTOR2I( bbox.GetWidth(), bbox.GetHeight() ) );
}
}
示例11: BestZoom
double LIB_VIEW_FRAME::BestZoom()
{
LIB_PART* part = NULL;
double defaultLibraryZoom = 7.33;
if( m_libraryName.IsEmpty() || m_entryName.IsEmpty() )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
return defaultLibraryZoom;
}
LIB_ALIAS* alias = nullptr;
try
{
alias = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName );
}
catch( ... )
{
}
if( alias )
part = alias->GetPart();
if( !part )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
return defaultLibraryZoom;
}
EDA_RECT boundingBox = part->GetUnitBoundingBox( m_unit, m_convert );
double sizeX = (double) boundingBox.GetWidth();
double sizeY = (double) boundingBox.GetHeight();
wxPoint centre = boundingBox.Centre();
// Reserve a 20% margin around component bounding box.
double margin_scale_factor = 1.2;
return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
}
示例12: AddMenusForEditComponent
void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_LIBS* aLibs )
{
if( Component->Type() != SCH_COMPONENT_T )
{
wxASSERT( 0 );
return;
}
wxString msg;
LIB_PART* part = NULL;
LIB_ALIAS* libEntry = aLibs->FindLibraryEntry( Component->GetPartName() );
if( libEntry )
part = libEntry->GetPart();
wxMenu* editmenu = new wxMenu;
msg = AddHotkeyName( _( "Edit" ), g_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( editmenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_component_xpm ) );
if( part && part->IsNormal() )
{
msg = AddHotkeyName( _( "Value" ), g_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_VALUE );
AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_VALUE, msg,
KiBitmap( edit_comp_value_xpm ) );
msg = AddHotkeyName( _( "Reference" ), g_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_REFERENCE );
AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_REFERENCE, msg,
KiBitmap( edit_comp_ref_xpm ) );
msg = AddHotkeyName( _( "Footprint" ), g_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_FOOTPRINT );
AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_FOOTPRINT, msg,
KiBitmap( edit_comp_footprint_xpm ) );
}
if( part && part->HasConversion() )
AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP, _( "Convert" ),
KiBitmap( component_select_alternate_shape_xpm ) );
if( part && part->GetUnitCount() >= 2 )
{
wxMenu* sel_unit_menu = new wxMenu;
int ii;
for( ii = 0; ii < part->GetUnitCount(); ii++ )
{
wxString num_unit;
int unit = Component->GetUnit();
num_unit.Printf( _( "Unit %s" ), GetChars( LIB_PART::SubReference( ii + 1, false ) ) );
wxMenuItem * item = sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii,
num_unit, wxEmptyString,
wxITEM_CHECK );
if( unit == ii + 1 )
item->Check(true);
// The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_CMP_MAX
// See eeschema_id to modify this value.
if( ii >= (ID_POPUP_SCH_SELECT_UNIT_CMP_MAX - ID_POPUP_SCH_SELECT_UNIT1) )
break; // We have used all IDs for these submenus
}
AddMenuItem( editmenu, sel_unit_menu, ID_POPUP_SCH_SELECT_UNIT_CMP,
_( "Unit" ), KiBitmap( component_select_unit_xpm ) );
}
if( !Component->GetFlags() )
{
msg = AddHotkeyName( _( "Edit with Library Editor" ), g_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_WITH_LIBEDIT );
AddMenuItem( editmenu, ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP,
msg, KiBitmap( libedit_xpm ) );
}
AddMenuItem( PopMenu, editmenu, ID_SCH_EDIT_ITEM,
_( "Edit Component" ), KiBitmap( edit_component_xpm ) );
}
示例13: AddAliasList
void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
const wxArrayString& aAliasNameList,
PART_LIB* aOptionalLib )
{
TREE_NODE* const lib_node = new TREE_NODE( TREE_NODE::TYPE_LIB, NULL, NULL,
aNodeName, wxEmptyString, wxEmptyString );
m_nodes.push_back( lib_node );
for( const wxString& aName : aAliasNameList )
{
LIB_ALIAS* a;
if( aOptionalLib )
a = aOptionalLib->FindAlias( aName );
else
a = m_libs->FindLibraryAlias( aName, wxEmptyString );
if( a == NULL )
continue;
wxString search_text;
search_text = ( a->GetKeyWords().empty() ) ? wxT(" ") : a->GetKeyWords();
search_text += a->GetDescription();
wxString display_info;
if( !a->GetDescription().empty() )
{
// Preformatting. Unfortunately, the tree widget doesn't have columns
// and using tabs does not work very well or does not work at all
// (depending on OS versions). So indent with spaces in fixed-font width.
// The 98%-ile of length of strings found in the standard library is 15
// characters. Use this as a reasonable cut-off point for aligned indentation.
// For the few component names longer than that, the description is indented a
// bit more.
// The max found in the default lib would be 20 characters, but that creates too
// much visible whitespace for the less extreme component names.
const int COLUMN_DESCR_POS = 15;
const int indent_len = COLUMN_DESCR_POS - a->GetName().length();
display_info = wxString::Format( wxT( " %*s [ %s ]" ),
indent_len > 0 ? indent_len : 0, wxT( "" ),
GetChars( a->GetDescription() ) );
}
TREE_NODE* alias_node = new TREE_NODE( TREE_NODE::TYPE_ALIAS, lib_node,
a, a->GetName(), display_info, search_text );
m_nodes.push_back( alias_node );
if( a->GetPart()->IsMulti() ) // Add all units as sub-nodes.
{
for( int u = 1; u <= a->GetPart()->GetUnitCount(); ++u )
{
wxString unitName = _("Unit");
unitName += wxT( " " ) + LIB_PART::SubReference( u, false );
TREE_NODE* unit_node = new TREE_NODE( TREE_NODE::TYPE_UNIT,
alias_node, a,
unitName,
wxEmptyString, wxEmptyString );
unit_node->Unit = u;
m_nodes.push_back( unit_node );
}
}
++m_components_added;
}
}
示例14: OnExportPart
void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event )
{
wxString msg, title;
LIB_PART* part = getTargetPart();
if( !part )
{
DisplayError( this, _( "There is no symbol selected to save." ) );
return;
}
wxFileName fn;
fn.SetName( part->GetName().Lower() );
fn.SetExt( SchematicLibraryFileExtension );
wxFileDialog dlg( this, _( "Export Symbol" ), m_mruPath, fn.GetFullName(),
SchematicLibraryFileWildcard(), wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
fn = dlg.GetPath();
fn.MakeAbsolute();
LIB_PART* old_part = NULL;
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
if( fn.FileExists() )
{
try
{
LIB_ALIAS* alias = pi->LoadSymbol( fn.GetFullPath(), part->GetName() );
if( alias )
old_part = alias->GetPart();
}
catch( const IO_ERROR& ioe )
{
msg.Printf( _( "Error occurred attempting to load symbol library file \"%s\"" ),
fn.GetFullPath() );
DisplayErrorMessage( this, msg, ioe.What() );
return;
}
if( old_part )
{
msg.Printf( _( "Symbol \"%s\" already exists in \"%s\"." ),
part->GetName(),
fn.GetFullName() );
KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) );
errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( errorDlg.ShowModal() == wxID_CANCEL )
return;
}
}
if( fn.Exists() && !fn.IsDirWritable() )
{
msg.Printf( _( "Write permissions are required to save library \"%s\"." ), fn.GetFullPath() );
DisplayError( this, msg );
return;
}
try
{
if( !fn.FileExists() )
pi->CreateSymbolLib( fn.GetFullPath() );
pi->SaveSymbol( fn.GetFullPath(), new LIB_PART( *part ) );
}
catch( const IO_ERROR& ioe )
{
msg = _( "Failed to create symbol library file " ) + fn.GetFullPath();
DisplayErrorMessage( this, msg, ioe.What() );
msg.Printf( _( "Error creating symbol library \"%s\"" ), fn.GetFullName() );
SetStatusText( msg );
return;
}
m_mruPath = fn.GetPath();
m_lastDrawItem = NULL;
SetDrawItem( NULL );
msg.Printf( _( "Symbol \"%s\" saved in library \"%s\"" ), part->GetName(), fn.GetFullPath() );
SetStatusText( msg );
// See if the user wants it added to a library table (global or project)
SYMBOL_LIB_TABLE* libTable = selectSymLibTable( true );
if( libTable )
{
if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
{
DisplayError( this, _( "Could not open the library file." ) );
return;
//.........这里部分代码省略.........
示例15: updateSelection
bool DIALOG_CHOOSE_COMPONENT::updateSelection()
{
int unit = 0;
LIB_ALIAS* selection = m_search_container->GetSelectedAlias( &unit );
m_componentView->Refresh();
m_componentDetails->Clear();
if( selection == NULL )
return false;
m_componentDetails->Freeze();
wxFont font_normal = m_componentDetails->GetFont();
wxFont font_bold = m_componentDetails->GetFont();
font_bold.SetWeight( wxFONTWEIGHT_BOLD );
wxTextAttr headline_attribute;
headline_attribute.SetFont( font_bold );
wxTextAttr text_attribute;
text_attribute.SetFont( font_normal );
const wxString name = selection->GetName();
if ( !name.empty() )
{
m_componentDetails->SetDefaultStyle( headline_attribute );
m_componentDetails->AppendText( name );
}
const wxString description = selection->GetDescription();
if( !description.empty() )
{
if ( !m_componentDetails->IsEmpty() )
m_componentDetails->AppendText( wxT( "\n\n" ) );
m_componentDetails->SetDefaultStyle( headline_attribute );
m_componentDetails->AppendText( _( "Description\n" ) );
m_componentDetails->SetDefaultStyle( text_attribute );
m_componentDetails->AppendText( description );
}
const wxString keywords = selection->GetKeyWords();
if( !keywords.empty() )
{
if ( !m_componentDetails->IsEmpty() )
m_componentDetails->AppendText( wxT( "\n\n" ) );
m_componentDetails->SetDefaultStyle( headline_attribute );
m_componentDetails->AppendText( _( "Keywords\n" ) );
m_componentDetails->SetDefaultStyle( text_attribute );
m_componentDetails->AppendText( keywords );
}
if ( !selection->IsRoot() )
{
LIB_PART* root_part = selection->GetPart();
const wxString root_component_name( root_part ? root_part->GetName() : _( "Unknown" ) );
if ( !m_componentDetails->IsEmpty() )
m_componentDetails->AppendText( wxT( "\n\n" ) );
m_componentDetails->SetDefaultStyle( headline_attribute );
m_componentDetails->AppendText( _( "Alias of " ) );
m_componentDetails->SetDefaultStyle( text_attribute );
m_componentDetails->AppendText( root_component_name );
}
m_componentDetails->SetInsertionPoint( 0 ); // scroll up.
m_componentDetails->Thaw();
return true;
}