KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_item_alignment.cpp File Reference
#include "sch_item_alignment.h"
#include <sch_item.h>
#include <sch_line.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_screen.h>
#include <tools/ee_grid_helper.h>
#include <map>
#include <set>

Go to the source code of this file.

Functions

void MoveSchematicItem (EDA_ITEM *aItem, const VECTOR2I &aDelta)
 Move a schematic item by a delta.
 
void AlignSchematicItemsToGrid (SCH_SCREEN *aScreen, const std::vector< EDA_ITEM * > &aItems, EE_GRID_HELPER &aGrid, GRID_HELPER_GRIDS aSelectionGrid, const SCH_ALIGNMENT_CALLBACKS &aCallbacks)
 Align a set of schematic items to the grid.
 

Function Documentation

◆ AlignSchematicItemsToGrid()

void AlignSchematicItemsToGrid ( SCH_SCREEN * aScreen,
const std::vector< EDA_ITEM * > & aItems,
EE_GRID_HELPER & aGrid,
GRID_HELPER_GRIDS aSelectionGrid,
const SCH_ALIGNMENT_CALLBACKS & aCallbacks )

Align a set of schematic items to the grid.

This function implements the core alignment logic used by the "Align Items to Grid" action. It handles different item types appropriately: lines align their endpoints, sheets align their corners and resize, sheet pins align to grid while maintaining connectivity with their connected wires, etc.

Parameters
aScreenThe schematic screen containing the items
aItemsThe items to align (typically the current selection)
aGridThe grid helper used for alignment calculations
aSelectionGridThe grid type to use for alignment
aCallbacksCallbacks for moving items and getting connected drag items

Definition at line 69 of file sch_item_alignment.cpp.

References GRID_HELPER::AlignGrid(), EDA_ITEM::ClearFlags(), delta, empty(), end, ENDPOINT, SCH_ITEM::GetConnectionPoints(), SCH_LINE::GetEndPoint(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), SCH_SHEET::GetSize(), SCH_LINE::GetStartPoint(), SCH_SCREEN::Items(), SCH_ALIGNMENT_CALLBACKS::m_doMoveItem, SCH_ALIGNMENT_CALLBACKS::m_getConnectedDragItems, SCH_ALIGNMENT_CALLBACKS::m_updateItem, EE_RTREE::OfType(), pin, SCH_FIELD_T, SCH_LINE_T, SCH_SHEET_T, SCH_TEXT_T, SELECTED, EDA_ITEM::SetFlags(), SCH_SHEET::SetSize(), STARTPOINT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_MOVE_TOOL::AlignToGrid(), BOOST_FIXTURE_TEST_CASE(), ISSUE22864_FIXTURE::RunAlignmentAndVerify(), and ISSUE22864_FIXTURE::RunAlignmentAndVerifyNoSkew().

◆ MoveSchematicItem()

void MoveSchematicItem ( EDA_ITEM * aItem,
const VECTOR2I & aDelta )

Move a schematic item by a delta.

This function implements the move logic for different item types, matching the behavior of SCH_MOVE_TOOL::moveItem in DRAG mode:

  • SCH_LINE_T: Moves only flagged endpoints (STARTPOINT/ENDPOINT)
  • SCH_SHEET_PIN_T: Uses SetStoredPos + ConstrainOnEdge
  • Other items: Calls Move()
Parameters
aItemThe item to move
aDeltaThe movement delta

Definition at line 37 of file sch_item_alignment.cpp.

References ENDPOINT, EDA_ITEM::HasFlag(), SCH_LINE::MoveEnd(), SCH_LINE::MoveStart(), pin, SCH_LINE_T, SCH_SHEET_PIN_T, STARTPOINT, and EDA_ITEM::Type().

Referenced by BOOST_FIXTURE_TEST_CASE(), SCH_MOVE_TOOL::moveItem(), ISSUE22864_FIXTURE::RunAlignmentAndVerify(), and ISSUE22864_FIXTURE::RunAlignmentAndVerifyNoSkew().