Remove newly dangling lines when dragging
These lines are remnants from drag operations that should be cleaned after commiting the new line positions Fixes https://gitlab.com/kicad/code/kicad/issues/12870
This commit is contained in:
parent
e517cad12b
commit
01cf6d76d8
|
@ -904,9 +904,11 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::trimOverlappingWires, true, &selectionCopy );
|
m_toolMgr->RunAction( EE_ACTIONS::trimOverlappingWires, true, &selectionCopy );
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selectionCopy );
|
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selectionCopy );
|
||||||
|
|
||||||
m_frame->RecalculateConnections( LOCAL_CLEANUP );
|
// This needs to run prior to `RecalculateConnections` because we need to identify
|
||||||
m_frame->TestDanglingEnds();
|
// the lines that are newly dangling
|
||||||
|
trimDanglingLines();
|
||||||
|
|
||||||
|
m_frame->RecalculateConnections( LOCAL_CLEANUP );
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,6 +925,37 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_MOVE_TOOL::trimDanglingLines()
|
||||||
|
{
|
||||||
|
// Need a local cleanup first to ensure we remove unneeded junctions
|
||||||
|
m_frame->SchematicCleanUp( m_frame->GetScreen() );
|
||||||
|
|
||||||
|
std::set<SCH_ITEM*> danglers;
|
||||||
|
|
||||||
|
std::function<void( SCH_ITEM* )> changeHandler =
|
||||||
|
[&]( SCH_ITEM* aChangedItem ) -> void
|
||||||
|
{
|
||||||
|
m_toolMgr->GetView()->Update( aChangedItem, KIGFX::REPAINT );
|
||||||
|
|
||||||
|
// Delete newly dangling lines
|
||||||
|
if( aChangedItem->IsDangling() && aChangedItem->IsType( {SCH_LINE_T } ) )
|
||||||
|
danglers.insert( aChangedItem );
|
||||||
|
};
|
||||||
|
|
||||||
|
m_frame->GetScreen()->TestDanglingEnds( nullptr, &changeHandler );
|
||||||
|
|
||||||
|
for( SCH_ITEM* line : danglers )
|
||||||
|
{
|
||||||
|
line->SetFlags( STRUCT_DELETED );
|
||||||
|
saveCopyInUndoList( line, UNDO_REDO::DELETED, true );
|
||||||
|
|
||||||
|
updateItem( line, false );
|
||||||
|
|
||||||
|
m_frame->RemoveFromScreen( line, m_frame->GetScreen() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_MOVE_TOOL::getConnectedItems( SCH_ITEM* aOriginalItem, const VECTOR2I& aPoint,
|
void SCH_MOVE_TOOL::getConnectedItems( SCH_ITEM* aOriginalItem, const VECTOR2I& aPoint,
|
||||||
EDA_ITEMS& aList )
|
EDA_ITEMS& aList )
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,6 +84,9 @@ private:
|
||||||
///< Set up handlers for various events.
|
///< Set up handlers for various events.
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
|
///< Cleanup dangling lines left after a drag
|
||||||
|
void trimDanglingLines();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///< Re-entrancy guard
|
///< Re-entrancy guard
|
||||||
bool m_inMoveTool;
|
bool m_inMoveTool;
|
||||||
|
|
Loading…
Reference in New Issue