KiCad PCB EDA Suite
placement_tool.cpp File Reference
#include "tool/selection.h"
#include "placement_tool.h"
#include "pcb_actions.h"
#include "selection_tool.h"
#include "edit_tool.h"
#include <tool/tool_manager.h>
#include <pcb_edit_frame.h>
#include <class_board.h>
#include <ratsnest_data.h>
#include <board_commit.h>
#include <bitmaps.h>
#include <confirm.h>
#include <menus_helpers.h>

Go to the source code of this file.

Functions

bool SortLeftmostX (const std::pair< BOARD_ITEM *, EDA_RECT > left, const std::pair< BOARD_ITEM *, EDA_RECT > right)
 
bool SortRightmostX (const std::pair< BOARD_ITEM *, EDA_RECT > left, const std::pair< BOARD_ITEM *, EDA_RECT > right)
 
bool SortTopmostY (const std::pair< BOARD_ITEM *, EDA_RECT > left, const std::pair< BOARD_ITEM *, EDA_RECT > right)
 
bool SortCenterX (const std::pair< BOARD_ITEM *, EDA_RECT > left, const std::pair< BOARD_ITEM *, EDA_RECT > right)
 
bool SortCenterY (const std::pair< BOARD_ITEM *, EDA_RECT > left, const std::pair< BOARD_ITEM *, EDA_RECT > right)
 
bool SortBottommostY (const std::pair< BOARD_ITEM *, EDA_RECT > left, const std::pair< BOARD_ITEM *, EDA_RECT > right)
 
ALIGNMENT_RECTS GetBoundingBoxes (const SELECTION &sel)
 

Function Documentation

ALIGNMENT_RECTS GetBoundingBoxes ( const SELECTION sel)

Definition at line 166 of file placement_tool.cpp.

References EDA_ITEM::GetBoundingBox(), and PCB_MODULE_T.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), and ALIGN_DISTRIBUTE_TOOL::doAlignRight().

167 {
168  const SELECTION& selection = sel;
169 
170  ALIGNMENT_RECTS rects;
171 
172  for( auto item : selection )
173  {
174  BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
175 
176  if( item->Type() == PCB_MODULE_T )
177  {
178  rects.emplace_back( std::make_pair( boardItem, static_cast<MODULE*>( item )->GetFootprintRect() ) );
179  }
180  else
181  {
182  rects.emplace_back( std::make_pair( boardItem, item->GetBoundingBox() ) );
183  }
184  }
185  return rects;
186 }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::vector< std::pair< BOARD_ITEM *, EDA_RECT > > ALIGNMENT_RECTS
class MODULE, a footprint
Definition: typeinfo.h:89
bool SortBottommostY ( const std::pair< BOARD_ITEM *, EDA_RECT left,
const std::pair< BOARD_ITEM *, EDA_RECT right 
)

Definition at line 160 of file placement_tool.cpp.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), and ALIGN_DISTRIBUTE_TOOL::DistributeVertically().

161 {
162  return ( left.second.GetBottom() > right.second.GetBottom() );
163 }
bool SortCenterX ( const std::pair< BOARD_ITEM *, EDA_RECT left,
const std::pair< BOARD_ITEM *, EDA_RECT right 
)

Definition at line 148 of file placement_tool.cpp.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), and ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally().

149 {
150  return ( left.second.GetCenter().x < right.second.GetCenter().x );
151 }
bool SortCenterY ( const std::pair< BOARD_ITEM *, EDA_RECT left,
const std::pair< BOARD_ITEM *, EDA_RECT right 
)

Definition at line 154 of file placement_tool.cpp.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), and ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically().

155 {
156  return ( left.second.GetCenter().y < right.second.GetCenter().y );
157 }
bool SortLeftmostX ( const std::pair< BOARD_ITEM *, EDA_RECT left,
const std::pair< BOARD_ITEM *, EDA_RECT right 
)

Definition at line 130 of file placement_tool.cpp.

Referenced by ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), and ALIGN_DISTRIBUTE_TOOL::doAlignLeft().

131 {
132  return ( left.second.GetX() < right.second.GetX() );
133 }
bool SortRightmostX ( const std::pair< BOARD_ITEM *, EDA_RECT left,
const std::pair< BOARD_ITEM *, EDA_RECT right 
)

Definition at line 136 of file placement_tool.cpp.

Referenced by ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), and ALIGN_DISTRIBUTE_TOOL::doAlignRight().

137 {
138  return ( left.second.GetRight() > right.second.GetRight() );
139 }
bool SortTopmostY ( const std::pair< BOARD_ITEM *, EDA_RECT left,
const std::pair< BOARD_ITEM *, EDA_RECT right 
)

Definition at line 142 of file placement_tool.cpp.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignTop(), and ALIGN_DISTRIBUTE_TOOL::DistributeVertically().

143 {
144  return ( left.second.GetY() < right.second.GetY() );
145 }