KiCad PCB EDA Suite
pad_tool.cpp File Reference
#include "pad_tool.h"
#include <wxPcbStruct.h>
#include <class_draw_panel_gal.h>
#include <view/view_controls.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <bitmaps.h>
#include <class_board_item.h>
#include <class_module.h>
#include <board_commit.h>
#include <dialogs/dialog_global_pads_edition.h>
#include "pcb_actions.h"
#include "selection_tool.h"
#include "pcb_selection_conditions.h"
#include "edit_tool.h"

Go to the source code of this file.

Classes

class  PAD_CONTEXT_MENU
 
struct  PAD_CONTEXT_MENU::ENABLEMENTS
 

Functions

static void globalChangePadSettings (BOARD &board, const D_PAD &aSrcPad, BOARD_COMMIT &commit, bool aSameFootprints, bool aPadShapeFilter, bool aPadOrientFilter, bool aPadLayerFilter)
 

Function Documentation

static void globalChangePadSettings ( BOARD board,
const D_PAD aSrcPad,
BOARD_COMMIT commit,
bool  aSameFootprints,
bool  aPadShapeFilter,
bool  aPadOrientFilter,
bool  aPadLayerFilter 
)
static

Definition at line 261 of file pad_tool.cpp.

References MODULE::GetFPID(), D_PAD::GetLayerSet(), MODULE::GetOrientation(), D_PAD::GetOrientation(), D_PAD::GetParent(), D_PAD::GetShape(), BOARD::m_Modules, COMMIT::Modify(), MODULE::Next(), and D_PAD::Next().

Referenced by PAD_TOOL::pushPadSettings().

268 {
269  const MODULE* moduleRef = aSrcPad.GetParent();
270 
271  // If there is no module, we can't make the comparisons to see which
272  // pads to apply the source pad settings to
273  if( moduleRef == nullptr )
274  {
275  wxLogDebug( "globalChangePadSettings() Error: NULL module" );
276  return;
277  }
278 
279  double pad_orient = aSrcPad.GetOrientation() - moduleRef->GetOrientation();
280 
281  for( const MODULE* module = board.m_Modules; module; module = module->Next() )
282  {
283  if( !aSameFootprints && ( module != moduleRef ) )
284  continue;
285 
286  if( module->GetFPID() != moduleRef->GetFPID() )
287  continue;
288 
289  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
290  {
291  // Filters changes prohibited.
292  if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
293  continue;
294 
295  double currpad_orient = pad->GetOrientation() - module->GetOrientation();
296 
297  if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
298  continue;
299 
300  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
301  continue;
302 
303  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
304  continue;
305 
306  commit.Modify( pad );
307 
308  // Apply source pad settings to this pad
309  pad->ImportSettingsFromMaster( aSrcPad );
310  }
311  }
312 }
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
MODULE * Next() const
Definition: class_module.h:120
MODULE * GetParent() const
Definition: class_pad.h:162
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
const LIB_ID & GetFPID() const
Definition: class_module.h:184
double GetOrientation() const
Definition: class_module.h:180
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:395
D_PAD * Next() const
Definition: class_pad.h:160
DLIST< MODULE > m_Modules
Definition: class_board.h:245
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375