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 260 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().

267 {
268  const MODULE* moduleRef = aSrcPad.GetParent();
269 
270  // If there is no module, we can't make the comparisons to see which
271  // pads to apply the source pad settings to
272  if( moduleRef == nullptr )
273  {
274  wxLogDebug( "globalChangePadSettings() Error: NULL module" );
275  return;
276  }
277 
278  double pad_orient = aSrcPad.GetOrientation() - moduleRef->GetOrientation();
279 
280  for( const MODULE* module = board.m_Modules; module; module = module->Next() )
281  {
282  if( !aSameFootprints && ( module != moduleRef ) )
283  continue;
284 
285  if( module->GetFPID() != moduleRef->GetFPID() )
286  continue;
287 
288  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
289  {
290  // Filters changes prohibited.
291  if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
292  continue;
293 
294  double currpad_orient = pad->GetOrientation() - module->GetOrientation();
295 
296  if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
297  continue;
298 
299  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
300  continue;
301 
302  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
303  continue;
304 
305  commit.Modify( pad );
306 
307  // Apply source pad settings to this pad
308  pad->ImportSettingsFromMaster( aSrcPad );
309  }
310  }
311 }
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
MODULE * Next() const
Definition: class_module.h:99
MODULE * GetParent() const
Definition: class_pad.h:108
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:166
const LIB_ID & GetFPID() const
Definition: class_module.h:151
double GetOrientation() const
Definition: class_module.h:147
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:235
D_PAD * Next() const
Definition: class_pad.h:106
DLIST< MODULE > m_Modules
Definition: class_board.h:243
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:214