本文整理汇总了C++中LIB_PART类的典型用法代码示例。如果您正苦于以下问题:C++ LIB_PART类的具体用法?C++ LIB_PART怎么用?C++ LIB_PART使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LIB_PART类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
示例2: 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 ) ) );
}
示例3: GetCurPart
void LIB_EDIT_FRAME::copySelectedItems()
{
LIB_PART* part = GetCurPart();
if( !part )
return;
m_clipboard.ClearListAndDeleteItems(); // delete previous saved list, if exists
m_clipboard.SetLastCursorPosition( GetScreen()->m_BlockLocate.GetEnd() ); // store the reference point
for( LIB_ITEM& item : part->GetDrawItems() )
{
// We *do not* copy fields because they are unique for the whole component
// so skip them (do not duplicate) if they are flagged selected.
if( item.Type() == LIB_FIELD_T )
item.ClearFlags( SELECTED );
if( !item.IsSelected() )
continue;
// Do not clear the 'selected' flag. It is required to have items drawn when they are pasted.
LIB_ITEM* copy = (LIB_ITEM*) item.Clone();
copy->SetFlags( copy->GetFlags() | UR_TRANSIENT );
ITEM_PICKER picker( copy, UR_NEW );
m_clipboard.PushItem( picker );
}
}
示例4: _
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event )
{
wxString aliasname = m_PartAliasListCtrl->GetStringSelection();
if( aliasname.IsEmpty() )
return;
if( aliasname.CmpNoCase( m_Parent->GetAliasName() ) == 0 )
{
wxString msg;
msg.Printf( _( "Alias <%s> cannot be removed while it is being edited!" ),
GetChars( aliasname ) );
DisplayError( this, msg );
return;
}
m_PartAliasListCtrl->Delete( m_PartAliasListCtrl->GetSelection() );
LIB_PART* component = m_Parent->GetCurPart();
if( component )
component->RemoveAlias( aliasname );
if( m_PartAliasListCtrl->IsEmpty() )
{
m_ButtonDeleteAllAlias->Enable( false );
m_ButtonDeleteOneAlias->Enable( false );
}
}
示例5: AnnotatePowerSymbols
void SCH_SHEET_PATH::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference )
{
int ref = 1;
if( aReference )
ref = *aReference;
for( EDA_ITEM* item = LastDrawList(); item; item = item->Next() )
{
if( item->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( !part || !part->IsPower() )
continue;
wxString refstr = component->GetPrefix();
//str will be "C?" or so after the ClearAnnotation call.
while( refstr.Last() == '?' )
refstr.RemoveLast();
if( !refstr.StartsWith( wxT( "#" ) ) )
refstr = wxT( "#" ) + refstr;
refstr << wxT( "0" ) << ref;
component->SetRef( this, refstr );
ref++;
}
if( aReference )
*aReference = ref;
}
示例6: GetCurPart
void LIB_EDIT_FRAME::RebuildSymbolUnitsList()
{
if( m_partSelectBox == NULL )
return;
if( m_partSelectBox->GetCount() != 0 )
m_partSelectBox->Clear();
LIB_PART* part = GetCurPart();
if( !part || part->GetUnitCount() <= 1 )
{
m_unit = 1;
m_partSelectBox->Append( wxEmptyString );
}
else
{
for( int i = 0; i < part->GetUnitCount(); i++ )
{
wxString sub = LIB_PART::SubReference( i+1, false );
wxString unit = wxString::Format( _( "Unit %s" ), GetChars( sub ) );
m_partSelectBox->Append( unit );
}
}
// Ensure the current selected unit is compatible with
// the number of units of the current part:
if( part && part->GetUnitCount() < m_unit )
m_unit = 1;
m_partSelectBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 );
}
示例7: GetCurPart
bool LIB_EDIT_FRAME::SynchronizePins()
{
LIB_PART* part = GetCurPart();
return !m_editPinsPerPartOrConvert && ( part &&
( part->HasConversion() || part->IsMulti() ) );
}
示例8: GetCurPart
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;
}
示例9: 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() );
}
示例10: getSelectedSymbol
void LIB_VIEW_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
{
LIB_PART* part = getSelectedSymbol();
int unit_count = 1;
if( part )
unit_count = std::max( part->GetUnitCount(), 1 );
m_unitChoice->Enable( unit_count > 1 );
if( unit_count > 1 )
{
// rebuild the unit list if it is not suitable (after a new selection for instance)
if( unit_count != (int)m_unitChoice->GetCount() )
{
m_unitChoice->Clear();
for( int ii = 0; ii < unit_count; ii++ )
m_unitChoice->Append( wxString::Format( _( "Unit %c" ), 'A' + ii ) );
}
if( m_unitChoice->GetSelection() != std::max( 0, m_unit - 1 ) )
m_unitChoice->SetSelection( std::max( 0, m_unit - 1 ) );
}
else if( m_unitChoice->GetCount() )
m_unitChoice->Clear();
}
示例11: SetUnsetConvert
/*
* Set or clear the component alternate body style ( DeMorgan ).
*/
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{
LIB_PART* component = m_Parent->GetCurPart();
if( component == NULL || ( m_Parent->GetShowDeMorgan() == component->HasConversion() ) )
return false;
if( m_Parent->GetShowDeMorgan() )
{
if( !IsOK( this, _( "Add new pins for alternate body style ( DeMorgan ) to component?" ) ) )
return false;
}
else if( component->HasConversion() )
{
if( !IsOK( this, _( "Delete alternate body style (DeMorgan) draw items from component?" ) ) )
{
m_Parent->SetShowDeMorgan( true );
return false;
}
}
component->SetConversion( m_Parent->GetShowDeMorgan() );
m_Parent->OnModify();
return true;
}
示例12: GetScreen
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();
}
示例13: 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;
}
示例14: InitBasicPanel
/*
* create the basic panel for component properties editing
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
{
LIB_PART* component = m_Parent->GetCurPart();
if( m_Parent->GetShowDeMorgan() )
m_AsConvertButt->SetValue( true );
int maxUnits = ID_POPUP_SCH_SELECT_UNIT_CMP_MAX - ID_POPUP_SCH_SELECT_UNIT1;
m_SelNumberOfUnits->SetRange (1, maxUnits );
m_staticTextNbUnits->SetLabel( wxString::Format(
_( "Number of Units (max allowed %d)" ), maxUnits ) );
/* Default values for a new component. */
if( component == NULL )
{
m_ShowPinNumButt->SetValue( true );
m_ShowPinNameButt->SetValue( true );
m_PinsNameInsideButt->SetValue( true );
m_SelNumberOfUnits->SetValue( 1 );
m_SetSkew->SetValue( 40 );
m_OptionPower->SetValue( false );
m_OptionPartsLocked->SetValue( false );
return;
}
m_ShowPinNumButt->SetValue( component->ShowPinNumbers() );
m_ShowPinNameButt->SetValue( component->ShowPinNames() );
m_PinsNameInsideButt->SetValue( component->GetPinNameOffset() != 0 );
m_SelNumberOfUnits->SetValue( component->GetUnitCount() );
m_SetSkew->SetValue( component->GetPinNameOffset() );
m_OptionPower->SetValue( component->IsPower() );
m_OptionPartsLocked->SetValue( component->UnitsLocked() && component->GetUnitCount() > 1 );
}
示例15: Prj
LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent,
bool aEndPointOnly ) const
{
SCH_ITEM* item;
SCH_COMPONENT* component = NULL;
LIB_PIN* pin = NULL;
for( item = m_drawList.begin(); item; item = item->Next() )
{
if( item->Type() != SCH_COMPONENT_T )
continue;
component = (SCH_COMPONENT*) item;
if( aEndPointOnly )
{
pin = NULL;
LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() );
if( !part )
continue;
for( pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
{
// Skip items not used for this part.
if( component->GetUnit() && pin->GetUnit() &&
( pin->GetUnit() != component->GetUnit() ) )
continue;
if( component->GetConvert() && pin->GetConvert() &&
( pin->GetConvert() != component->GetConvert() ) )
continue;
if(component->GetPinPhysicalPosition( pin ) == aPosition )
break;
}
if( pin )
break;
}
else
{
pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T );
if( pin )
break;
}
}
if( pin && aComponent )
*aComponent = component;
return pin;
}