From 23a9df8a591136427a17418bc5837c8d2a0937e6 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 11 Sep 2020 09:31:38 -0700 Subject: [PATCH] ADDED: Allow Eeschema dragging graphical corners This separates the two options (drag/move) into different actions. Drag will drag all graphical lines connected. Move will disconnect the graphical lines when moving. --- eeschema/sch_line.cpp | 48 ++++++++++++++++++++++---------- eeschema/tools/sch_move_tool.cpp | 24 ++++++++-------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 770a479d28..a69e84d0ab 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -582,22 +582,42 @@ bool SCH_LINE::IsConnectable() const bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const { - switch( aItem->Type() ) + if( m_Layer == LAYER_WIRE ) { - case SCH_JUNCTION_T: - case SCH_NO_CONNECT_T: - case SCH_LABEL_T: - case SCH_GLOBAL_LABEL_T: - case SCH_HIER_LABEL_T: - case SCH_BUS_WIRE_ENTRY_T: - case SCH_COMPONENT_T: - case SCH_SHEET_T: - case SCH_SHEET_PIN_T: - return true; - - default: - return aItem->GetLayer() == m_Layer; + switch( aItem->Type() ) + { + case SCH_JUNCTION_T: + case SCH_NO_CONNECT_T: + case SCH_LABEL_T: + case SCH_GLOBAL_LABEL_T: + case SCH_HIER_LABEL_T: + case SCH_BUS_WIRE_ENTRY_T: + case SCH_COMPONENT_T: + case SCH_SHEET_T: + case SCH_SHEET_PIN_T: + return true; + default: + break; + } } + else if( m_Layer == LAYER_BUS ) + { + switch( aItem->Type() ) + { + case SCH_JUNCTION_T: + case SCH_LABEL_T: + case SCH_GLOBAL_LABEL_T: + case SCH_HIER_LABEL_T: + case SCH_BUS_WIRE_ENTRY_T: + case SCH_SHEET_T: + case SCH_SHEET_PIN_T: + return true; + default: + break; + } + } + + return aItem->GetLayer() == m_Layer; } diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 5876ffa7df..dc91921570 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -208,18 +208,16 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // for( EDA_ITEM* item : selection ) { - if( static_cast( item )->IsConnectable() ) - { - std::vector connections; + std::vector connections; - if( item->Type() == SCH_LINE_T ) - static_cast( item )->GetSelectedPoints( connections ); - else - connections = static_cast( item )->GetConnectionPoints(); + if( item->Type() == SCH_LINE_T ) + static_cast( item )->GetSelectedPoints( connections ); + else + connections = static_cast( item )->GetConnectionPoints(); - for( wxPoint point : connections ) - getConnectedDragItems( (SCH_ITEM*) item, point, m_dragAdditions ); - } + for( wxPoint point : connections ) + getConnectedDragItems( static_cast( item ), point, + m_dragAdditions ); } m_selectionTool->AddItemsToSel( &m_dragAdditions, QUIET_MODE ); @@ -495,9 +493,11 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoint, EDA_ITEMS& aList ) { - for( SCH_ITEM* test : m_frame->GetScreen()->Items() ) + EE_RTREE& items = m_frame->GetScreen()->Items(); + + for( SCH_ITEM *test : items.Overlapping( aOriginalItem->GetBoundingBox() ) ) { - if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aOriginalItem ) ) + if( test->IsSelected() || !test->CanConnect( aOriginalItem ) ) continue; KICAD_T testType = test->Type();