Eeschema: add junction to 3-component/wire connection

Fixes: lp:1737014
* https://bugs.launchpad.net/kicad/+bug/1737014
This commit is contained in:
Seth Hillbrand 2017-12-07 12:19:53 -08:00 committed by Wayne Stambaugh
parent d205366da7
commit f0fecba9e1
1 changed files with 14 additions and 11 deletions

View File

@ -352,24 +352,25 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
bool has_line = false; bool has_line = false;
bool has_nonparallel = false; bool has_nonparallel = false;
int end_count = 0; int end_count = 0;
int pin_count = 0;
std::vector< SCH_LINE* > lines; std::vector< SCH_LINE* > lines;
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{ {
if( item->GetFlags() & STRUCT_DELETED ) if( item->GetFlags() & STRUCT_DELETED )
continue; continue;
if( aNew && ( item->Type() == SCH_JUNCTION_T ) && ( item->HitTest( aPosition ) ) ) if( aNew && ( item->Type() == SCH_JUNCTION_T ) && ( item->HitTest( aPosition ) ) )
return false; return false;
if( item->Type() != SCH_LINE_T ) if( ( item->Type() == SCH_LINE_T )
continue; && ( item->GetLayer() == LAYER_WIRE )
&& ( item->HitTest( aPosition, 0 ) ) )
if( item->GetLayer() != LAYER_WIRE )
continue;
if( item->HitTest( aPosition, 0 ) )
lines.push_back( (SCH_LINE*) item ); lines.push_back( (SCH_LINE*) item );
if( ( item->Type() == SCH_COMPONENT_T )
&& ( item->IsConnected( aPosition ) ) )
pin_count++;
} }
BOOST_FOREACH( SCH_LINE* line, lines) BOOST_FOREACH( SCH_LINE* line, lines)
@ -390,10 +391,12 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
} }
} }
int has_pin = !!( GetPin( aPosition, NULL, true ) ); // If there is line intersecting a pin
if( pin_count && has_line )
return true;
// If there is line intersecting a pin or non-parallel end // If there are three or more endpoints
if( has_pin && ( has_line || end_count > 1 ) ) if( pin_count + end_count > 2 )
return true; return true;
// If there is at least one segment that ends on a non-parallel line or // If there is at least one segment that ends on a non-parallel line or