diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 01406558ee..2299aae33c 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -145,6 +145,13 @@ const KICAD_T GENERAL_COLLECTOR::Dimensions[] = { }; +const KICAD_T GENERAL_COLLECTOR::DraggableItems[] = { + PCB_TRACE_T, + PCB_VIA_T, + PCB_FOOTPRINT_T, + PCB_ARC_T, + EOT +}; SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) diff --git a/pcbnew/collectors.h b/pcbnew/collectors.h index 6da17572ca..125d4cb8ad 100644 --- a/pcbnew/collectors.h +++ b/pcbnew/collectors.h @@ -308,6 +308,11 @@ public: */ static const KICAD_T Dimensions[]; + /** + * A scan list for items that can be dragged + */ + static const KICAD_T DraggableItems[]; + /** * Constructor GENERALCOLLECTOR */ diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 8443e14b1e..ac6cd5585c 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1459,7 +1459,7 @@ void ROUTER_TOOL::NeighboringSegmentFilter( const VECTOR2I& aPt, GENERAL_COLLECT } -bool ROUTER_TOOL::CanInlineDrag() +bool ROUTER_TOOL::CanInlineDrag( int aDragMode ) { m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, NeighboringSegmentFilter ); const PCB_SELECTION& selection = m_toolMgr->GetTool()->GetSelection(); @@ -1468,11 +1468,17 @@ bool ROUTER_TOOL::CanInlineDrag() { const BOARD_ITEM* item = static_cast( selection.Front() ); - if( item->Type() == PCB_TRACE_T - || item->Type() == PCB_VIA_T - || item->Type() == PCB_FOOTPRINT_T ) + // Note: EDIT_TOOL::Drag temporarily handles items of type PCB_ARC_T on its own using + // DragArcTrack(), so PCB_ARC_T should never occur here. + if( item->IsType( GENERAL_COLLECTOR::DraggableItems ) ) { - return true; + static const KICAD_T footprints[] = { PCB_FOOTPRINT_T, EOT }; + + // Footprints cannot be dragged freely. + if( item->IsType( footprints ) ) + return !( aDragMode & PNS::DM_FREE_ANGLE ); + else + return true; } } diff --git a/pcbnew/router/router_tool.h b/pcbnew/router/router_tool.h index d714b80787..e1594f130a 100644 --- a/pcbnew/router/router_tool.h +++ b/pcbnew/router/router_tool.h @@ -37,7 +37,7 @@ public: int MainLoop( const TOOL_EVENT& aEvent ); int InlineBreakTrack( const TOOL_EVENT& aEvent ); - bool CanInlineDrag(); + bool CanInlineDrag( int aDragMode ); int InlineDrag( const TOOL_EVENT& aEvent ); int SelectCopperLayerPair( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 7f7c460376..24301e715d 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -135,9 +135,12 @@ bool EDIT_TOOL::Init() menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); menu.AddItem( PCB_ACTIONS::inlineBreakTrack, SELECTION_CONDITIONS::Count( 1 ) - && SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ); - menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ); - menu.AddItem( PCB_ACTIONS::dragFreeAngle, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ); + && SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ); + menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::Count( 1 ) + && SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::DraggableItems ) ); + menu.AddItem( PCB_ACTIONS::dragFreeAngle, SELECTION_CONDITIONS::Count( 1 ) + && SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::DraggableItems ) + && !SELECTION_CONDITIONS::OnlyType( PCB_FOOTPRINT_T ) ); menu.AddItem( PCB_ACTIONS::filletTracks, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ); menu.AddItem( PCB_ACTIONS::rotateCcw, SELECTION_CONDITIONS::NotEmpty ); menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty ); @@ -211,7 +214,7 @@ bool EDIT_TOOL::invokeInlineRouter( int aDragMode ) if( theRouter->IsToolActive() ) return false; - if( theRouter->CanInlineDrag() ) + if( theRouter->CanInlineDrag( aDragMode ) ) { m_toolMgr->RunAction( PCB_ACTIONS::routerInlineDrag, true, aDragMode ); return true;