Cleanup wire merge code

This commit is contained in:
Seth Hillbrand 2019-10-18 20:15:29 -07:00
parent 92011d91d2
commit 080275b4ee
2 changed files with 16 additions and 8 deletions

View File

@ -405,19 +405,17 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
} }
} }
//
// If there are three or more endpoints // If there are three or more endpoints
if( pin_count && pin_count + end_count[0] > 2 ) if( pin_count && pin_count + end_count[WIRES] > 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
// junction of two other lines // junction of two other lines
if( has_nonparallel[0] && end_count[0] > 2 ) if( has_nonparallel[WIRES] && end_count[WIRES] > 2 )
return true; return true;
// Check for bus - bus junction requirements // Check for bus - bus junction requirements
if( has_nonparallel[1] && end_count[1] > 2 ) if( has_nonparallel[BUSSES] && end_count[BUSSES] > 2 )
return true; return true;
return false; return false;

View File

@ -146,6 +146,9 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems ); EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
bool unselect = selection.IsHover(); bool unselect = selection.IsHover();
// Keep an original copy of the starting points for cleanup after the move
std::vector<DANGLING_END_ITEM> internalPoints;
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -181,6 +184,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
// Setup a drag or a move // Setup a drag or a move
// //
m_dragAdditions.clear(); m_dragAdditions.clear();
internalPoints.clear();
for( SCH_ITEM* it = m_frame->GetScreen()->GetDrawItems(); it; it = it->Next() ) for( SCH_ITEM* it = m_frame->GetScreen()->GetDrawItems(); it; it = it->Next() )
{ {
@ -218,9 +222,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
else else
{ {
// Mark the edges of the block with dangling flags for a move. // Mark the edges of the block with dangling flags for a move.
//
std::vector<DANGLING_END_ITEM> internalPoints;
for( EDA_ITEM* item : selection ) for( EDA_ITEM* item : selection )
static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints ); static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints );
@ -436,7 +437,16 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
} }
else else
{ {
// If we move items away from a junction, we _may_ want to add a junction there
// to denote the state.
for( auto it : internalPoints )
{
if( m_frame->GetScreen()->IsJunctionNeeded( it.GetPosition(), true ) )
m_frame->AddJunction( it.GetPosition(), true, false );
}
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection ); m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
m_frame->SchematicCleanUp(); m_frame->SchematicCleanUp();
m_frame->TestDanglingEnds(); m_frame->TestDanglingEnds();