本文整理汇总了C++中SCH_ITEM::HitTest方法的典型用法代码示例。如果您正苦于以下问题:C++ SCH_ITEM::HitTest方法的具体用法?C++ SCH_ITEM::HitTest怎么用?C++ SCH_ITEM::HitTest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SCH_ITEM
的用法示例。
在下文中一共展示了SCH_ITEM::HitTest方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdatePickList
int SCH_SCREEN::UpdatePickList()
{
ITEM_PICKER picker;
EDA_RECT area;
unsigned count;
area.SetOrigin( m_BlockLocate.GetOrigin() );
area.SetSize( m_BlockLocate.GetSize() );
area.Normalize();
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
// An item is picked if its bounding box intersects the reference area.
if( item->HitTest( area ) )
{
picker.SetItem( item );
m_BlockLocate.PushItem( picker );
}
}
// if the block is composed of one item,
// select it as the current item
count = m_BlockLocate.GetCount();
if( count == 1 )
{
SetCurItem( (SCH_ITEM*) m_BlockLocate.GetItem( 0 ) );
}
else
{
SetCurItem( NULL );
}
return count;
}
示例2: GetLine
SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLayer,
SCH_LINE_TEST_T aSearchType )
{
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
if( item->Type() != SCH_LINE_T )
continue;
if( item->GetLayer() != aLayer )
continue;
if( !item->HitTest( aPosition, aAccuracy ) )
continue;
switch( aSearchType )
{
case ENTIRE_LENGTH_T:
return (SCH_LINE*) item;
case EXCLUDE_END_POINTS_T:
if( !( (SCH_LINE*) item )->IsEndPoint( aPosition ) )
return (SCH_LINE*) item;
break;
case END_POINTS_ONLY_T:
if( ( (SCH_LINE*) item )->IsEndPoint( aPosition ) )
return (SCH_LINE*) item;
}
}
return NULL;
}
示例3: GetNode
int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList )
{
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
if( item->Type() == SCH_LINE_T && item->HitTest( aPosition )
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
{
aList.push_back( item );
}
else if( item->Type() == SCH_JUNCTION_T && item->HitTest( aPosition ) )
{
aList.push_back( item );
}
}
return (int) aList.size();
}
示例4: GetWireOrBus
SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition )
{
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
if( (item->Type() == SCH_LINE_T) && item->HitTest( aPosition )
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
{
return (SCH_LINE*) item;
}
}
return NULL;
}
示例5: GetItem
SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) const
{
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
if( item->HitTest( aPosition, aAccuracy ) && (aType == NOT_USED) )
return item;
if( (aType == SCH_FIELD_T) && (item->Type() == SCH_COMPONENT_T) )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
for( int i = REFERENCE; i < component->GetFieldCount(); i++ )
{
SCH_FIELD* field = component->GetField( i );
if( field->HitTest( aPosition, aAccuracy ) )
return (SCH_ITEM*) field;
}
}
else if( (aType == SCH_SHEET_PIN_T) && (item->Type() == SCH_SHEET_T) )
{
SCH_SHEET* sheet = (SCH_SHEET*)item;
SCH_SHEET_PIN* label = sheet->GetPin( aPosition );
if( label )
return (SCH_ITEM*) label;
}
else if( (item->Type() == aType) && item->HitTest( aPosition, aAccuracy ) )
{
return item;
}
}
return NULL;
}
示例6: SchematicCleanUp
bool SCH_SCREEN::SchematicCleanUp()
{
bool modified = false;
for( SCH_ITEM* item = m_drawList.begin() ; item; item = item->Next() )
{
if( ( item->Type() != SCH_LINE_T ) && ( item->Type() != SCH_JUNCTION_T ) )
continue;
bool restart;
for( SCH_ITEM* testItem = item->Next(); testItem; testItem = restart ? m_drawList.begin() : testItem->Next() )
{
restart = false;
if( ( item->Type() == SCH_LINE_T ) && ( testItem->Type() == SCH_LINE_T ) )
{
SCH_LINE* line = (SCH_LINE*) item;
if( line->MergeOverlap( (SCH_LINE*) testItem ) )
{
// Keep the current flags, because the deleted segment can be flagged.
item->SetFlags( testItem->GetFlags() );
DeleteItem( testItem );
restart = true;
modified = true;
}
}
else if ( ( ( item->Type() == SCH_JUNCTION_T )
&& ( testItem->Type() == SCH_JUNCTION_T ) ) && ( testItem != item ) )
{
if ( testItem->HitTest( item->GetPosition() ) )
{
// Keep the current flags, because the deleted segment can be flagged.
item->SetFlags( testItem->GetFlags() );
DeleteItem( testItem );
restart = true;
modified = true;
}
}
}
}
TestDanglingEnds();
return modified;
}
示例7: GetLabel
SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
{
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
switch( item->Type() )
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
if( item->HitTest( aPosition, aAccuracy ) )
return (SCH_TEXT*) item;
default:
;
}
}
return NULL;
}
示例8: 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 );
}
}
}
示例9: IsJunctionNeeded
bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
{
bool has_nonparallel[2] = { false };
int end_count[2] = { 0 };
int pin_count = 0;
std::vector<SCH_LINE*> lines[2];
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
if( item->GetFlags() & STRUCT_DELETED )
continue;
if( aNew && ( item->Type() == SCH_JUNCTION_T ) && ( item->HitTest( aPosition ) ) )
return false;
if( ( item->Type() == SCH_LINE_T )
&& ( item->HitTest( aPosition, 0 ) ) )
{
if( item->GetLayer() == LAYER_WIRE )
lines[0].push_back( (SCH_LINE*) item );
else if( item->GetLayer() == LAYER_BUS )
lines[1].push_back( (SCH_LINE*) item );
}
if( ( item->Type() == SCH_COMPONENT_T )
&& ( item->IsConnected( aPosition ) ) )
pin_count++;
}
for( int i = 0; i < 2; i++ )
{
bool removed_overlapping = false;
end_count[i] = lines[i].size();
for( auto line = lines[i].begin(); line < lines[i].end(); line++ )
{
// Consider ending on a line to be equivalent to two endpoints because
// we will want to split the line if anything else connects
if( !(*line)->IsEndPoint( aPosition ) )
end_count[i]++;
for( auto second_line = lines[i].end() - 1; second_line > line; second_line-- )
{
if( !(*line)->IsParallel( *second_line ) )
has_nonparallel[i] = true;
else if( !removed_overlapping
&& (*line)->IsSameQuadrant( *second_line, aPosition ) )
{
/**
* Overlapping lines that point in the same direction should not be counted
* as extra end_points. We remove the overlapping lines, being careful to only
* remove them once.
*/
removed_overlapping = true;
end_count[i]--;
}
}
}
}
//
// If there are three or more endpoints
if( pin_count + end_count[0] > 2 )
return true;
// If there is at least one segment that ends on a non-parallel line or
// junction of two other lines
if( has_nonparallel[0] && end_count[0] > 2 )
return true;
// Check for bus - bus junction requirements
if( has_nonparallel[1] && end_count[1] > 2 )
return true;
return false;
}