KiCad PCB EDA Suite
pad_tool.cpp File Reference
#include "pad_tool.h"
#include <pcb_edit_frame.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 <utility>
#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 269 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(), PCB_TOOL::module(), MODULE::Next(), D_PAD::Next(), and MODULE::PadsList().

Referenced by PAD_TOOL::pushPadSettings().

276 {
277  const MODULE* moduleRef = aSrcPad.GetParent();
278 
279  // If there is no module, we can't make the comparisons to see which
280  // pads to apply the source pad settings to
281  if( moduleRef == nullptr )
282  {
283  wxLogDebug( "globalChangePadSettings() Error: NULL module" );
284  return;
285  }
286 
287  double pad_orient = aSrcPad.GetOrientation() - moduleRef->GetOrientation();
288 
289  for( const MODULE* module = board.m_Modules; module; module = module->Next() )
290  {
291  if( !aSameFootprints && ( module != moduleRef ) )
292  continue;
293 
294  if( module->GetFPID() != moduleRef->GetFPID() )
295  continue;
296 
297  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
298  {
299  // Filters changes prohibited.
300  if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
301  continue;
302 
303  double currpad_orient = pad->GetOrientation() - module->GetOrientation();
304 
305  if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
306  continue;
307 
308  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
309  continue;
310 
311  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
312  continue;
313 
314  commit.Modify( pad );
315 
316  // Apply source pad settings to this pad
317  pad->ImportSettingsFromMaster( aSrcPad );
318  }
319  }
320 }
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
MODULE * Next() const
Definition: class_module.h:121
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:191
double GetOrientation() const
Definition: class_module.h:187
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:402
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:382