diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 82f4229468..cf1a464818 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -405,19 +405,17 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew ) } } - // - // 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; // 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 ) + if( has_nonparallel[WIRES] && end_count[WIRES] > 2 ) return true; // 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 false; diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 5e0ff75e83..adcddce95a 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -146,6 +146,9 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems ); bool unselect = selection.IsHover(); + // Keep an original copy of the starting points for cleanup after the move + std::vector internalPoints; + if( selection.Empty() ) return 0; @@ -181,6 +184,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // Setup a drag or a move // m_dragAdditions.clear(); + internalPoints.clear(); 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 { // Mark the edges of the block with dangling flags for a move. - // - std::vector internalPoints; - for( EDA_ITEM* item : selection ) static_cast( item )->GetEndPoints( internalPoints ); @@ -436,7 +437,16 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) } 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_frame->SchematicCleanUp(); m_frame->TestDanglingEnds();