From 7a2d9dff62d4cf9fd18d1a556479ab1a29d1298c Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 23 Jan 2018 12:29:15 -0800 Subject: [PATCH] Sets additional conditions for when a wire is trimmed This adds a set of conditions that will prevent a wire from being automatically trimmed. Wires that are currently being moved or are newly created or are explicitly avoided will not be removed. This also adds a function to set a flag on items in a block. Fixes: lp:1744632 * https://bugs.launchpad.net/kicad/+bug/1744632 --- eeschema/block.cpp | 9 +++++++++ eeschema/bus-wire-junction.cpp | 9 +++++++-- include/block_commande.h | 10 ++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 77ec91a51c..c83a34ff93 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -127,6 +127,14 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) if( m_canvas->IsMouseCaptured() ) m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); + // If the block wasn't changed, don't update the schematic + if( block->GetMoveVector() == wxPoint( 0, 0 ) ) + { + // This calls the block-abort command routine on cleanup + m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor() ); + return; + } + SaveCopyInUndoList( block->GetItems(), UR_CHANGED, false, block->GetMoveVector() ); MoveItemsInList( block->GetItems(), block->GetMoveVector() ); break; @@ -252,6 +260,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) { nextcmd = true; GetScreen()->SelectBlockItems(); + block->SetFlags( IS_MOVED ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false ); m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false ); diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 9c9791944c..801ce7d44f 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -270,7 +270,11 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) void SCH_EDIT_FRAME::GetSchematicConnections( std::vector< wxPoint >& aConnections ) { for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() ) - item->GetConnectionPoints( aConnections ); + { + // Avoid items that are changing + if( !( item->GetFlags() & ( IS_DRAGGED | IS_MOVED | IS_DELETED ) ) ) + item->GetConnectionPoints( aConnections ); + } // We always have some overlapping connection points. Drop duplicates here std::sort( aConnections.begin(), aConnections.end(), @@ -452,7 +456,8 @@ bool SCH_EDIT_FRAME::TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool // Don't remove wires that are already deleted, are currently being // dragged or are just created - if( item->GetFlags() & ( STRUCT_DELETED | IS_DRAGGED | IS_NEW ) ) + if( item->GetFlags() & + ( STRUCT_DELETED | IS_DRAGGED | IS_NEW | IS_MOVED | SKIP_STRUCT ) ) continue; if( item->Type() != SCH_LINE_T || item->GetLayer() != LAYER_WIRE ) diff --git a/include/block_commande.h b/include/block_commande.h index 89d5d3120c..806e5507a8 100644 --- a/include/block_commande.h +++ b/include/block_commande.h @@ -168,6 +168,16 @@ public: return NULL; } + /** + * Function SetFlags + * sets a status flag on each item in a block selector. + */ + void SetFlags( const STATUS_FLAGS aFlag ) + { + for( unsigned i = 0; i < m_items.GetCount(); i++ ) + m_items.GetPickedItem( i )->SetFlags( aFlag ); + } + /** * Function IsDragging * returns true if the current block command is a drag operation.