diff --git a/eeschema/tools/ee_grid_helper.cpp b/eeschema/tools/ee_grid_helper.cpp index 5e3a71ce52..aeed97ec43 100644 --- a/eeschema/tools/ee_grid_helper.cpp +++ b/eeschema/tools/ee_grid_helper.cpp @@ -61,6 +61,12 @@ EE_GRID_HELPER::EE_GRID_HELPER( TOOL_MANAGER* aToolMgr ) : } +VECTOR2I EE_GRID_HELPER::AlignGrid( const VECTOR2I& aPoint, GRID_HELPER_GRIDS aGrid ) const +{ + return AlignGrid( aPoint, GetGridSize( aGrid ), GetOrigin() ); +} + + VECTOR2I EE_GRID_HELPER::Align( const VECTOR2I& aPoint, GRID_HELPER_GRIDS aGrid ) const { return Align( aPoint, GetGridSize( aGrid ), GetOrigin() ); @@ -356,12 +362,13 @@ GRID_HELPER_GRIDS EE_GRID_HELPER::GetItemGrid( const SCH_ITEM* aItem ) return GRID_CONNECTABLE; case SCH_TEXT_T: - case SCH_TEXTBOX_T: case SCH_FIELD_T: return GRID_TEXT; case SCH_SHAPE_T: case SCH_BITMAP_T: + // The text box's border lines are what need to be on the graphic grid + case SCH_TEXTBOX_T: return GRID_GRAPHICS; case SCH_JUNCTION_T: diff --git a/eeschema/tools/ee_grid_helper.h b/eeschema/tools/ee_grid_helper.h index c6464e5ce2..c85dfe1bbc 100644 --- a/eeschema/tools/ee_grid_helper.h +++ b/eeschema/tools/ee_grid_helper.h @@ -55,6 +55,7 @@ public: using GRID_HELPER::Align; using GRID_HELPER::AlignGrid; VECTOR2I Align( const VECTOR2I& aPoint, GRID_HELPER_GRIDS aGrid ) const; + VECTOR2I AlignGrid( const VECTOR2I& aPoint, GRID_HELPER_GRIDS aGrid ) const; /** * Function GetSnapped diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 920e55aa44..60c70b3ea2 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -1564,6 +1564,7 @@ int SCH_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) { EE_GRID_HELPER grid( m_toolMgr); EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::MovableItems ); + GRID_HELPER_GRIDS selectionGrid = grid.GetSelectionGrid( selection ); SCH_COMMIT commit( m_toolMgr ); auto doMoveItem = @@ -1616,7 +1617,7 @@ int SCH_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) getConnectedDragItems( &commit, line, pts[ii], drag_items ); std::set unique_items( drag_items.begin(), drag_items.end() ); - VECTOR2I gridpt = grid.AlignGrid( pts[ii] ) - pts[ii]; + VECTOR2I gridpt = grid.AlignGrid( pts[ii], selectionGrid ) - pts[ii]; if( gridpt != VECTOR2I( 0, 0 ) ) { @@ -1630,9 +1631,10 @@ int SCH_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) } } } - else if( item->Type() == SCH_FIELD_T ) + else if( item->Type() == SCH_FIELD_T || item->Type() == SCH_TEXT_T ) { - VECTOR2I gridpt = grid.AlignGrid( item->GetPosition() ) - item->GetPosition(); + VECTOR2I gridpt = + grid.AlignGrid( item->GetPosition(), selectionGrid ) - item->GetPosition(); if( gridpt != VECTOR2I( 0, 0 ) ) doMoveItem( item, gridpt ); @@ -1642,8 +1644,8 @@ int SCH_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) SCH_SHEET* sheet = static_cast( item ); VECTOR2I topLeft = sheet->GetPosition(); VECTOR2I bottomRight = topLeft + sheet->GetSize(); - VECTOR2I tl_gridpt = grid.AlignGrid( topLeft ) - topLeft; - VECTOR2I br_gridpt = grid.AlignGrid( bottomRight ) - bottomRight; + VECTOR2I tl_gridpt = grid.AlignGrid( topLeft, selectionGrid ) - topLeft; + VECTOR2I br_gridpt = grid.AlignGrid( bottomRight, selectionGrid ) - bottomRight; if( tl_gridpt != VECTOR2I( 0, 0 ) || br_gridpt != VECTOR2I( 0, 0 ) ) { @@ -1696,7 +1698,7 @@ int SCH_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) for( const VECTOR2I& conn : connections ) { - VECTOR2I gridpt = grid.AlignGrid( conn ) - conn; + VECTOR2I gridpt = grid.AlignGrid( conn, selectionGrid ) - conn; shifts[gridpt]++;