本文整理汇总了C++中LIB_ITEM::SetParent方法的典型用法代码示例。如果您正苦于以下问题:C++ LIB_ITEM::SetParent方法的具体用法?C++ LIB_ITEM::SetParent怎么用?C++ LIB_ITEM::SetParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LIB_ITEM
的用法示例。
在下文中一共展示了LIB_ITEM::SetParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pasteClipboard
void LIB_EDIT_FRAME::pasteClipboard( const wxPoint& aOffset )
{
LIB_PART* part = GetCurPart();
if( !part || m_clipboard.GetCount() == 0 )
return;
for( unsigned int i = 0; i < m_clipboard.GetCount(); i++ )
{
// Append a copy to the current part, so the clipboard buffer might be pasted multiple times
LIB_ITEM* item = (LIB_ITEM*) m_clipboard.GetItem( i )->Clone();
item->SetParent( part );
item->SetSelected();
item->SetUnit( GetUnit() );
part->AddDrawItem( item );
}
BlockMoveSelectedItems( aOffset, GetCurPart(), &GetScreen()->m_BlockLocate );
RebuildView();
GetCanvas()->Refresh();
OnModify();
}
示例2: LoadOneSymbol
void LIB_EDIT_FRAME::LoadOneSymbol()
{
LIB_PART* part = GetCurPart();
// Exit if no library entry is selected or a command is in progress.
if( !part || ( m_drawItem && m_drawItem->GetFlags() ) )
return;
PROJECT& prj = Prj();
SEARCH_STACK* search = prj.SchSearchS();
m_canvas->SetIgnoreMouseEvents( true );
wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
if( !default_path )
default_path = search->LastVisitedPath();
wxFileDialog dlg( this, _( "Import Symbol Drawings" ), default_path,
wxEmptyString, SchematicSymbolFileWildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return;
SetCrossHairPosition( wxPoint( 0, 0 ) );
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
wxString filename = dlg.GetPath();
prj.SetRString( PROJECT::SCH_LIB_PATH, filename );
std::unique_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_SYMBOL, filename ) );
wxString err;
if( !lib->Load( err ) )
{
wxString msg = wxString::Format( _(
"Error '%s' occurred loading part file '%s'." ),
GetChars( err ),
GetChars( filename )
);
DisplayError( this, msg );
return;
}
if( lib->IsEmpty() )
{
wxString msg = wxString::Format( _(
"No parts found in part file '%s'." ),
GetChars( filename )
);
DisplayError( this, msg );
return;
}
if( lib->GetCount() > 1 )
{
wxString msg = wxString::Format( _(
"More than one part in part file '%s'." ),
GetChars( filename )
);
wxMessageBox( msg, _( "Warning" ), wxOK | wxICON_EXCLAMATION, this );
}
LIB_PART* first = lib->GetFirstEntry()->GetPart();
LIB_ITEMS& drawList = first->GetDrawItemList();
for( LIB_ITEM& item : drawList )
{
if( item.Type() == LIB_FIELD_T )
continue;
if( item.GetUnit() )
item.SetUnit( m_unit );
if( item.GetConvert() )
item.SetConvert( m_convert );
item.SetFlags( IS_NEW | SELECTED );
LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
newItem->SetParent( part );
part->AddDrawItem( newItem );
}
part->RemoveDuplicateDrawItems();
part->ClearSelectedItems();
OnModify();
m_canvas->Refresh();
}