本文整理汇总了C++中SCH_ITEM::GetConnectionPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ SCH_ITEM::GetConnectionPoints方法的具体用法?C++ SCH_ITEM::GetConnectionPoints怎么用?C++ SCH_ITEM::GetConnectionPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SCH_ITEM
的用法示例。
在下文中一共展示了SCH_ITEM::GetConnectionPoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckListConnections
void SCH_EDIT_FRAME::CheckListConnections( PICKED_ITEMS_LIST& aItemsList, bool aAppend )
{
std::vector< wxPoint > pts;
std::vector< wxPoint > connections;
GetSchematicConnections( connections );
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
std::vector< wxPoint > new_pts;
if( !item->IsConnectable() )
continue;
item->GetConnectionPoints( new_pts );
pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
// If the item is a line, we also add any connection points from the rest of the schematic
// that terminate on the line after it is moved.
if( item->Type() == SCH_LINE_T )
{
SCH_LINE* line = (SCH_LINE*) item;
for( auto i : connections )
if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) )
pts.push_back( i );
}
else
{
// Clean up any wires that short non-wire connections in the list
for( auto point = new_pts.begin(); point != new_pts.end(); point++ )
{
for( auto second_point = point + 1; second_point != new_pts.end(); second_point++ )
{
aAppend |= TrimWire( *point, *second_point, aAppend );
}
}
}
}
// We always have some overlapping connection points. Drop duplicates here
std::sort( pts.begin(), pts.end(),
[]( const wxPoint& a, const wxPoint& b ) -> bool
{ return a.x < b.x || (a.x == b.x && a.y < b.y); } );
pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
for( auto point : pts )
{
if( GetScreen()->IsJunctionNeeded( point, true ) )
{
AddJunction( point, aAppend );
aAppend = true;
}
}
}
示例2: SelectBlockItems
void SCH_SCREEN::SelectBlockItems()
{
PICKED_ITEMS_LIST* pickedlist = &m_BlockLocate.GetItems();
if( pickedlist->GetCount() == 0 )
return;
ClearDrawingState();
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
item->SetFlags( SELECTED );
}
if( !m_BlockLocate.IsDragging() )
return;
// Select all the items in the screen connected to the items in the block.
// be sure end lines that are on the block limits are seen inside this block
m_BlockLocate.Inflate( 1 );
unsigned last_select_id = pickedlist->GetCount();
for( unsigned ii = 0; ii < last_select_id; ii++ )
{
SCH_ITEM* item = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
item->SetFlags( IS_DRAGGED );
if( item->Type() == SCH_LINE_T )
{
item->IsSelectStateChanged( m_BlockLocate );
if( !item->IsSelected() )
{ // This is a special case:
// this selected wire has no ends in block.
// But it was selected (because it intersects the selecting area),
// so we must keep it selected and select items connected to it
// Note: an other option could be: remove it from drag list
item->SetFlags( SELECTED | SKIP_STRUCT );
std::vector< wxPoint > connections;
item->GetConnectionPoints( connections );
for( size_t i = 0; i < connections.size(); i++ )
addConnectedItemsToBlock( connections[i] );
}
pickedlist->SetPickerFlags( item->GetFlags(), ii );
}
else if( item->IsConnectable() )
{
std::vector< wxPoint > connections;
item->GetConnectionPoints( connections );
for( size_t jj = 0; jj < connections.size(); jj++ )
addConnectedItemsToBlock( connections[jj] );
}
}
m_BlockLocate.Inflate( -1 );
}
示例3: addConnectedItemsToBlock
void SCH_SCREEN::addConnectedItemsToBlock( const SCH_ITEM* aItem, const wxPoint& position )
{
SCH_ITEM* item;
ITEM_PICKER picker;
for( item = m_drawList.begin(); item; item = item->Next() )
{
if( !item->IsConnectable() || ( item->GetFlags() & SKIP_STRUCT )
|| !item->CanConnect( aItem ) || item == aItem )
continue;
// A line having 2 ends, it can be tested twice: one time per end
if( item->Type() == SCH_LINE_T )
{
SCH_LINE* line = (SCH_LINE*) item;
if( !item->HitTest( position ) )
continue;
// First time through. Flags set to denote an end that is not moving
if( !item->IsSelected() )
item->SetFlags( CANDIDATE | STARTPOINT | ENDPOINT );
if( line->GetStartPoint() == position )
item->ClearFlags( STARTPOINT );
else if( line->GetEndPoint() == position )
item->ClearFlags( ENDPOINT );
else
// This picks up items such as labels that can connect to the middle of a line
item->ClearFlags( STARTPOINT | ENDPOINT );
}
// We want to move a mid-connected label or bus entry when the full line is being moved
else if( !item->IsSelected()
&& aItem->Type() == SCH_LINE_T
&& !( aItem->GetFlags() & ( ENDPOINT | STARTPOINT ) ) )
{
std::vector< wxPoint > connections;
item->GetConnectionPoints( connections );
for( auto conn : connections )
{
if( aItem->HitTest( conn ) )
{
item->SetFlags( CANDIDATE );
break;
}
}
}
if( item->IsSelected() )
continue;
if( ( item->GetFlags() & CANDIDATE ) || item->IsConnected( position ) ) // Deal with all non-line items
{
item->ClearFlags( CANDIDATE );
item->SetFlags( SELECTED );
picker.SetItem( item );
picker.SetFlags( item->GetFlags() );
m_BlockLocate.GetItems().PushItem( picker );
}
}
}