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-2021 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_design_settings.h>
32 #include <board_item.h>
33 #include <footprint.h>
34 #include <fp_shape.h>
35 #include <pad.h>
36 #include <board_commit.h>
38 #include <tools/pcb_actions.h>
41 #include <tools/edit_tool.h>
43 #include <widgets/infobar.h>
44 
46  PCB_TOOL_BASE( "pcbnew.PadTool" ),
47  m_padCopied( false ),
48  m_wasHighContrast( false ),
49  m_editPad( niluuid )
50 {}
51 
52 
54 {}
55 
56 
58 {
59  if( aReason == MODEL_RELOAD )
60  m_lastPadNumber = wxT( "1" );
61 
62  m_padCopied = false;
64 }
65 
66 
68 {
70 
71  if( selTool )
72  {
73  // Add context menu entries that are displayed when selection tool is active
74  CONDITIONAL_MENU& menu = selTool->GetToolMenu().GetMenu();
75 
79 
80  auto explodeCondition =
81  [&]( const SELECTION& aSel )
82  {
83  return m_editPad == niluuid && aSel.Size() == 1 && aSel[0]->Type() == PCB_PAD_T;
84  };
85 
86  auto recombineCondition =
87  [&]( const SELECTION& aSel )
88  {
89  return m_editPad != niluuid;
90  };
91 
92  menu.AddSeparator( 400 );
93 
95  {
97  menu.AddItem( PCB_ACTIONS::recombinePad, recombineCondition, 400 );
98  menu.AddItem( PCB_ACTIONS::explodePad, explodeCondition, 400 );
99  }
100 
101  menu.AddItem( PCB_ACTIONS::copyPadSettings, singlePadSel, 400 );
102  menu.AddItem( PCB_ACTIONS::applyPadSettings, padSel, 400 );
103  menu.AddItem( PCB_ACTIONS::pushPadSettings, singlePadSel, 400 );
104  }
105 
106  auto& ctxMenu = m_menu.GetMenu();
107 
108  // cancel current tool goes in main context menu at the top if present
110  ctxMenu.AddSeparator( 1 );
111 
117 
118  // Finally, add the standard zoom/grid items
119  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
120 
121  return true;
122 }
123 
124 
126 {
128  const PCB_SELECTION& selection = selTool->GetSelection();
129  const PAD* masterPad = frame()->GetDesignSettings().m_Pad_Master.get();
130 
131  BOARD_COMMIT commit( frame() );
132 
133  // for every selected pad, paste global settings
134  for( EDA_ITEM* item : selection )
135  {
136  if( item->Type() == PCB_PAD_T )
137  {
138  commit.Modify( item );
139  static_cast<PAD&>( *item ).ImportSettingsFrom( *masterPad );
140  }
141  }
142 
143  commit.Push( _( "Paste Pad Properties" ) );
144 
146  frame()->Refresh();
147 
148  return 0;
149 }
150 
151 
153 {
155  const PCB_SELECTION& selection = selTool->GetSelection();
156 
157  // can only copy from a single pad
158  if( selection.Size() == 1 )
159  {
160  EDA_ITEM* item = selection[0];
161 
162  if( item->Type() == PCB_PAD_T )
163  {
164  const PAD& selPad = static_cast<const PAD&>( *item );
165  frame()->GetDesignSettings().m_Pad_Master->ImportSettingsFrom( selPad );
166  m_padCopied = true;
167  }
168  }
169 
170  return 0;
171 }
172 
173 
174 static void doPushPadProperties( BOARD& board, const PAD& aSrcPad, BOARD_COMMIT& commit,
175  bool aSameFootprints,
176  bool aPadShapeFilter,
177  bool aPadOrientFilter,
178  bool aPadLayerFilter,
179  bool aPadTypeFilter )
180 {
181  const FOOTPRINT* refFootprint = aSrcPad.GetParent();
182 
183  double pad_orient = aSrcPad.GetOrientation() - refFootprint->GetOrientation();
184 
185  for( FOOTPRINT* footprint : board.Footprints() )
186  {
187  if( !aSameFootprints && ( footprint != refFootprint ) )
188  continue;
189 
190  if( footprint->GetFPID() != refFootprint->GetFPID() )
191  continue;
192 
193  for( auto pad : footprint->Pads() )
194  {
195  if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
196  continue;
197 
198  double currpad_orient = pad->GetOrientation() - footprint->GetOrientation();
199 
200  if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
201  continue;
202 
203  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
204  continue;
205 
206  if( aPadTypeFilter && ( pad->GetAttribute() != aSrcPad.GetAttribute() ) )
207  continue;
208 
209  // Special-case for aperture pads
210  if( aPadTypeFilter && pad->GetAttribute() == PAD_ATTRIB::CONN )
211  {
212  if( pad->IsAperturePad() != aSrcPad.IsAperturePad() )
213  continue;
214  }
215 
216  commit.Modify( pad );
217 
218  // Apply source pad settings to this pad
219  pad->ImportSettingsFrom( aSrcPad );
220  }
221  }
222 }
223 
224 
226 {
228  const PCB_SELECTION& selection = selTool->GetSelection();
229  PAD* srcPad;
230 
231  if( selection.Size() == 1 && selection[0]->Type() == PCB_PAD_T )
232  srcPad = static_cast<PAD*>( selection[0] );
233  else
234  return 0;
235 
236  FOOTPRINT* footprint = srcPad->GetParent();
237 
238  if( !footprint )
239  return 0;
240 
242 
244  int dialogRet = dlg.ShowModal();
245 
246  if( dialogRet == wxID_CANCEL )
247  return 0;
248 
249  const bool edit_Same_Modules = (dialogRet == 1);
250 
251  BOARD_COMMIT commit( frame() );
252 
253  doPushPadProperties( *getModel<BOARD>(), *srcPad, commit, edit_Same_Modules,
258 
259  commit.Push( _( "Push Pad Settings" ) );
260 
262  frame()->Refresh();
263 
264  return 0;
265 }
266 
267 
269 {
270  if( !board()->GetFirstFootprint() || board()->GetFirstFootprint()->Pads().empty() )
271  return 0;
272 
273  GENERAL_COLLECTOR collector;
274  const KICAD_T types[] = { PCB_PAD_T, EOT };
275 
277  guide.SetIgnoreMTextsMarkedNoShow( true );
278  guide.SetIgnoreMTextsOnBack( true );
279  guide.SetIgnoreMTextsOnFront( true );
280  guide.SetIgnoreModulesVals( true );
281  guide.SetIgnoreModulesRefs( true );
282 
283  DIALOG_ENUM_PADS settingsDlg( frame() );
284 
285  if( settingsDlg.ShowModal() != wxID_OK )
286  return 0;
287 
288  int seqPadNum = settingsDlg.GetStartNumber();
289  wxString padPrefix = settingsDlg.GetPrefix();
290  std::deque<int> storedPadNumbers;
291  std::map<wxString, std::pair<int, wxString>> oldNumbers;
292 
294 
295  std::string tool = aEvent.GetCommandStr().get();
296  frame()->PushTool( tool );
297 
298  VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
299  std::list<PAD*> selectedPads;
300  BOARD_COMMIT commit( frame() );
301  bool isFirstPoint = true; // make sure oldCursorPos is initialized at least once
302 
303  auto setCursor =
304  [&]()
305  {
307  };
308 
309  Activate();
310  // Must be done after Activate() so that it gets set into the correct context
311  getViewControls()->ShowCursor( true );
312  // Set initial cursor
313  setCursor();
314 
315  STATUS_TEXT_POPUP statusPopup( frame() );
316  wxString msg = _( "Click on pad %s%d\nPress <esc> to cancel or double-click to commit" );
317  statusPopup.SetText( wxString::Format( msg, padPrefix, seqPadNum ) );
318  statusPopup.Popup();
319  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
320 
321  while( TOOL_EVENT* evt = Wait() )
322  {
323  setCursor();
324 
325  if( evt->IsCancelInteractive() )
326  {
328  commit.Revert();
329 
330  frame()->PopTool( tool );
331  break;
332  }
333  else if( evt->IsActivate() )
334  {
335  commit.Push( _( "Renumber pads" ) );
336 
337  frame()->PopTool( tool );
338  break;
339  }
340  else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
341  {
342  selectedPads.clear();
343  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
344 
345  // Be sure the old cursor mouse position was initialized:
346  if( isFirstPoint )
347  {
348  oldCursorPos = cursorPos;
349  isFirstPoint = false;
350  }
351 
352  // wxWidgets deliver mouse move events not frequently enough, resulting in skipping
353  // pads if the user moves cursor too fast. To solve it, create a line that approximates
354  // the mouse move and search pads that are on the line.
355  int distance = ( cursorPos - oldCursorPos ).EuclideanNorm();
356  // Search will be made every 0.1 mm:
357  int segments = distance / int( 0.1*IU_PER_MM ) + 1;
358  const wxPoint line_step( ( cursorPos - oldCursorPos ) / segments );
359 
360  collector.Empty();
361 
362  for( int j = 0; j < segments; ++j )
363  {
364  wxPoint testpoint( cursorPos.x - j * line_step.x, cursorPos.y - j * line_step.y );
365  collector.Collect( board(), types, testpoint, guide );
366 
367  for( int i = 0; i < collector.GetCount(); ++i )
368  selectedPads.push_back( static_cast<PAD*>( collector[i] ) );
369  }
370 
371  selectedPads.unique();
372 
373  for( PAD* pad : selectedPads )
374  {
375  // If pad was not selected, then enumerate it
376  if( !pad->IsSelected() )
377  {
378  commit.Modify( pad );
379 
380  // Rename pad and store the old name
381  int newval;
382 
383  if( storedPadNumbers.size() > 0 )
384  {
385  newval = storedPadNumbers.front();
386  storedPadNumbers.pop_front();
387  }
388  else
389  newval = seqPadNum++;
390 
391  wxString newNumber = wxString::Format( wxT( "%s%d" ), padPrefix, newval );
392  oldNumbers[newNumber] = { newval, pad->GetNumber() };
393  pad->SetNumber( newNumber );
394  SetLastPadNumber( newNumber );
395  pad->SetSelected();
396  getView()->Update( pad );
397 
398  // Ensure the popup text shows the correct next value
399  if( storedPadNumbers.size() > 0 )
400  newval = storedPadNumbers.front();
401  else
402  newval = seqPadNum;
403 
404  statusPopup.SetText( wxString::Format( msg, padPrefix, newval ) );
405  }
406 
407  // ... or restore the old name if it was enumerated and clicked again
408  else if( pad->IsSelected() && evt->IsClick( BUT_LEFT ) )
409  {
410  auto it = oldNumbers.find( pad->GetNumber() );
411  wxASSERT( it != oldNumbers.end() );
412 
413  if( it != oldNumbers.end() )
414  {
415  storedPadNumbers.push_back( it->second.first );
416  pad->SetNumber( it->second.second );
417  SetLastPadNumber( it->second.second );
418  oldNumbers.erase( it );
419 
420  int newval = storedPadNumbers.front();
421 
422  statusPopup.SetText( wxString::Format( msg, padPrefix, newval ) );
423  }
424 
425  pad->ClearSelected();
426  getView()->Update( pad );
427  }
428  }
429  }
430  else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) ||
431  evt->IsDblClick( BUT_LEFT ) )
432  {
433  commit.Push( _( "Renumber pads" ) );
434  frame()->PopTool( tool );
435  break;
436  }
437  else if( evt->IsClick( BUT_RIGHT ) )
438  {
440  }
441  else
442  {
443  evt->SetPassEvent();
444  }
445 
446  // Prepare the next loop by updating the old cursor mouse position
447  // to this last mouse cursor position
448  oldCursorPos = getViewControls()->GetCursorPosition();
449  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
450  }
451 
452  for( PAD* p : board()->GetFirstFootprint()->Pads() )
453  {
454  p->ClearSelected();
455  getView()->Update( p );
456  }
457 
458  statusPopup.Hide();
460  return 0;
461 }
462 
463 
464 int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
465 {
466  if( !board()->GetFirstFootprint() )
467  return 0;
468 
469  struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
470  {
471  PAD_PLACER( PAD_TOOL* aPadTool )
472  {
473  m_padTool = aPadTool;
474  }
475 
476  virtual ~PAD_PLACER()
477  {
478  }
479 
480  std::unique_ptr<BOARD_ITEM> CreateItem() override
481  {
482  PAD* pad = new PAD( m_board->GetFirstFootprint() );
483 
484  pad->ImportSettingsFrom( *(m_frame->GetDesignSettings().m_Pad_Master.get()) );
485 
486  if( pad->CanHaveNumber() )
487  {
488  wxString padNumber = m_padTool->GetLastPadNumber();
489  padNumber = m_board->GetFirstFootprint()->GetNextPadNumber( padNumber );
490  pad->SetNumber( padNumber );
491  m_padTool->SetLastPadNumber( padNumber );
492  }
493 
494  return std::unique_ptr<BOARD_ITEM>( pad );
495  }
496 
497  bool PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit ) override
498  {
499  PAD* pad = dynamic_cast<PAD*>( aItem );
500 
501  if( pad )
502  {
503  m_frame->GetDesignSettings().m_Pad_Master->ImportSettingsFrom( *pad );
504  pad->SetLocalCoord();
505  aCommit.Add( aItem );
506  return true;
507  }
508 
509  return false;
510  }
511 
512  PAD_TOOL* m_padTool;
513  };
514 
515  PAD_PLACER placer( this );
516 
517  doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place pad" ),
519 
520  return 0;
521 }
522 
523 
524 int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
525 {
527  WX_INFOBAR* infoBar = frame()->GetInfoBar();
529  wxString msg;
530 
531  if( m_editPad != niluuid )
532  {
533  PAD* pad = dynamic_cast<PAD*>( frame()->GetItem( m_editPad ) );
534 
535  if( pad )
536  recombinePad( pad );
537 
538  m_editPad = niluuid;
539  }
540  else if( selection.Size() == 1 && selection[0]->Type() == PCB_PAD_T )
541  {
542  PAD* pad = static_cast<PAD*>( selection[0] );
543  PCB_LAYER_ID layer = explodePad( pad );
544 
546  frame()->SetActiveLayer( layer );
547 
548  if( !m_wasHighContrast )
550 
551  if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
552  {
553  msg.Printf( _( "Pad Edit Mode. Press %s again to exit." ),
555 
556  else
557  {
558  msg.Printf( _( "Pad Edit Mode. Press %s to exit." ),
560  }
561 
562  infoBar->RemoveAllButtons();
563  infoBar->ShowMessage( msg, wxICON_INFORMATION );
564 
565  m_editPad = pad->m_Uuid;
566  }
567 
568  if( m_editPad == niluuid )
569  {
570  bool highContrast = ( opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL );
571 
572  if( m_wasHighContrast != highContrast )
574 
575  infoBar->Dismiss();
576  }
577 
578  return 0;
579 }
580 
581 
583 {
584  PCB_LAYER_ID layer;
585  BOARD_COMMIT commit( frame() );
586 
587  if( aPad->IsOnLayer( F_Cu ) )
588  layer = F_Cu;
589  else if( aPad->IsOnLayer( B_Cu ) )
590  layer = B_Cu;
591  else
592  layer = *aPad->GetLayerSet().UIOrder();
593 
594  if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
595  {
596  commit.Modify( aPad );
597 
598  for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
599  {
600  FP_SHAPE* shape = new FP_SHAPE( board()->GetFirstFootprint() );
601 
602  shape->SetShape( primitive->GetShape() );
603  shape->SetFilled( primitive->IsFilled() );
604  shape->SetWidth( primitive->GetWidth() );
605  shape->SetStart( primitive->GetStart() );
606  shape->SetEnd( primitive->GetEnd() );
607  shape->SetBezierC1( primitive->GetBezierC1());
608  shape->SetBezierC2( primitive->GetBezierC2());
609  shape->SetAngle( primitive->GetAngle() );
610  shape->SetPolyShape( primitive->GetPolyShape() );
611  shape->SetLocalCoord();
612  shape->Move( aPad->GetPosition() );
613  shape->Rotate( aPad->GetPosition(), aPad->GetOrientation() );
614  shape->SetLayer( layer );
615 
616  commit.Add( shape );
617  }
618 
619  aPad->SetShape( aPad->GetAnchorPadShape() );
620  aPad->DeletePrimitivesList();
621  m_editPad = aPad->m_Uuid;
622  }
623 
624  commit.Push( _("Edit pad shapes") );
626  return layer;
627 }
628 
629 
631 {
632  int maxError = board()->GetDesignSettings().m_MaxError;
633 
634  auto findNext =
635  [&]( PCB_LAYER_ID aLayer ) -> FP_SHAPE*
636  {
637  SHAPE_POLY_SET padPoly;
638  aPad->TransformShapeWithClearanceToPolygon( padPoly, aLayer, 0, maxError,
639  ERROR_INSIDE );
640 
641  for( BOARD_ITEM* item : board()->GetFirstFootprint()->GraphicalItems() )
642  {
643  PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( item );
644 
645  if( !shape || ( shape->GetEditFlags() & STRUCT_DELETED ) )
646  continue;
647 
648  if( shape->GetLayer() != aLayer )
649  continue;
650 
651  SHAPE_POLY_SET drawPoly;
652  shape->TransformShapeWithClearanceToPolygon( drawPoly, aLayer, 0, maxError,
653  ERROR_INSIDE );
654  drawPoly.BooleanIntersection( padPoly, SHAPE_POLY_SET::PM_FAST );
655 
656  if( !drawPoly.IsEmpty() )
657  return (FP_SHAPE*) item;
658  }
659 
660  return nullptr;
661  };
662 
663  BOARD_COMMIT commit( frame() );
664  PCB_LAYER_ID layer;
665 
666  if( aPad->IsOnLayer( F_Cu ) )
667  layer = F_Cu;
668  else if( aPad->IsOnLayer( B_Cu ) )
669  layer = B_Cu;
670  else
671  layer = *aPad->GetLayerSet().UIOrder();
672 
673  while( FP_SHAPE* fpShape = findNext( layer ) )
674  {
675  commit.Modify( aPad );
676 
677  // We've found an intersecting item. First convert the pad to a custom-shape
678  // pad (if it isn't already)
679  //
680  if( aPad->GetShape() == PAD_SHAPE::RECT || aPad->GetShape() == PAD_SHAPE::CIRCLE )
681  {
682  aPad->SetAnchorPadShape( aPad->GetShape() );
683  }
684  else if( aPad->GetShape() != PAD_SHAPE::CUSTOM )
685  {
686  // Create a new minimally-sized circular anchor and convert existing pad
687  // to a polygon primitive
688  SHAPE_POLY_SET existingOutline;
689  aPad->TransformShapeWithClearanceToPolygon( existingOutline, layer, 0, maxError,
690  ERROR_INSIDE );
691 
693  if( aPad->GetSizeX() > aPad->GetSizeY() )
694  aPad->SetSizeX( aPad->GetSizeY() );
695 
696  aPad->SetOffset( wxPoint( 0, 0 ) );
697 
698  PCB_SHAPE* shape = new PCB_SHAPE;
699  shape->SetShape( SHAPE_T::POLY );
700  shape->SetFilled( true );
701  shape->SetWidth( 0 );
702  shape->SetPolyShape( existingOutline );
703  shape->Move( - aPad->GetPosition() );
704  shape->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation() );
705 
706  aPad->AddPrimitive( shape );
707  }
708 
709  aPad->SetShape( PAD_SHAPE::CUSTOM );
710 
711  // Now add the new shape to the primitives list
712  //
713  PCB_SHAPE* pcbShape = new PCB_SHAPE;
714 
715  pcbShape->SetShape( fpShape->GetShape() );
716  pcbShape->SetFilled( fpShape->IsFilled() );
717  pcbShape->SetWidth( fpShape->GetWidth() );
718  pcbShape->SetStart( fpShape->GetStart() );
719  pcbShape->SetEnd( fpShape->GetEnd() );
720  pcbShape->SetBezierC1( fpShape->GetBezierC1());
721  pcbShape->SetBezierC2( fpShape->GetBezierC2());
722  pcbShape->SetAngle( fpShape->GetAngle() );
723  pcbShape->SetPolyShape( fpShape->GetPolyShape() );
724 
725  pcbShape->Move( - aPad->GetPosition() );
726  pcbShape->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation() );
727  aPad->AddPrimitive( pcbShape );
728 
729  fpShape->SetFlags( STRUCT_DELETED );
730  commit.Remove( fpShape );
731  }
732 
733  commit.Push(_("Recombine pads") );
734 }
735 
736 
738 {
742 
745 
748 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
void Empty()
Clear the list.
Definition: collector.h:95
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable 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:142
void SetOffset(const wxPoint &aOffset)
Definition: pad.h:249
void SetLastPadNumber(const wxString &aPadNumber)
Definition: pad_tool.h:63
const int GetSizeY() const
Definition: pad.h:237
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
static TOOL_ACTION explodePad
Definition: pcb_actions.h:381
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
KIID niluuid(0)
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
void SetShape(SHAPE_T aShape)
Definition: pcb_shape.h:109
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
polygon (not yet used for tracks, but could be in microwave apps)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
KIID m_editPad
Definition: pad_tool.h:85
Model changes (required full reload)
Definition: tool_base.h:80
void DeletePrimitivesList()
Clear the basic shapes list.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
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:174
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
static constexpr double IU_PER_MM
Mock up a conversion function.
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:571
void SetIgnoreModulesVals(bool ignore)
Definition: collectors.h:547
void SetFilled(bool aFlag)
Definition: pcb_shape.h:73
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:79
virtual void Revert() override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
PAD_TOOL()
Definition: pad_tool.cpp:45
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool IsEmpty() const
static TOOL_ACTION enumeratePads
Tool for quick pad enumeration.
Definition: pcb_actions.h:385
Like smd, does not appear on the solder paste layer (default)
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
Tool relating to pads and pad settings.
Definition: pad_tool.h:35
double GetOrientation() const
Definition: footprint.h:190
TOOL_MENU & GetToolMenu()
void SetIgnoreModulesRefs(bool ignore)
Definition: collectors.h:553
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pad.h:567
void SetSizeX(const int aX)
Definition: pad.h:234
static SELECTION_CONDITION HasType(KICAD_T aType)
Create 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:82
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:379
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:108
class PAD, a pad in a footprint
Definition: typeinfo.h:89
static SELECTION_CONDITION Count(int aNumber)
Create 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
Rotate this object.
Definition: pcb_shape.cpp:241
bool IsAperturePad() const
Definition: pad.h:378
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void Reset(RESET_REASON aReason) override
Basic initialization.
Definition: pad_tool.cpp:57
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:589
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
std::unique_ptr< PAD > m_Pad_Master
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
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:405
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
virtual void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:156
Container for display options like enable/disable some optional drawings.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:101
bool m_wasHighContrast
Definition: pad_tool.h:84
const PCB_SELECTION & selection() const
wxString m_lastPadNumber
Definition: pad_tool.h:81
double GetOrientation() const
Return the rotation angle of the pad in a variety of units (the basic call returns tenths of degrees)...
Definition: pad.h:349
int pushPadSettings(const TOOL_EVENT &aEvent)
Definition: pad_tool.cpp:225
void SetIgnoreMTextsOnBack(bool ignore)
Definition: collectors.h:505
static TOOL_ACTION copyPadSettings
Copy the selected pad's settings to the board design settings.
Definition: pcb_actions.h:399
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
Represent a set of closed polygons.
virtual void PopTool(const std::string &actionName)
void SetIgnoreMTextsOnFront(bool ignore)
Definition: collectors.h:511
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
Definition: fp_shape.cpp:277
FOOTPRINTS & Footprints()
Definition: board.h:233
void SetAngle(double aAngle, bool aUpdateEnd=true) override
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:142
Generic, UI-independent tool event.
Definition: tool_event.h:152
Inactive layers are shown normally (no high-contrast mode)
wxString GetPrefix() const
static TOOL_ACTION applyPadSettings
Copy the default pad settings to the selected pad.
Definition: pcb_actions.h:402
int pastePadProperties(const TOOL_EVENT &aEvent)
Copy pad settings from a pad to the board design settings.
Definition: pad_tool.cpp:125
FOOTPRINT * footprint() const
static TOOL_ACTION recombinePad
Definition: pcb_actions.h:382
PAD_SHAPE GetShape() const
Definition: pad.h:170
#define STRUCT_DELETED
flag indication structures to be erased
#define _(s)
virtual void Popup(wxWindow *aFocus=nullptr)
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
const LIB_ID & GetFPID() const
Definition: footprint.h:194
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:368
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
Definition: commit.h:90
std::function< bool(const SELECTION &)> SELECTION_CONDITION
< Functor type that checks a specific condition for selected items.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:158
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
virtual void Move(const wxPoint &aWhere)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:499
int EnumeratePads(const TOOL_EVENT &aEvent)
Tool for quick pad enumeration.
Definition: pad_tool.cpp:268
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset union between a and b, store the result in it self For aFastMode meaning,...
bool m_isFootprintEditor
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
PCB_LAYER_ID explodePad(PAD *aPad)
Definition: pad_tool.cpp:582
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
const KIID m_Uuid
Definition: eda_item.h:475
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:102
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
FOOTPRINT * GetParent() const
Definition: pad.cpp:1354
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
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
Convert the pad shape to a closed polygon.
wxPoint GetPosition() const override
Definition: pad.h:178
void SetStart(const wxPoint &aStart)
Definition: pcb_shape.h:127
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
PAD_ATTRIB GetAttribute() const
Definition: pad.h:371
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
~PAD_TOOL()
React to model/view changes.
Definition: pad_tool.cpp:53
Definition: layer_ids.h:70
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
const int GetSizeX() const
Definition: pad.h:235
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
void AddPrimitive(PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
void SetWidth(int aWidth)
Definition: pcb_shape.h:96
The selection tool: currently supports:
static bool empty(const wxTextEntryBase *aCtrl)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:77
void Activate()
Run the tool.
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:161
WX_INFOBAR * GetInfoBar()
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
void SetLocalCoord()
Set relative coordinates from draw coordinates.
Definition: fp_shape.cpp:54
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: pcb_shape.h:248
int GetStartNumber() const
Return common prefix for all enumerated pads.
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
Definition: fp_shape.cpp:289
void SetBezierC2(const wxPoint &aPoint)
Definition: pcb_shape.h:115
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
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
void recombinePad(PAD *aPad)
Definition: pad_tool.cpp:630
int EditPad(const TOOL_EVENT &aEvent)
Enter/exit WYSIWYG pad shape editing.
Definition: pad_tool.cpp:524
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:377
Definition: pad.h:57
bool Init() override
Init() is called once upon a registration of the tool.
Definition: pad_tool.cpp:67
int PlacePad(const TOOL_EVENT &aEvent)
Place a pad in footprint editor.
Definition: pad_tool.cpp:464
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the draw segment to a closed polygon.
LSEQ UIOrder() const
Definition: lset.cpp:895
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Set the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: pcb_shape.cpp:519
static TOOL_ACTION highContrastMode
Definition: actions.h:103
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171
void setTransitions() override
< Bind handlers to corresponding TOOL_ACTIONs.
Definition: pad_tool.cpp:737
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
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:301
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:183
void SetText(const wxString &aText)
Display a text.
void SetEnd(const wxPoint &aEnd)
Definition: pcb_shape.h:137
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1518
void SetBezierC1(const wxPoint &aPoint)
Definition: pcb_shape.h:112
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
int copyPadSettings(const TOOL_EVENT &aEvent)
Push pad settings from a pad to other pads on board or footprint.
Definition: pad_tool.cpp:152
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition: pad.h:209