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 <class_board_item.h>
32 #include <class_module.h>
33 #include <class_edge_mod.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_editPad( niluuid )
48 {}
49 
50 
52 {}
53 
54 
56 {
57  if( aReason == MODEL_RELOAD )
58  m_lastPadName = wxT( "1" );
59 
60  m_padCopied = false;
62 }
63 
64 
66 {
68 
69  if( selTool )
70  {
71  // Add context menu entries that are displayed when selection tool is active
72  CONDITIONAL_MENU& menu = selTool->GetToolMenu().GetMenu();
73 
77 
78  auto explodeCondition = [&]( const SELECTION& aSel )
79  {
80  return m_editPad == niluuid
81  && aSel.Size() == 1 && aSel[0]->Type() == PCB_PAD_T;
82  };
83 
84  auto recombineCondition = [&]( const SELECTION& aSel )
85  {
86  return m_editPad != niluuid;
87  };
88 
89  menu.AddSeparator( 400 );
90 
91  if( m_editModules )
92  {
94  menu.AddItem( PCB_ACTIONS::recombinePad, recombineCondition, 400 );
95  menu.AddItem( PCB_ACTIONS::explodePad, explodeCondition, 400 );
96  }
97 
98  menu.AddItem( PCB_ACTIONS::copyPadSettings, singlePadSel, 400 );
99  menu.AddItem( PCB_ACTIONS::applyPadSettings, padSel, 400 );
100  menu.AddItem( PCB_ACTIONS::pushPadSettings, singlePadSel, 400 );
101  }
102 
103  return true;
104 }
105 
106 
108 {
109  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
110  const auto& selection = selTool.GetSelection();
111  const D_PAD& masterPad = frame()->GetDesignSettings().m_Pad_Master;
112 
113  BOARD_COMMIT commit( frame() );
114 
115  // for every selected pad, paste global settings
116  for( auto item : selection )
117  {
118  if( item->Type() == PCB_PAD_T )
119  {
120  commit.Modify( item );
121  static_cast<D_PAD&>( *item ).ImportSettingsFrom( masterPad );
122  }
123  }
124 
125  commit.Push( _( "Paste Pad Properties" ) );
126 
128  frame()->Refresh();
129 
130  return 0;
131 }
132 
133 
135 {
136  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
137  const auto& selection = selTool.GetSelection();
138 
139  D_PAD& masterPad = frame()->GetDesignSettings().m_Pad_Master;
140 
141  // can only copy from a single pad
142  if( selection.Size() == 1 )
143  {
144  auto item = selection[0];
145 
146  if( item->Type() == PCB_PAD_T )
147  {
148  const auto& selPad = static_cast<const D_PAD&>( *item );
149  masterPad.ImportSettingsFrom( selPad );
150  m_padCopied = true;
151  }
152  }
153 
154  return 0;
155 }
156 
157 
158 static void doPushPadProperties( BOARD& board, const D_PAD& aSrcPad, BOARD_COMMIT& commit,
159  bool aSameFootprints,
160  bool aPadShapeFilter,
161  bool aPadOrientFilter,
162  bool aPadLayerFilter,
163  bool aPadTypeFilter )
164 {
165  const MODULE* moduleRef = aSrcPad.GetParent();
166 
167  double pad_orient = aSrcPad.GetOrientation() - moduleRef->GetOrientation();
168 
169  for( auto module : board.Modules() )
170  {
171  if( !aSameFootprints && ( module != moduleRef ) )
172  continue;
173 
174  if( module->GetFPID() != moduleRef->GetFPID() )
175  continue;
176 
177  for( auto pad : module->Pads() )
178  {
179  if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
180  continue;
181 
182  double currpad_orient = pad->GetOrientation() - module->GetOrientation();
183 
184  if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
185  continue;
186 
187  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
188  continue;
189 
190  if( aPadTypeFilter && ( pad->GetAttribute() != aSrcPad.GetAttribute() ) )
191  continue;
192 
193  // Special-case for aperture pads
194  if( aPadTypeFilter && pad->GetAttribute() == PAD_ATTRIB_CONN )
195  {
196  if( pad->IsAperturePad() != aSrcPad.IsAperturePad() )
197  continue;
198  }
199 
200  commit.Modify( pad );
201 
202  // Apply source pad settings to this pad
203  pad->ImportSettingsFrom( aSrcPad );
204  }
205  }
206 }
207 
208 
210 {
211  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
212  const auto& selection = selTool.GetSelection();
213  D_PAD* srcPad;
214 
215  if( selection.Size() == 1 && selection[0]->Type() == PCB_PAD_T )
216  srcPad = static_cast<D_PAD*>( selection[0] );
217  else
218  return 0;
219 
220  MODULE* module = srcPad->GetParent();
221 
222  if( !module )
223  return 0;
224 
225  frame()->SetMsgPanel( module );
226 
228  int dialogRet = dlg.ShowModal();
229 
230  if( dialogRet == wxID_CANCEL )
231  return 0;
232 
233  const bool edit_Same_Modules = (dialogRet == 1);
234 
235  BOARD_COMMIT commit( frame() );
236 
237  doPushPadProperties( *getModel<BOARD>(), *srcPad, commit, edit_Same_Modules,
242 
243  commit.Push( _( "Push Pad Settings" ) );
244 
246  frame()->Refresh();
247 
248  return 0;
249 }
250 
251 
253 {
254  if( !board()->GetFirstModule() || board()->GetFirstModule()->Pads().empty() )
255  return 0;
256 
257  DIALOG_ENUM_PADS settingsDlg( frame() );
258 
259  if( settingsDlg.ShowModal() != wxID_OK )
260  return 0;
261 
262  std::string tool = aEvent.GetCommandStr().get();
263  frame()->PushTool( tool );
264  Activate();
265 
266  GENERAL_COLLECTOR collector;
267  const KICAD_T types[] = { PCB_PAD_T, EOT };
268 
270  guide.SetIgnoreMTextsMarkedNoShow( true );
271  guide.SetIgnoreMTextsOnBack( true );
272  guide.SetIgnoreMTextsOnFront( true );
273  guide.SetIgnoreModulesVals( true );
274  guide.SetIgnoreModulesRefs( true );
275 
276  int seqPadNum = settingsDlg.GetStartNumber();
277  wxString padPrefix = settingsDlg.GetPrefix();
278  std::deque<int> storedPadNumbers;
279 
281  getViewControls()->ShowCursor( true );
282 
284  VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
285  std::list<D_PAD*> selectedPads;
286  BOARD_COMMIT commit( frame() );
287  std::map<wxString, std::pair<int, wxString>> oldNames;
288  bool isFirstPoint = true; // used to be sure oldCursorPos will be initialized at least once.
289 
290  STATUS_TEXT_POPUP statusPopup( frame() );
291  wxString msg = _( "Click on pad %s%d\nPress <esc> to cancel or double-click to commit" );
292  statusPopup.SetText( wxString::Format( msg, padPrefix, seqPadNum ) );
293  statusPopup.Popup();
294  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
295 
296  while( TOOL_EVENT* evt = Wait() )
297  {
298  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
299 
300  if( evt->IsCancelInteractive() )
301  {
303  commit.Revert();
304 
305  frame()->PopTool( tool );
306  break;
307  }
308 
309  else if( evt->IsActivate() )
310  {
311  commit.Push( _( "Renumber pads" ) );
312 
313  frame()->PopTool( tool );
314  break;
315  }
316 
317  else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
318  {
319  selectedPads.clear();
320  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
321 
322  // Be sure the old cursor mouse position was initialized:
323  if( isFirstPoint )
324  {
325  oldCursorPos = cursorPos;
326  isFirstPoint = false;
327  }
328 
329  // wxWidgets deliver mouse move events not frequently enough, resulting in skipping
330  // pads if the user moves cursor too fast. To solve it, create a line that approximates
331  // the mouse move and search pads that are on the line.
332  int distance = ( cursorPos - oldCursorPos ).EuclideanNorm();
333  // Search will be made every 0.1 mm:
334  int segments = distance / int( 0.1*IU_PER_MM ) + 1;
335  const wxPoint line_step( ( cursorPos - oldCursorPos ) / segments );
336 
337  collector.Empty();
338 
339  for( int j = 0; j < segments; ++j )
340  {
341  wxPoint testpoint( cursorPos.x - j * line_step.x, cursorPos.y - j * line_step.y );
342  collector.Collect( board(), types, testpoint, guide );
343 
344  for( int i = 0; i < collector.GetCount(); ++i )
345  selectedPads.push_back( static_cast<D_PAD*>( collector[i] ) );
346  }
347 
348  selectedPads.unique();
349 
350  for( D_PAD* pad : selectedPads )
351  {
352  // If pad was not selected, then enumerate it
353  if( !pad->IsSelected() )
354  {
355  commit.Modify( pad );
356 
357  // Rename pad and store the old name
358  int newval;
359 
360  if( storedPadNumbers.size() > 0 )
361  {
362  newval = storedPadNumbers.front();
363  storedPadNumbers.pop_front();
364  }
365  else
366  newval = seqPadNum++;
367 
368  wxString newName = wxString::Format( wxT( "%s%d" ), padPrefix, newval );
369  oldNames[newName] = { newval, pad->GetName() };
370  pad->SetName( newName );
371  SetLastPadName( newName );
372  pad->SetSelected();
373  getView()->Update( pad );
374 
375  // Ensure the popup text shows the correct next value
376  if( storedPadNumbers.size() > 0 )
377  newval = storedPadNumbers.front();
378  else
379  newval = seqPadNum;
380 
381  statusPopup.SetText( wxString::Format( msg, padPrefix, newval ) );
382  }
383 
384  // ... or restore the old name if it was enumerated and clicked again
385  else if( pad->IsSelected() && evt->IsClick( BUT_LEFT ) )
386  {
387  auto it = oldNames.find( pad->GetName() );
388  wxASSERT( it != oldNames.end() );
389 
390  if( it != oldNames.end() )
391  {
392  storedPadNumbers.push_back( it->second.first );
393  pad->SetName( it->second.second );
394  SetLastPadName( it->second.second );
395  oldNames.erase( it );
396 
397  int newval = storedPadNumbers.front();
398 
399  statusPopup.SetText( wxString::Format( msg, padPrefix, newval ) );
400  }
401 
402  pad->ClearSelected();
403  getView()->Update( pad );
404  }
405  }
406  }
407 
408  else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) ||
409  evt->IsDblClick( BUT_LEFT ) )
410  {
411  commit.Push( _( "Renumber pads" ) );
412  frame()->PopTool( tool );
413  break;
414  }
415 
416  else if( evt->IsClick( BUT_RIGHT ) )
417  {
419  }
420 
421  else
422  evt->SetPassEvent();
423 
424  // Prepare the next loop by updating the old cursor mouse position
425  // to this last mouse cursor position
426  oldCursorPos = getViewControls()->GetCursorPosition();
427  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
428  }
429 
430  for( auto p : board()->GetFirstModule()->Pads() )
431  {
432  p->ClearSelected();
433  view->Update( p );
434  }
435 
436  statusPopup.Hide();
437  return 0;
438 }
439 
440 
441 int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
442 {
443  if( !board()->GetFirstModule() )
444  return 0;
445 
446  struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
447  {
448  PAD_PLACER( PAD_TOOL* aPadTool )
449  {
450  m_padTool = aPadTool;
451  }
452 
453  virtual ~PAD_PLACER()
454  {
455  }
456 
457  std::unique_ptr<BOARD_ITEM> CreateItem() override
458  {
459  D_PAD* pad = new D_PAD( m_board->GetFirstModule() );
460 
461  pad->ImportSettingsFrom( m_frame->GetDesignSettings().m_Pad_Master );
462 
463  if( PAD_NAMING::PadCanHaveName( *pad ) )
464  {
465  wxString padName = m_padTool->GetLastPadName();
466  padName = m_board->GetFirstModule()->GetNextPadName( padName );
467  pad->SetName( padName );
468  m_padTool->SetLastPadName( padName );
469  }
470 
471  return std::unique_ptr<BOARD_ITEM>( pad );
472  }
473 
474  bool PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit ) override
475  {
476  D_PAD* pad = dynamic_cast<D_PAD*>( aItem );
477 
478  if( pad )
479  {
480  m_frame->GetDesignSettings().m_Pad_Master.ImportSettingsFrom( *pad );
481  pad->SetLocalCoord();
482  aCommit.Add( aItem );
483  return true;
484  }
485 
486  return false;
487  }
488 
489  PAD_TOOL* m_padTool;
490  };
491 
492  PAD_PLACER placer( this );
493 
494  doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place pad" ),
496 
497  return 0;
498 }
499 
500 
501 int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
502 {
504  WX_INFOBAR* infoBar = frame()->GetInfoBar();
506  wxString msg;
507 
508  if( m_editPad != niluuid )
509  {
510  D_PAD* pad = dynamic_cast<D_PAD*>( frame()->GetItem( m_editPad ) );
511 
512  if( pad )
513  recombinePad( pad );
514 
515  m_editPad = niluuid;
516  }
517  else if( selection.Size() == 1 && selection[0]->Type() == PCB_PAD_T )
518  {
519  D_PAD* pad = static_cast<D_PAD*>( selection[0] );
520  PCB_LAYER_ID layer = explodePad( pad );
521 
523  frame()->SetActiveLayer( layer );
524 
525  if( !opts.m_ContrastModeDisplay )
527 
528  if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
529  msg.Printf( _( "Pad Edit Mode. Press %s again to exit." ),
531  else
532  msg.Printf( _( "Pad Edit Mode. Press %s to exit." ),
534 
535  infoBar->RemoveAllButtons();
536  infoBar->ShowMessage( msg, wxICON_INFORMATION );
537 
538  m_editPad = pad->m_Uuid;
539  }
540 
541  if( m_editPad == niluuid )
542  {
545 
546  infoBar->Dismiss();
547  }
548 
549  return 0;
550 }
551 
552 
554 {
555  PCB_LAYER_ID layer;
556  BOARD_COMMIT commit( frame() );
557 
558  if( aPad->IsOnLayer( F_Cu ) )
559  layer = F_Cu;
560  else if( aPad->IsOnLayer( B_Cu ) )
561  layer = B_Cu;
562  else
563  layer = *aPad->GetLayerSet().UIOrder();
564 
565  if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
566  {
567  commit.Modify( aPad );
568 
569  for( const std::shared_ptr<DRAWSEGMENT>& primitive : aPad->GetPrimitives() )
570  {
571  EDGE_MODULE* ds = new EDGE_MODULE( board()->GetFirstModule() );
572 
573  ds->SetShape( primitive->GetShape() );
574  ds->SetWidth( primitive->GetWidth() );
575  ds->SetStart( primitive->GetStart() );
576  ds->SetEnd( primitive->GetEnd() );
577  ds->SetBezControl1( primitive->GetBezControl1() );
578  ds->SetBezControl2( primitive->GetBezControl2() );
579  ds->SetAngle( primitive->GetAngle() );
580  ds->SetPolyShape( primitive->GetPolyShape() );
581  ds->SetLocalCoord();
582  ds->Move( aPad->GetPosition() );
583  ds->Rotate( aPad->GetPosition(), aPad->GetOrientation() );
584  ds->SetLayer( layer );
585 
586  commit.Add( ds );
587  }
588 
589  aPad->SetShape( aPad->GetAnchorPadShape() );
590  aPad->DeletePrimitivesList();
591  m_editPad = aPad->m_Uuid;
592  }
593 
594  commit.Push( _("Edit pad shapes") );
596  return layer;
597 }
598 
599 
601 {
602  auto findNext = [&]( PCB_LAYER_ID aLayer ) -> EDGE_MODULE*
603  {
604  SHAPE_POLY_SET padPoly;
605  aPad->TransformShapeWithClearanceToPolygon( padPoly, 0 );
606 
607  for( BOARD_ITEM* item : board()->GetFirstModule()->GraphicalItems() )
608  {
609  DRAWSEGMENT* draw = dynamic_cast<DRAWSEGMENT*>( item );
610 
611  if( !draw || ( draw->GetEditFlags() & STRUCT_DELETED ) )
612  continue;
613 
614  if( draw->GetLayer() != aLayer )
615  continue;
616 
617  SHAPE_POLY_SET drawPoly;
618  draw->TransformShapeWithClearanceToPolygon( drawPoly, 0 );
619  drawPoly.BooleanIntersection( padPoly, SHAPE_POLY_SET::PM_FAST );
620 
621  if( !drawPoly.IsEmpty() )
622  return (EDGE_MODULE*) item;
623  }
624 
625  return nullptr;
626  };
627 
628  BOARD_COMMIT commit( frame() );
629  PCB_LAYER_ID layer;
630 
631  if( aPad->IsOnLayer( F_Cu ) )
632  layer = F_Cu;
633  else if( aPad->IsOnLayer( B_Cu ) )
634  layer = B_Cu;
635  else
636  layer = *aPad->GetLayerSet().UIOrder();
637 
638  while( EDGE_MODULE* edge = findNext( layer ) )
639  {
640  commit.Modify( aPad );
641 
642  // We've found an intersecting item. First convert the pad to a custom-shape
643  // pad (if it isn't already)
644  //
645  if( aPad->GetShape() == PAD_SHAPE_RECT || aPad->GetShape() == PAD_SHAPE_CIRCLE )
646  {
647  aPad->SetAnchorPadShape( aPad->GetShape() );
648  }
649  else if( aPad->GetShape() != PAD_SHAPE_CUSTOM )
650  {
651  // Create a new minimally-sized circular anchor and convert existing pad
652  // to a polygon primitive
653  SHAPE_POLY_SET existingOutline;
654  int maxError = board()->GetDesignSettings().m_MaxError;
655  aPad->TransformShapeWithClearanceToPolygon( existingOutline, 0, maxError );
656 
658  wxSize minAnnulus( Millimeter2iu( 0.2 ), Millimeter2iu( 0.2 ) );
659  aPad->SetSize( aPad->GetDrillSize() + minAnnulus );
660  aPad->SetOffset( wxPoint( 0, 0 ) );
661 
662  DRAWSEGMENT* shape = new DRAWSEGMENT;
663  shape->SetShape( S_POLYGON );
664  shape->SetPolyShape( existingOutline );
665  shape->Move( - aPad->GetPosition() );
666  shape->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation() );
667 
668  aPad->AddPrimitive( shape );
669  }
670 
671  aPad->SetShape( PAD_SHAPE_CUSTOM );
672 
673  // Now add the new shape to the primitives list
674  //
675  DRAWSEGMENT* ds = new DRAWSEGMENT;
676 
677  ds->SetShape( edge->GetShape() );
678  ds->SetWidth( edge->GetWidth() );
679  ds->SetStart( edge->GetStart() );
680  ds->SetEnd( edge->GetEnd() );
681  ds->SetBezControl1( edge->GetBezControl1() );
682  ds->SetBezControl2( edge->GetBezControl2() );
683  ds->SetAngle( edge->GetAngle() );
684  ds->SetPolyShape( edge->GetPolyShape() );
685 
686  ds->Move( - aPad->GetPosition() );
687  ds->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation() );
688  aPad->AddPrimitive( ds );
689 
690  edge->SetFlags( STRUCT_DELETED );
691  commit.Remove( edge );
692  }
693 
694  commit.Push(_("Recombine pads") );
695 }
696 
697 
699 {
703 
706 
709 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:109
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)
Function ShowAlways 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:119
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:284
double GetOrientation() const
Definition: class_module.h:211
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
void recombinePad(D_PAD *aPad)
Definition: pad_tool.cpp:600
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
static TOOL_ACTION explodePad
Definition: pcb_actions.h:357
void SetShape(STROKE_T aShape)
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
void SetPolyShape(const SHAPE_POLY_SET &aShape)
virtual void Move(const wxPoint &aMoveVector) override
Function Move move this object.
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:100
Model changes (required full reload)
Definition: tool_base.h:82
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
PAD_SHAPE_T GetAnchorPadShape() const
Function GetAnchorPadShape.
Definition: class_pad.h:167
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...
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:539
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
void SetIgnoreModulesVals(bool ignore)
Definition: collectors.h:589
SELECTION_TOOL.
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
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
polygon (not yet used for tracks, but could be in microwave apps)
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:361
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool PadCanHaveName(const D_PAD &aPad)
Check if a pad should be named.
Definition: pad_naming.cpp:26
PAD_TOOL.
Definition: pad_tool.h:37
TOOL_MENU & GetToolMenu()
void SetIgnoreModulesRefs(bool ignore)
Definition: collectors.h:595
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
static SELECTION_CONDITION HasType(KICAD_T aType)
Function HasType Creates a functor that tests if among the selected items there is at least one of a ...
bool m_padCopied
Definition: pad_tool.h:97
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:355
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
const LIB_ID & GetFPID() const
Definition: class_module.h:215
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
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:55
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
void SetBezControl2(const wxPoint &aPoint)
Implementing DIALOG_ENUM_PADS_BASE.
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:206
void SetLocalCoord()
Set relative coordinates.
Definition: class_pad.cpp:396
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:332
void AddPrimitive(DRAWSEGMENT *aPrimitive)
PCB_BASE_EDIT_FRAME * frame() const
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
static TOOL_ACTION pushPadSettings
Copy the current pad's settings to other pads in the module or on the board.
Definition: pcb_actions.h:381
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:100
void SetAnchorPadShape(PAD_SHAPE_T aShape)
Function SetAnchorPadShape Set the shape of the anchor pad for custm shped pads.
Definition: class_pad.h:194
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:139
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
const PCBNEW_SELECTION & selection() const
bool m_wasHighContrast
Definition: pad_tool.h:99
void SetLastPadName(const wxString &aPadName)
Definition: pad_tool.h:74
int pushPadSettings(const TOOL_EVENT &aEvent)
Push pad settings from a pad to other pads on board or module
Definition: pad_tool.cpp:209
void SetIgnoreMTextsOnBack(bool ignore)
Definition: collectors.h:547
static TOOL_ACTION copyPadSettings
Copy the selected pad's settings to the board design settings.
Definition: pcb_actions.h:375
MODULES & Modules()
Definition: class_board.h:266
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
Definition: class_pad.h:127
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:237
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:553
TOOL_EVENT.
Definition: tool_event.h:171
KIID niluuid(0)
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:329
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:378
int pastePadProperties(const TOOL_EVENT &aEvent)
Apply pad settings from board design settings to a pad
Definition: pad_tool.cpp:107
static TOOL_ACTION recombinePad
Definition: pcb_actions.h:358
KIGFX::PCB_VIEW * view() const
void SetSize(const wxSize &aSize)
Definition: class_pad.h:219
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
virtual void Popup(wxWindow *aFocus=nullptr)
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.
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)
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:541
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
int EnumeratePads(const TOOL_EVENT &aEvent)
Function EnumeratePads() Tool for quick pad enumeration.
Definition: pad_tool.cpp:252
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
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:212
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
void SetStart(const wxPoint &aStart)
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
const KIID m_Uuid
Definition: base_struct.h:162
MODULE * GetParent() const
Definition: class_pad.h:107
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
PCB_LAYER_ID explodePad(D_PAD *aPad)
Definition: pad_tool.cpp:553
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
void SetLocalCoord()
Set relative coordinates from draw coordinates.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
Handle the rotate action in the loop by calling the item's rotate method.
static void doPushPadProperties(BOARD &board, const D_PAD &aSrcPad, BOARD_COMMIT &commit, bool aSameFootprints, bool aPadShapeFilter, bool aPadOrientFilter, bool aPadLayerFilter, bool aPadTypeFilter)
Definition: pad_tool.cpp:158
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:313
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
void ImportSettingsFrom(const D_PAD &aMasterPad)
Imports the pad settings from aMasterPad.
Definition: class_pad.cpp:1109
~PAD_TOOL()
Definition: pad_tool.cpp:51
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
wxString m_lastPadName
Definition: pad_tool.h:96
const wxSize & GetDrillSize() const
Definition: class_pad.h:226
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type.
D_PAD m_Pad_Master
A dummy pad to store all default parameters.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
static bool empty(const wxTextEntryBase *aCtrl)
bool IsAperturePad() const
Definition: class_pad.h:339
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
void SetShape(PAD_SHAPE_T aShape)
Set the new shape of this pad.
Definition: class_pad.h:144
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
void SetEnd(const wxPoint &aEnd)
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
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 ...
int GetStartNumber() const
Returns the starting number that is going to be used for the first enumerated pad.
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:153
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...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VIEW.
Definition: view.h:61
const std::vector< std::shared_ptr< DRAWSEGMENT > > & GetPrimitives() const
Accessor to the basic shape list.
Definition: class_pad.h:268
int EditPad(const TOOL_EVENT &aEvent)
Enters/exits WYSIWYG pad shape editing.
Definition: pad_tool.cpp:501
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:385
bool Init() override
Basic initalization
Definition: pad_tool.cpp:65
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_pad.h:499
const wxPoint GetPosition() const override
Definition: class_pad.h:161
int PlacePad(const TOOL_EVENT &aEvent)
Function PlacePad() Places a pad in module editor.
Definition: pad_tool.cpp:441
EDGE_MODULE class definition.
LSEQ UIOrder() const
Definition: lset.cpp:839
void SetOffset(const wxPoint &aOffset)
Definition: class_pad.h:228
static TOOL_ACTION highContrastMode
Definition: actions.h:99
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void setTransitions() override
Bind handlers to corresponding TOOL_ACTIONs
Definition: pad_tool.cpp:698
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
void DeletePrimitivesList()
clear the basic shapes list
void SetText(const wxString &aText)
Display a text.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
int copyPadSettings(const TOOL_EVENT &aEvent)
Copy pad settings from a pad to the board design settings
Definition: pad_tool.cpp:134
void SetBezControl1(const wxPoint &aPoint)
void SetWidth(int aWidth)