KiCad PCB EDA Suite
pad_tool.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
25 #include "pad_tool.h"
26 #include <class_draw_panel_gal.h>
27 #include <view/view_controls.h>
28 #include <view/view.h>
29 #include <tool/tool_manager.h>
30 #include <bitmaps.h>
31 #include <board_item.h>
32 #include <footprint.h>
33 #include <fp_shape.h>
34 #include <board_commit.h>
36 #include <tools/pcb_actions.h>
37 #include <tools/selection_tool.h>
39 #include <tools/edit_tool.h>
41 #include <pad_naming.h>
42 #include <widgets/infobar.h>
43 
45  PCB_TOOL_BASE( "pcbnew.PadTool" ),
46  m_padCopied( false ),
47  m_wasHighContrast( false ),
48  m_editPad( niluuid )
49 {}
50 
51 
53 {}
54 
55 
57 {
58  if( aReason == MODEL_RELOAD )
59  m_lastPadName = wxT( "1" );
60 
61  m_padCopied = false;
63 }
64 
65 
67 {
69 
70  if( selTool )
71  {
72  // Add context menu entries that are displayed when selection tool is active
73  CONDITIONAL_MENU& menu = selTool->GetToolMenu().GetMenu();
74 
78 
79  auto explodeCondition = [&]( const SELECTION& aSel )
80  {
81  return m_editPad == niluuid
82  && aSel.Size() == 1 && aSel[0]->Type() == PCB_PAD_T;
83  };
84 
85  auto recombineCondition = [&]( const SELECTION& aSel )
86  {
87  return m_editPad != niluuid;
88  };
89 
90  menu.AddSeparator( 400 );
91 
93  {
95  menu.AddItem( PCB_ACTIONS::recombinePad, recombineCondition, 400 );
96  menu.AddItem( PCB_ACTIONS::explodePad, explodeCondition, 400 );
97  }
98 
99  menu.AddItem( PCB_ACTIONS::copyPadSettings, singlePadSel, 400 );
100  menu.AddItem( PCB_ACTIONS::applyPadSettings, padSel, 400 );
101  menu.AddItem( PCB_ACTIONS::pushPadSettings, singlePadSel, 400 );
102  }
103 
104  return true;
105 }
106 
107 
109 {
110  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
111  const auto& selection = selTool.GetSelection();
112  const PAD& masterPad = frame()->GetDesignSettings().m_Pad_Master;
113 
114  BOARD_COMMIT commit( frame() );
115 
116  // for every selected pad, paste global settings
117  for( EDA_ITEM* item : selection )
118  {
119  if( item->Type() == PCB_PAD_T )
120  {
121  commit.Modify( item );
122  static_cast<PAD&>( *item ).ImportSettingsFrom( masterPad );
123  }
124  }
125 
126  commit.Push( _( "Paste Pad Properties" ) );
127 
129  frame()->Refresh();
130 
131  return 0;
132 }
133 
134 
136 {
137  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
138  const auto& selection = selTool.GetSelection();
139 
140  PAD& masterPad = frame()->GetDesignSettings().m_Pad_Master;
141 
142  // can only copy from a single pad
143  if( selection.Size() == 1 )
144  {
145  EDA_ITEM* item = selection[0];
146 
147  if( item->Type() == PCB_PAD_T )
148  {
149  const PAD& selPad = static_cast<const PAD&>( *item );
150  masterPad.ImportSettingsFrom( selPad );
151  m_padCopied = true;
152  }
153  }
154 
155  return 0;
156 }
157 
158 
159 static void doPushPadProperties( BOARD& board, const PAD& aSrcPad, BOARD_COMMIT& commit,
160  bool aSameFootprints,
161  bool aPadShapeFilter,
162  bool aPadOrientFilter,
163  bool aPadLayerFilter,
164  bool aPadTypeFilter )
165 {
166  const FOOTPRINT* refFootprint = aSrcPad.GetParent();
167 
168  double pad_orient = aSrcPad.GetOrientation() - refFootprint->GetOrientation();
169 
170  for( FOOTPRINT* footprint : board.Footprints() )
171  {
172  if( !aSameFootprints && ( footprint != refFootprint ) )
173  continue;
174 
175  if( footprint->GetFPID() != refFootprint->GetFPID() )
176  continue;
177 
178  for( auto pad : footprint->Pads() )
179  {
180  if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
181  continue;
182 
183  double currpad_orient = pad->GetOrientation() - footprint->GetOrientation();
184 
185  if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
186  continue;
187 
188  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
189  continue;
190 
191  if( aPadTypeFilter && ( pad->GetAttribute() != aSrcPad.GetAttribute() ) )
192  continue;
193 
194  // Special-case for aperture pads
195  if( aPadTypeFilter && pad->GetAttribute() == PAD_ATTRIB_CONN )
196  {
197  if( pad->IsAperturePad() != aSrcPad.IsAperturePad() )
198  continue;
199  }
200 
201  commit.Modify( pad );
202 
203  // Apply source pad settings to this pad
204  pad->ImportSettingsFrom( aSrcPad );
205  }
206  }
207 }
208 
209 
211 {
212  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
213  const auto& selection = selTool.GetSelection();
214  PAD* srcPad;
215 
216  if( selection.Size() == 1 && selection[0]->Type() == PCB_PAD_T )
217  srcPad = static_cast<PAD*>( selection[0] );
218  else
219  return 0;
220 
221  FOOTPRINT* footprint = srcPad->GetParent();
222 
223  if( !footprint )
224  return 0;
225 
227 
229  int dialogRet = dlg.ShowModal();
230 
231  if( dialogRet == wxID_CANCEL )
232  return 0;
233 
234  const bool edit_Same_Modules = (dialogRet == 1);
235 
236  BOARD_COMMIT commit( frame() );
237 
238  doPushPadProperties( *getModel<BOARD>(), *srcPad, commit, edit_Same_Modules,
243 
244  commit.Push( _( "Push Pad Settings" ) );
245 
247  frame()->Refresh();
248 
249  return 0;
250 }
251 
252 
254 {
255  if( !board()->GetFirstFootprint() || board()->GetFirstFootprint()->Pads().empty() )
256  return 0;
257 
258  DIALOG_ENUM_PADS settingsDlg( frame() );
259 
260  if( settingsDlg.ShowModal() != wxID_OK )
261  return 0;
262 
263  std::string tool = aEvent.GetCommandStr().get();
264  frame()->PushTool( tool );
265  Activate();
266 
267  GENERAL_COLLECTOR collector;
268  const KICAD_T types[] = { PCB_PAD_T, EOT };
269 
271  guide.SetIgnoreMTextsMarkedNoShow( true );
272  guide.SetIgnoreMTextsOnBack( true );
273  guide.SetIgnoreMTextsOnFront( true );
274  guide.SetIgnoreModulesVals( true );
275  guide.SetIgnoreModulesRefs( true );
276 
277  int seqPadNum = settingsDlg.GetStartNumber();
278  wxString padPrefix = settingsDlg.GetPrefix();
279  std::deque<int> storedPadNumbers;
280 
282  getViewControls()->ShowCursor( true );
283 
285  VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
286  std::list<PAD*> selectedPads;
287  BOARD_COMMIT commit( frame() );
288  std::map<wxString, std::pair<int, wxString>> oldNames;
289  bool isFirstPoint = true; // used to be sure oldCursorPos will be initialized at least once.
290 
291  STATUS_TEXT_POPUP statusPopup( frame() );
292  wxString msg = _( "Click on pad %s%d\nPress <esc> to cancel or double-click to commit" );
293  statusPopup.SetText( wxString::Format( msg, padPrefix, seqPadNum ) );
294  statusPopup.Popup();
295  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
296 
297  auto setCursor =
298  [&]()
299  {
301  };
302 
303  // Set initial cursor
304  setCursor();
305 
306  while( TOOL_EVENT* evt = Wait() )
307  {
308  setCursor();
309 
310  if( evt->IsCancelInteractive() )
311  {
313  commit.Revert();
314 
315  frame()->PopTool( tool );
316  break;
317  }
318  else if( evt->IsActivate() )
319  {
320  commit.Push( _( "Renumber pads" ) );
321 
322  frame()->PopTool( tool );
323  break;
324  }
325  else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
326  {
327  selectedPads.clear();
328  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
329 
330  // Be sure the old cursor mouse position was initialized:
331  if( isFirstPoint )
332  {
333  oldCursorPos = cursorPos;
334  isFirstPoint = false;
335  }
336 
337  // wxWidgets deliver mouse move events not frequently enough, resulting in skipping
338  // pads if the user moves cursor too fast. To solve it, create a line that approximates
339  // the mouse move and search pads that are on the line.
340  int distance = ( cursorPos - oldCursorPos ).EuclideanNorm();
341  // Search will be made every 0.1 mm:
342  int segments = distance / int( 0.1*IU_PER_MM ) + 1;
343  const wxPoint line_step( ( cursorPos - oldCursorPos ) / segments );
344 
345  collector.Empty();
346 
347  for( int j = 0; j < segments; ++j )
348  {
349  wxPoint testpoint( cursorPos.x - j * line_step.x, cursorPos.y - j * line_step.y );
350  collector.Collect( board(), types, testpoint, guide );
351 
352  for( int i = 0; i < collector.GetCount(); ++i )
353  selectedPads.push_back( static_cast<PAD*>( collector[i] ) );
354  }
355 
356  selectedPads.unique();
357 
358  for( PAD* pad : selectedPads )
359  {
360  // If pad was not selected, then enumerate it
361  if( !pad->IsSelected() )
362  {
363  commit.Modify( pad );
364 
365  // Rename pad and store the old name
366  int newval;
367 
368  if( storedPadNumbers.size() > 0 )
369  {
370  newval = storedPadNumbers.front();
371  storedPadNumbers.pop_front();
372  }
373  else
374  newval = seqPadNum++;
375 
376  wxString newName = wxString::Format( wxT( "%s%d" ), padPrefix, newval );
377  oldNames[newName] = { newval, pad->GetName() };
378  pad->SetName( newName );
379  SetLastPadName( newName );
380  pad->SetSelected();
381  getView()->Update( pad );
382 
383  // Ensure the popup text shows the correct next value
384  if( storedPadNumbers.size() > 0 )
385  newval = storedPadNumbers.front();
386  else
387  newval = seqPadNum;
388 
389  statusPopup.SetText( wxString::Format( msg, padPrefix, newval ) );
390  }
391 
392  // ... or restore the old name if it was enumerated and clicked again
393  else if( pad->IsSelected() && evt->IsClick( BUT_LEFT ) )
394  {
395  auto it = oldNames.find( pad->GetName() );
396  wxASSERT( it != oldNames.end() );
397 
398  if( it != oldNames.end() )
399  {
400  storedPadNumbers.push_back( it->second.first );
401  pad->SetName( it->second.second );
402  SetLastPadName( it->second.second );
403  oldNames.erase( it );
404 
405  int newval = storedPadNumbers.front();
406 
407  statusPopup.SetText( wxString::Format( msg, padPrefix, newval ) );
408  }
409 
410  pad->ClearSelected();
411  getView()->Update( pad );
412  }
413  }
414  }
415  else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) ||
416  evt->IsDblClick( BUT_LEFT ) )
417  {
418  commit.Push( _( "Renumber pads" ) );
419  frame()->PopTool( tool );
420  break;
421  }
422  else if( evt->IsClick( BUT_RIGHT ) )
423  {
425  }
426  else
427  {
428  evt->SetPassEvent();
429  }
430 
431  // Prepare the next loop by updating the old cursor mouse position
432  // to this last mouse cursor position
433  oldCursorPos = getViewControls()->GetCursorPosition();
434  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
435  }
436 
437  for( PAD* p : board()->GetFirstFootprint()->Pads() )
438  {
439  p->ClearSelected();
440  view->Update( p );
441  }
442 
443  statusPopup.Hide();
445  return 0;
446 }
447 
448 
449 int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
450 {
451  if( !board()->GetFirstFootprint() )
452  return 0;
453 
454  struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
455  {
456  PAD_PLACER( PAD_TOOL* aPadTool )
457  {
458  m_padTool = aPadTool;
459  }
460 
461  virtual ~PAD_PLACER()
462  {
463  }
464 
465  std::unique_ptr<BOARD_ITEM> CreateItem() override
466  {
467  PAD* pad = new PAD( m_board->GetFirstFootprint() );
468 
469  pad->ImportSettingsFrom( m_frame->GetDesignSettings().m_Pad_Master );
470 
471  if( PAD_NAMING::PadCanHaveName( *pad ) )
472  {
473  wxString padName = m_padTool->GetLastPadName();
474  padName = m_board->GetFirstFootprint()->GetNextPadName( padName );
475  pad->SetName( padName );
476  m_padTool->SetLastPadName( padName );
477  }
478 
479  return std::unique_ptr<BOARD_ITEM>( pad );
480  }
481 
482  bool PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit ) override
483  {
484  PAD* pad = dynamic_cast<PAD*>( aItem );
485 
486  if( pad )
487  {
488  m_frame->GetDesignSettings().m_Pad_Master.ImportSettingsFrom( *pad );
489  pad->SetLocalCoord();
490  aCommit.Add( aItem );
491  return true;
492  }
493 
494  return false;
495  }
496 
497  PAD_TOOL* m_padTool;
498  };
499 
500  PAD_PLACER placer( this );
501 
502  doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place pad" ),
504 
505  return 0;
506 }
507 
508 
509 int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
510 {
512  WX_INFOBAR* infoBar = frame()->GetInfoBar();
514  wxString msg;
515 
516  if( m_editPad != niluuid )
517  {
518  PAD* pad = dynamic_cast<PAD*>( frame()->GetItem( m_editPad ) );
519 
520  if( pad )
521  recombinePad( pad );
522 
523  m_editPad = niluuid;
524  }
525  else if( selection.Size() == 1 && selection[0]->Type() == PCB_PAD_T )
526  {
527  PAD* pad = static_cast<PAD*>( selection[0] );
528  PCB_LAYER_ID layer = explodePad( pad );
529 
532  frame()->SetActiveLayer( layer );
533 
534  if( !m_wasHighContrast )
536 
537  if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
538  msg.Printf( _( "Pad Edit Mode. Press %s again to exit." ),
540  else
541  msg.Printf( _( "Pad Edit Mode. Press %s to exit." ),
543 
544  infoBar->RemoveAllButtons();
545  infoBar->ShowMessage( msg, wxICON_INFORMATION );
546 
547  m_editPad = pad->m_Uuid;
548  }
549 
550  if( m_editPad == niluuid )
551  {
552  bool highContrast = ( opts.m_ContrastModeDisplay !=
554 
555  if( m_wasHighContrast != highContrast )
557 
558  infoBar->Dismiss();
559  }
560 
561  return 0;
562 }
563 
564 
566 {
567  PCB_LAYER_ID layer;
568  BOARD_COMMIT commit( frame() );
569 
570  if( aPad->IsOnLayer( F_Cu ) )
571  layer = F_Cu;
572  else if( aPad->IsOnLayer( B_Cu ) )
573  layer = B_Cu;
574  else
575  layer = *aPad->GetLayerSet().UIOrder();
576 
577  if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
578  {
579  commit.Modify( aPad );
580 
581  for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
582  {
583  FP_SHAPE* shape = new FP_SHAPE( board()->GetFirstFootprint() );
584 
585  shape->SetShape( primitive->GetShape() );
586  shape->SetFilled( primitive->IsFilled() );
587  shape->SetWidth( primitive->GetWidth() );
588  shape->SetStart( primitive->GetStart() );
589  shape->SetEnd( primitive->GetEnd() );
590  shape->SetBezControl1( primitive->GetBezControl1() );
591  shape->SetBezControl2( primitive->GetBezControl2() );
592  shape->SetAngle( primitive->GetAngle() );
593  shape->SetPolyShape( primitive->GetPolyShape() );
594  shape->SetLocalCoord();
595  shape->Move( aPad->GetPosition() );
596  shape->Rotate( aPad->GetPosition(), aPad->GetOrientation() );
597  shape->SetLayer( layer );
598 
599  commit.Add( shape );
600  }
601 
602  aPad->SetShape( aPad->GetAnchorPadShape() );
603  aPad->DeletePrimitivesList();
604  m_editPad = aPad->m_Uuid;
605  }
606 
607  commit.Push( _("Edit pad shapes") );
609  return layer;
610 }
611 
612 
614 {
615  int maxError = board()->GetDesignSettings().m_MaxError;
616 
617  auto findNext =
618  [&]( PCB_LAYER_ID aLayer ) -> FP_SHAPE*
619  {
620  SHAPE_POLY_SET padPoly;
621  aPad->TransformShapeWithClearanceToPolygon( padPoly, aLayer, 0, maxError,
622  ERROR_INSIDE );
623 
624  for( BOARD_ITEM* item : board()->GetFirstFootprint()->GraphicalItems() )
625  {
626  PCB_SHAPE* draw = dynamic_cast<PCB_SHAPE*>( item );
627 
628  if( !draw || ( draw->GetEditFlags() & STRUCT_DELETED ) )
629  continue;
630 
631  if( draw->GetLayer() != aLayer )
632  continue;
633 
634  SHAPE_POLY_SET drawPoly;
635  draw->TransformShapeWithClearanceToPolygon( drawPoly, aLayer, 0, maxError,
636  ERROR_INSIDE );
637  drawPoly.BooleanIntersection( padPoly, SHAPE_POLY_SET::PM_FAST );
638 
639  if( !drawPoly.IsEmpty() )
640  return (FP_SHAPE*) item;
641  }
642 
643  return nullptr;
644  };
645 
646  BOARD_COMMIT commit( frame() );
647  PCB_LAYER_ID layer;
648 
649  if( aPad->IsOnLayer( F_Cu ) )
650  layer = F_Cu;
651  else if( aPad->IsOnLayer( B_Cu ) )
652  layer = B_Cu;
653  else
654  layer = *aPad->GetLayerSet().UIOrder();
655 
656  while( FP_SHAPE* fpShape = findNext( layer ) )
657  {
658  commit.Modify( aPad );
659 
660  // We've found an intersecting item. First convert the pad to a custom-shape
661  // pad (if it isn't already)
662  //
663  if( aPad->GetShape() == PAD_SHAPE_RECT || aPad->GetShape() == PAD_SHAPE_CIRCLE )
664  {
665  aPad->SetAnchorPadShape( aPad->GetShape() );
666  }
667  else if( aPad->GetShape() != PAD_SHAPE_CUSTOM )
668  {
669  // Create a new minimally-sized circular anchor and convert existing pad
670  // to a polygon primitive
671  SHAPE_POLY_SET existingOutline;
672  aPad->TransformShapeWithClearanceToPolygon( existingOutline, layer, 0, maxError,
673  ERROR_INSIDE );
674 
676  wxSize minAnnulus( Millimeter2iu( 0.2 ), Millimeter2iu( 0.2 ) );
677  aPad->SetSize( aPad->GetDrillSize() + minAnnulus );
678  aPad->SetOffset( wxPoint( 0, 0 ) );
679 
680  PCB_SHAPE* shape = new PCB_SHAPE;
681  shape->SetShape( S_POLYGON );
682  shape->SetFilled( true );
683  shape->SetPolyShape( existingOutline );
684  shape->Move( - aPad->GetPosition() );
685  shape->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation() );
686 
687  aPad->AddPrimitive( shape );
688  }
689 
690  aPad->SetShape( PAD_SHAPE_CUSTOM );
691 
692  // Now add the new shape to the primitives list
693  //
694  PCB_SHAPE* pcbShape = new PCB_SHAPE;
695 
696  pcbShape->SetShape( fpShape->GetShape() );
697  pcbShape->SetFilled( fpShape->IsFilled() );
698  pcbShape->SetWidth( fpShape->GetWidth() );
699  pcbShape->SetStart( fpShape->GetStart() );
700  pcbShape->SetEnd( fpShape->GetEnd() );
701  pcbShape->SetBezControl1( fpShape->GetBezControl1() );
702  pcbShape->SetBezControl2( fpShape->GetBezControl2() );
703  pcbShape->SetAngle( fpShape->GetAngle() );
704  pcbShape->SetPolyShape( fpShape->GetPolyShape() );
705 
706  pcbShape->Move( - aPad->GetPosition() );
707  pcbShape->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation() );
708  aPad->AddPrimitive( pcbShape );
709 
710  fpShape->SetFlags( STRUCT_DELETED );
711  commit.Remove( fpShape );
712  }
713 
714  commit.Push(_("Recombine pads") );
715 }
716 
717 
719 {
723 
726 
729 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:134
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:113
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:120
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:290
void SetOffset(const wxPoint &aOffset)
Definition: pad.h:242
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
static TOOL_ACTION explodePad
Definition: pcb_actions.h:376
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
KIID niluuid(0)
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
KIID m_editPad
Definition: pad_tool.h:90
Model changes (required full reload)
Definition: tool_base.h:82
void DeletePrimitivesList()
clear the basic shapes list
void SetBezControl2(const wxPoint &aPoint)
Definition: pcb_shape.h:134
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Definition: board_item.h:206
static void doPushPadProperties(BOARD &board, const PAD &aSrcPad, BOARD_COMMIT &commit, bool aSameFootprints, bool aPadShapeFilter, bool aPadOrientFilter, bool aPadLayerFilter, bool aPadTypeFilter)
Definition: pad_tool.cpp:159
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
static constexpr double IU_PER_MM
Mock up a conversion function.
VIEW_CONTROLS class definition.
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
Definition: collectors.cpp:560
void SetIgnoreModulesVals(bool ignore)
Definition: collectors.h:580
void SetFilled(bool aFlag)
Definition: pcb_shape.h:94
SELECTION_TOOL.
STATUS_TEXT_POPUP.
Definition: status_popup.h:82
virtual void Revert() override
Revertes the commit by restoring the modifed items state.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
PAD_TOOL()
Definition: pad_tool.cpp:44
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
static TOOL_ACTION enumeratePads
Tool for quick pad enumeration.
Definition: pcb_actions.h:380
void SetAnchorPadShape(PAD_SHAPE_T aShape)
Function SetAnchorPadShape Set the shape of the anchor pad for custm shped pads.
Definition: pad.h:200
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
Definition: pad.h:126
PAD_TOOL.
Definition: pad_tool.h:37
double GetOrientation() const
Definition: footprint.h:204
TOOL_MENU & GetToolMenu()
void SetIgnoreModulesRefs(bool ignore)
Definition: collectors.h:586
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: pad.h:544
static SELECTION_CONDITION HasType(KICAD_T aType)
Creates a functor that tests if among the selected items there is at least one of a given type.
bool m_padCopied
Definition: pad_tool.h:87
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:374
class PAD, a pad in a footprint
Definition: typeinfo.h:90
PAD_SHAPE_T GetShape() const
Definition: pad.h:159
void SetSize(const wxSize &aSize)
Definition: pad.h:225
static SELECTION_CONDITION Count(int aNumber)
Creates a functor that tests if the number of selected items is equal to the value given as parameter...
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
Definition: pcb_shape.cpp:197
bool IsAperturePad() const
Definition: pad.h:355
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
void Reset(RESET_REASON aReason) override
React to model/view changes
Definition: pad_tool.cpp:56
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
Implementing DIALOG_ENUM_PADS_BASE.
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:213
PAD_ATTR_T GetAttribute() const
Definition: pad.h:348
void ImportSettingsFrom(const PAD &aMasterPad)
Imports the pad settings from aMasterPad.
PCB_BASE_EDIT_FRAME * frame() const
static TOOL_ACTION pushPadSettings
Copy the current pad's settings to other pads in the footprint or on the board.
Definition: pcb_actions.h:400
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:104
virtual void Move(const wxPoint &aMoveVector) override
Function Move move this object.
Definition: pcb_shape.cpp:112
const wxSize & GetDrillSize() const
Definition: pad.h:236
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:140
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:94
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
const PCBNEW_SELECTION & selection() const
bool m_wasHighContrast
Definition: pad_tool.h:89
void SetLastPadName(const wxString &aPadName)
Definition: pad_tool.h:67
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in a variety of units (the basic call r...
Definition: pad.h:334
void SetShape(PCB_SHAPE_TYPE_T aShape)
Definition: pcb_shape.h:128
int pushPadSettings(const TOOL_EVENT &aEvent)
Push pad settings from a pad to other pads on board or footprint
Definition: pad_tool.cpp:210
void SetIgnoreMTextsOnBack(bool ignore)
Definition: collectors.h:538
static TOOL_ACTION copyPadSettings
Copy the selected pad's settings to the board design settings.
Definition: pcb_actions.h:394
void SetLocalCoord()
Set relative coordinates.
Definition: pcbnew/pad.cpp:497
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
STATUS_FLAGS GetEditFlags() const
Definition: eda_item.h:225
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SHAPE_POLY_SET.
virtual void PopTool(const std::string &actionName)
void SetIgnoreMTextsOnFront(bool ignore)
Definition: collectors.h:544
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
Definition: fp_shape.cpp:281
bool PadCanHaveName(const PAD &aPad)
Check if a pad should be named.
Definition: pad_naming.cpp:26
FOOTPRINTS & Footprints()
Definition: board.h:283
void SetAngle(double aAngle, bool aUpdateEnd=true) override
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:151
TOOL_EVENT.
Definition: tool_event.h:171
wxString GetPrefix() const
Returns common prefix for all enumerated pads.
static TOOL_ACTION applyPadSettings
Copy the default pad settings to the selected pad.
Definition: pcb_actions.h:397
int pastePadProperties(const TOOL_EVENT &aEvent)
Apply pad settings from board design settings to a pad
Definition: pad_tool.cpp:108
FOOTPRINT * footprint() const
static TOOL_ACTION recombinePad
Definition: pcb_actions.h:377
KIGFX::PCB_VIEW * view() const
virtual void Popup(wxWindow *aFocus=nullptr)
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
const LIB_ID & GetFPID() const
Definition: footprint.h:208
LSET GetLayerSet() const override
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
Definition: pad.h:345
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: eda_item.h:115
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
virtual void Move(const wxPoint &aWhere)
PAD_SHAPE_T GetAnchorPadShape() const
Function GetAnchorPadShape.
Definition: pad.h:173
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:532
void SetBezControl1(const wxPoint &aPoint)
Definition: pcb_shape.h:131
void SetShape(PAD_SHAPE_T aShape)
Set the new shape of this pad.
Definition: pad.h:150
int EnumeratePads(const TOOL_EVENT &aEvent)
Function EnumeratePads() Tool for quick pad enumeration.
Definition: pad_tool.cpp:253
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset intersection For aFastMode meaning, see function booleanOp
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
bool m_isFootprintEditor
Subclass of DIALOG_ENUM_PADS_BASE, which is generated by wxFormBuilder.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:226
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
PCB_LAYER_ID explodePad(PAD *aPad)
Definition: pad_tool.cpp:565
void AddSeparator(int aOrder=ANY_ORDER)
Adds a separator to the menu.
const KIID m_Uuid
Definition: eda_item.h:151
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
FOOTPRINT * GetParent() const
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:70
Handle the rotate action in the loop by calling the item's rotate method.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
wxPoint GetPosition() const override
Definition: pad.h:167
void SetStart(const wxPoint &aStart)
Definition: pcb_shape.h:147
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:186
#define _(s)
Definition: 3d_actions.cpp:33
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:241
~PAD_TOOL()
Definition: pad_tool.cpp:52
wxString m_lastPadName
Definition: pad_tool.h:86
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Creates a functor that tests if the selected items are only of given type.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
void AddPrimitive(PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
void SetWidth(int aWidth)
Definition: pcb_shape.h:117
static bool empty(const wxTextEntryBase *aCtrl)
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
void Activate()
Function Activate() Runs the tool.
WX_INFOBAR * GetInfoBar()
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Function KeyNameFromKeyCode return the key name from the key code Only some wxWidgets key values are ...
void SetLocalCoord()
Set relative coordinates from draw coordinates.
Definition: fp_shape.cpp:53
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: pcb_shape.h:267
int GetStartNumber() const
Returns the starting number that is going to be used for the first enumerated pad.
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
Definition: fp_shape.cpp:293
void doInteractiveItemPlacement(const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
Helper function for performing a common interactive idiom: wait for a left click, place an item there...
static PCB_SHAPE * findNext(PCB_SHAPE *aShape, const wxPoint &aPoint, const std::vector< PCB_SHAPE * > &aList, unsigned aLimit)
Searches for a PCB_SHAPE matching a given end point or start point in a list.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VIEW.
Definition: view.h:63
void recombinePad(PAD *aPad)
Definition: pad_tool.cpp:613
int EditPad(const TOOL_EVENT &aEvent)
Enters/exits WYSIWYG pad shape editing.
Definition: pad_tool.cpp:509
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:376
Definition: pad.h:59
bool Init() override
Basic initalization
Definition: pad_tool.cpp:66
int PlacePad(const TOOL_EVENT &aEvent)
Function PlacePad() Places a pad in footprint editor.
Definition: pad_tool.cpp:449
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...
LSEQ UIOrder() const
Definition: lset.cpp:888
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: pcb_shape.cpp:444
static constexpr int Millimeter2iu(double mm)
static TOOL_ACTION highContrastMode
Definition: actions.h:101
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Adds a menu entry to run a TOOL_ACTION on selected items.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
Definition: board_item.h:185
void setTransitions() override
Bind handlers to corresponding TOOL_ACTIONs
Definition: pad_tool.cpp:718
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:286
void SetText(const wxString &aText)
Display a text.
void SetEnd(const wxPoint &aEnd)
Definition: pcb_shape.h:158
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1513
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
int copyPadSettings(const TOOL_EVENT &aEvent)
Copy pad settings from a pad to the board design settings
Definition: pad_tool.cpp:135