本文整理汇总了C++中SCH_COMPONENT类的典型用法代码示例。如果您正苦于以下问题:C++ SCH_COMPONENT类的具体用法?C++ SCH_COMPONENT怎么用?C++ SCH_COMPONENT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SCH_COMPONENT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFullyQualifiedText
bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
{
bool isReplaced;
wxString text = GetFullyQualifiedText();
if( m_id == REFERENCE )
{
wxCHECK_MSG( aAuxData != NULL, false,
wxT( "Cannot replace reference designator without valid sheet path." ) );
wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
wxT( "Invalid replace component reference field call." ) ) ;
SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
wxCHECK_MSG( component != NULL, false,
wxT( "No component associated with field" ) + text );
text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
// if( component->GetUnitCount() > 1 )
// text << LIB_PART::SubReference( component->GetUnit() );
isReplaced = EDA_ITEM::Replace( aSearchData, text );
if( isReplaced )
component->SetRef( ((SCH_SHEET_PATH*) aAuxData)->Last(), text );
}
else
{
isReplaced = EDA_ITEM::Replace( aSearchData, m_Text );
}
return isReplaced;
}
示例2: GetComponents
void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols )
{
// Search to sheet path number:
int sheetnumber = 1; // 1 = root
SCH_SHEET_LIST sheetList;
for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext(), sheetnumber++ )
{
if( Cmp( *path ) == 0 )
break;
}
for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
{
if( item->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
// Skip pseudo components, which have a reference starting with #. This mainly
// affects power symbols.
if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
continue;
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( part )
{
SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
reference.SetSheetNumber( sheetnumber );
aReferences.AddItem( reference );
}
}
}
}
示例3: GetText
bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
{
bool isReplaced;
wxString text = GetText();
if( m_id == REFERENCE && aAuxData != NULL )
{
wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
wxT( "Invalid replace component reference field call." ) ) ;
SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
wxCHECK_MSG( component != NULL, false,
wxT( "No component associated with field" ) + text );
text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
if( component->GetPartCount() > 1 )
text << LIB_COMPONENT::ReturnSubReference( component->GetUnit() );
isReplaced = EDA_ITEM::Replace( aSearchData, text );
if( isReplaced )
component->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
}
else
{
isReplaced = EDA_ITEM::Replace( aSearchData, m_Text );
}
return isReplaced;
}
示例4: Kiway
void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event )
{
if( GetCurPart() )
{
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
if( schframe == NULL ) // happens when the schematic editor is not active (or closed)
{
DisplayErrorMessage( this, _( "No schematic currently open." ) );
return;
}
SCH_COMPONENT* component = new SCH_COMPONENT( *GetCurPart(), GetCurPart()->GetLibId(),
g_CurrentSheet, GetUnit(), GetConvert() );
// Be sure the link to the corresponding LIB_PART is OK:
component->Resolve( *Prj().SchSymbolLibTable() );
if( schframe->GetAutoplaceFields() )
component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
schframe->Raise();
schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, component );
}
}
示例5: GetScreen
void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
{
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T,
wxT( "Cannot change orientation of invalid schematic item." ) );
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
m_canvas->MoveCursorToCrossHair();
if( item->GetFlags() == 0 )
SetUndoItem( item );
INSTALL_UNBUFFERED_DC( dc, m_canvas );
component->SetOrientation( aOrientation );
m_canvas->CrossHairOn( &dc );
if( item->GetFlags() == 0 )
{
addCurrentItemToList();
SchematicCleanUp( true );
}
if( GetScreen()->TestDanglingEnds() )
m_canvas->Refresh();
OnModify();
}
示例6: 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;
}
示例7: GetBoundingBox
EDA_RECT SCH_FIELD::GetBoundingBox() const
{
SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness;
// We must pass the effective text thickness to GetTextBox
// when calculating the bounding box
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
// Calculate the text bounding box:
EDA_RECT rect;
// set USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR to 0 to use
// a justification relative to the text itself
// i.e. justification relative to an horizontal text
// or to 1 to keep the initial behavior
#if (USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR == 1 )
if( m_Orient == TEXT_ORIENT_VERT )
{
// For vertical texts, exchange the horizontal and the vertical justification
// The idea is to keep the justification always left or top for instance,
// no matter the text orientation
SCH_FIELD text( *this ); // Make a local copy to swap justifications
// because GetBoundingBox() is const
int tmp = (int)text.m_VJustify;
NEGATE( tmp );
text.m_VJustify = (EDA_TEXT_VJUSTIFY_T)text.m_HJustify;
text.m_HJustify = (EDA_TEXT_HJUSTIFY_T)tmp;
rect = text.GetTextBox( -1, linewidth );
}
else
#endif
rect = GetTextBox( -1, linewidth );
// Calculate the bounding box position relative to the component:
wxPoint origin = parentComponent->GetPosition();
wxPoint pos = m_Pos - origin;
wxPoint begin = rect.GetOrigin() - origin;
wxPoint end = rect.GetEnd() - origin;
RotatePoint( &begin, pos, m_Orient );
RotatePoint( &end, pos, m_Orient );
// Due to the Y axis direction, we must mirror the bounding box,
// relative to the text position:
begin.y -= pos.y;
end.y -= pos.y;
NEGATE( begin.y );
NEGATE( end.y );
begin.y += pos.y;
end.y += pos.y;
// Now, apply the component transform (mirror/rot)
begin = parentComponent->GetTransform().TransformCoordinate( begin );
end = parentComponent->GetTransform().TransformCoordinate( end );
rect.SetOrigin( begin);
rect.SetEnd( end);
rect.Move( origin );
rect.Normalize();
return rect;
}
示例8: GetShortNetName
/**
* return the short net name of the item i.e. the net name
* from the "best" label without any prefix.
* 2 different nets can have the same short name
*/
wxString NETLIST_OBJECT::GetShortNetName( bool adoptTimestamp ) const
{
if( m_netNameCandidate == NULL )
return wxEmptyString;
wxString netName;
if( m_netNameCandidate->m_Type == NET_PIN )
{
SCH_COMPONENT* link = m_netNameCandidate->GetComponentParent();
if( link ) // Should be always true
{
netName = wxT("Net-(");
netName << link->GetRef( &m_netNameCandidate->m_SheetPath );
if( adoptTimestamp && netName.Last() == '?' )
netName << link->GetTimeStamp();
netName << wxT("-Pad") << m_netNameCandidate->m_PinNum << wxT(")");
}
}
else
netName = m_netNameCandidate->m_Label;
return netName;
}
示例9: wxCHECK_MSG
SEARCH_RESULT SCH_FIND_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestData )
{
wxPoint position;
if( aItem->Matches( m_findReplaceData, m_sheetPath, &position ) )
{
if( aItem->Type() == LIB_PIN_T )
{
wxCHECK_MSG( aTestData && ( (EDA_ITEM*) aTestData )->Type() == SCH_COMPONENT_T,
SEARCH_CONTINUE, wxT( "Cannot inspect invalid data. Bad programmer!" ) );
// Pin positions are relative to their parent component's position and
// orientation in the schematic. The pin's position must be converted
// schematic coordinates.
SCH_COMPONENT* component = (SCH_COMPONENT*) aTestData;
TRANSFORM transform = component->GetTransform();
position.y = -position.y;
position = transform.TransformCoordinate( position ) + component->GetPosition();
}
Append( aItem );
m_data.push_back( SCH_FIND_COLLECTOR_DATA( position, m_sheetPath->PathHumanReadable(),
(SCH_ITEM*) aTestData ) );
}
return SEARCH_CONTINUE;
}
示例10: ChangeSymbolLibNickname
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;
}
示例11: GetLibNicknames
size_t SCH_SCREENS::GetLibNicknames( wxArrayString& aLibNicknames )
{
SCH_COMPONENT* symbol;
SCH_ITEM* item;
SCH_ITEM* nextItem;
SCH_SCREEN* screen;
wxString nickname;
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 );
nickname = symbol->GetLibId().GetLibNickname();
if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
aLibNicknames.Add( nickname );;
}
}
return aLibNicknames.GetCount();
}
示例12: HasNoFullyDefinedLibIds
bool SCH_SCREENS::HasNoFullyDefinedLibIds()
{
SCH_COMPONENT* symbol;
SCH_ITEM* item;
SCH_ITEM* nextItem;
SCH_SCREEN* screen;
unsigned 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;
cnt += 1;
symbol = dynamic_cast< SCH_COMPONENT* >( item );
wxASSERT( symbol );
if( !symbol->GetLibId().GetLibNickname().empty() )
return false;
}
}
if( cnt == 0 )
return false;
return true;
}
示例13: GetScreen
void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
{
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
GetCanvas()->MoveCursorToCrossHair();
if( item->GetFlags() == 0 )
SetUndoItem( item );
component->SetOrientation( aOrientation );
m_canvas->CrossHairOn( );
if( item->GetFlags() == 0 )
{
addCurrentItemToScreen();
SchematicCleanUp();
}
TestDanglingEnds();
RefreshItem( item );
if( item->GetFlags() == 0 )
OnModify();
}
示例14: ComponentCount
int SCH_SHEET::ComponentCount()
{
int n = 0;
if( m_screen )
{
EDA_ITEM* bs;
for( bs = m_screen->GetDrawItems(); bs != NULL; bs = bs->Next() )
{
if( bs->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs;
if( Cmp->GetField( VALUE )->GetText().GetChar( 0 ) != '#' )
n++;
}
if( bs->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = (SCH_SHEET*) bs;
n += sheet->ComponentCount();
}
}
}
return n;
}
示例15: GetParent
void SCH_FIELD::Plot( PLOTTER* aPlotter )
{
SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();
wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
wxT( "Cannot plot field with invalid parent." ) );
EDA_COLOR_T color = ReturnLayerColor( GetLayer() );
if( m_Attributs & TEXT_NO_VISIBLE )
return;
if( IsVoid() )
return;
/* Calculate the text orientation, according to the component
* orientation/mirror */
int orient = m_Orient;
if( parent->GetTransform().y1 ) // Rotate component 90 deg.
{
if( orient == TEXT_ORIENT_HORIZ )
orient = TEXT_ORIENT_VERT;
else
orient = TEXT_ORIENT_HORIZ;
}
/* Calculate the text justification, according to the component
* orientation/mirror
* this is a bit complicated due to cumulative calculations:
* - numerous cases (mirrored or not, rotation)
* - the DrawGraphicText function recalculate also H and H justifications
* according to the text orientation.
* - When a component is mirrored, the text is not mirrored and
* justifications are complicated to calculate
* so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered
*/
EDA_RECT BoundaryBox = GetBoundingBox();
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = BoundaryBox.Centre();
int thickness = GetPenSize();
if( (parent->GetPartCount() <= 1) || (m_id != REFERENCE) )
{
aPlotter->Text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify,
thickness, m_Italic, m_Bold );
}
else /* We plot the reference, for a multiple parts per package */
{
/* Adding A, B ... to the reference */
wxString Text = m_Text + LIB_COMPONENT::ReturnSubReference( parent->GetUnit() );
aPlotter->Text( textpos, color, Text, orient, m_Size, hjustify, vjustify,
thickness, m_Italic, m_Bold );
}
}